[KinoSearch] which field matched a term

Marvin Humphrey marvin at rectangular.com
Wed Feb 24 10:00:23 PST 2010

On Wed, Feb 24, 2010 at 09:15:37AM -0600, Peter Karman wrote:
> How do I know which field a term matched in?

During regular matching, not possible. Not only does that information never
make it to the HitCollector, it's not kept by any combining Matchers, e.g.
ORMatcher.  Only scores are accumulated, as a single floating point primitive.
So, writing a custom HitCollector subclass wouldn't work -- you'd need to
reimplement the entire Matcher hierarchy.

For StringType (exact match) fields, post-processing might work.  For
FullTextType fields, it would be harder and kludgy.

> E.g., if I am creating a Highlighter object, I need to pass in a field
> name, but how do I know which (of potentially dozens) of fields to pick?

Can't be done that way.  And I don't know how you could design an efficient
matching algorithm that *would* work that way, because storing such
meta-information during the initial pass would add considerable overhead.

Is this for some kind of facet highlighting?  I think we'll need to work out a
different approach for you, e.g. a common field or something like that.

Long term, maybe some sort of explain() method or technique would help us out.
We'd feed it the single-document inverted index used by highlighter (formerly
known as "term vector" data)...

Marvin Humphrey

More information about the kinosearch mailing list