Script condition for not matching records

Hi,

I am selecting records based on range query.

/_update_by_query?conflicts=proceed
{
	"query":{"range":{"dateTime":{"gte":"xxx","lte":"xxx"}}},
	"script":{"source":"ctx._source.selected = true"}
}

how can i unselect rest of the records(means records which doesn't belong to above range)? because there might be previously selected records which may not be in new range.

Thanks

Hi,
Use Boolean query to negate the range query.

Hi,
Thanks for the response, yes I could do that, but how i can do that in the same request?
it is possible to have 2 query and 2 respective actions in the same request?

Maybe no. is there any problem if you use two requests for the queries? Why you want to.do it in a single request?

No problem with making 2 request, thought single request could be faster.
anyway I am using your "Boolean query to negate the range query" suggestion to make parallel requests, one to unselect and another to select. thanks for answer.

1 Like

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