Difference between NGramFilterFactory and EdgeNGramFilterFactory
Asked Answered
O

1

5

I am a beginner in Solr. In my project, NGramFilterFactory and EdgeNGramFilterFactory, both are being used for a field. My understanding as per the document is EdgeNGramFilterFactory is used for "starts with" query while NGramFilterFactory is suitable for "contains" query.

I indexed a small dataset for both combinations (one in which I used only NGramFilterFactory and in another I used both NGramFilterFactory and EdgeNGramFilterFactory) but I did not see any difference in the output.

If my understanding is correct, in a way EdgeNGramFilterFactory is a subset of NGramFilterFactory. If this is true then is there any benefit of using both types of filters on the same field?

Obligatory answered 18/5, 2015 at 9:14 Comment(3)
did you had a read here cwiki.apache.org/confluence/display/solr/…Ramos
Yes, I already referred this document but I want to be 100% sure that removing EdgeNGramFilterFactory wont affect result as this change is going to be in production.Obligatory
I would suggest try analysis of it using the solr analysis tool. That gives you clear idea of how indexing output would be ...Ramos
T
9

You should not be using both filters on the same field, they will completely mess up your matching. If you need to match in a middle of a token, you use NGrams. If you only need to match from the start, you use EdgeNGrams. Never both together.

Teage answered 18/5, 2015 at 23:40 Comment(2)
The matching from the end is deprecated and - in later Solr - does not work. If matching from the end is required, a reversing filter should be used in both analysis and query chains.Teage
Ah, good point. I forgot that. The wiki really needs to be updated.Linguini

© 2022 - 2024 — McMap. All rights reserved.