lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Colin Young" <Colin.Yo...@tembizi.com>
Subject RE: Search on Keyword rather than Text?
Date Tue, 07 Feb 2006 12:32:54 GMT
I had the same problem (almost exactly, even down to searching city
names) and the way I solved it was to provide my own tokenizer that
doesn't tokenize -- I'm passing in stuff to the analyzer already
tokenized, so in your example I'd pass in "new york" as a single entity
to analyze, and the tokenizer would return the whole thing as a single
token.

Colin 

-----Original Message-----
From: Simon Porritt [mailto:simon.porritt@dealchecker.co.uk] 
Sent: 7 February, 2006 05:47
To: java-user@lucene.apache.org
Subject: Search on Keyword rather than Text?

Hello,

We have a document type for which we wish to create an index that may
contain spaces, and we don't want the values to be tokenized.  The data
is a list of cities.  We are currently creating the index using
Field.Text:

Field.Text("index", "New York")

...which of course means that the string is tokenized before being
indexed.  Running this search:

new yo

which translates to

index:new index:yo

returns New York amongst the results, as well as any cities starting
with 'yo' - not what we want.  For that search we want no results at
all.  In fact we want that search to translate to

index:"new yo"

where the whole of "new yo" is considered the search term.  Of course in
that example the presence of the quotes means that Lucene treats the
term as if it must exist in its entirety, which we also don't want!

It looked like the solution was to use Field.Keyword:

Field.Keyword("index", "New York")

but now we get no results on any search at all!

We use a SimpleAnalyser for creating the index and running the searches.
If anyone has an idea that could steer us in the right direction we
would be most appreciative.

Thanks,

Simon


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



Notice: This email message is for the sole use of the intended recipient(s) and may contain
confidential and privileged information. Any unauthorized review, use, disclosure or distribution
is prohibited. If you are not the intended recipient, please contact the sender by reply email
and destroy all copies of the original message.


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


Mime
View raw message