lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alain Camus <...@ngi.be>
Subject RangeQuery with multiple ranges ?
Date Fri, 05 Nov 2010 15:25:43 GMT
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); 
query.add(scaleRangeClause); 
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 ? 

Alain 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message