搜索字符串类型字段时遇到问题 [英] Facing issue while searching on string type field
问题描述
我在 Solr 搜索中遇到问题.我的架构如下
I am facing issue in Solr search. My schema is as follows
<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
I am searching on email field. which contains the data in following format
Tarun Nagpal <tarunn@abc.com>
//This is working fine
email:*tarun*
但是下面没有结果
email:"Tarun Nagpal"
你能帮忙吗,为什么它不像在电子邮件字段中搜索那样搜索词组.在 data_s 字段上搜索工作正常.
Can you please help, why it is not searching phrase like search on email field. Search on data_s field is working fine.
推荐答案
您需要使用文本字段类型,因为您打算搜索标记:
You need to use the text field type since you intend to search the tokens:
针对Tarun Nagpal
:
string 字段将回答 ==
等式和通配符查询,例如 *un Nagp*
、*unn@abc.com>
甚至更明显的奇特查询.
A string field will answer ==
equality and wildcard queries like *un Nagp*
, *unn@abc.com>
and even more apparently exotic queries.
text 字段将回答标记 tarun
、nagpal
、tarunn
abc
和 com
.
A text field will answer to the tokens tarun
, nagpal
, tarunn
abc
and com
.
其他实现 N-gram 和 Soundex 的字段类型甚至可以纠正您的拼写.
Other field types implementing N-gram and Soundex can even correct your spelling.
查看优秀的https://stackoverflow.com/a/2119479/604511
这篇关于搜索字符串类型字段时遇到问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!