使用 multiValued 中的一个单词匹配来提升 solr 结果
我有包含某些字段的 solr 模式:
<field name="id" type="integer" indexed="true" stored="true" required="true" multiValued="false" />
<field name="title" type="text" indexed="true" stored="true" multiValued="false" />
<field name="note" type="text" indexed="true" stored="true" multiValued="false" />
现在我用查询搜索它(其中 %s 是我的搜索字符串)
q={!boost b=recip(ms(NOW,date), 3.16e-11,1,1)}%s&defType=dismax&qf=title^100 note
我需要每个记录的标签之类的东西。
<field name="tags" type="string" indexed="true" stored="false" multiValued="true" />
当其中一个单词与“标签”字段中的值之一匹配时,我如何提高该记录的结果?
更新
刚刚发现,如果我从我的 q 中删除 {!boost b=recip(ms(NOW,date),3.16e-11,1,1)} ,我的查询将完全按照我想要的方式工作。但这样它就不会
更新 2
刚刚发现,以前的“刚刚发现”是完全错误的。我让它适用于某些搜索字符串,但对我来说效果不佳。我认为我需要这种行为:
在“标题”和“注释”字段中,我需要使用“AND”搜索单词,但在“标签”字段中,我需要使用“OR”搜索。我怎样才能用 dismax 做到这一点?
我现在尝试使用 {!boost} 和查询函数,但没有任何好的结果
I have solr schema with certain fields:
<field name="id" type="integer" indexed="true" stored="true" required="true" multiValued="false" />
<field name="title" type="text" indexed="true" stored="true" multiValued="false" />
<field name="note" type="text" indexed="true" stored="true" multiValued="false" />
Now i searching over it with query (where %s is my search string)
q={!boost b=recip(ms(NOW,date),3.16e-11,1,1)}%s&defType=dismax&qf=title^100 note
and i need something like tags for each record.
<field name="tags" type="string" indexed="true" stored="false" multiValued="true" />
How can i boost results for that records, where one of words match one of value from "tags" field?
update
Just figured out, that if i remove {!boost b=recip(ms(NOW,date),3.16e-11,1,1)} from my q, my query working exactly how i want. But with this it don't
update 2
Just figured out, that previously "just figured out" was completele wrong. I get it work for some search strings, but it don't work well for me. I think that i need this behaviour:
in "title" and "note" fields i need search words with "AND", but in "tags" field i need search with "OR". How can i do it with dismax?
I try now with {!boost} and query functions, but without any good result
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的查询看起来像是从网络复制的。
1.) 确保您的环境中存在名为“日期”的字段。
2.)查看solr输出。如果您在 tomcat 中运行 solr,请查看 catalina.out...
...以了解命中数和错误数。
查看海拔组件: http://wiki.apache.org/solr/QueryElevationComponent
Your query looks like you copied from the web.
1.) Make sure, that an field called "date" exists in your environment.
2.) look at the solr output. If you are running solr inside tomcat, so look at the catalina.out...
...for number of hits and errors.
Look at the elevation component for that: http://wiki.apache.org/solr/QueryElevationComponent
您可以使用 dismax 的
bq
(增强查询)来实现此目的。在此处阅读有关bq
的信息:http://wiki.apache .org/solr/DisMaxQParserPlugin#bq_.28Boost_Query.29您必须将查询分解为单独的单词和搜索标签,并分别使用每个单词和搜索标签。因此,如果您的查询是“abc pqr”,您将得到:
You can use dismax's
bq
(boost query) to achieve this. Read aboutbq
here: http://wiki.apache.org/solr/DisMaxQParserPlugin#bq_.28Boost_Query.29You'll have to break your query into individual words and search tags using each of those separately. So if your query is "abc pqr" you'll have: