On Mon, 2006-07-24 at 15:17 +0200, karl wettin wrote: > On Mon, 2006-07-24 at 15:15 +0200, karl wettin wrote: > > Yes, it effects PhraseQuery. Only "the x men are" will match. > > I'm stupid. Forget about it. I should of course analyze the query too.
But still it fails on xmen. Could it have something to do with this: WordDelimiterFilter(ts, 1,1,0,0,0); ? I can't figure out what the parameters does. ;) The new code: package org.apache.solr.analysis; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.Term; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.PhraseQuery; import org.apache.lucene.store.Directory; import org.apache.lucene.store.RAMDirectory; import org.apache.lucene.queryParser.QueryParser; import java.io.Reader; import java.util.HashSet; public class TestWordDelimiterFilter { public static void main(String[] args) throws Exception { final String field = "field"; Directory dir = new RAMDirectory(); Analyzer a = new Analyzer(); IndexWriter w = new IndexWriter(dir, a, true); Document d = new Document(); d.add(new Field(field, "the x-men are here", Field.Store.NO, Field.Index.TOKENIZED, Field.TermVector.NO)); w.addDocument(d); w.close(); IndexSearcher is = new IndexSearcher(dir); QueryParser qp = new QueryParser(field, a); System.out.println(is.search(qp.parse("\"the x men are\"")).length()); System.out.println(is.search(qp.parse("\"the xmen are\"")).length()); // expected 1, get 0. System.out.println(is.search(qp.parse("\"the x-men are\"")).length()); is.close(); dir.close(); } public static class Analyzer extends org.apache.lucene.analysis.Analyzer { public TokenStream tokenStream(String fieldName, Reader reader) { TokenStream ts = new StandardAnalyzer(new HashSet()).tokenStream(fieldName, reader); ts = new WordDelimiterFilter(ts, 1,1,0,0,0); return ts; } } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]