Imagine a situation where you have an e-commerce bookstore and you want to make a search algorithm that tries to bring the best search results to your customers. However, you notice that many of your customers tend to make queries with too many words, which results in an empty result list. So, you decide to make a query that will require a maximum of two of the words, which the user entered, to be matched. This recipe will show you how to do it.
Before we continue, it is crucial to mention that the following method can only be used with the dismax
or edismax
query parser. For the list of available query parsers, refer to http://wiki.apache.org/solr/QueryParser.