I think this question has been asked a few times in various ways. As I understand, AppSearch aims to have a high recall. We have a use-case where we'd like to increase precision.
One way to do that is by adjusting the fuzziness, but this does not seem to be doable. Is this something that is on the roadmap?
The solution about filtering results on a set score threshold does not seem to work either. Sometimes a query will return results with high scores (20-30) and results that are not relevant will still have a score on ~5. Other times, the most relevant result has a score of 1, so setting a "hard" threshold does not seem to work.
Are there any other options? Hopefully you can help
A suggestion I've made before for someone implementing a search on a Name field, was to have a primary query that is very specific, and then a fallback query if that returns no results. So in other words, if a user searches for "John Smith", try performing an exact match query by searching for "John Smith" (with quotes), and if that returns 0 results, fallback to performing that query without quotes.
I recently came across a quirk that can help increase precision. It's a side effect of this suggestion:
The query doesn't necessarily need to be "more specific". Introducing any Boolean operator (AND, OR etc) changes the matching mode app search uses. Without Boolean operators, search terms are chopped into parts ("ngrams") so that dress effectively searches for dress OR dre OR ess. This form of fuzzy matching should rank dress or dresses highest but will also match words like mattress.
As soon as you introduce a Boolean operator of any kind app-search switches mode and searches for exact words only, not parts of words. The example searches below would only match documents with the word dress and not mattress:
dress AND dress
dress OR dress
dress NOT wordThatDoesNotExist
dress OR wordThatDoesNotExist
"dress"
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.