1

I have framed Range query as below - Java High Level REST Client

QueryBuilder rangeQu = QueryBuilders.rangeQuery("price").gt(30).lt(5000);

In this I want to include NULL/Empty values as well. How to include it?

2
  • Combine your query with a "not exists"-Query via boolean-"OR". elastic.co/guide/en/elasticsearch/reference/current/… Commented Aug 18, 2018 at 8:28
  • I understand from elastic query but need to know how to do with Java High Level REST client? Commented Aug 18, 2018 at 9:49

1 Answer 1

2

Creating a bool query that takes either the range query or the not exist should work something like this:

BoolQueryBuilder queryFilter = QueryBuilders.boolQuery();
queryFilter.should(QueryBuilders.rangeQuery("price").gt(30).lt(5000));
queryFilter.should(QueryBuilders.boolQuery().mustNot(QueryBuilders.existsQuery("price")));
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.