Solr 1.4中的突出显示-requireFieldMatch [英] Highlighting in Solr 1.4 - requireFieldMatch

查看:505
本文介绍了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=truehl.usePhraseHighlighter=true作为对SOLR的查询的一部分,在进行通用的非字段搜索时,我无法在所有三个位置上都突出显示.有没有办法让这两种情况同时起作用?

我关闭了这两个项目,但是我在查询的某些字段部分中添加了用户看不到的部分,例如,该部分仅显示已发布项目".问题是

(foo AND status:published)

当用户仅搜索单词"foo"时,

会使体内发布的单词突出显示.

解决方案

事实证明,与使用solr/lucene相比,使用act_as_solr可能更像是一个怪癖.

我在solr中利用了fq选项 http://wiki.apache.org/solr/CommonQueryParameters#fq

查询不再像

(foo AND status:published)

看起来更像

q=foo&fq=status:published

击中太阳时

fq不会影响突出显示,这似乎是一种更好的方法,因为您可以获得一些solr缓存的好处.

仍然有一个act/as_solr未实现的错误/功能,也需要利用此错误.

例如,如果我的模型命名为article,并且用户搜索article这个词,则AAS会在幕后构建一个看起来像

的查询

(article AND type_t:article)

这会导致相同的问题,当您不希望使用文章文章一词在所有地方突出显示时,以及当用户搜索术语文章"时,他们都会获得系统中的每个对象. /p>

快速浏览一下act_as_solr的GitHub分支,尚未看到任何实现此功能的人.在parser_methods.rb

中有一个不错的#TODO

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 added hl.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".

解决方案

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

(foo AND status:published)

Looks more like

q=foo&fq=status:published

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

(article AND type_t:article)

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

这篇关于Solr 1.4中的突出显示-requireFieldMatch的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆