Hi guys,
I’m trying to solve this myself but figured I should ask here in case someone knows what I’m doing wrong quicker than I do.
I have a document that looks like this:
{
"id": "guid",
"attributes": {
"startPath": "string",
"endPath": "string",
"startChar": "0",
"endChar": "0"
},
"clientModified": "string",
"serverModified": "string",
}
I need to update these documents’ nested object “attributes”, and change the names inside the dictionary. Instead of startPath and endPath, we want startSpan and endSpan. My updatequery looks like this:
UPDATE MyBucket
SET attributes.startSpan = attributes.startPath, attributes.endSpan = attributes.endPath
UNSET attributes.startPath,attributes.endPath
;
I cannot execute this without creating an appropriate index, and I don’t want to create a PRIMARY INDEX because I think those are the heaviest indexes and it would take a long time (we have hundreds of millions of documents).
Creating a PRIMARY INDEX on MyBucket lets the query work, but I want to create as minimal of an index as possible. I am not sure what I need inside the index.
I have been trying different indexes on those values like
CREATE INDEX
idx_fix_spans1ON
MyBucket(attributes.startPath, attributes.endPath)
OR
CREATE INDEX
idx_fix_spans2ON
MyBucket(attributes)
OR
CREATE INDEX
idx_fix_spans3ON
MyBucket(attributes, attributes.startPath, attributes.endPath)
OR
CREATE INDEX
idx_fix_spans4ON
MyBucket(attributes, attributes.startPath, attributes.endPath, attributes.startSpan, attributes.endSpan)
So far, no luck. Anyone have any insight into what my index should look like?
FYI: Our intention is to use this index for this update query, then drop it after the update runs.
EDIT: Does updating a field in a document mean couchbase is re-saving the whole doc, and thus couchbase absolutely needs a PRIMARY INDEX for this functionality?