following are two fields defined in the entity
Code:
@Column(name = "min_price")
@Field(index = Index.YES, analyze = Analyze.YES, store = Store.NO)
@NumericField
@FieldBridge(impl = IntegerBridge.class)
private Integer minPrice;
@Column(name = "max_price")
@Field(index = Index.YES, analyze = Analyze.YES, store = Store.NO)
@NumericField
@FieldBridge(impl = IntegerBridge.class)
private Integer maxPrice;
full text query is generated using entityManager as following
Code:
BooleanJunction priceBooleanJunction = queryBuilder.bool();
//Building range query for price
if (minPrice != null) {
Query rangeQueryMinPrice = queryBuilder.range().onField("minPrice").above(minPrice).createQuery();
priceBooleanJunction.must(rangeQueryMinPrice);
}
if (maxPrice != null) {
Query rangeQueryMaxPrice = queryBuilder.range().onField("maxPrice").below(maxPrice).createQuery();
priceBooleanJunction.must(rangeQueryMaxPrice);
}
BooleanJunction combainedBoolean = queryBuilder.bool();
if (!priceBooleanJunction.isEmpty()) {
combainedBoolean.must(priceBooleanJunction.createQuery());
}
Query searchQuery = combainedBoolean.createQuery();
FullTextQuery query = fullTextEntityManager.createFullTextQuery(searchQuery, ServiceProvider.class);
LOGGER.info(query.toString());
the last log prints the following for 40, 90 input
Code:
FullTextQueryImpl(+minPrice:[40 TO *] +maxPrice:[* TO 90])
database contains the values (min,max) as (50, 80) and (80, 90)
still result is empty.