QueryBuilders rangeQuery with null date or values

Hello!

trying to found a solution for range query
using QueryBuilders.rangeQuery

Problem:
DateFrom can be null or higher than today
DateTill can be null or smaller than today
quantyti remaining can be null or value can be higher than 0

only then documents must appear in search results i was trying to solve this problem with

      //Query Mean - quantityRemaining must to be null or higher than 1
    publishedFilter
        .should(QueryBuilders.boolQuery()
            .mustNot(QueryBuilders.existsQuery(SearchAble.QUANTITY_REMAINING)))
        .should(QueryBuilders.rangeQuery(SearchAble.QUANTITY_REMAINING).gte(1))
        .minimumShouldMatch(1);

    QueryBuilders.boolQuery()
        .must(QueryBuilders.rangeQuery(SearchAble.DATE_TIME_FROM).lte(time))
        .mustNot(QueryBuilders.rangeQuery(SearchAble.DATE_TIME_TILL).lte(time));

but this solution working only for quantyti remaining instead of the dateFrom and dateTill

any ideas ?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.