在SOLR 4.1中使用termfreq(field,term)函数表示带空格的短语



我使用termfreq(字段,术语)SOLR函数。如此:

?fl=product_name,termfreq(product_name,"iphon")&q=iphone 4s     //Found freq

但问题是,像"iphone 4s"这样的术语有空格

?fl=product_name,termfreq(product_name,"iphon 4s")&q=iphone 4s  //Return 0 freq

返回0频率,尽管该术语(短语)存在于文档中。所以,问题是,我可以使用termfreq()函数与完整的短语,如"iphone 4s",以及如何?

我正在使用SOLR 4.1。字段的分析器为

<fieldType name="text_ws" class="solr.TextField">
    <analyzer>
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>
        <filter class="solr.LowerCaseFilterFactory"/>
    </analyzer>
</fieldType>

字段

<field name="product_name" type="text_ws" indexed="true" stored="true"/>

当您使用WhitespaceTokenizerFactory时,术语iphone 4s将不作为术语存在。
您可以使用KeywordTokenizerFactory进行索引,它不会对单词进行标记,而短语应该可用。
否则,您可以检查带状选项,它将为您分组单词。

最新更新