当solr是结果的一部分时,首先显示一些结果
我认为这个 solr psedo-doc
<doc>
<field name="title"/>
<field name="name"/>
<field name="keywords"/>
</doc>
一些文档将具有关键字“up”,这意味着当且仅当它们是一部分时,它们应该首先出现(尽管它们的初始顺序位置)搜索结果的强>。
所以可以说我有:
doc1('title1','Bob, Alice','people, up, couple')
doc2('title2','Smart Phone, Laptop, Bob','devices, electronics')
如果我用“title:title2 name:Bob”查询,那么我应该首先得到doc1(它有'up'关键字)。 如果我用“name:Bob”查询,出于同样的原因,我仍然首先得到 doc1。 如果我使用“name:Laptop”查询,那么我应该只在结果中得到 doc2。不应包含 doc1,因为它与我的搜索查询不匹配。
有什么建议可以这样做吗?
I consider this solr psedo-doc
<doc>
<field name="title"/>
<field name="name"/>
<field name="keywords"/>
</doc>
Some doc's will have the keyword "up" which means that they should appear first (despite of their initial order position) when and only when they are part of the search results.
So lets say I have:
doc1('title1','Bob, Alice','people, up, couple')
doc2('title2','Smart Phone, Laptop, Bob','devices, electronics')
if I query with "title:title2 name:Bob" then I should get doc1 first (it has the 'up' keyword).
if I query with "name:Bob" I still get doc1 first for the same reason.
if I query with "name:Laptop" then I should only get doc2 in my results. doc1 should not be included since it doesnt match my search query.
Any suggestion to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您有多种选择可以执行类似操作:
例如(使用 dismax 处理程序) :
You have several options to do something like that:
For example (with dismax handler):
这可以通过 Solr 的查询时间提升来解决。因此,按照 Solr 相关性常见问题解答 的指导 - 您可以添加额外的内容增强所有查询的搜索词,例如
title:title2 name:Bob keywords:up^2
您还可以在每个文档的索引时,确定 up 关键字是否存在,然后将其存储在架构中的附加字段(例如布尔值)中,并根据该布尔值增强查询结果场地。
This can be solved with Solr's query time boosting. So following the guidance from the Solr Relevancy FAQ - you could add an additional boosted search term to all queries, e.g.
title:title2 name:Bob keywords:up^2
You could also at index time for each document, determine if the up keyword is present then store that in an additional field (boolean for example) in your schema and boost the query results based on that boolean field.