Need return value only if document is updated else ignore

My document structure is as below
{
“Name”:“xyz”,
“Bookings”:[

{“StartDate”:“2017-07-12”,“EndDate”:“2017-07-19”,“BookingId”:“123344”}, {“StartDate”:“2017-07-20”,“EndDate”:“2017-07-22”,“BookingId”:“123344”}

]
}
UPDATE default SET Bookings = ARRAY book FOR book IN Bookings WHEN NOT STR_TO_MILLIS(book.EndDate) <= STR_TO_MILLIS(“2017-07-19”) END RETURNING Name

I need only the Name of a booking as return value if it is updated, but the above update query is always returning all the booking names no matter whether it is updated or not.

Can any one please suggest what is wrong with the above query.

Regards,
Srikar

Returning clause returns qualified mutations as you don’t have any predicate every document qualifies update (in set clause you updating some cases same document with same value).

UPDATE default 
SET Bookings = ARRAY book FOR book IN Bookings WHEN  book.EndDate > "2017-07-19" END
WHERE ANY book IN Bookings  SATISFIES book.EndDate <= "2017-07-19" END
 RETURNING Name;

If you want query run faster create following index

CREATE INDEX ix1 ON default( DISTINCT ARRAY book.EndDate FOR book IN Bookings END);

Above query is working for me.

Can you please help me out understanding how index ix1 can be used when combined with the above query.

Thanks for the help @vsr1

Above query already uses ix1. Details are available
https://developer.couchbase.com/documentation/server/current/n1ql/n1ql-language-reference/indexing-arrays.html
https://blog.couchbase.com/making-the-most-of-your-arrays-with-array-indexing/