Unable to query xattrs

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”
}
}
}

You need to give actual xattribute

SELECT META(b).xattrs._sync, META(b).*
FROM mybucket AS b
WHERE …

unfortunately this still does not show xattrs.

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”;

Thanks for the reply, doesn’t seem to be working however.

It should work. Provide EXPLAIN.

I think this is what you’re looking for.

I need text from Plan Text Tab which has more info

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"
                }
            ]
        }
    }
]

}

Seems right. Can u try
MTEA(b).*, META(b).xattrs._sync

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"
                }
            ]
        }
    }
]

}

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;

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 ?

No index needed. I really don’t have idea why it is not working.

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.

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” ;

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.

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.