Solr Facet and Tokenizer

坚强是说给别人听的谎言 提交于 2019-12-25 09:07:19

问题


I have solr array field that could contain string with some separate words as a one value, for example ["Super Ball", "BlaBla", "Info"]. I need to see all those 3 values as an facet values and have case insensitive search by fields as well.

If I use next field type setting I see 3 values in facet but case insensitive search doesn't work.

<fieldType name="myLower" class="solr.TextField" positionIncrementGap="100">
     <analyzer type="index"> 
        <tokenizer class="solr.KeywordTokenizerFactory"/>    
        <filter class="solr.LowerCaseFilterFactory"/>
      </analyzer>
      <analyzer type="query">     
        <tokenizer class="solr.KeywordTokenizerFactory"/>       
        <filter class="solr.LowerCaseFilterFactory"/>
      </analyzer>
   </fieldType>

if I use <tokenizer class="solr.StandardTokenizerFactory"/> I can use lower case search, but I see 4 facet values, becourse StandardTokenizerFactory splits "Super Ball" to 2 words.

How to manage such case ?


回答1:


Use two separate fields. One for faceting and one for searching - they're different operations and different field definitions will suite each better.

Use <copyField source="searchfield" dest="facetfield" maxChars="30000" /> to copy the contents you're sending into your searchfield to a dedicated faceting field. Use the facetfield (with either keywordtokenizer + lowercasing or just a string field if you want to keep the case intact) for faceting, and perform searches against the searchfield. The facetfield will also be used when you're applying fq filters when the user has picked a facet for further filtering.



来源:https://stackoverflow.com/questions/41483832/solr-facet-and-tokenizer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!