I have a collection of product data (cameras) that I am indexing.
Users can search a product by providing a phrase and I want to enable
'auto complete' or 'auto suggestions' feature.
Being new to search domain, what query types are recommended for these
2 use cases?
Currently, I am inclined towards textPhrasePrefixQuery for 'auto
suggestions' and text query for user provided search string.
I'm also implementing an 'autocomplete' feature and I'm not very experienced
in that area.
textPhrasePrefixQuery is a good starting point, but I dropped it for
several reasons:
ranking is a bit strange
That looked a bit slow to run (but I did not make a scientific
evaluation of that).
if the prefix is too short, it can fail.
If you look for 'fo ba', it will miss 'foo bar'
Internally, it generates a lot of sub queries (one for every token in the
index that has the same prefix) and I suppose it does some kind of a massive
OR or dismax between them (that explains the problem I had).
So instead, I choose to index my field with an NGram token filter and I just
do a regular 'text' query on it. I'm happy with the results for now
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.