lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <>
Subject Re[2]: exact match
Date Tue, 05 Apr 2005 21:23:39 GMT
: >> I have documents with tokenized, indexes and stored field. This field
: >> contain one-two words usually. I need to be able to search exact
: >> matches for two words.
: >> For example search "John" should return documents with field
: >> containing "John" only, not "John Doe" or "John Foo".
: >>
: >> Any ideas?
: EH> Use an untokenized field to search on in the case of finding an exact
: EH> match.
: And no other ways to reach this?

are there any cases in which you ever want to search the field for
tokenized values?

if not, then you can just use an analyzer that knows about this special
field and "tokenizes" any value it gets into a single token that is an
exact match.

if you sometimes need exact matches, and sometimes need "ord" matches (for
hte sake of argument let's assume your tokens are simple shitespace
seperated words) then you're going to need somewhat of knowing which case
you wnat when you parse the query -- the easy way to go is with a seperate
field like Erik described.  if you have some other usecase, then you can
index the field using an analyzer that generates a single unparsed "token"
for hte whole string followed by some marker token that isn't likely to
appear in your data (ie: the token "_BOOYA!_" would probably work),
followed by the more conventional tokens -- given the first of those
tokens a very high  positionalIncriment.

Then if you want an exact match, your custom query parsing code could
generate either a Phrase or Span query containing a single Term for your
input, followed by the marker Term (ie: "_BOOYA!_").  a "regular" toekn
based search would work just as it did before.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message