Query context for scopes using N1QL

I had a small doubt about using N1QL for scopes and collections in the enterprise 7.0 release.
Based on this article, I tried using N1QL to set query context on the sample travel-sample bucket.
The query I used was set query_context = "default:travel-sample.inventory";.
The error I got was:

[
  {
    "code": 3000,
    "msg": "syntax error - at query_context",
    "query": "set query_context = \"default:travel-sample.inventory\";"
  }
]

Is there something from the article I’m missing?
Would be very grateful if someone could help me with this, I’m a student dev new to using CB.
Thanks!

1 Like

@aditi,

There is special character - (minus arithmetic operation), each part is identifier escape if need using back ticks.

"default:`travel-sample`.inventory"

If using Query Work Bench (Chose bucket then scope) as shown in the screen shot. It automatically sets query_context

If using cbq shell

\set -query_context   "default:`travel-sample`.inventory";

Thank you so much @vsr1!
I knew how to do it using cbq and the Query Workbench, N1QL was the only one not working.

1 Like