Solr电子邮件地址搜索返回0结果

时间:2015-04-23 01:52:25

标签: solr

我正在尝试允许在Solr 4.0中进行部分或完整的电子邮件搜索。

以下是我的测试用例:

  • flast@company.com
  • 式Flash

我试过了this。但是我没有得到第一个案例的确切结果,其中提供了整个电子邮件而没有获得第二个结果的任何结果(这恰好是一个唯一的值),这意味着Solr没有查看电子邮件字段。 / p>

这是截断的架构。我必须遗漏一些明显的东西,但我没有看到它。

<schema name="Search" version="1.5">
<types>
    <fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/>

    <fieldType name="text_email" class="solr.TextField" sortMissingLast="true" omitNorms="true" autoGeneratePhraseQueries="true">
      <analyzer type="index">
        <tokenizer class="solr.StandardTokenizerFactory" />
        <filter class="solr.LowerCaseFilterFactory" />
        <filter class="solr.WordDelimiterFilterFactory" />
      </analyzer>
      <analyzer type="query">
        <tokenizer class="solr.StandardTokenizerFactory" />
        <filter class="solr.LowerCaseFilterFactory" />
        <filter class="solr.WordDelimiterFilterFactory" />
      </analyzer>
    </fieldType>
</types>

<fields>
    .
    .
    .
    <field name="email" type="text_email" indexed="true"  stored="true"/>
    .
    .
    .
</fields>

1 个答案:

答案 0 :(得分:1)

Use wordDelimiterFilterFactory as below.

<filter class="solr.WordDelimiterFilterFactory"
                generateWordParts="1"
                generateNumberParts="0"
                catenateWords="0"
                catenateNumbers="0"
                catenateAll="0"
                preserveOriginal="1"
                />

generateWordParts="1" will help to generate parts of words:

preserveOriginal="1" causes the original token to be indexed without modifications.

The final type should look like :

<analyzer type="index">
        <tokenizer class="solr.StandardTokenizerFactory" />
        <filter class="solr.WordDelimiterFilterFactory"
                generateWordParts="1"
                generateNumberParts="0"
                catenateWords="0"
                catenateNumbers="0"
                catenateAll="0"
                preserveOriginal="1"
                />
        <filter class="solr.LowerCaseFilterFactory" />
      </analyzer>
      <analyzer type="query">
        <tokenizer class="solr.StandardTokenizerFactory" />
        <filter class="solr.WordDelimiterFilterFactory"
                generateWordParts="1"
                generateNumberParts="0"
                catenateWords="0"
                catenateNumbers="0"
                catenateAll="0"
                preserveOriginal="1"
                />
        <filter class="solr.LowerCaseFilterFactory" />
      </analyzer>