Make sure duplicates are not running while automatic indexing in elasticsearch

I have many channels that go to my server.

Example document is as follows -
{
"company" : "sony",
"size" : "10X",
"name" : "Kakhee pants",
"color" : "red"
}

The fields "company" and "name" must be unique. That is, I do not want 2 documents with the same company and name, but with a different color and size. How can I install this in Elasticsearch?

+4
source share
1 answer

A better strategy for this would be to create a docID based on the value of these three fields. For example, for this document -

{
"company" : "sony",
"size" : "10X",
"name" : "Kakhee pants",
"color" : "red"
}

Make docID as sony + Kakhee_pants + red And then select the size and color of the attribute array.

{
  "company": "sony",
  "name": "Kakhee pants",
  "color": "red",
  "attributes": [
    {
      "size": "10X",
      "color": "red"
    }
  ]
}

, , upsert , , , .

+3

All Articles