您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

Elasticsearch:在将JSON数据上传到Elasticsearch之前如何创建映射

Elasticsearch:在将JSON数据上传到Elasticsearch之前如何创建映射

client.bulk()拨打电话之前,您首先需要client.indices.putMapping()拨打另一个这样的电话,以便为您要通过该bulk电话发送的数据保存正确的映射:

client.indices.putMapping({
   "index": "testindex",
   "type": "testtype",
   "body": {
      "testtype": {
          "properties": {
              "your_int_field": {
                  "type": "integer"
              },
              "your_string_field": {
                  "type": "string"
              },
              "your_double_field": {
                  "type": "double"
              },
              // your other fields
          }
      }
   }
}, function (err, response) {
   // from this point on, if you don't get any error, you may call bulk.
});

请记住,所有这些调用是异步的,所以一定要小心,只叫bulk一次,putMapping已成功返回。

其他 2022/1/1 18:17:44 有483人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶