Sunspot `LIKE` query

后端 未结 1 660
忘掉有多难
忘掉有多难 2021-01-14 22:25

I\'m using sunspot. How can I run a LIKE query (LIKE %q%)? I would like to do something like this:

 @search = Sunspot.         


        
相关标签:
1条回答
  • 2021-01-14 23:18

    If you use the standard DisMax handler, it does not support wildcards. You have 2 options:

    a. Activate EdgeNGramFilter:

    <fieldType name="text" class="solr.TextField" omitNorms="false">
      <analyzer type="index">
        ..
        <filter class="solr.EdgeNGramFilterFactory" minGramSize="2" maxGramSize="15" side="front"/>
        ..
      </analyzer>
    </fieldType>
    

    b. Use nightly build Solr with EDismax Handler.

    See wiki article on sunspot docs or similar question on SO.

    0 讨论(0)
提交回复
热议问题