rails 4 solr搜索复数词

时间:2013-11-20 18:38:47

标签: ruby-on-rails solr ruby-on-rails-4 sunspot sunspot-solr

我的网站上有文字搜索,用户会在其中发布一些内容。例如,这些是两个帖子的标题

1. car for sale
2. cars selling company

如果我搜索car,它会同时显示结果,但如果我搜索cars我没有得到任何结果,但实际上我需要两个结果。

这是我的schema.xml

                                                                   

  <analyzer type="query">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.StandardFilterFactory"/>
    <filter class="solr.LowerCaseFilterFactory"/>
  </analyzer>
</fieldType>
<fieldType name="boolean" class="solr.BoolField" omitNorms="true"/>
<fieldType name="date" class="solr.DateField" omitNorms="true"/>
<fieldType name="sdouble" class="solr.SortableDoubleField" omitNorms="true"/>
<fieldType name="sfloat" class="solr.SortableFloatField" omitNorms="true"/>
<fieldType name="sint" class="solr.SortableIntField" omitNorms="true"/>
<fieldType name="slong" class="solr.SortableLongField" omitNorms="true"/>
<fieldType name="tint" class="solr.TrieIntField" omitNorms="true"/>
<fieldType name="tfloat" class="solr.TrieFloatField" omitNorms="true"/>
<fieldType name="tdate" class="solr.TrieDateField" omitNorms="true"/>


<fieldType name="location" class="solr.LatLonType" subFieldSuffix="_coordinate"/>

  

<field name="id" stored="true" type="string" multiValued="false" indexed="true"/>
<field name="type" stored="false" type="string" multiValued="true" indexed="true"/>
<field name="class_name" stored="false" type="string" multiValued="false" indexed="true"/>
<field name="text" stored="false" type="string" multiValued="true" indexed="true"/>
<field name="lat" stored="true" type="tdouble" multiValued="false" indexed="true"/>
<field name="lng" stored="true" type="tdouble" multiValued="false" indexed="true"/>
<dynamicField name="random_*" stored="false" type="rand" multiValued="false" indexed="true"/>
<dynamicField name="_local*" stored="false" type="tdouble" multiValued="false" indexed="true"/>
<dynamicField name="*_text" stored="false" type="text" multiValued="true" indexed="true"/>
<dynamicField name="*_texts" stored="true" type="text" multiValued="true" indexed="true"/>
<dynamicField name="*_b" stored="false" type="boolean" multiValued="false" indexed="true"/>
<dynamicField name="*_bm" stored="false" type="boolean" multiValued="true" indexed="true"/>
<dynamicField name="*_bs" stored="true" type="boolean" multiValued="false" indexed="true"/>
<dynamicField name="*_bms" stored="true" type="boolean" multiValued="true" indexed="true"/>
<dynamicField name="*_d" stored="false" type="date" multiValued="false" indexed="true"/>
<dynamicField name="*_dm" stored="false" type="date" multiValued="true" indexed="true"/>
<dynamicField name="*_ds" stored="true" type="date" multiValued="false" indexed="true"/>

<dynamicField name="*_dms" stored="true" type="date" multiValued="true" indexed="true"/>

<dynamicField name="*_e" stored="false" type="sdouble" multiValued="false" indexed="true"/>

<dynamicField name="*_em" stored="false" type="sdouble" multiValued="true" indexed="true"/>

<dynamicField name="*_es" stored="true" type="sdouble" multiValued="false" indexed="true"/>

<dynamicField name="*_ems" stored="true" type="sdouble" multiValued="true" indexed="true"/>

<dynamicField name="*_f" stored="false" type="sfloat" multiValued="false" indexed="true"/>

<dynamicField name="*_fm" stored="false" type="sfloat" multiValued="true" indexed="true"/>

<dynamicField name="*_fs" stored="true" type="sfloat" multiValued="false" indexed="true"/>
<dynamicField name="*_fms" stored="true" type="sfloat" multiValued="true" indexed="true"/>
<dynamicField name="*_i" stored="false" type="sint" multiValued="false" indexed="true"/>

<dynamicField name="*_im" stored="false" type="sint" multiValued="true" indexed="true"/>

<dynamicField name="*_is" stored="true" type="sint" multiValued="false" indexed="true"/>

<dynamicField name="*_ims" stored="true" type="sint" multiValued="true" indexed="true"/>

<dynamicField name="*_l" stored="false" type="slong" multiValued="false" indexed="true"/>
<dynamicField name="*_lm" stored="false" type="slong" multiValued="true" indexed="true"/>
<dynamicField name="*_ls" stored="true" type="slong" multiValued="false" indexed="true"/>
<dynamicField name="*_lms" stored="true" type="slong" multiValued="true" indexed="true"/>
<dynamicField name="*_s" stored="false" type="string" multiValued="false" indexed="true"/>
<dynamicField name="*_sm" stored="false" type="string" multiValued="true" indexed="true"/>
<dynamicField name="*_ss" stored="true" type="string" multiValued="false" indexed="true"/>
<dynamicField name="*_sms" stored="true" type="string" multiValued="true" indexed="true"/>
<dynamicField name="*_it" stored="false" type="tint" multiValued="false" indexed="true"/>
<dynamicField name="*_itm" stored="false" type="tint" multiValued="true" indexed="true"/>
<dynamicField name="*_its" stored="true" type="tint" multiValued="false" indexed="true"/>
<dynamicField name="*_itms" stored="true" type="tint" multiValued="true" indexed="true"/>
<dynamicField name="*_ft" stored="false" type="tfloat" multiValued="false" indexed="true"/>
<dynamicField name="*_ftm" stored="false" type="tfloat" multiValued="true" indexed="true"/>
<dynamicField name="*_fts" stored="true" type="tfloat" multiValued="false" indexed="true"/>
<dynamicField name="*_ftms" stored="true" type="tfloat" multiValued="true" indexed="true"/>
<dynamicField name="*_dt" stored="false" type="tdate" multiValued="false" indexed="true"/>
<dynamicField name="*_dtm" stored="false" type="tdate" multiValued="true" indexed="true"/>
<dynamicField name="*_dts" stored="true" type="tdate" multiValued="false" indexed="true"/>
<dynamicField name="*_dtms" stored="true" type="tdate" multiValued="true" indexed="true"/>
<dynamicField name="*_textv" stored="false" termVectors="true" type="text" multiValued="true" indexed="true"/>
<dynamicField name="*_textsv" stored="true" termVectors="true" type="text" multiValued="true" indexed="true"/>
<dynamicField name="*_et" stored="false" termVectors="true" type="tdouble" multiValued="false" indexed="true"/>
<dynamicField name="*_etm" stored="false" termVectors="true" type="tdouble" multiValued="true" indexed="true"/>
<dynamicField name="*_ets" stored="true" termVectors="true" type="tdouble" multiValued="false" indexed="true"/>
<dynamicField name="*_etms" stored="true" termVectors="true" type="tdouble" multiValued="true" indexed="true"/>

<dynamicField name="*_coordinate"  type="tdouble" indexed="true"  stored="false" multiValued="false"/>
<dynamicField name="*_p" type="location" indexed="true" stored="true" multiValued="false"/>

<dynamicField name="*_ll" stored="false" type="location" multiValued="false" indexed="true"/>
<dynamicField name="*_llm" stored="false" type="location" multiValued="true" indexed="true"/>
<dynamicField name="*_lls" stored="true" type="location" multiValued="false" indexed="true"/>
<dynamicField name="*_llms" stored="true" type="location" multiValued="true" indexed="true"/>

  ID   文本   

1 个答案:

答案 0 :(得分:1)

您似乎在使用字段类型中使用不同的分析器来搜索文档:

<analyzer type="query">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.StandardFilterFactory"/>
    <filter class="solr.LowerCaseFilterFactory"/>
</analyzer>

我假设您正在使用此分析器搜索文档,索引部分缺失...

您可以在solr admin的分析页面中查看查询:

/ solr的/#/ COREX /分析