问题
I used the online N1QL tutorial to practices writing queries. Now that I have a couchbase server of my own, I want to query my own data.
My questions is
Where in the Couchbase server can I write my queries?
thanks
回答1:
Remember that N1Q1 is still in Beta.
The way it works is that you have to run Couchbase Query Server (aka CBQ). It runs in a default port 8093 (see N1QL) The query server will connect to the specified Couchbase instance/cluster. e.g.
cbq-engine -couchbase <CB-location>
Once CB Query Engine up and running you can run command line client and in a command prompt can issue your N1QL statements, e.g.:
cbq -engine http://your-cb-host:8093/
cbq> SELECT 'Hello World' AS Greeting
{
"resultset": [
{
"Greeting": "Hello World"
}
],
"info": [
{
"caller": "http_response:160",
"code": 100,
"key": "total_rows",
"message": "1"
},
{
"caller": "http_response:162",
"code": 101,
"key": "total_elapsed_time",
"message": "4.0002ms"
}
]
}
回答2:
N1QL is released and available as part of Couchbase Server. Please download Couchbase Server 4.1 http://www.couchbase.com/nosql-databases/downloads
Learn more at: http://www.couchbase.com/n1ql
回答3:
Just to note, there is a new developer preview of N1QL out now (http://docs.couchbase.com/developer/n1ql-dp3/n1ql-intro.html) and the way to connect to a Couchbase cluster has changed from the answer given by user1697575; it's now:
cbq-engine -datastore <CB-location>
The Couchbase query engine can also serve N1QL queries from a file system, and there is a file system included in the download that can be queried:
cbq-engine -datastore=dir:./data
来源:https://stackoverflow.com/questions/25620506/couchbase-n1ql-queries-on-server