lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler" <>
Subject RE: Problem searching non analyzed fields
Date Tue, 29 Sep 2009 22:38:46 GMT

If you do not analyze fields during indexing, you cannot really use
QueryParser on the search side (because the QueryParser itsself always
analyzes the entered query string).

If you added some fields using NOT_ANALYZED, just use a simple "new
TermQuery(new Term(field, term))" to search for them. This is simplier and
does not analyze. If you are creating such queries programmatically and have
special "id" fields, it is the classical case for TermQueries.

Or, as Robert said, use an Analyzer, but use a special one, not corrupting
your ASINs.


Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen

> -----Original Message-----
> From: Paul Taylor []
> Sent: Wednesday, September 30, 2009 12:17 AM
> To:
> Subject: Problem searching non analyzed fields
> I  use the same Analyzer for both creating an index and searching
> however I'm having a problem with some fields that I added with
> Field.Index.NOT_ANALYZED, how can I enforce they are also search without
> being analysed.
> I did this for some fields containg Guids and products codes because I
> didn't want them modifying/tokenizing at all and it works fine for
> Guids, however one of these fields contains Amazon Id of B00004Y6O9 and
> I think when I search for this it fails because the analyzer I'm using
> lowercases all text and nowhere do I specify when parsing not to use the
> analyzer when searching, but of course its not getting lowercased when
> added to the index.
> code extract:
> IndexSearcher is = IndexSearcher( NIOFSDirectory(new
> File(indexDir + '/' + indexName + '/'), null), true));
> QueryParser qp = new QueryParser(defaultFields.get(0), analyzer);
> TopScoreDocCollector collector = TopScoreDocCollector.create(offset +
> limit, true);
>, collector);
> So how do I tell the parser not to analyse some fields, Im guessing the
> idea  is to subclass the QueryParser  but how, or should I be using
> Field.Index.ANALYZED when adding to the index
> thanks Paul
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

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

View raw message