[KinoSearch] which field matched a term
Peter Karman
peter at peknet.com
Wed Feb 24 11:17:41 PST 2010
Marvin Humphrey wrote on 02/24/2010 12:00 PM:
> 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)...
>
ok, understood.
The question came up for me because I was debugging some result sets and
was curious as to where the term match was happening. In this case, the
Highlighter example was just that -- an example -- because I do what I
suggested to Ashley, using Search::Tools and iterating over all fields
to create highlighted snippets. (Aside: this is one reason I wrote
Search::Tools, to allow for arbitrary snipping/highlighting of
previously-unanalyzed text.)
I don't think this is an issue that needs fixing or more thought at this
point. Mostly I was just curious, given my need to debug a result set,
and the API for Highlighter et al, how I might get the field match
information.
Thanks, Marvin.
--
Peter Karman . http://peknet.com/ . peter at peknet.com
More information about the kinosearch
mailing list