How to query n-gram completions that match phrase prefix?

How can I query my index to suggest phrases that complete the user's query? I'd like a query similar to match_phrase_prefix , except instead of retrieving the entire doc it returns n-grams from the doc fields that completes the phrase?

None of the suggesters seem to fit my use-case, where completion suggester requires that suggestions be indexed explicity, and phrase suggester seems to suggest spelling error fixes instead of phrase completions.

can you share a reproducible example, including index/mapping/query and what does not work as you expect it to be, so other can follow your example better? Thanks!

More precisely, I want the same functionality as search_as_you_type (example), except with word n-gram results, instead of retrieving the entire _source. For example, if the _source in the search_as_you_type field is "quick brown fox jump lazy dog", and my query is "brown f", then the result should be "brown fox", or "quick brown fox", not "quick brown fox jump lazy dog".

Also, I'd like to achieve this without additional indexing ie explicitly add suggest entries as with the completion suggester.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.