lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Condit <>
Subject Best practice for stemming and exact matching
Date Tue, 29 Mar 2011 22:56:52 GMT
I have Lucene indexes build using a shingled, stemmed custom analyzer.
I have a new requirement that exact searches match correctly.
ie: bar AND "nachos"
will only fetch results with plural nachos. Right now, with the
stemming, singular nacho results are returned as well. I realize that
I'm going to have to create a separate field for this so I made a new
field suffixed with _exact and used a SimpleAnalyzer on it.

The problem is that after my QueryParser parses the query it's already
mucked up the PhraseQuery with the custom analyzer (stemming down to
nacho). I thought I could traverse the query tree and switch the field
and the query text, but if I do that I don't know which part of the
query the clause came from. Ideally I'd like to have the parser use the
custom analyzer for everything unless it's going to parse a clause into
a PhraseQuery or a MultiPhraseQuery, in which case it uses the
SimpleAnalyzer and looks in the _exact field - but I can't figure out
the best way to accomplish this.

Has anyone else encountered the same problem?
Is there a best practice for doing this - or something much easier that
I'm missing?


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

View raw message