我有一张包含以下数据的表格:
[
{
"payment_id": 1,
"provider_id": "ABC123 ",
"status": "pending",
"item_service": [
{
"code": "NY100",
"provider_type":"Medical_Center",
"description": "Initial Consultation - History, examination and treatment",
"rate": "20"
},
{
"code": "NY101",
"provider_type":"Medical_Center",
"description": "Brief Consultation - Selective review, examination and treatment",
"rate": "25"
},
{
"code": "NY102",
"provider_type":"Medical_Center",
"description": "Standard Consultation - History, examination and treatment",
"rate": "30"
}
]
}
]
和搜索索引功能
请告诉我您如何分割数据并使用结果中每个值的键名显示。例如:
"code": "PY102",
"provider_type":"Medical_Center",
"description": "Standard Consultation - History, examination and treatment",
"rate": "30"
答案 0 :(得分:2)
如果你的索引如下:
function (doc) {
if (doc.item_service){
for (var m in doc.item_service){
for (var n in doc.item_service[m]){
index(n, doc.item_service[m][n], {"store":true});
}
}
}
}
比您的字段:
"fields": {
"rate": [
"30",
"25",
"20"
],
"description": [
"Standard Consultation - History, examination and treatment",
"Brief Consultation - Selective review, examination and treatment",
"Initial Consultation - History, examination and treatment"
],
"code": [
"NY102",
"NY101",
"NY100"
],
"provider_type": [
"Medical_Center",
"Medical_Center",
"Medical_Center"
]
}
这是你打算得到的结果吗?