Site rank (which is a pre-determined numeric rank)
I have a search field that the user can search on the "site name". My intention is to allow the search and then order the results based on the site rank. I tried to sort the documents based on the site rank, but then the result has all irrelevant documents, i.e., the query result is not being used for sort
I have tried function_score, but my results are messed up, where-in search for "char" gives results that start with "chas".
sorting the search results on a numeric field after filtering the documents by some search should work. So I'd check first that everything is okay with your search. What is the mapping of the field you allow your users to search on?
Your example suggests you are using two different filter criteria (some locale and some other value, its unclear to me chat it represents). If you combine those in a "should" clause, documents satisfying either of those two this get returned, so maybe this is something to look into first.
The locale is to boost results specific to region. The reason for should is if the search exhausts the results of that region, then the search should return results in other regions (this works). I can even remove the locale in this case and try only sorting the results after search, but sort just sorts everything with the highest rank and not based on my search results
Why are you using the edge_ngram filter with those settings? This explains
because you are indexing each input token with lots if edge ngrams. At search time the analyzer is also applied to your query, so when searching for "char"m this will also be broken donw as "c", "ch", "cha" and "char", so you will get tons of matches. You should define another search_analyzer that doesn't do the edge ngram analysis.
I wanted to have edge-ngram so that I can enable 'search as user types' and not using it would not help my usecase. Can you please confirm
Can you suggest any other mechanism on how I can enable 'search as user types' but not use edge-ngram
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.