Solr 查询返回一个字段的部分匹配项,而不是另一字段
我的网站上有一个搜索自动完成功能,我正在使用 Solr 来查找匹配的文档。我正在尝试获取页面标题的部分匹配,例如 Java* 将匹配 Java、Javascript 等。截至目前,自动完成功能已设置为对页面中的所有文本进行部分匹配,这给出了一些奇怪的结果,所以我决定改用页面标题。但是,当我尝试将页面文本的搜索词从 text
切换为 title
时,查询突然不再获取部分匹配项。这是我原来的查询的一个例子:
q=text:java^2+text:"java"
&hl=true&hl.snippets=1&hl.fragsize=25&hl.fl=title&start=0&rows=3
不幸的是,为我设置这个的人不再和我一起工作了,所以我不知道“幕后”发生了什么。我正在使用 Spring/J2EE 作为我的后端,如果这有什么区别的话。
I have a search autocomplete on my site, and I'm using Solr to find matching documents. I am trying to get partial matches on page titles, so for example Java* would match Java, Javascript, etc. As of right now, the autocomplete is set up to give me partial matches on all of the text in the page, which gives some weird results, so I've decided to switch over to using the page title. However, when I try to switch the search term from text
for the page text to title
, the query suddenly does not pick up partial matches any more. Here is an example of my original query:
q=text:java^2+text:"java"
&hl=true&hl.snippets=1&hl.fragsize=25&hl.fl=title&start=0&rows=3
Unfortunately, the guy who set this up for me does not work with me any more, so I have little idea what's going on 'under the hood'. I'm using Spring/J2EE for my backend, if that makes any difference.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要确保该字段不是基于字符串的字段。如果您查看
schema.xml
,则可以查找此内容。如果您在字符串字段中使用Java*
进行搜索,它将仅匹配以Java*
开头的标题。另一件事是您需要确保您知道通配符查询区分大小写(请参阅此)。
You need to make sure that the field is no string based field. You can lookup this if you take a look at your
schema.xml
. If you search withJava*
inside a string field it will match only titles which start withJava*
.Another thing is that you need to make sure that you are aware that Wildcard Queries are case sensitive (see this).
取决于字段标题的分析方式,请查看 schema.xml 以了解该字段的类型以及如何分析它以创建术语。简单的方法是转到 solr admin http://localhost:8983/solr/admin /analysis.jsp,选择相同名称选项,输入字段名称(我猜是“标题”),输入一些示例文本并查询以查看创建和匹配的术语。
Depends on how the field title was analyzed, look at schema.xml to see what type the field is and how its analyzed to create term. Easy way to do that would be to go to solr admin http://localhost:8983/solr/admin/analysis.jsp, choose the same name option, type in the field name (am guessing 'title') put some sample text and query to see what terms are created and matched.