RangeQuery is for Term ranges, not phrase ranges. With your data, you would be able to do a RangeQuery of [Auburn TO UAH], but "Auburn University" gets split into two terms by StandardAnalyzer. If you set the fields to be untokenized (but still indexed) you'd be able to do a RangeQuery with "Auburn University" as the beginning term, though that might not work for your other searching needs.

    Erik



On Jun 28, 2005, at 2:49 PM, Andrew Boyd wrote:
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: [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