Reputation: 164
I am trying to create an autocomplete (search-as-you-type) that combines the individual term suggestions based on their common documents and then sorts the term combinations based on the no of documents.
So I have set up a completion suggester, I indexed my invidiual terms as suggest terms, and then I do a suggest query for each of the terms (words). I then get a suggestion list for each of my terms (words). After that I create a list of combinations between those suggestions (cartesian product) and I get a bunch of potentially! useful combinations like:
tag1 tag2
tag1 tag3
etc...
What I need now is to:
a) run a full text match query for every combination to make sure it actually returns any results (the term combination might not actually return any documents)
b) sort the combinations based on how many documents each of them returns
c) aggregate some other document attributes for each of the combination queries
What I tried so far is: named queries. But all I get is a list of the queries that matched and not the actual document count for each, so I can sort them. Also, I get a document list and a list of matched queries for that document, so not really that useful at all :)
Upvotes: 1
Views: 349
Reputation: 164
The solution was to run a bulk search (_msearch) on each combination of terms, to get the actual results for each (and also aggregates if needed) - instead of running multiple searches for each combination.
Upvotes: 0