Searching multiple models at the same time - DXP 7.4

Jamie Sammons, modified 2 Years ago. Regular Member Posts: 131 Join Date: 7/28/17 Recent Posts

In the documentaiton given below:

https://help.liferay.com/hc/en-us/articles/360034199592-Querying-for-Guestbook-Entry-Documents#implementing-keywordquerycontributor

We need to create an Indexer for the model that we need to search. In this case, GuestBookEntry.class. What if i need to search at the same time on JournalArticle.class and GuestBookEntry.class models, and not separate searches. So that I get a combined search score. How to do this?

Indexer<GuestbookEntry> indexer = IndexerRegistryUtil.getIndexer(GuestbookEntry.class);
thumbnail
Vishnu S Kumar, modified 2 Years ago. Expert Posts: 308 Join Date: 2/13/13 Recent Posts

IndexerRegistryUtil has a getIndexers() method to retrieve all indexers. That said, I'm not exactly sure how to execute multiple indexer searches at once to get a combined score. Instead you could perhaps run a regular search using the search APIs, and filter the models you want returned.

See the Queries and Filters docs, and the docs on Building Queries and Filters, to get started. These links are for 7.2, but they should apply equally to 7.4 (where the docs don't yet exist).