You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by ya...@bloglines.com on 2004/07/12 21:17:44 UTC

Exact match search

Hi,

I want to match documents that exactly equal a certain value, not just
contain it.

If I search for "foo" in Lucene I get back documents like these:

"foo"
"foo bar"
"bar foo"

Is there a way to just get the ones that exactly
equal the value I'm searching for?  In this case, I want to only return the
first document (ex. "foo").

I have a workaround where I store all the values
and then after I get the hits I go through them and skip those that don't
match.  But this will return result sets of hundreds of documents that I don't
need.

Help!

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


Re: Exact match search

Posted by Don Vaillancourt <do...@webimpact.com>.
How do you go about getting an exact match for a document that can contain 
hundreds of words?  As I understand it, when you tokenize a document it is 
broken into words so really all the results you show are exact matches.

At 03:17 PM 12/07/2004, you wrote:
>Hi,
>
>I want to match documents that exactly equal a certain value, not just
>contain it.
>
>If I search for "foo" in Lucene I get back documents like these:
>
>"foo"
>"foo bar"
>"bar foo"
>
>Is there a way to just get the ones that exactly
>equal the value I'm searching for?  In this case, I want to only return the
>first document (ex. "foo").
>
>I have a workaround where I store all the values
>and then after I get the hits I go through them and skip those that don't
>match.  But this will return result sets of hundreds of documents that I don't
>need.
>
>Help!
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: lucene-user-help@jakarta.apache.org

Don Vaillancourt
Director of Software Development

WEB IMPACT INC.
416-815-2000 ext. 245
email: donv@web-impact.com
web: http://www.web-impact.com




This email message is intended only for the addressee(s)
and contains information that may be confidential and/or
copyright.  If you are not the intended recipient please
notify the sender by reply email and immediately delete
this email. Use, disclosure or reproduction of this email
by anyone other than the intended recipient(s) is strictly
prohibited. No representation is made that this email or
any attachments are free of viruses. Virus scanning is
recommended and is the responsibility of the recipient.












Re: Exact match search

Posted by Daniel Naber <da...@t-online.de>.
On Monday 12 July 2004 21:17, yahootintin.1247688@bloglines.com wrote:

> I want to match documents that exactly equal a certain value, not just
> contain it.

Just don't tokenize your Fields, and make sure that the query also doesn't 
get tokenized (the easiest way to ensure that is probably to not use 
QueryParser but just build a TermQuery directly from the user's input).

Regards
 Daniel

-- 
http://www.danielnaber.de

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