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 christophe <ch...@lemoine-fr.com> on 2008/10/29 16:35:37 UTC

Highlighting and fields

Hi,

I'm doing the following query:
q=text:abc AND type:typeA
And I ask to return highlighting (query.setHighlight(true);). The search 
term for field "type" (typeA) is also highlighted in the "text" field.
Anyway to avoid this ?

Thanks
Christophe

Re: Highlighting and fields

Posted by Mark Miller <ma...@gmail.com>.
christophe wrote:
> Hi,
>
> I'm doing the following query:
> q=text:abc AND type:typeA
> And I ask to return highlighting (query.setHighlight(true);). The 
> search term for field "type" (typeA) is also highlighted in the "text" 
> field.
> Anyway to avoid this ?
>
> Thanks
> Christophe
I havn't used solrj really, but have you tried addHighlightField?

Re: Highlighting and fields

Posted by christophe <ch...@lemoine-fr.com>.
Hi Lars,

Thanks for it: it works great.

BR
Christophe

Lars Kotthoff wrote:
>> I'm doing the following query:
>> q=text:abc AND type:typeA
>> And I ask to return highlighting (query.setHighlight(true);). The search 
>> term for field "type" (typeA) is also highlighted in the "text" field.
>> Anyway to avoid this ?
>>     
>
> Use setHighlightRequireFieldMatch(true) on the query object [1].
>
> Lars
>
>
> [1] http://lucene.apache.org/solr/api/org/apache/solr/client/solrj/SolrQuery.html#setHighlightRequireFieldMatch(boolean)
>   

Re: Highlighting and fields

Posted by Lars Kotthoff <li...@larsko.org>.
> I'm doing the following query:
> q=text:abc AND type:typeA
> And I ask to return highlighting (query.setHighlight(true);). The search 
> term for field "type" (typeA) is also highlighted in the "text" field.
> Anyway to avoid this ?

Use setHighlightRequireFieldMatch(true) on the query object [1].

Lars


[1] http://lucene.apache.org/solr/api/org/apache/solr/client/solrj/SolrQuery.html#setHighlightRequireFieldMatch(boolean)