Solr 搜索忽略第一个单词
我在网上浏览过SO和其他地方,但没有找到任何特定于我的问题的内容。我想知道还有其他人经历过吗?他们又是如何解决的呢?
我正在尝试对多单词字段进行通配符搜索,当我输入第一个单词时,它工作得很好,但是一旦我开始输入第二个单词,第一个单词就会被忽略。
我的索引的每个文档代表一个人,并具有索引字段“姓名”。
<field name="name" type="string" indexed="true" stored="true" required="true" />
应该发生什么:
当我输入“Bruce Rob”时,它应该返回文档“Bruce Robertson”。
发生了什么:
当我输入“Bru”时,它确实返回“Bruce Robertson”。但是,一旦我开始第二个单词,例如“Bruce Rob”,它就会开始返回以“Rob”开头的结果 - 完全忽略前面的单词。
我正在使用 PHP 客户端库。它生成的查询如下所示:
fq=type%3Aperson&sort=id+desc&wt=json&json.nl=map&q=name%3Abruce+rob%2A&start=0&rows=3
任何帮助将不胜感激。
编辑:PHP 代码
$options = array('fq' => "type:person",'sort' => 'id desc');
$results = $this->solr->search('name:' . $val . '*', 0, 3, $options);
I've looked around SO and elsewhere online but haven't found anything specific to my problem. I was wondering anyone else experienced it? And how did they resolve?
I am trying to do a wildcard search for a multi worded field, which works fine while I type the first word, but as soon as I start typing the second word the first word gets ignored.
Each document of my index represents one person and has the indexed field 'name'.
<field name="name" type="string" indexed="true" stored="true" required="true" />
What should happen:
When I type: 'Bruce Rob' it should return the document 'Bruce Robertson'.
What is happening:
When I type 'Bru' it does return 'Bruce Robertson'. But as soon as I start the second word e.g. 'Bruce Rob' it will begin to return results that start with 'Rob' - totally ignoring the word that came before.
I'm using the PHP client library. The query it generates looks like so:
fq=type%3Aperson&sort=id+desc&wt=json&json.nl=map&q=name%3Abruce+rob%2A&start=0&rows=3
Any help would be greatly appreciated.
EDIT: PHP Code
$options = array('fq' => "type:person",'sort' => 'id desc');
$results = $this->solr->search('name:' . $val . '*', 0, 3, $options);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它正在名称字段
name:bruce
中搜索 bruce,但由于 rob 没有使用字段名称限定,因此它将针对默认字段搜索
在您的架构中定义。rob*
defaultSearchFieldIt is searching for bruce in the name field
name:bruce
but since rob isn't qualified with a field name it will search forrob*
against the default fielddefaultSearchField
defined in your schema.