lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Fertig" <>
Subject RE: RangeQuery with multiple ranges ?
Date Fri, 05 Nov 2010 15:43:42 GMT
You can use a query parser to parse your text query into the appropriate query objects.

-----Original Message-----
From: Alain Camus [] 
Sent: Friday, November 5, 2010 11:26 AM
Subject: RangeQuery with multiple ranges ?

Hello list, 

I'm new to lucene, trying to find out if this is possible : 

In Luke, I can write a query that gets me the results I want, that is : 
+denominator:([10000 TO 10000] OR [20000 TO 20000]) 

I'd like to write the same in java. I tried the next code but it doesn't work : 
BooleanClause.Occur scaleOccur = LuceneUtils.convertRequiredAndProhibitedToOccur(true, false);

Term term1 = new Term(LuceneIndexField.SCALE, "10000"); 
Term term2 = new Term(LuceneIndexField.SCALE, "50000"); 
RangeQuery rangeQuery1 = new RangeQuery(term1, term1, true); 
RangeQuery rangeQuery2 = new RangeQuery(term2, term2, true); 
BooleanQuery booleanQuery = new BooleanQuery(); 
booleanQuery .setMinimumNumberShouldMatch(1); 
booleanQuery .add(rangeQuery1, scaleOccur); 
booleanQuery .add(rangeQuery2, scaleOccur); 
BooleanClause scaleRangeClause = new BooleanClause(bq, scaleOccur); 
The resulting query doesn't give me the expected results : 
+((+denominator:[10000 TO 10000] +denominator:[50000 TO 50000])~1) 

Is it possible to do what I want ? Any documentation I could read about this ? 


View raw message