sarvesh
sarvesh

Reputation: 57

partial word search in solr example: sarvesh , i want search like rves

examples:Beautiful
search based: auti...
I would like to search with only part of a word, not the whole word.
For example when I search auti only the middle 3 letters ,not the whole word.I am not getting results : For the moment I am using the search api with apache solr (and perhaps views).
Any suggestions please?
I am using this one

<fieldType name="string_ci" class="solr.TextField" sortMissingLast="true" omitNorms="true">
    <analyzer>
        <tokenizer class="solr.StandardTokenizerFactory"/>
        <filter class="solr.StandardFilterFactory"/>
        <filter class="solr.LowerCaseFilterFactory"/>
        <filter class="solr.EdgeNGramFilterFactory" minGramSize="1" maxGramSize="10"/>
    </analyzer>
</fieldType>

Upvotes: 3

Views: 6128

Answers (2)

Aujasvi Chitkara
Aujasvi Chitkara

Reputation: 939

Now since you wanna search for sub-strings inside words, you can add side="back" to your definition, and that should help you achieve your goal.

So your fieldtype definition will look like this:

<fieldType name="string_ci" class="solr.TextField" sortMissingLast="true" omitNorms="true">
    <analyzer>
        <tokenizer class="solr.StandardTokenizerFactory"/>
        <filter class="solr.StandardFilterFactory"/>
        <filter class="solr.LowerCaseFilterFactory"/>
        <filter class="solr.EdgeNGramFilterFactory" minGramSize="1" maxGramSize="10" side="front" />
        <filter class="solr.EdgeNGramFilterFactory" minGramSize="1" maxGramSize="10" side="back" />
    </analyzer>
</fieldType>

Upvotes: 1

Aujasvi Chitkara
Aujasvi Chitkara

Reputation: 939

You can use wildcard query.

In your example above, you should prepend and append your search terms with an asterix, so if someone searches for auti, the query you send to server will be auti

This should pull all results with all words that contain the word auti within them.

http://www.solrtutorial.com/solr-query-syntax.html

Upvotes: 4

Related Questions