# "\_id" and mappings

**URL:** https://discuss.elastic.co/t/-id-and-mappings/55185
**Category:** Elasticsearch
**Created:** [July 11, 2016, 11:29am UTC](https://discuss.elastic.co/t/-id-and-mappings/55185 "2016-07-11T11:29:53Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Nilesh\_Gaikwad](https://avatars.discourse-cdn.com/v4/letter/n/e495f1/32.png) [@Nilesh\_Gaikwad](https://discuss.elastic.co/u/Nilesh_Gaikwad)
#### Post date: [July 11, 2016, 11:29am UTC](https://discuss.elastic.co/t/-id-and-mappings/55185/1 "2016-07-11T11:29:53Z")

</div>

Hi,

I'm doing something like below,

```
try:
	es_client = Elasticsearch([EShost], timeout=1000)
	if not es_client.indices.exists(index):
		settings = '''
		{  
		  "settings" : {
				"analysis": {
					"filter": {
						"bigrams_filter": {
							"type": "nGram",
							"min_gram": 12,
							"max_gram": 12
						}
					},
					"analyzer": {
						"bigrams": {
							"type": "custom",
							"tokenizer": "standard",
							"filter": [
								"lowercase",
								"bigrams_filter"
							]
						}
					}
				}
			},"mappings": {
				"'''+estype+'''": {
					"properties": {
						"_id": {
							"type": "string",
							"analyzer": "bigrams" 
						}
					}
				}
			}
		}'''
		print "\nCreating index..!!"
		es_client.indices.create(index=index, ignore=400, body=settings)
except:
	print traceback.print_exc()

```

So that I ll get all the id's having specified string as a substring.  
But I'm not able to retrieve any id which is having specified input string in it.  
Am I missing anything..?

Below is the \_mapping output:-

```
{
  "string_database" : {
	"mappings" : {
	  "strings" : {
		"properties" : {
		  "occurence" : {
			"type" : "long"
		  },
		  "timestamp" : {
			"type" : "date",
			"format" : "strict_date_optional_time||epoch_millis"
		  }
		}
	  }
	}
  }
}

```

Here "\_id" is not present.

---

<div class="post-metadata">

### Author: ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)
#### Post date: [July 11, 2016, 2:46pm UTC](https://discuss.elastic.co/t/-id-and-mappings/55185/2 "2016-07-11T14:46:31Z")

</div>

The `"_id"` field is an internal field that Elasticsearch manages... you cannot configure analyzers for it. If you need that behavior, you'll have to configure your own field in the document (e.g. `"my_id"`) which has the desired analyzers.

---

<div class="post-metadata">

### Author: ![Nilesh\_Gaikwad](https://avatars.discourse-cdn.com/v4/letter/n/e495f1/32.png) [@Nilesh\_Gaikwad](https://discuss.elastic.co/u/Nilesh_Gaikwad)
#### Post date: [July 12, 2016, 5:55am UTC](https://discuss.elastic.co/t/-id-and-mappings/55185/3 "2016-07-12T05:55:27Z")

</div>

Hello Polyfractal,

Thanks for your reply. I have added new field inside "\_source" field and it worked.

I have one more query, is it possible to create new field outside the "\_source" field and apply analyzer for it..??(I have tried same but didn't worked) or ES allows field to be created inside \_source field only.. ??

And if it is possible then(applying analyzer too), will it impact search performance..?? because searching inside the \_source will be more costlier than searching outside it. (I'm new to ES I might be thinking in wrong direction)

Regards

---

<div class="post-metadata">

### Author: ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)
#### Post date: [July 12, 2016, 2:26pm UTC](https://discuss.elastic.co/t/-id-and-mappings/55185/4 "2016-07-12T14:26:02Z")

</div>

Hmm, I'm not _quite_ sure I know what you mean.

The `_source` field represents the original JSON that you send to Elasticsearch. So it will contain basically the exact document that you sent.

It's possible to add fields that are indexed/searchable but not in the original `_source` document using a feature called [multi-fields](https://www.elastic.co/guide/en/elasticsearch/reference/current/_multi_fields.html). This allows you to analyze a single field in different ways. The contents of the field are only sent once in the original document, but multiple analysis processes are used to create "virtual fields" which are query'able.

Similarly, you can use the [copy\_to parameter](https://www.elastic.co/guide/en/elasticsearch/reference/current/copy-to.html) to copy the contents of multiple fields into a single new "virtual field". This is also not present in the original \_source, but it is searchable.

> And if it is possible then(applying analyzer too), will it impact search performance..?? because searching inside the \_source will be more costlier than searching outside it. (I'm new to ES I might be thinking in wrong direction)

This isn't really a problem as the `_source` is never actually searched 🙂 That field just holds the original JSON so that you can use it later (to show to users, etc). The actual searching is done on internal data structures that are generated when the document is indexed.

---

<div class="post-metadata">

### Author: ![Nilesh\_Gaikwad](https://avatars.discourse-cdn.com/v4/letter/n/e495f1/32.png) [@Nilesh\_Gaikwad](https://discuss.elastic.co/u/Nilesh_Gaikwad)
#### Post date: [July 14, 2016, 9:36am UTC](https://discuss.elastic.co/t/-id-and-mappings/55185/5 "2016-07-14T09:36:33Z")

</div>

> [@polyfractal](#):
>
> actual

Thanks a lot Polyfractal, your reply was very informative.

---

<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: [July 5, 2017, 10:35pm UTC](https://discuss.elastic.co/t/-id-and-mappings/55185/6 "2017-07-05T22:35:46Z")

</div>


