Matching Search Terms?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Matching Search Terms?

James Carman
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.
Reply | Threaded
Open this post in threaded view
|

Re: Matching Search Terms?

Erik Hatcher

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

Reply | Threaded
Open this post in threaded view
|

Re: Matching Search Terms?

James Carman
Erik,

Thanks!  Glad to see you on this project (we miss you on HiveMind)!
I'll try the Highlighter approach and see if that works.  Are there
any examples out there?

James

On Tue, Jul 22, 2008 at 10:59 AM, Erik Hatcher
<[hidden email]> wrote:

>
> 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
>
>