Skip to content

Commit

Permalink
Added test for combining two numeric range queries... from a mail con…
Browse files Browse the repository at this point in the history
…versation
  • Loading branch information
tinwelint committed Apr 24, 2012
1 parent 859d71e commit 6f12581
Showing 1 changed file with 18 additions and 0 deletions.
Expand Up @@ -46,10 +46,12 @@

import org.apache.lucene.index.Term;
import org.apache.lucene.queryParser.QueryParser.Operator;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.DefaultSimilarity;
import org.apache.lucene.search.NumericRangeQuery;
import org.apache.lucene.search.Sort;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.BooleanClause.Occur;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -1694,4 +1696,20 @@ private void numericValueForGet( Index<Node> index )
restartTx();
assertEquals( node, index.get( "name", ValueContext.numeric( id ) ).getSingle() );
}

@Test
public void combinedNumericalQuery() throws Exception
{
Index<Node> index = nodeIndex( testname.getMethodName(), LuceneIndexImplementation.EXACT_CONFIG );

Node node = graphDb.createNode();
index.add( node, "start", ValueContext.numeric( 10 ) );
index.add( node, "end", ValueContext.numeric( 20 ) );
restartTx();

BooleanQuery q = new BooleanQuery();
q.add( LuceneUtil.rangeQuery( "start", 9, null, true, true ), Occur.MUST );
q.add( LuceneUtil.rangeQuery( "end", null, 30, true, true ), Occur.MUST );
assertContains( index.query( q ), node );
}
}

0 comments on commit 6f12581

Please sign in to comment.