开发者

Solr search query similar to %text%

I a开发者_开发知识库m using Solr. I need to search those entries which also matches partially with the provided text

the functionality should be similar to the sql query

like %text%

how will I do this?


I solved my problem...

simply I need to use *text*

Thanks all


You should consider using n-gram analysis instead of asteriks. It is slow compared to n-gram. Take a look at, N-Gram Tokenizer


Thanks zinan.yumak

I did it again in your way

<fieldType name="text_en" class="solr.TextField" positionIncrementGap="100">

    <analyzer type="index">
        <tokenizer class="solr.StandardTokenizerFactory" />
        <filter class="solr.StandardFilterFactory"/>
        <filter class="solr.SynonymFilterFactory" synonyms="index_immo_synonyms_en.txt" ignoreCase="true" expand="true" />
        <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1"
            catenateNumbers="1" catenateAll="0" splitOnCaseChange="1" />
        <filter class="solr.LowerCaseFilterFactory"/>
        <filter class="solr.StopFilterFactory" ignoreCase="true" words="immo_stopwords_en.txt" />
        <filter class="solr.SnowballPorterFilterFactory" language="English"  protected="protwords_en.txt"/>
        <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
    </analyzer>

    <analyzer type="query">
        <tokenizer class="solr.WhitespaceTokenizerFactory" />
        <filter class="solr.StandardFilterFactory"/>
        <!-- we only use synonyms at index time <filter class="solr.SynonymFilterFactory" synonyms="index_immo_synonyms_en.txt"
             ignoreCase="true" expand="true"/>. Having expand="false" at query time, all equivalent synonyms will be reduced
             to the first in the list -->
        <filter class="solr.SynonymFilterFactory" synonyms="query_immo_synonyms_en.txt" ignoreCase="true" expand="false" />
        <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0"
            catenateNumbers="0" catenateAll="0" splitOnCaseChange="1" />
        <filter class="solr.LowerCaseFilterFactory"/>
        <filter class="solr.StopFilterFactory" ignoreCase="true" words="immo_stopwords_en.txt" />
        <filter class="solr.SnowballPorterFilterFactory" language="English"  protected="protwords_en.txt"/>
        <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
    </analyzer>
</fieldType>

And use this type type to the fields

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜