You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by John Eberly <jo...@eberly.org> on 2009/09/08 19:58:35 UTC

Highlighting... is highlighting too many fields

I currently have highlighting working, but when I search for

Query: "smith~ category_id:(1 OR 2 OR 3)"
Results: "name: Mr. John <em>Smith</em>, addresses: <em>1</em> Main St, NYC,
NY, 55<em>2</em>666"

Why does it show highlights on the addresses, when I specifically sent in a
query for category_id?  When I set hl.requireFieldMatch and
hl.usePhraseHighlighter to true, I get 0 results highlighted.

Any help greatly appreciated.

John

Re: Highlighting... is highlighting too many fields

Posted by AHMET ARSLAN <io...@yahoo.com>.

--- On Wed, 9/9/09, John Eberly <jo...@eberly.org> wrote:

> From: John Eberly <jo...@eberly.org>
> Subject: Re: Highlighting... is highlighting too many fields
> To: solr-user@lucene.apache.org
> Date: Wednesday, September 9, 2009, 7:12 PM
> Thanks Ahmet,
> 
> Your second suggestion about using the filter query
> works.  Ideally I would
> like to be able to use the first solution with
> hl.requireFieldMatch=true,
> but I cannot seem to get it to work no matter what I do.
> 
> I changed the query to just 'smith~' and
> hl.requireFieldMatch=true and I get
> results but no highlights.... :(

What is your defaultSearchField defined in schema.xml?
On what field are you highlighting? hl.fl=?

If query just 'smith~' and hl.requireFieldMatch=true aren't returning highlights it seems that your default search field and hl.fl are different.

you can try ?q=sameField:smith~&hl.requireFieldMatch=true&hl.fl=sameField
it should return highlights if the sameField is stored="true".


      

Re: Highlighting... is highlighting too many fields

Posted by John Eberly <jo...@eberly.org>.
Thanks Ahmet,

Your second suggestion about using the filter query works.  Ideally I would
like to be able to use the first solution with hl.requireFieldMatch=true,
but I cannot seem to get it to work no matter what I do.

I changed the query to just 'smith~' and hl.requireFieldMatch=true and I get
results but no highlights.... :(

On Tue, Sep 8, 2009 at 12:12 PM, AHMET ARSLAN <io...@yahoo.com> wrote:

> > I currently have highlighting working, but when I search for
> > Query: "smith~ category_id:(1 OR 2 OR 3)"
> > Results: "name: Mr. John <em>Smith</em>,
> > addresses: <em>1</em> Main St, NYC,
> > NY, 55<em>2</em>666"
>
> > Why does it show highlights on the addresses, when I
> > specifically sent in a
> > query for category_id?  When I set
> > hl.requireFieldMatch and
> > hl.usePhraseHighlighter to true, I get 0 results
> > highlighted.
>
> Althougth hl.usePhraseHighlighter is about PhraseQuery (and SpanQuery)
> hl.requireFieldMatch=true should work for your case.
> When you set hl.requireFieldMatch to true, do you get result returned? But
> without highlighted? If yes I think your default operator is set to OR.
> Those results without highlights are coming from category_id:(1 OR 2 OR 3)
> part of your query.
> Try "smith~ AND category_id:(1 OR 2 OR 3)" or alternatively you can use
> filter queries for structured fields (integer, string) like
> q=smith~&fq=category_id:(1 OR 2 OR 3)
>
> Hope this helps.
>
>
>
>

Re: Highlighting... is highlighting too many fields

Posted by AHMET ARSLAN <io...@yahoo.com>.
> I currently have highlighting working, but when I search for
> Query: "smith~ category_id:(1 OR 2 OR 3)"
> Results: "name: Mr. John <em>Smith</em>,
> addresses: <em>1</em> Main St, NYC,
> NY, 55<em>2</em>666"

> Why does it show highlights on the addresses, when I
> specifically sent in a
> query for category_id?  When I set
> hl.requireFieldMatch and
> hl.usePhraseHighlighter to true, I get 0 results
> highlighted.

Althougth hl.usePhraseHighlighter is about PhraseQuery (and SpanQuery) 
hl.requireFieldMatch=true should work for your case.
When you set hl.requireFieldMatch to true, do you get result returned? But without highlighted? If yes I think your default operator is set to OR. Those results without highlights are coming from category_id:(1 OR 2 OR 3) part of your query.
Try "smith~ AND category_id:(1 OR 2 OR 3)" or alternatively you can use filter queries for structured fields (integer, string) like q=smith~&fq=category_id:(1 OR 2 OR 3)

Hope this helps.