Set solr search term required characters

2019-07-08 03:11发布

问题:

Where in Solr can we set the limit for required characters in Solr search terms?

For example, I want to set the search term characters limit to nothing which should return all the results

Another example-

Suppose, I want to set the search term characters limit to 5. So when I search for "apple" (5 characters) or "orange" (5 characters or more) should return results. In this case, if I search for "cat", it should not return any results as the minimum required characters is 5.

Where do we set such required characters limit for search terms in Solr?

回答1:

If you don't want to index and / or search terms with a predefined interval of characters you can do that by configuring a LengthFilter in your analyzer (at index and / or query time depending on your specific needs)

See here:

http://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters#solr.LengthFilterFactory