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

**URL:** <https://discuss.elastic.co/t/elasticsearch-improve-research-using-special-field-as-p-k-into-the-template/220170>\
**Category:** Elasticsearch\
**Created:** [February 20, 2020, 11:21am UTC](https://discuss.elastic.co/t/elasticsearch-improve-research-using-special-field-as-p-k-into-the-template/220170 "2020-02-20T11:21:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![zam999](https://avatars.discourse-cdn.com/v4/letter/z/b9e5f3/32.png) [@zam999](https://discuss.elastic.co/u/zam999)\
**Post date:** [February 20, 2020, 11:21am UTC](https://discuss.elastic.co/t/elasticsearch-improve-research-using-special-field-as-p-k-into-the-template/220170/1 "2020-02-20T11:21:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 20, 2020, 11:36am UTC](https://discuss.elastic.co/t/elasticsearch-improve-research-using-special-field-as-p-k-into-the-template/220170/2 "2020-02-20T11:36:34Z")

</div>

Welcome!

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

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

---

<div class="post-metadata">

**Author:** ![zam999](https://avatars.discourse-cdn.com/v4/letter/z/b9e5f3/32.png) [@zam999](https://discuss.elastic.co/u/zam999)\
**Post date:** [February 20, 2020, 11:44am UTC](https://discuss.elastic.co/t/elasticsearch-improve-research-using-special-field-as-p-k-into-the-template/220170/3 "2020-02-20T11:44:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 4, 2020, 12:47pm UTC](https://discuss.elastic.co/t/elasticsearch-improve-research-using-special-field-as-p-k-into-the-template/220170/4 "2020-03-04T12:47:24Z")

</div>

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
```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 1, 2020, 12:47pm UTC](https://discuss.elastic.co/t/elasticsearch-improve-research-using-special-field-as-p-k-into-the-template/220170/5 "2020-04-01T12:47:30Z")

</div>

Closed on April 1, 2020, 12:47pm UTC

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