Juan Carlos Serrano
Juan Carlos Serrano

Reputation: 103

The best practice to search on solr with wildcard at the beginning and at the end

I want to search text within words, as foo to find barfoobar or foobar or barfoo With solr.

My field type configuration is:

<fieldtype name="searchableContentTokenized" class="solr.TextField" positionIncrementGap="100">
    <analyzer type="index">
        <charFilter class="solr.MappingCharFilterFactory" mapping="char-mapping.txt" />
        <tokenizer class="solr.PatternTokenizerFactory" pattern="[\s\&quot;]+" />
        <filter class="solr.LowerCaseFilterFactory" />
    </analyzer>
    <analyzer type="query">
        <charFilter class="solr.MappingCharFilterFactory" mapping="char-mapping.txt" />
        <tokenizer class="solr.PatternTokenizerFactory" pattern="[\s\&quot;]+" />
        <filter class="solr.LowerCaseFilterFactory" />
    </analyzer>
</fieldtype>

When use foo in query (q=content:* foo *) the search takes too long because my index the has 500,000 documents and occupies 30 GB.

There is a better way to do the search?

Thanks, in advance.

Upvotes: 0

Views: 383

Answers (1)

Abhijit Bashetti
Abhijit Bashetti

Reputation: 8658

try with the below field type

<fieldType name="text_reference" class="solr.TextField" sortMissingLast="true" omitNorms="true" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.EdgeNGramFilterFactory" minGramSize="2" maxGramSize="50" side="front"/>
<filter class="solr.EdgeNGramFilterFactory" minGramSize="2" maxGramSize="50" side="back"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>

Upvotes: 1

Related Questions