How to search for blank key in json document which is stored in couchbase

Hi all,

For some reason we need to maintain a blank key in our json document.
Is there any way in the N1Q1 query to get that. We have only 1 such blank key at that level. I tried if any indexing can do the job but it didn’t work for me.

Here is an example:

{
“standalone”: {
“”: {
‘a’: 23,
‘b’: 56
}
}
}

I want to access element ‘a’. How to access it using N1Q1?

Thank you.

  insert into default values ("k01",{ "standalone": { "": { 'a': 23, 'b': 56 } } });

 SELECT OBJECT_VALUES(d.standalone.[""])[0].a 
FROM default AS d USE KEYS "k01";

SELECT  (FIRST v.val FOR v IN OBJECT_PAIRS(d.standalone) WHEN v.name = "" END).a 
FROM default AS d USE KEYS "k01";
1 Like

Thank you very much vsr1 :slight_smile: