You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@lucene.apache.org by James Carman <ja...@carmanconsulting.com> on 2008/07/22 16:53:51 UTC

Matching Search Terms?

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.

Re: Matching Search Terms?

Posted by James Carman <ja...@carmanconsulting.com>.
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
<er...@ehatchersolutions.com> 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
>
>

Re: Matching Search Terms?

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
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