UPDATE content SET categories = ARRAY a FOR a IN categories WHEN a != “veg” END
WHERE _type=“UserAsset” AND type IN [“IMAGE”,“AUDIO”,“VIDEO”,“SVG”,“FILE”,“PPT”] RETURNING categories
How to create a index for the above query… so that it will execute with in miliseconds ??
I have created index like
type) WHERE (
_type = “UserAsset”).
But its not working it seems.
Do you mean that it is not updating in milliseconds?
yes.it is not updating in miliseconds. Its taking about 20sec to execute.
I assume you want to update a very limited number of documents?
Could you show us the plan?
CREATE INDEX ix1d_UserAsset ON content(type, DISTINCT ARRAY v FOR v IN categories END)
WHERE (_type = "UserAsset");
SET categories = ARRAY a FOR a IN categories WHEN a != "veg" END
AND type IN ["IMAGE","AUDIO","VIDEO","SVG","FILE","PPT"]
AND ANY v IN categories SATISFIES v = "veg" END
- UPDATE requires whole document Fetch
- mutation of document is controlled by WHERE clause. SET clause only decides what to set. If you have condition in set clause that can result in update same document with out any change. So you need to add that condition to WHERE clause avoid unnecessary mutation.