Mailing List Archive

Getting the terms that matched the HitDoc?
I've been looking around the org.apache.lucene.search.* code and can't
seem to find an answer to this.

I would like to present the terms that matched for each document in the
Hits. For example, to the user it would look like:

***********************************************************
Search Phrase: double blind study found injections
Search Terms: (doubl blind studi found inject)

Results:
Doc1 doubl blind studi found inject
Doc2 doubl blind studi found inject
Doc3 doubl blind studi inject
Doc4 studi inject
...
***********************************************************

Is there a way to get the search terms that were used in the relevance
scoring?


thanks,
rob

http://www.robdecker.com/
http://www.planetside.com/


--
To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>
Re: Getting the terms that matched the HitDoc? [ In reply to ]
Hi Rob,

One possibility might be to use the IndexReader's termDocs(Term) method
and then use the skipTo(int) method on the TermDocs object. Iterate
over your document list and then your term list for each document. Each
time skipTo puts you at the document you are looking for, you can add
that term to the document's term list. This probably isn't the most
efficient method but it should work.

Nathan

Robert A. Decker wrote:

>I've been looking around the org.apache.lucene.search.* code and can't
>seem to find an answer to this.
>
>I would like to present the terms that matched for each document in the
>Hits. For example, to the user it would look like:
>
>***********************************************************
>Search Phrase: double blind study found injections
>Search Terms: (doubl blind studi found inject)
>
>Results:
>Doc1 doubl blind studi found inject
>Doc2 doubl blind studi found inject
>Doc3 doubl blind studi inject
>Doc4 studi inject
>...
>***********************************************************
>
>Is there a way to get the search terms that were used in the relevance
>scoring?
>
>
>thanks,
>rob
>
>http://www.robdecker.com/
>http://www.planetside.com/
>
>
>--
>To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@jakarta.apache.org>
>For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>
>



--
To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>
Re: Getting the terms that matched the HitDoc? [ In reply to ]
Sorry... That should be:

1) iterate over your term list
2) for each term, iterate over your document list using the document
number in the skipTo() method
3) if skipTo puts you on the current document, add term to
(document,term) list

Nathan

Nathan G. Freier wrote:

> Hi Rob,
>
> One possibility might be to use the IndexReader's termDocs(Term)
> method and then use the skipTo(int) method on the TermDocs object.
> Iterate over your document list and then your term list for each
> document. Each time skipTo puts you at the document you are looking
> for, you can add that term to the document's term list. This probably
> isn't the most efficient method but it should work.
>
> Nathan
>
> Robert A. Decker wrote:
>
>> I've been looking around the org.apache.lucene.search.* code and can't
>> seem to find an answer to this.
>>
>> I would like to present the terms that matched for each document in the
>> Hits. For example, to the user it would look like:
>>
>> ***********************************************************
>> Search Phrase: double blind study found injections
>> Search Terms: (doubl blind studi found inject)
>>
>> Results:
>> Doc1 doubl blind studi found inject
>> Doc2 doubl blind studi found inject
>> Doc3 doubl blind studi inject
>> Doc4 studi inject
>> ...
>> ***********************************************************
>>
>> Is there a way to get the search terms that were used in the relevance
>> scoring?
>>
>>
>> thanks,
>> rob
>>
>> http://www.robdecker.com/
>> http://www.planetside.com/
>>
>>
>> --
>> To unsubscribe, e-mail:
>> <mailto:lucene-user-unsubscribe@jakarta.apache.org>
>> For additional commands, e-mail:
>> <mailto:lucene-user-help@jakarta.apache.org>
>>
>
>
>
> --
> To unsubscribe, e-mail:
> <mailto:lucene-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:lucene-user-help@jakarta.apache.org>
>



--
To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>
Re: Getting the terms that matched the HitDoc? [ In reply to ]
Thanks. This seems to work for stored fields (although I haven't completed
all of the steps). However, I want it to work with an indexed, but
unstored field, and I'm not getting anything back in my termDocs.

There must be some way to do it because this information is what is being
used in the scoring.

I'll keep poking around the source code, and if you or anyone else has any
more suggestions they would be greatly appreciated.

thanks,
rob

http://www.robdecker.com/
http://www.planetside.com/

On Fri, 29 Mar 2002, Nathan G. Freier wrote:

> Sorry... That should be:
>
> 1) iterate over your term list
> 2) for each term, iterate over your document list using the document
> number in the skipTo() method
> 3) if skipTo puts you on the current document, add term to
> (document,term) list
>
> Nathan
>
> Nathan G. Freier wrote:
>
> > Hi Rob,
> >
> > One possibility might be to use the IndexReader's termDocs(Term)
> > method and then use the skipTo(int) method on the TermDocs object.
> > Iterate over your document list and then your term list for each
> > document. Each time skipTo puts you at the document you are looking
> > for, you can add that term to the document's term list. This probably
> > isn't the most efficient method but it should work.
> >
> > Nathan
> >
> > Robert A. Decker wrote:
> >
> >> I've been looking around the org.apache.lucene.search.* code and can't
> >> seem to find an answer to this.
> >>
> >> I would like to present the terms that matched for each document in the
> >> Hits. For example, to the user it would look like:
> >>
> >> ***********************************************************
> >> Search Phrase: double blind study found injections
> >> Search Terms: (doubl blind studi found inject)
> >>
> >> Results:
> >> Doc1 doubl blind studi found inject
> >> Doc2 doubl blind studi found inject
> >> Doc3 doubl blind studi inject
> >> Doc4 studi inject
> >> ...
> >> ***********************************************************
> >>
> >> Is there a way to get the search terms that were used in the relevance
> >> scoring?
> >>
> >>
> >> thanks,
> >> rob
> >>
> >> http://www.robdecker.com/
> >> http://www.planetside.com/
> >>
> >>
> >> --
> >> To unsubscribe, e-mail:
> >> <mailto:lucene-user-unsubscribe@jakarta.apache.org>
> >> For additional commands, e-mail:
> >> <mailto:lucene-user-help@jakarta.apache.org>
> >>
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:lucene-user-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail:
> > <mailto:lucene-user-help@jakarta.apache.org>
> >
>
>
>
> --
> To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>
>


--
To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>