Ibm cloud Cloudant搜索索引

Ibm cloud Cloudant搜索索引,ibm-cloud,cloudant,Ibm Cloud,Cloudant,我有一个数据表,如下所示: [ { "payment_id": 1, "provider_id": "ABC123 ", "status": "pending", "item_service": [ { "code": "NY100", "provider_type":"Medical_Center",

我有一个数据表,如下所示:

[
    {
        "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"

如果您将索引设置为:

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"
        ]
      }

这是您想要得到的结果吗?

如果您将索引设置为:

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"
        ]
      }

这是您想要得到的结果吗?

感谢您的回复,我们可以将:费率、说明、代码和供应商类型添加到名为item_service[i]的组中?是的,您可以-但您在问题中发布的代码将是您的原始代码<代码>字段在搜索响应中返回没有层次结构,您不能向其添加子字段(例如“速率”、“描述”)。感谢您的响应,我们可以将:速率、描述、代码和提供者类型添加到名为item_service[i]的组中?是,你可以-但你在问题中发布的是你的原始代码<代码>字段搜索响应中返回的字段没有层次结构,您不能向其添加子字段(例如“速率”、“说明”…)。