lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Streeton" <mike.stree...@ardentia.co.uk>
Subject RE: Search on Keyword rather than Text?
Date Wed, 08 Feb 2006 10:25:29 GMT
Override QueryParser and intercept queries of specific fields producing
TermQuery instead of letting it be generated from the analyzed value
using the default parser. If you want to look for "New Yo" try also
creating a prefix query from the TermQuery.

Mike

www.ardentia.com the home of NetSearch
-----Original Message-----
From: Simon Porritt [mailto:simon.porritt@dealchecker.co.uk] 
Sent: 07 February 2006 10: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


---------------------------------------------------------------------
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