N1QL Query - multiple docs types in single bucket not working 4.0RC


#1

Hi,

We are evaluating the 4.0RC N1QL. I have seen in earlier posts that the following query should work but it is not working on our instance. We get no rows returned. When I change it to Left Join I get data

explain select * from NAPS_ENTITIES ru JOIN NAPS_ENTITIES ra;
{
“requestID”: “1e00440c-d53b-419c-9a6e-65f1d9359d1e”,
“signature”: “json”,
“results”: [
{
"#operator": “Sequence”,
"~children": [
{
"#operator": “PrimaryScan”,
“index”: “#primary”,
“keyspace”: “NAPS_ENTITIES”,
“namespace”: “default”,
“using”: “gsi”
},
{
"#operator": “Parallel”,
"~child": {
"#operator": “Sequence”,
"~children": [
{
"#operator": “Fetch”,
“as”: “n”,
“keyspace”: “NAPS_ENTITIES”,
“namespace”: “default”
},
{
"#operator": “Join”,
“as”: “accts”,
“keyspace”: “NAPS_ENTITIES”,
“namespace”: “default”,
“on_keys”: “(n.bookId)”
},
{
"#operator": “InitialProject”,
“result_terms”: [
{
“star”: true
}
]
},
{
"#operator": “FinalProject”
}
]
}
}
]
}
],
“status”: “success”,
“metrics”: {
“elapsedTime”: “2.0002ms”,
“executionTime”: “2.0002ms”,
“resultCount”: 1,
“resultSize”: 1661
}
}


#2

does n.bookid match the document key of other documents in the NAPS_ENTITIES bucket?


#3

Yes that was the problem. Thanks


#4

Can you query like this?
select * from NAPS_ENTITIES position NEST Books account ON KEYS “account_”+position.bookId ;


#5

That works. concat operator is || so pls try
…ON KEYS “account_”||TOSTRING(position.bookId);
thanks
-cihan