in my solr schema file i have a default search field which uses EdgeNGramFilterFactory
<filter class="solr.EdgeNGramFilterFactory" minGramSize="3" maxGramSize="15" side="front" />
assumed that my search query is
tes
so I get results like that:
tess
test
tesla
...
if I search for
test
I get results like
test
tess
tesla
...
Its ok because I use EdgeNGramFilterFactory with minGramSize=3 but I want the following:
When I search for a string which length is more than 3 characters (for example test) I want that solr ignore all the terms which consists of 3 characters (EdgeNGramFilterFactory). When I search for "test" i don't want to get results like "tess" or "tesla". I wont get Results which begin with test (4 characters) like
test
test for
test-drive
...
Is it possible to configure that in solr?
You may configure the EdgeNGram filter in the field's index analyzer only; for query analyzer, still do regular tokenization w/o any EdgeNGram. So that when you search "test", only results prefixed with exact "test" will be returned.
config e.g. (don't define EdgeNGram for query analyzer)
<fieldType name=...>
<analyzer type="index">
...
<filter class="solr.EdgeNGramFilterFactory" minGramSize="4" maxGramSize="15" side="front" />
</analyzer>
<analyzer type="query">
...
<!-- <filter class="solr.EdgeNGramFilterFactory" minGramSize="4" maxGramSize="15" side="front" /> -->
</analyzer>
</fieldType>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With