cloudant - How to combine multiple CouchDB queries into a single request? -
i'm trying query documents in cloudant.com database (couchdb). 2 following query requests work fine separately:
{ "selector": { "some_field": "value_1" } } { "selector": { "some_field": "value_2" } }
cloudant's documentation seems indicate should able combine 2 queries single http request follows:
{ "selector": { "$or": [ { "some_field": "value_1" }, { "some_field": "value_2" } ] } }
but when try receive following response:
{"error":"no_usable_index", "reason":"there no operator in selector can used index."}
can tell me need work?
there doesn't seem way achieve cloudant query @ moment. however, can use view query instead using index created cloudant query. assuming index in design document named ae97413b0892b3738572e05b2101cdd303701bb8
:
curl -x post \ 'https://youraccount.cloudant.com/db/_design/ae97413b0892b3738572e05b2101cdd303701bb8/_view/ae97413b0892b3738572e05b2101cdd303701bb8?reduce=false&include_docs=true' \ -d ' { "keys":[ ["value_1"], ["value_2"] ] }'
this give response this:
{ "total_rows": 3, "offset": 1, "rows": [ { "id": "5fcec42ba5cad4fb48a676400dc8f127", "key": [ "abc" ], "value": null, "doc": { "_id": "5fcec42ba5cad4fb48a676400dc8f127", "_rev": "1-0042bf88a7d830e9fdb0326ae957e3bc", "some_field": "value_1" } }, { "id": "955606432c9d3aaa48cab0c34dc2a9c8", "key": [ "ghi" ], "value": null, "doc": { "_id": "955606432c9d3aaa48cab0c34dc2a9c8", "_rev": "1-68fac0c180923a2bf133132301b1c15e", "some_field": "value_2" } } ] }
Comments
Post a Comment