Jim Lynch wrote:

From what I've read, if you want to have a choice, the easiest way is to index the documents twice. Once with stemming on and once with it off placing the results in two different indexes. Then at query time, select which index you want to use based on whether you want stemming on or off.

IMHO keeping the data in the same index is easiest.

PerFieldAnalyzerWrapper is part of the magic...approx uasge follows from my code below. Second magic is to call doc.add(...) multiple times, "redundantly".

Don't use code below exactly however - things like MySnowballAnalyzer should become SnowballAnalyzer in your code...


Analyzer fa;
Analyzer getAnalyzer()
{
Analyzer snowball = new MySnowballStopAnalyzer();
Analyzer def = new AlphaNumStopAnalyzer(); // prob StandardAnalyzer for most people..
PerFieldAnalyzerWrapper fa = new PerFieldAnalyzerWrapper( def);
fa.addAnalyzer( "scontents", snowball); // "s" in "scontents" if for stemming
fa.addAnalyzer( "stitle", snowball);
return fa;
}



...

later:

Document doc = new Document();
doc.add( Field.Text( "title", title));
doc.add( Field.Text( "stitle", new StringReader( title))); // don't need recall
String body = ...;
doc.add( Field.Text( "contents", new StringReader( body), true)); // term vector
doc.add( Field.Text( "scontents", new StringReader( body)));
writer.addDocument( doc);





Jim.

Peter Kim wrote:

Hi,

I'm new to Lucene, so I apologize if this issue has been discussed
before (I'm sure it has), but I had a hard time finding an answer using
google. (Maybe this would be a good candidate for the FAQ!) :)

Is it possible to enable stem queries on a per-query basis? It doesn't
seem to be possible since the stem tokenizing is done during the
indexing process. Are people basically stuck with having all their
queries stemmed or none at all?

Thanks!
Peter

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



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to