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 Kevin Osborn <os...@yahoo.com> on 2009/08/25 02:26:26 UTC
how to get highlighter to only show matched term
If my query is something like manufacturer:IBM OR productTitle:Thinkpad, I actually just want to printout "IBM" or "Thinkpad" in any of the highlighted fields. I don't want to parse through any HTML or other text. Basically, I just want to know which of the terms in my query matched and in which field they matched (could be different from my example). I assume that I may need to write my own Formatter for just outputting nothing. But, I'm not sure where to start to get only my needed term. Do I need a custom Fragmenter?
Re: how to get highlighter to only show matched term
Posted by Chris Hostetter <ho...@fucit.org>.
: text. Basically, I just want to know which of the terms in my query
: matched and in which field they matched (could be different from my
: example). I assume that I may need to write my own Formatter for just
: outputting nothing. But, I'm not sure where to start to get only my
: needed term. Do I need a custom Fragmenter?
I believe so yes ... i think you might be able to get away with a Fragment
that always returns "true" from isNewFragment, because i *think* the
highlighter will do the right thing and merge adjacent fragments that
both contain matches (in the case of phrase queries) but i'm not 100%
certain.
for questions about implementing Formatters & Fragmenters, you'll probably
want to ask on java-user@lucene ... there are a lot more people over there
that udnerstand teh internals of the highlighting code.
-Hoss