在具有相同 ID 的 elasticsearch 2 文档中

In elasticsearch 2 docs with same ID

大家好,我是 Elasticsearch 的新手,我使用的是 Elasticsearch 5.6 版,因为我知道 Elasticsearch 中每个文档的 _id 都是唯一的。 但是在重新索引日志时我发现了这一点。一些文档具有相同的_id。例如下面两个日志 有相同的ID。怎么可能?

{
  "_index": "orders",
  "_type": "pending",
  "_id": "1473531",
  "_score": 1,
  "_routing": "44540",
  "_parent": "44540",
  "_source": {
    "id": 1473531,
    "level": "info",
    "type": "pending",
    "status": "",
    "message": "Order marked cancelled by system"
  }
}
{
  "_index": "orders",
  "_type": "confirmed",
  "_id": "1473531",
  "_score": 1,
  "_source": {
    "id": 1473531,
    "source_address": "Independence, MO 64055",
    "dest_address": "MO 64138",
    "short_source": "Select Physical Therapy",
    "short_dest": "Home",
    "customer_remarks": null,
    "source_lat_long": ["39.0334554", "-94.3761432"],
    "dest_lat_long": ["38.986449", "-94.4661768"]
  }
}

这是因为,您在索引中的类型不同。

第一个文档有索引 orders 但类型为 pending 而另一个文档有相同的索引 orders 但类型为 confirmed.

在最新的 ES 版本中删除了类型,请参阅 removal of types 了解更多信息。