lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Otis Gospodnetic <otis_gospodne...@yahoo.com>
Subject RE: PhrasePrefixQuery.java and MultipleTermPositions.java
Date Thu, 18 Jul 2002 04:44:39 GMT
Is anyone using this (+ PhrasePrefixQuery)?
I am trying to test them, but my unit test is failing, and I'm not sure
if I'm using this wrong or if the submitted code doesn't work as
described.

The test looks like this:

    public void testPhrasePrefix()
        throws IOException
    {
        RAMDirectory indexStore = new RAMDirectory();
        IndexWriter writer = new IndexWriter(indexStore, new
SimpleAnalyzer(), true);
        Document doc1 = new Document();
        Document doc2 = new Document();
        Document doc3 = new Document();
	doc1.add(Field.Text("body", "blueberry pie"));
        doc2.add(Field.Text("body", "blueberry pancake"));
        doc3.add(Field.Text("body", "blueberry muffin"));
        writer.addDocument(doc1);
        writer.addDocument(doc2);
        writer.addDocument(doc3);
	writer.optimize();
	writer.close();

	IndexSearcher searcher = new IndexSearcher(indexStore);

	PhrasePrefixQuery query = new PhrasePrefixQuery();
	query.add(new Term("body", "blueberry"));

	IndexReader ir = IndexReader.open(indexStore);
	TermEnum te = ir.terms(new Term("body", "pi*"));
	do {
	    query.add(te.term());
	} while (te.next());
	    

	Hits result = searcher.search(query);
	assertEquals(2, result.length());
    }
}


Result:

Testcase: testPhrasePrefix took 1.047 sec
        FAILED
expected:<2> but was:<0>


Thanks,
Otis


--- Anders Nielsen <anders@visator.com> wrote:
> 
> Here's an updated version of MultipleTermPositions.java.
> 
> In this version next() uses adjustTop() instead of pop()-push() as
> per
> Doug's suggestion.
> 
> And instead of a SortedSet for keeping positions, it keeps them in a
> class
> that reuses an int[].
> 
> 
> regards,
> Anders Nielsen
> 
> 
> 

> ATTACHMENT part 2 application/octet-stream
name=MultipleTermPositions.java
> --
> To unsubscribe, e-mail:  
> <mailto:lucene-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:lucene-dev-help@jakarta.apache.org>


__________________________________________________
Do You Yahoo!?
Yahoo! Autos - Get free new car price quotes
http://autos.yahoo.com

--
To unsubscribe, e-mail:   <mailto:lucene-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-dev-help@jakarta.apache.org>


Mime
View raw message