Вы можете использовать вид, как это. Это пример. Не решение
function(doc) {
var product, value;
if (doc.type != "master" && doc.type == "a" && doc.company == 9 && doc.products && Array.isArray(doc.products)) {
doc.products.forEach(function(product) {
Object.keys(product).forEach(function(key) {
emit([key, product[key].id]);
});
});
}
}
Создает вывод как
{
"total_rows": 16,
"offset": 0,
"rows": [
{
"key": [
"article",
1132
],
"id": "check",
"value": null
},
{
"key": [
"article",
1132
],
"id": "check",
"value": null
},
{
"key": [
"article_code",
null
],
"id": "check",
"value": null
},
{
"key": [
"article_code",
null
],
"id": "check",
"value": null
},
{
"key": [
"order",
null
],
"id": "check",
"value": null
},
{
"key": [
"order",
null
],
"id": "check",
"value": null
},
{
"key": [
"provider",
2313
],
"id": "check",
"value": null
},
{
"key": [
"provider",
2313
],
"id": "check",
"value": null
},
{
"key": [
"qty",
null
],
"id": "check",
"value": null
},
{
"key": [
"qty",
null
],
"id": "check",
"value": null
},
{
"key": [
"unit",
9
],
"id": "check",
"value": null
},
{
"key": [
"unit",
9
],
"id": "check",
"value": null
},
{
"key": [
"warehouse",
18
],
"id": "check",
"value": null
},
{
"key": [
"warehouse",
18
],
"id": "check",
"value": null
},
{
"key": [
"warehouse_company",
9
],
"id": "check",
"value": null
},
{
"key": [
"warehouse_company",
9
],
"id": "check",
"value": null
}
]
}
Вы можете искать "склад" с идентификатором 18 как
using key=["warehouse",18]