0

我正在使用标准的 Solr ngram 字段定义——

<fieldType name="ngram" class="solr.TextField" positionIncrementGap="100" stored="false" multiValued="true">
  <analyzer type="index">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <!-- potentially word delimiter, synonym filter, stop words, NOT stemming -->
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.NGramFilterFactory" minGramSize="2" maxGramSize="15"/>
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <!-- potentially word delimiter, synonym filter, stop words, NOT stemming -->
    <filter class="solr.LowerCaseFilterFactory"/>
  </analyzer>
</fieldType>

<field name="item" type="text" indexed="true" stored="true"/>
<field name="item_ngram" type="ngram" indexed="true" stored="true"/>

现在“item:ipad AND item:2”找到“iPad 2”,但“item_ngram:ipad AND item_ngram:2”没有。

任何的想法?

4

1 回答 1

2

您的 n-gram 的最小长度为 2 (minGramSize="2")。所以 item_ngram:2 不会匹配任何东西。将其减少到 1,您将获得匹配项。

于 2012-01-05T10:47:39.530 回答