use of org.apache.solr.legacy.LegacyNumericRangeQuery in project lucene-solr by apache.
the class TestLegacyNumericRangeQueryBuilder method testGetFilterLong.
@SuppressWarnings({ "unchecked", "rawtypes" })
public void testGetFilterLong() throws Exception {
LegacyNumericRangeQueryBuilder filterBuilder = new LegacyNumericRangeQueryBuilder();
String xml = "<LegacyNumericRangeQuery fieldName='AGE' type='LoNg' lowerTerm='-2321' upperTerm='60000000'/>";
Document doc = getDocumentFromString(xml);
Query filter = filterBuilder.getQuery(doc.getDocumentElement());
assertTrue(filter instanceof LegacyNumericRangeQuery<?>);
LegacyNumericRangeQuery<Long> numRangeFilter = (LegacyNumericRangeQuery) filter;
assertEquals(Long.valueOf(-2321L), numRangeFilter.getMin());
assertEquals(Long.valueOf(60000000L), numRangeFilter.getMax());
assertEquals("AGE", numRangeFilter.getField());
assertTrue(numRangeFilter.includesMin());
assertTrue(numRangeFilter.includesMax());
String xml2 = "<LegacyNumericRangeQuery fieldName='AGE' type='LoNg' lowerTerm='-2321' upperTerm='60000000' includeUpper='false'/>";
Document doc2 = getDocumentFromString(xml2);
Query filter2 = filterBuilder.getQuery(doc2.getDocumentElement());
assertTrue(filter2 instanceof LegacyNumericRangeQuery<?>);
LegacyNumericRangeQuery<Long> numRangeFilter2 = (LegacyNumericRangeQuery) filter2;
assertEquals(Long.valueOf(-2321L), numRangeFilter2.getMin());
assertEquals(Long.valueOf(60000000L), numRangeFilter2.getMax());
assertEquals("AGE", numRangeFilter2.getField());
assertTrue(numRangeFilter2.includesMin());
assertFalse(numRangeFilter2.includesMax());
}
use of org.apache.solr.legacy.LegacyNumericRangeQuery in project lucene-solr by apache.
the class TestLegacyNumericRangeQueryBuilder method testGetFilterInt.
@SuppressWarnings({ "unchecked", "rawtypes" })
public void testGetFilterInt() throws Exception {
LegacyNumericRangeQueryBuilder filterBuilder = new LegacyNumericRangeQueryBuilder();
String xml = "<LegacyNumericRangeQuery fieldName='AGE' type='int' lowerTerm='-1' upperTerm='10'/>";
Document doc = getDocumentFromString(xml);
Query filter = filterBuilder.getQuery(doc.getDocumentElement());
assertTrue(filter instanceof LegacyNumericRangeQuery<?>);
LegacyNumericRangeQuery<Integer> numRangeFilter = (LegacyNumericRangeQuery<Integer>) filter;
assertEquals(Integer.valueOf(-1), numRangeFilter.getMin());
assertEquals(Integer.valueOf(10), numRangeFilter.getMax());
assertEquals("AGE", numRangeFilter.getField());
assertTrue(numRangeFilter.includesMin());
assertTrue(numRangeFilter.includesMax());
String xml2 = "<LegacyNumericRangeQuery fieldName='AGE' type='int' lowerTerm='-1' upperTerm='10' includeUpper='false'/>";
Document doc2 = getDocumentFromString(xml2);
Query filter2 = filterBuilder.getQuery(doc2.getDocumentElement());
assertTrue(filter2 instanceof LegacyNumericRangeQuery<?>);
LegacyNumericRangeQuery<Integer> numRangeFilter2 = (LegacyNumericRangeQuery) filter2;
assertEquals(Integer.valueOf(-1), numRangeFilter2.getMin());
assertEquals(Integer.valueOf(10), numRangeFilter2.getMax());
assertEquals("AGE", numRangeFilter2.getField());
assertTrue(numRangeFilter2.includesMin());
assertFalse(numRangeFilter2.includesMax());
}
use of org.apache.solr.legacy.LegacyNumericRangeQuery in project lucene-solr by apache.
the class TestLegacyNumericRangeQueryBuilder method testGetFilterFloat.
@SuppressWarnings({ "unchecked", "rawtypes" })
public void testGetFilterFloat() throws Exception {
LegacyNumericRangeQueryBuilder filterBuilder = new LegacyNumericRangeQueryBuilder();
String xml = "<LegacyNumericRangeQuery fieldName='AGE' type='FLOAT' lowerTerm='-2.321432' upperTerm='32432.23'/>";
Document doc = getDocumentFromString(xml);
Query filter = filterBuilder.getQuery(doc.getDocumentElement());
assertTrue(filter instanceof LegacyNumericRangeQuery<?>);
LegacyNumericRangeQuery<Float> numRangeFilter = (LegacyNumericRangeQuery) filter;
assertEquals(Float.valueOf(-2.321432f), numRangeFilter.getMin());
assertEquals(Float.valueOf(32432.23f), numRangeFilter.getMax());
assertEquals("AGE", numRangeFilter.getField());
assertTrue(numRangeFilter.includesMin());
assertTrue(numRangeFilter.includesMax());
String xml2 = "<LegacyNumericRangeQuery fieldName='AGE' type='FLOAT' lowerTerm='-2.321432' upperTerm='32432.23' includeUpper='false' precisionStep='2' />";
Document doc2 = getDocumentFromString(xml2);
Query filter2 = filterBuilder.getQuery(doc2.getDocumentElement());
assertTrue(filter2 instanceof LegacyNumericRangeQuery<?>);
LegacyNumericRangeQuery<Float> numRangeFilter2 = (LegacyNumericRangeQuery) filter2;
assertEquals(Float.valueOf(-2.321432f), numRangeFilter2.getMin());
assertEquals(Float.valueOf(32432.23f), numRangeFilter2.getMax());
assertEquals("AGE", numRangeFilter2.getField());
assertTrue(numRangeFilter2.includesMin());
assertFalse(numRangeFilter2.includesMax());
}
use of org.apache.solr.legacy.LegacyNumericRangeQuery in project lucene-solr by apache.
the class TestLegacyNumericRangeQueryBuilder method testGetFilterDouble.
@SuppressWarnings({ "unchecked", "rawtypes" })
public void testGetFilterDouble() throws Exception {
LegacyNumericRangeQueryBuilder filterBuilder = new LegacyNumericRangeQueryBuilder();
String xml = "<LegacyNumericRangeQuery fieldName='AGE' type='doubLe' lowerTerm='-23.21' upperTerm='60000.00023'/>";
Document doc = getDocumentFromString(xml);
Query filter = filterBuilder.getQuery(doc.getDocumentElement());
assertTrue(filter instanceof LegacyNumericRangeQuery<?>);
LegacyNumericRangeQuery<Double> numRangeFilter = (LegacyNumericRangeQuery) filter;
assertEquals(Double.valueOf(-23.21d), numRangeFilter.getMin());
assertEquals(Double.valueOf(60000.00023d), numRangeFilter.getMax());
assertEquals("AGE", numRangeFilter.getField());
assertTrue(numRangeFilter.includesMin());
assertTrue(numRangeFilter.includesMax());
String xml2 = "<LegacyNumericRangeQuery fieldName='AGE' type='doubLe' lowerTerm='-23.21' upperTerm='60000.00023' includeUpper='false'/>";
Document doc2 = getDocumentFromString(xml2);
Query filter2 = filterBuilder.getQuery(doc2.getDocumentElement());
assertTrue(filter2 instanceof LegacyNumericRangeQuery<?>);
LegacyNumericRangeQuery<Double> numRangeFilter2 = (LegacyNumericRangeQuery) filter2;
assertEquals(Double.valueOf(-23.21d), numRangeFilter2.getMin());
assertEquals(Double.valueOf(60000.00023d), numRangeFilter2.getMax());
assertEquals("AGE", numRangeFilter2.getField());
assertTrue(numRangeFilter2.includesMin());
assertFalse(numRangeFilter2.includesMax());
}
use of org.apache.solr.legacy.LegacyNumericRangeQuery in project lucene-solr by apache.
the class TestMaxScoreQueryParser method testFallbackToLucene.
@Test
public void testFallbackToLucene() {
q = parse("foo");
assertEquals(new TermQuery(new Term("text", "foo")), q);
q = parse("foo^3.0");
assertEquals(new BoostQuery(new TermQuery(new Term("text", "foo")), 3f), q);
q = parse("price:[0 TO 10]");
assertTrue(q instanceof LegacyNumericRangeQuery || (q instanceof IndexOrDocValuesQuery && ((IndexOrDocValuesQuery) q).getIndexQuery() instanceof PointRangeQuery));
}
Aggregations