在字符串类型字段上搜索时遇到问题

时间:2012-04-27 18:08:20

标签: solr solrj

我在Solr搜索中遇到问题。 我的架构如下

<fieldType name="c_text" class="solr.TextField">
<analyzer type="index">
    <tokenizer class="solr.WhitespaceTokenizerFactory"/>
    <filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
    <tokenizer class="solr.WhitespaceTokenizerFactory"/>
    <filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
<field name="parentId" type="string" indexed="true" stored="true"/>
<field name="data_s" type="c_text" indexed="true" stored="true"/>
<field name="email" type="string" indexed="true" stored="true"/>
<field name="receivedDate" type="tdate" indexed="true" stored="true"/>

我在电子邮件领域搜索。其中包含以下格式的数据
Tarun Nagpal&lt; tarunn@abc.com>

//This is working fine
email:*tarun*

但是下面没有给出结果

email:"Tarun Nagpal"

你能帮忙吗,为什么不搜索电子邮件领域的搜索短语。 在data_s字段上搜索工作正常。

1 个答案:

答案 0 :(得分:3)

您需要使用文本字段类型,因为您打算搜索令牌:

具体针对Tarun Nagpal <tarunn@abc.com>

字符串字段将回答==平等和通配符查询,例如*un Nagp**unn@abc.com>以及更明显的异国情调查询。

文字字段将回答令牌tarunnagpaltarunn abccom

实现N-gram和Soundex的其他字段类型甚至可以纠正您的拼写。


查看优秀的https://stackoverflow.com/a/2119479/604511

相关问题