@Test void should_throw_exception_for_unsupported_comparison() { assertThrows(IllegalStateException.class, () -> new RangeQuery(Comparison.BETWEEN) .doBuild("name", STRING, ExprValueUtils.stringValue("John"))); }
@Override protected QueryBuilder doBuild(String fieldName, ExprType fieldType, ExprValue literal) { Object value = literal.value(); RangeQueryBuilder query = QueryBuilders.rangeQuery(fieldName); switch (comparison) { case LT: return query.lt(value); case GT: return query.gt(value); case LTE: return query.lte(value); case GTE: return query.gte(value); default: throw new IllegalStateException("Comparison is supported by range query: " + comparison); } }
RangeQuery extends LuceneQuery { @Override protected QueryBuilder doBuild(String fieldName, ExprType fieldType, ExprValue literal) { Object value = literal.value(); RangeQueryBuilder query = QueryBuilders.rangeQuery(fieldName); switch (comparison) { case LT: return query.lt(value); case GT: return query.gt(value); case LTE: return query.lte(value); case GTE: return query.gte(value); default: throw new IllegalStateException("Comparison is supported by range query: " + comparison); } } }
RangeQuery extends LuceneQuery { @Override protected QueryBuilder doBuild(String fieldName, ExprType fieldType, ExprValue literal) { Object value = literal.value(); RangeQueryBuilder query = QueryBuilders.rangeQuery(fieldName); switch (comparison) { case LT: return query.lt(value); case GT: return query.gt(value); case LTE: return query.lte(value); case GTE: return query.gte(value); default: throw new IllegalStateException("Comparison is supported by range query: " + comparison); } }  }
RangeQuery extends LuceneQuery { @Override protected QueryBuilder doBuild(String fieldName, ExprType fieldType, ExprValue literal) { Object value = literal.value(); RangeQueryBuilder query = QueryBuilders.rangeQuery(fieldName); switch (comparison) { case LT: return query.lt(value); case GT: return query.gt(value); case LTE: return query.lte(value); case GTE: return query.gte(value); default: throw new IllegalStateException("Comparison is supported by range query: " + comparison); } }   }
RangeQuery extends LuceneQuery { @Override protected QueryBuilder doBuild(String fieldName, ExprType fieldType, ExprValue literal) { Object value = literal.value(); RangeQueryBuilder query = QueryBuilders.rangeQuery(fieldName); switch (comparison) { case LT: return query.lt(value); case GT: return query.gt(value); case LTE: return query.lte(value); case GTE: return query.gte(value); default: throw new IllegalStateException("Comparison is supported by range query: " + comparison); } }    }