On Jul 22, 2008, at 10:53 AM, James Carman wrote:
We have a requirement for our project where the user would like to be
able to paste a bunch of terms into a search box. They want to
basically "or" together each line of the pasted text as a full-text
search query. However, when the results come back, they'd like to
know which one of the lines matched the specific item returned. Is
there an easy way to do that with Lucene? I looked at the Hit API,
but nothing really jumped out at me. I would think that's where I
should look.
There are two options to consider... one is the Highlighter (one of
Java Lucene's contrib modules) and the other is converting the query
to a SpanQuery and walking the Spans from that API. The Highlighter
is the simplest approach to see if it suffices.
Erik