Using latest version of Couchnode, I am able to get and set objects no problem. However, I am not able to use N1QL query. every request comes back with “Not Found”.
For instance, I have a simple “default” bucket with an object as {_id: 1, username: myname, password:123}.
From Node, I run a query like:
select * from default ==> "not found"
select * from default where username = ‘myname’ ==> “not found”
I get a similar result when I run the same query from the command line.
I’m sure I am missing something simple and significant in the setup of Couchbase to use N1QL, but I’m unsure what it is, and any help would be appreciated.
Thanks for the response, Gerald. You’re steps got me in the right direction and it’s working properly now. I wasn’t sure exactly what to make of the instructions that came with the Developer preview. It wasn’t clear for me if they were specific to the tutorial, or if they were the instructions on running the N1QL engine in general.
Where I was going wrong was running cbq-engine from the terminal, thinking it would be a long-running process, then in the same terminal window was running cbq. Also, I was attempting to run cbq against port 8091, not 8093. I now have everything working.
For those just starting with N1QL and NodeJS, here are the steps I took:
Ensure Couchbase is installed and runs properly (obviously), and that you can connect through Couchnode properly.
Download the Developer Preview 3 of N1QL, unpack it and put it in whatever directory you like
Open Terminal or CMD window, CD into the directory with the developer preview, run cbq-engine with: ./cbq-engine -couchbase http://:8091/ **This terminal window must remain open, unless using a utility or command to keep it running
Back in Node, ensure you add the following to your connection object when setting up the Couchbase Client:
queryhosts":“127.0.0.1:8093”
For example, the entire connection object might look like:
am getting below error when am trying to exicute below query
cbq> SELECT * FROM beer-sample WHERE city = 'San Francisco’
14:59:05.012828 ERROR: Post =http://ec2-54-163-253-172.compute-1.amazonaws.com:8093/query: unsupported protocol scheme “” – main.HandleInteractiveMode() at interactive.go:54
Request you to please let me know , Where am wrong.
Am using
couchbase 3.0 Enterprise , N1QL Developer Preview 3.
What are the steps to connect to bucket.?
Do note however that this is legal JSON: [123, 456, 789]
as is 123456
and even null
In the long past, there were some parsers that would not consider it legal JSON unless it was in an object, but this has been clarified in updates on the standard. I think the (hilariously named) ECMA-404 is the right authority these days though it builds on the IETF RFCs and what is at json.org.
Thanks for the note; I’ve verified that the query “SELECT ifa[0] FROM ifa” works when the document is of the format: [123, 456, 789]
Ashwini, if this is still an issue for you please send on the output of the query “SELECT ifa FROM ifa LIMIT 10”. This will show us what your data looks like and help diagnose the issue.
I fail to understand where should I run cbq-engine and where to run cbq.
Let’s say I have a remote ubuntu couchbase server and osx local machine.
Is this what I should do to connect my local machine to run interactive queries (like the tutorial) in the remote server through my local machine?