I have a situation where I need to use both EdgeNGramFilterFactory and NGramFilterFactory.
I am using NGramFilterFactory to perform a “contains” style search with min number of characters as 2. I also want to search for the first letter, like a “startswith” with a front EdgeNGramFilterFactory.
I dont want to lower the NGramFilterFactory to min characters of 1 as I dont want to index all characters.
Some help would be greatly appreciated
Cheers
You don’t necessarily have to do all this in the same field. I would create a different fields using different custom types for each treatment so that you can apply the logic separately.
In the following:
textcontains the original tokens, minimally processed;text_ngramuses the NGramFilter for your two-character-minimum tokenstext_first_letteruses EdgeNGram for your one-character initial-letter tokensIf you’re processing all
textfields in this way, then you might be able to get away with using acopyFieldto populate the fields. Otherwise, you can instruct your Solr client to send in the same field values for the three separate field types.When searching, include all of them in your searches with the
qfparameter.Setting up
fieldanddynamicFielddefinitions are left up to you. Or let me know if you have more questions and I can edit with clarifications.