Solr在搜索数字时没有回答

时间:2013-09-10 13:24:38

标签: solr

我正在使用

查询
http://...:8983/solr/vault/select?q="design test"&fl=PackageName

我得到3个结果:

  • 设计测试
  • design test 2013
  • 工作的设计测试

现在当我使用q =“test for jobs”查询时    - >我只得到“工作的设计测试”

但是当我使用q = 2013查询时

http://...:8983/solr/vault/select?q=2013&fl=PackageName

我没有结果。 当我用数字查询时,为什么它不会返回答案?

在架构xml中

 <field name="PackageName" type="text_en" indexed="true" stored="true" required="true"/>

修改 的 这是text_en。 它附带初始配置(schema.xml)

<fieldType name="text_en" class="solr.TextField" positionIncrementGap="100">
  <analyzer type="index">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <!-- in this example, we will only use synonyms at query time
    <filter class="solr.SynonymFilterFactory" synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/>
    -->
    <!-- Case insensitive stop word removal.
      add enablePositionIncrements=true in both the index and query
      analyzers to leave a 'gap' for more accurate phrase queries.
    -->
    <filter class="solr.StopFilterFactory"
            ignoreCase="true"
            words="lang/stopwords_en.txt"
            enablePositionIncrements="true"
            />
    <filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.EnglishPossessiveFilterFactory"/>
    <filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/>
<!-- Optionally you may want to use this less aggressive stemmer instead of PorterStemFilterFactory:
    <filter class="solr.EnglishMinimalStemFilterFactory"/>
-->
    <filter class="solr.PorterStemFilterFactory"/>
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
    <filter class="solr.StopFilterFactory"
            ignoreCase="true"
            words="lang/stopwords_en.txt"
            enablePositionIncrements="true"
            />
    <filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.EnglishPossessiveFilterFactory"/>
    <filter class="solr.KeywordMarkerFilterFactory" protected="protwords.txt"/>
<!-- Optionally you may want to use this less aggressive stemmer instead of PorterStemFilterFactory:
    <filter class="solr.EnglishMinimalStemFilterFactory"/>
-->
    <filter class="solr.PorterStemFilterFactory"/>
  </analyzer>
</fieldType>

1 个答案:

答案 0 :(得分:0)

默认text_en类型不会删除数字。您可以在管理面板的“分析”选项卡中进行检查:在组合框中选择text_en,然后在索引和查询字段中键入2013,并查看它们的分析方式。

查询应如下所示:http://...:8983/solr/vault/select?q=PackageName:2013http://...:8983/solr/vault/select?q=2013&fl=PackageName表示您要在默认字段中搜索(默认字段是什么?),并希望在结果中仅显示PackageName字段。