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:[EMAIL PROTECTED] 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]