为什么solr仅通过精确搜索返回结果? [英] Why is solr returning result with only exact search?
问题描述
我创建了一个核心,secondCore{id, resid, title, name, cat, role, exp}
考虑一个样本数据:{"id" : "11","resid" : 384,"title" : "perl and java developer","name" : "appnede new name","cat" : "22,11","role" : "new role","exp" : 1 }
.
当我搜索title:perl
时,我得到0个结果.仅当我搜索title:"perl and java developer"
或title:perl*
时,我才会得到提及的结果.
响应:
I have created a core, secondCore{id, resid, title, name, cat, role, exp}
Consider a sample data: {"id" : "11","resid" : 384,"title" : "perl and java developer","name" : "appnede new name","cat" : "22,11","role" : "new role","exp" : 1 }
.
When I search for title:perl
, I get 0 result. I get mentioned result, only if I search for title:"perl and java developer"
or title:perl*
.
Response:
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">2</int>
<lst name="params">
<str name="indent">true</str>
<str name="q">title:perl*</str>
<str name="_">1444371225114</str>
<str name="wt">xml</str>
</lst>
</lst>
<result name="response" numFound="1" start="0">
<doc>
<str name="id">11</str>
<arr name="resid">
<long>384</long>
</arr>
<arr name="title">
<str>perl and java developer</str>
</arr>
<arr name="name">
<str>appnede new name</str>
</arr>
<arr name="cat">
<long>2211</long>
</arr>
<arr name="role">
<str>new role</str>
</arr>
<arr name="exp">
<long>1</long>
</arr>
<long name="_version_">1514531870450122752</long></doc>
</result>
</response>
此外,为什么响应在arr <arr name="role"><str>new role</str></arr>
中?我想要在<str name="role">new role</str>
中使用它,因此也需要其他文件.怎么做?我正在使用solr 5.3.0.
Also, why response is in arr <arr name="role"><str>new role</str></arr>
? I want it in <str name="role">new role</str>
and so with other fileds also. How to do? I'm using solr 5.3.0.
推荐答案
我认为您已将字段定义为字符串而不是文本.字符串字段确实匹配,而文本字段将为您提供所需的结果.
I think you have defined your field as string instead of text. String field does exact match whereas a text field will get you the results you are looking for.
还可以查看其他答案: https://stackoverflow.com/a/7187441/147306
Check out this other answer also : https://stackoverflow.com/a/7187441/147306
这篇关于为什么solr仅通过精确搜索返回结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!