Basically, I have a request to search for documents with specific tag(s) attached in create range between given startDate and endDate. I use below code for query
createBoolQuery(): Query {
return (
esb
.boolQuery()
.filter(esb.termsQuery("tags", ["tag1", "tag2", "tag3"]))
);
}
createRangeQuery(): Query {
const query = esb.rangeQuery("createdDate");
if (this._rangeStartDate) {
const startDate = moment(this._rangeStartDate);
query.gte(startDate.format("MM/DD/YYYY"));
}
if (this._rangeEndDate) {
const endDate = moment(this._rangeEndDate);
query.lte(endDate.format("MM/DD/YYYY"));
}
return query;
}
const query
const searchQuery = esb.RequestBodySearch().query(this.createBoolQuery()).query(this.createRangeQuery())
searchQuery in above code is
query: {range: {createdDate: {gte: "09/29/2021", lte: "11/03/2021"}}}
which you can see boolQuery part is missing, however if I replace code to use boolquery only, like
const searchQuery = esb.RequestBodySearch().query(this.createBoolQuery())
then the searchQuery is
query: {filter: {terms: {tags: ["tag1", "tag2", "tag3"]}}}}
Need big help to use just one query including both boolQuery and rangeQuery.