解析数字上的异常

时间:2016-11-23 14:00:41

标签: node.js elasticsearch

我正在尝试索引如下所示的数据:

var json = {
    "kwg": {
        "kwg0List": [
            {
                "lemma": "bilingue",
                "categories": [
                    "terme"
                ],
                "occList": [
                    {
                        "startTimeSec": 537.1,
                        "endTimeSec": 537.46,
                        "value": "bilingue"
                    },
                    {
                        "startTimeSec": 563.2,
                        "endTimeSec": 563.55,
                        "value": "bilingue"
                    }
                ]
            }
        ]
    }
}

一切正常。现在,让我们说,无论出于何种原因,startTimeSec字段之一等于10。它被解释为long,而不再是double

我会收到以下错误:mapper_parsing_exception,告诉我应该有double而不是long

现在我的问题是:有没有办法强迫"强迫"索引时要long转换为double,或者之前检查数据格式是否正确,这是唯一的方法吗?

追踪:

{
    "took": 1112,
    "errors": true,
    "items": [
      {
        "create": {
          "_index": "library",
          "_type": "relevance",
          "_id": "AViRhRJ-_Tb2laJ1W4JH",
          "status": 400,
          "error": {
            "type": "mapper_parsing_exception",
            "reason": "failed to parse",
            "caused_by": {
              "type": "illegal_argument_exception",
              "reason": "mapper [kwg.kwg0List.occList.endTimeSec] of different type, current_type [double], merged_type [long]"
            }
          }
        }
      }
    ]
  }

0 个答案:

没有答案