lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Boyd <andrew.b...@mindspring.com>
Subject Phrase/Range Query Bug?
Date Tue, 28 Jun 2005 18:49:51 GMT
Hi All,
  When I try to do a Range Query with Phrase as one of the end points I'm not getting the
results I would expect.
Here is a JUnit that shows what I'm trying to do.  It fails on the last assertEquals

    public void testRangeBug(){
        try{
            RAMDirectory ramDir = new RAMDirectory();
            Analyzer stdAnalyzer = new StandardAnalyzer();
            QueryParser queryParser = new QueryParser("title", stdAnalyzer);

            org.apache.lucene.document.Document auburnDoc = new org.apache.lucene.document.Document();
            Field auburnTitle = new Field("title", "Auburn University",
                                          Field.Store.YES, Field.Index.TOKENIZED,
                                          Field.TermVector.WITH_POSITIONS_OFFSETS);

            org.apache.lucene.document.Document bamaDoc = new org.apache.lucene.document.Document();
            Field bamaTitle = new Field("title", "BAMA",
                                        Field.Store.YES, Field.Index.TOKENIZED,
                                        Field.TermVector.WITH_POSITIONS_OFFSETS);
            org.apache.lucene.document.Document uahDoc = new org.apache.lucene.document.Document();
            Field uahTitle = new Field("title", "UAH",
                                       Field.Store.YES, Field.Index.TOKENIZED,
                                       Field.TermVector.WITH_POSITIONS_OFFSETS);


            IndexWriter writer = new IndexWriter(ramDir, stdAnalyzer, true);
            auburnDoc.add(auburnTitle);
            bamaDoc.add(bamaTitle);
            uahDoc.add(uahTitle);

            writer.addDocument(auburnDoc);
            writer.addDocument(bamaDoc);
            writer.addDocument(uahDoc);
            writer.close();

            IndexSearcher searcher = new IndexSearcher(ramDir);

            Hits hits = searcher.search(queryParser.parse("\"Auburn University\""));
            assertEquals("Should get one hit back ", 1, hits.length());

            // Exclusive 
            hits = searcher.search(queryParser.parse("{\"Auburn University\" TO UAH}"));
            assertEquals("Should get one hit back ", 1, hits.length());
            
            // Inclusive 
            hits = searcher.search(queryParser.parse("[\"Auburn University\" TO UAH]"));
            assertEquals("Should get all three back ", 3, hits.length());  // <<<<<
only returning 2

        } catch(Throwable e){
            e.printStackTrace();
        }

    }

Andrew

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message