Search code examples
node.jselasticsearchaws-elasticsearch

In elasticsearch 2 docs with same ID


Hi I'm new to Elasticsearch and I'm using Elasticsearch version 5.6 as I know _id of every doc in Elasticsearch is unique. but while re-indexing logs I found that. some of doc have same _id. for example below two logs have same id. How is it possible?

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

Solution

  • This is because, your type in the index is different.

    first document has index orders but type as pending while other document has same index orders but type is confirmed.

    In latest ES version types are removed, refer removal of types for more info.