MERGE with UPDATE not working as expected?

Your query did not match any records because d.name is not a part of the Key of document in travel-sample.

In this case you can use direct update instead of merge.

The merge query is.

merge into travel-sample p using (select meta().id from travel-sample where name=‘Texas Wings’) as d on key d.id when matched then update set p.iata=‘Bush’;

merge into travel-sample p using (select d.type||"_"||to_string(d.id) as idx from travel-sample d where d.name=‘Texas Wings’) as d on key d.idx when matched then update set p.iata=‘Bush’;

If you need to use * you need to select all the fileds of the document not the whole document like below.

merge into travel-sample p
using (select d.* from travel-sample d where d.name=‘Texas Wings’) as d on key d.name
when matched then update set p.iata=‘Bush’

1 Like