Solr 1.4 中的高亮显示 - requireFieldMatch
我有一个对象
Title : foo
Summary : foo bar
Body : this is a published story about a foo and a bar
所有三个对象都设置为stored=true 的字段。
用户在我的系统中搜索“
"foo"
我想在所有三个位置突出显示 foo”这个词。
用户在标题中搜索单词 foo
"title:foo"
我只想在标题中突出显示 foo 。
当我添加 hl.requireFieldMatch=true
和 hl.usePhraseHighlighter=true
作为我对 SOLR 查询的一部分,在执行通用非字段操作时,我无法在所有三个地方突出显示搜索。有没有办法让这两种情况都起作用?
我关闭了这两个项目,但我添加了查询的一些字段部分,用户看不到这些部分,例如仅显示已发布的项目。问题是
(foo AND status:published)
当用户仅搜索单词“foo”时,导致正文中发布的单词突出显示。
I have an object
Title : foo
Summary : foo bar
Body : this is a published story about a foo and a bar
All three are set up as fields with stored=true.
The user searches across my system for the word
"foo"
I would like to highlight foo in all three places.
The user searches for the word foo in the title
"title:foo"
I only want to highlight foo within the title.
When I addedhl.requireFieldMatch=true
and hl.usePhraseHighlighter=true
as part of my query over to SOLR I am unable to get the highlighting in all three places when doing a generic non fielded search. Is there a way to get both scenarios to work?
I had these two items turned off, but I am adding in some fielded portions of the query that the user does not see which only display Published items for instance. the problem is
(foo AND status:published)
is causing the word published in the body to highlight when the user only searched for the word "foo".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明,与 solr / lucene 相比,这可能更像是 act_as_solr 的怪癖。
我利用了 solr 中的 fq 选项
http://wiki.apache.org/solr/CommonQueryParameters#fq
查询否更长的看起来像
看起来更像是
当它击中 solr 时
fq 不会影响突出显示,而且这似乎是一个更好的方法,因为您可以获得一些 solr 缓存的好处。
仍然存在一个错误/功能未使用acts_as_solr 实现,它也需要利用这一点。
例如,如果我的模型名为“文章”,并且用户搜索“文章”一词,AAS 会在幕后构建一个查询,如下所示。
这会导致相同的问题,即当您不想要它时,“文章”一词会在各处突出显示以及当用户搜索术语“文章”时,他们会返回系统中的每个对象。
快速浏览了一下 acts_as_solr 的 GitHub 分支,没有看到任何人已经实现了这个。 parser_methods.rb 中有很好的#TODO
Turns out that this may be more of a quirk with act_as_solr than it is with solr / lucene.
I took advantage of the fq option within solr
http://wiki.apache.org/solr/CommonQueryParameters#fq
the query no longer looks like
Looks more like
when it hits solr
The fq does not impact highlighting and it seems like a better way to do this since you get some solr caching benefits.
There is still a bug / feature not implemented with acts_as_solr which needs to take advantage of this as well.
For instance if my model is named article, and the user searches for the word article, AAS is building a query behind the scenes that looks like
This causes the same problem that the word article highlights all over the place when you don't want it to, as well as when the user searches for the term "article" they get back every single object in the system.
Took a quick look at GitHub forks of acts_as_solr and didn't see anyone that has implemented this yet. There is nice #TODO sitting there within parser_methods.rb