Simple HTTP View Query using CURL

Okay, I feel pretty stupid having built the Couchbase 2.0 preview from source and not even being able to query a simple view using CURL, but I am at the end of my rope and going to ask the stupid question anyway:

How do I simply use CURL in a CouchDB-specific manner (not memcached and using HTTP) to return the JSON associated with a view I created using a test document?
I am new to CouchDB and Couchbase, watched a bunch of videos, and apparently am still not getting how to do this simple thing. My apologies for the stupid question.
For your reference, I have created a single document and a development view called “notes”.

Thanks,
Travis

Hi Travis,
To query the view, try curl -X GET
http://127.0.0.1:8092/default/_design/<design_doc_name>/_view/<view_name>
Note: replace <design_doc_name> and <view_name>.

Here’s an example of query results from a view name “test” that I created where I only want the JSON documents that match the key “Dipti”

dipti$ curl -X GET http://127.0.0.1:8092/default/_design/dev_test/_view/test?key=“Dipti”

{“total_rows”:10,“rows”:[
{“id”:“dipti1”,“key”:“Dipti”,“value”:{“id”:27,“type”:“newMessage”,“msg”:“notification”}},
{“id”:“dipti2”,“key”:“Dipti”,“value”:{“id”:28,“type”:“newMessage”,“msg”:“notification”}},
{“id”:“dipti3”,“key”:“Dipti”,“value”:{“id”:30,“type”:“newMessage”,“msg”:“notification”}},
{“id”:“dipti4”,“key”:“Dipti”,“value”:{“id”:30,“type”:“newMessage”,“msg”:“notification”}},
{“id”:“dipti5”,“key”:“Dipti”,“value”:{“id”:31,“type”:“newMessage”,“msg”:“notification”}},
{“id”:“dipti6”,“key”:“Dipti”,“value”:{“id”:32,“type”:“newMessage”,“msg”:“notification”}},
{“id”:“dipti8”,“key”:“Dipti”,“value”:{“id”:33,“type”:“newMessage”,“msg”:“notification”}},
{“id”:“dipti9”,“key”:“Dipti”,“value”:{“id”:34,“type”:“newMessage”,“msg”:“notification”}}
]
}

You can find more information on the different arguments you can use for querying here: http://www.couchbase.com/docs/couchbase-manual-2.0/couchbase-views-writing-querying.html
hope this helps.

  • Dipti