I have the following json (simplified) objects in a couchdb storage:
[{
"_id": "5ea7a53e670b432e0fe22a7bc10024db",
"_rev": "1-ae70c8906f7aa6d73539a89f7ad960ee",
"type": "job"
}, {
"_id": "5ea7a53e670b432e0fe22a7bc10041d9",
"_rev": "4-fa0ba68c35ca548b497a7309389f9087",
"type": "scan",
"job_id": "5ea7a53e670b432e0fe22a7bc10024db",
"number": 1
}, {
"_id": "5ea7a53e670b432e0fe22a7bc100520e",
"_rev": "4-3e6b1a028786c265ecb7362e245d049e",
"type": "scan",
"job_id": "5ea7a53e670b432e0fe22a7bc10024db",
"number": 2
}]
I want to make a post request with the keys [“5ea7a53e670b432e0fe22a7bc10024db”, 2] (the job id and a scan number). How can I make a map function for a view to filter out the job that has the given id and the measurement that matches the job_id and the number?
Thanks,
Radu
What is you expected output of the request? If you just want to get the scan, emit in
mapthe key you want to search for:If you need two documents — the job (full document, not just
id) and the scan, either emit both of them in singleemitwithinclude_docs=trueparameter in the request’s URL:or in two
emit‘s with:You will get both document with
startkey=["5ea7a53e670b432e0fe22a7bc10024db", 2]&endkey=["5ea7a53e670b432e0fe22a7bc10024db", 2, {}]&include_docs=true(orkeys=[]) in the URL.Check the view API for the
include_docsoption.