Elasticsearch: Improve research using special field as P.K. into the template

The following is a templeate in ElasticSearch (v.2.4.5), my question is, if there is a way to promote one of these fields, for example timeStamp , as primary key to help the research during the query; like it happens on database usually.

  {
  "order": 0,
  "template": "simsamples-*",
  "settings": {
"index": {
  "number_of_shards": "1"
}
  },
  "mappings": {
"ProbeSamples": {
  "properties": {
    "date": {
      "index": "no",
      "type": "string"
    },
    "timeStamp": {
      "format": "epoch_second",
      "type": "date"
    },
    "temperatures": {
      "type": "double"
    },
    "id": {
      "index": "not_analyzed",
      "type": "string"
    }
  }
}
  }
}

Or by other words, there is a way to optimize the template to research a particular field of interest.

Thank you

Welcome!

No it's not possible but nothing prevents you from doing:

PUT index/_doc/1234
{
  "id": "1234",
  "foo": "bar"
}
1 Like

Thank you for the welcome.

Do you mean, forming an id field , could I search more fast it?

I'm reading documentation, what about to use keyword?
My aim is to search a field directly, if I can.

Thank you.

I was just saying that the _id of the document will be the primary key. It can be whatever value you want which could also reflect a field that you have in your document.

But this is even better:

PUT index/_doc/1234
{
  "foo": "bar"
}
GET index/_doc/1234

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.