This is a source code that shows the problem I am talking about. In this example a new analyzer is made that outputs all words to the same position (all but the first one are positionIncrement=0). To get the problem I am talking about uncomment the only commented line. //---------------------------------------------------------------- public class TestPhraseQuery {
public static void main(String[] args) { try { Directory ramDirectory = new RAMDirectory(); IndexWriter indexWriter = new IndexWriter(ramDirectory, new TestAnalyzer(),true); Document testDocument = new Document(); testDocument.add(Field.Text("line","hello all of you")); indexWriter.addDocument(testDocument); indexWriter.close(); IndexSearcher indexSearcher = new IndexSearcher(ramDirectory); PhraseQuery query = new PhraseQuery(); query.add(new Term("line","hello"),1); query.add(new Term("line","all"),1); // query.add(new Term("line","huullo"),1); Hits hits = indexSearcher.search(query); System.out.println(hits.length()); } catch (IOException e) { e.printStackTrace(); } } } class TestAnalyzer extends StandardAnalyzer { @Override public TokenStream tokenStream(String fieldName, Reader reader) { TokenStream result = super.tokenStream(fieldName, reader); result = new TestFilter(result); return result; } } class TestFilter extends TokenFilter { boolean first = true; public TestFilter(TokenStream input) { super(input); } @Override public Token next() throws IOException { Token token = input.next(); if (token == null) return null; if (!first) { token.setPositionIncrement(0); } first = false; return token; } } //-------------------------------------------------------------------------- On 11/4/05, Erik Hatcher <[EMAIL PROTECTED]> wrote: > > On 4 Nov 2005, at 13:45, Daniel Naber wrote: > > > On Freitag 04 November 2005 11:33, Erik Hatcher wrote: > > > > > >>> This should have been fixed one year ago with Daniel and myself. > >>> > >> > >> Really? It works in this OR kind of fashion with tokens in 0- > >> incremented positions? > >> > > > > Yes, this test case shows it (multi will be turned into multi and > > multi2, > > both at the same position by the analyzer used here): > > > > assertEquals("+(multi multi2) +foo", qp.parse("multi foo").toString > > ()); > > Thanks. Sorry, I meant to send an immediate follow-up to my own > silly question. I knew better as soon as I hit send. > > Erik > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- regards, Ahmed Saad --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]