OBJECT in this case is not function it is collection similar to ARRAY syntax. @prasad, Can you check if this documented. @atom_yang In mean time you can see syntax ARRAY, FIRST, and OBJECT https://github.com/couchbase/query/blob/master/docs/n1ql-select.md
Left side of colon is name which is evaluated and dynamically derived. Right side of colon is value. FOR each element treated as attribute of item and builds json object.
The following is better because names are unique and values are not.
OBJECT p:[k0,k1,k2][ARRAY_POSITION([βk0β,βk1β,βk2β],p)] FOR p IN [βk0β,βk1β,βk2β] END
Both arrays needs to be of same size and we are building name:value pair form both arrays at the same position.
so p is name ,such as βk0β,βk1β,βk2β, and [k0,k1,k2][ARRAY_POSITION(["k0","k1","k2"],p)] is corresponding value ?
I am still confused why [k0,k1,k2][ARRAY_POSITION(["k0","k1","k2"],p)] is corresponding value from items?
If p is βk1β
ARRAY_POSITION([βk0β,βk1β,βk2β],p) ===> 1
[k0,k1,k2][ARRAY_POSITION([βk0β,βk1β,βk2β],p)] ===> [k0,k1,k2][1]===> k1
p:[k0,k1,k2][ARRAY_POSITION([βk0β,βk1β,βk2β],p)] ===> βk1β:k1
now k1 is expression (it is not a string, no string quotes) so it evaluates form the document and picks value.
Other easy way is [k0,k1,k2] is array of expressions when evaluated (picks the values from the document) becomes array of values.