Jayfry
November 4, 2020, 12:17am
1
Hello.
I’m able to query META(), and return some meta data from my documents. But when i query META().xattrs I get nothing returned.
When I check in Documents, select a document, and choose Metadata. I see xattrs.
I’m using the newest version of couchbase 6.6. Wonder if i’m missing something, or if some setting has to be check when I sync data?
My results look like this.
[
{},
{}
]
My document meta data looks like this
{
“meta”: {
“id”: “04baad4d-2030-4d3f-b9f2-972072ceb30a”,
“rev”: “1-162c31d5334400000000000000000000”,
“expiration”: 0,
“flags”: 0,
“type”: “json”
},
“xattrs”: {
“_sync”: {
“rev”: “1-98faf8cffaa7c9b73753be9f39d98bee”,
“sequence”: 192,
“recent_sequences”: [
192
],
“history”: {
“revs”: [
“1-98faf8cffaa7c9b73753be9f39d98bee”
],
“parents”: [
-1
],
“channels”: [
null
]
},
“cas”: “0x00004433d5312c16”,
“value_crc32c”: “0x60d5500f”,
“time_saved”: “2020-08-17T23:25:59.567214583Z”
}
}
}
vsr1
November 4, 2020, 2:18am
2
You need to give actual xattribute
SELECT META(b).xattrs._sync, META(b).*
FROM mybucket AS b
WHERE …
Jayfry
November 4, 2020, 3:29pm
3
unfortunately this still does not show xattrs.
vsr1
November 4, 2020, 3:47pm
4
The document you are looking might not have it. Pick the document you think you have and try it
SELECT META(b).xattrs._sync, META(b).*
FROM mybucket AS b USE KEYS “04baad4d-2030-4d3f-b9f2-972072ceb30a”;
Jayfry
November 4, 2020, 4:23pm
5
Thanks for the reply, doesn’t seem to be working however.
vsr1
November 4, 2020, 4:28pm
6
It should work. Provide EXPLAIN.
Jayfry
November 4, 2020, 4:31pm
7
I think this is what you’re looking for.
vsr1
November 4, 2020, 4:32pm
8
I need text from Plan Text Tab which has more info
Jayfry
November 4, 2020, 4:34pm
9
Got it, here you go.
{
"#operator": "Sequence",
"~children": [
{
"#operator": "IndexScan3",
"as": "b",
"index": "#primary",
"index_id": "1942de312b0c9e6b",
"keyspace": "LongtermStorage",
"namespace": "default",
"spans": [
{
"exact": true,
"range": [
{
"high": "\"04baad4d-2030-4d3f-b9f2-972072ceb30a\"",
"inclusion": 3,
"low": "\"04baad4d-2030-4d3f-b9f2-972072ceb30a\""
}
]
}
],
"using": "gsi"
},
{
"#operator": "Fetch",
"as": "b",
"keyspace": "LongtermStorage",
"namespace": "default",
"subpaths": [
"_sync"
]
},
{
"#operator": "Parallel",
"~child": {
"#operator": "Sequence",
"~children": [
{
"#operator": "Filter",
"condition": "((meta(`b`).`id`) = \"04baad4d-2030-4d3f-b9f2-972072ceb30a\")"
},
{
"#operator": "InitialProject",
"result_terms": [
{
"expr": "((meta(`b`).`xattrs`).`_sync`)"
},
{
"expr": "meta(`b`)",
"star": true
}
]
},
{
"#operator": "FinalProject"
}
]
}
}
]
}
vsr1
November 4, 2020, 4:35pm
10
Seems right. Can u try
MTEA(b).*, META(b).xattrs._sync
Jayfry
November 4, 2020, 4:37pm
11
same results.
{
"#operator": "Sequence",
"~children": [
{
"#operator": "IndexScan3",
"as": "b",
"index": "#primary",
"index_id": "1942de312b0c9e6b",
"keyspace": "LongtermStorage",
"namespace": "default",
"spans": [
{
"exact": true,
"range": [
{
"high": "\"04baad4d-2030-4d3f-b9f2-972072ceb30a\"",
"inclusion": 3,
"low": "\"04baad4d-2030-4d3f-b9f2-972072ceb30a\""
}
]
}
],
"using": "gsi"
},
{
"#operator": "Fetch",
"as": "b",
"keyspace": "LongtermStorage",
"namespace": "default",
"subpaths": [
"_sync"
]
},
{
"#operator": "Parallel",
"~child": {
"#operator": "Sequence",
"~children": [
{
"#operator": "Filter",
"condition": "((meta(`b`).`id`) = \"04baad4d-2030-4d3f-b9f2-972072ceb30a\")"
},
{
"#operator": "InitialProject",
"result_terms": [
{
"expr": "meta(`b`)",
"star": true
},
{
"expr": "((meta(`b`).`xattrs`).`_sync`)"
}
]
},
{
"#operator": "FinalProject"
}
]
}
}
]
}
vsr1
November 4, 2020, 4:46pm
12
Not sure why it is not working. Try this. What is version of CB?
SELECT META(b) AS meta, b
FROM LongtermStorage AS b USE KEYS "04baad4d-2030-4d3f-b9f2-972072ceb30a"
LET sync = META(b).xattrs._sync;
Jayfry
November 4, 2020, 4:50pm
13
Same, no xattrs are returned. I’m seeing this version when I go to the dashboard.
Enterprise Edition 6.6.0 build 7909
Do i have to create an index for the xattrs ?
vsr1
November 4, 2020, 4:53pm
14
No index needed. I really don’t have idea why it is not working.
Jayfry
November 4, 2020, 4:57pm
15
dang. Thanks for all the help so far. I think we have an enterprise contact I can reach out to. Maybe they can help.
I’ll post solution once we find it.
vsr1
November 4, 2020, 4:57pm
16
That will be great if you can do that.
Enterprise Edition 6.6.0 build 7909
created default bucket
cbc-subdoc -u Administrator -P password
set -x sync={“rev”:1} k01 {“a”:1}
In Query work bench
select META().xattrs.sync,* FROM default USE KEYS “k01” ;
Jayfry
November 4, 2020, 6:37pm
17
Thanks. I have a meeting today with the couchbase team. I’ll let them know you were able to get the data so we at least start with the baseline that it is possible.
appreciate all the help so far. I’ll keep you posted.
Jayfry
November 4, 2020, 10:07pm
18
okay well now i feel a little dumb lol. So When i clicked on "buckets’ in the couchbase UI i assumed it was taking me to my LongtermStorage bucket, however it was taking me to another buket. That bucket has the same objects, but they actually come from syn gateway which gives it the xattrs attributes.
When i looked at the documents in the correct bucket they did not have xattrs. Turns out we run an eventing script to move that data from one bucket to another, and we do not carry over the xattrs when doing so.
Sorry about that. Glad i learned a bit more about how this all works.