# \_id and mappings

**URL:** <https://discuss.elastic.co/t/-id-and-mappings/4455>\
**Category:** Elasticsearch\
**Created:** [May 23, 2011, 1:09am UTC](https://discuss.elastic.co/t/-id-and-mappings/4455 "2011-05-23T01:09:56Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bryan\_Green](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bryan_green/32/3028_2.png) [@Bryan\_Green](https://discuss.elastic.co/u/Bryan_Green)\
**Post date:** [May 23, 2011, 1:09am UTC](https://discuss.elastic.co/t/-id-and-mappings/4455/1 "2011-05-23T01:09:56Z")

</div>

Hi,

I'd like to index the '\_id' field for all types across all indexes.  
How do I do this? I have a clean index from 0.16.1.

Can I place this in the default-mapping.json file:?  
{  
"_default_" : {  
"properties" : {  
"\_id": {  
"type":"long",  
"index": "not\_analyzed",  
"store": "yes"  
}  
}  
}  
}

It doesn't seem to work.

Also, I am trying to dynamically create mappings for all types in an  
index. Is there a way to do this via the /config/mapping/\_default/  
\*.json route or do I need to specifically define the type for each  
mapping? I dynamically create the types so I'll never really know  
every type that could be created.

Thanks a lot for everyone's effort on this project. A special shout-  
out to Shay.

Thanks,  
Bryan

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [May 23, 2011, 1:20am UTC](https://discuss.elastic.co/t/-id-and-mappings/4455/2 "2011-05-23T01:20:37Z")

</div>

The \_id definition should exists on the same level as the top level properties. Its type is always string btw. Can I ask why do you need it analyzed? What are you missing? Also, 99% chance that you don't really need it to be stored as well (you get it back on all operations without it being stored).

Yes, you can place all mappings in config/mapping/\_default/\*.json. I personally like the index template option that does not really require you to mess with local configuration of each node.

-shay.banon  
On Monday, May 23, 2011 at 4:09 AM, Bryan Green wrote:

> Hi,
> 
> I'd like to index the '\_id' field for all types across all indexes.  
> How do I do this? I have a clean index from 0.16.1.
> 
> Can I place this in the default-mapping.json file:?  
> {  
> "_default_" : {  
> "properties" : {  
> "\_id": {  
> "type":"long",  
> "index": "not\_analyzed",  
> "store": "yes"  
> }  
> }  
> }  
> }
> 
> It doesn't seem to work.
> 
> Also, I am trying to dynamically create mappings for all types in an  
> index. Is there a way to do this via the /config/mapping/\_default/  
> \*.json route or do I need to specifically define the type for each  
> mapping? I dynamically create the types so I'll never really know  
> every type that could be created.
> 
> Thanks a lot for everyone's effort on this project. A special shout-  
> out to Shay.
> 
> Thanks,  
> Bryan

---

<div class="post-metadata">

**Author:** ![Bryan\_Green](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bryan_green/32/3028_2.png) [@Bryan\_Green](https://discuss.elastic.co/u/Bryan_Green)\
**Post date:** [May 23, 2011, 2:18am UTC](https://discuss.elastic.co/t/-id-and-mappings/4455/3 "2011-05-23T02:18:12Z")

</div>

Am I incorrect in thinking that this should return an item that has an  
\_id of 40716 in the 'serc' index?

curl -XGET [http://localhost:9200/serc/\_search?pretty=true](http://localhost:9200/serc/_search?pretty=true) -d '{"query":  
{"term":{"\_id":40716}}}'

Do I just need to set this field's index property to 'not\_analyzed'?  
What are the benefits of storing the \_id field?

Would an index template apply to future indexes that are created or  
only to existing indexes when the command is issued?

I need the \_id because some external records point to unique documents  
and link various processes & states to the document(item). I don't  
want to use \_uid because I'd like to set the id dynamically although  
it's just sequential...

I appreciate your quick response.

On May 22, 8:20 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> The \_id definition should exists on the same level as the top level properties. Its type is always string btw. Can I ask why do you need it analyzed? What are you missing? Also, 99% chance that you don't really need it to be stored as well (you get it back on all operations without it being stored).
> 
> Yes, you can place all mappings in config/mapping/\_default/\*.json. I personally like the index template option that does not really require you to mess with local configuration of each node.
> 
> -shay.banon
> 
> On Monday, May 23, 2011 at 4:09 AM, Bryan Green wrote:
> 
> > Hi,
> 
> > I'd like to index the '\_id' field for all types across all indexes.  
> > How do I do this? I have a clean index from 0.16.1.
> 
> > Can I place this in the default-mapping.json file:?  
> > {  
> > "_default_" : {  
> > "properties" : {  
> > "\_id": {  
> > "type":"long",  
> > "index": "not\_analyzed",  
> > "store": "yes"  
> > }  
> > }  
> > }  
> > }
> 
> > It doesn't seem to work.
> 
> > Also, I am trying to dynamically create mappings for all types in an  
> > index. Is there a way to do this via the /config/mapping/\_default/  
> > \*.json route or do I need to specifically define the type for each  
> > mapping? I dynamically create the types so I'll never really know  
> > every type that could be created.
> 
> > Thanks a lot for everyone's effort on this project. A special shout-  
> > out to Shay.
> 
> > Thanks,  
> > Bryan

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [May 23, 2011, 2:20am UTC](https://discuss.elastic.co/t/-id-and-mappings/4455/4 "2011-05-23T02:20:36Z")

</div>

On Monday, May 23, 2011 at 5:18 AM, Bryan Green wrote:  
Am I incorrect in thinking that this should return an item that has an

> \_id of 40716 in the 'serc' index?
> 
> curl -XGET [http://localhost:9200/serc/\_search?pretty=true](http://localhost:9200/serc/_search?pretty=true) -d '{"query":  
> {"term":{"\_id":40716}}}'  
> This will not work if \_id is not indexed. But, you can use the ids filter / ids query which do not require the \_id to be indexed (use the internal \_uid and are actually faster).
> 
> Do I just need to set this field's index property to 'not\_analyzed'?  
> You don't really need to if you use the ids filter / query.  
> What are the benefits of storing the \_id field?  
> Donno, you wanted to do it :). You get the \_id back for all operations without storing it.
> 
> Would an index template apply to future indexes that are created or  
> only to existing indexes when the command is issued?  
> Only on future ones.
> 
> I need the \_id because some external records point to unique documents  
> and link various processes & states to the document(item). I don't  
> want to use \_uid because I'd like to set the id dynamically although  
> it's just sequential...
> 
> I appreciate your quick response.
> 
> On May 22, 8:20 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> 
> > The \_id definition should exists on the same level as the top level properties. Its type is always string btw. Can I ask why do you need it analyzed? What are you missing? Also, 99% chance that you don't really need it to be stored as well (you get it back on all operations without it being stored).
> > 
> > Yes, you can place all mappings in config/mapping/\_default/\*.json. I personally like the index template option that does not really require you to mess with local configuration of each node.
> > 
> > -shay.banon
> > 
> > On Monday, May 23, 2011 at 4:09 AM, Bryan Green wrote:
> > 
> > > Hi,
> > 
> > > I'd like to index the '\_id' field for all types across all indexes.  
> > > How do I do this? I have a clean index from 0.16.1.
> > 
> > > Can I place this in the default-mapping.json file:?  
> > > {  
> > > "_default_" : {  
> > > "properties" : {  
> > > "\_id": {  
> > > "type":"long",  
> > > "index": "not\_analyzed",  
> > > "store": "yes"  
> > > }  
> > > }  
> > > }  
> > > }
> > 
> > > It doesn't seem to work.
> > 
> > > Also, I am trying to dynamically create mappings for all types in an  
> > > index. Is there a way to do this via the /config/mapping/\_default/  
> > > \*.json route or do I need to specifically define the type for each  
> > > mapping? I dynamically create the types so I'll never really know  
> > > every type that could be created.
> > 
> > > Thanks a lot for everyone's effort on this project. A special shout-  
> > > out to Shay.
> > 
> > > Thanks,  
> > > Bryan

---

<div class="post-metadata">

**Author:** ![Bryan\_Green](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bryan_green/32/3028_2.png) [@Bryan\_Green](https://discuss.elastic.co/u/Bryan_Green)\
**Post date:** [May 23, 2011, 11:04am UTC](https://discuss.elastic.co/t/-id-and-mappings/4455/5 "2011-05-23T11:04:20Z")

</div>

Hi,

I tried using the 'ids' query/filter but it seems to require a type  
which I don't always know when trying to pull data back via the '\_id'.  
Is there anyway around this? Define all types?

If I simply want to have the \_id accessible to the filter and queries  
what is the right way to map it? just map "index":"not\_analyzed" for  
'\_id'?

I tried using an index template as well but this seems to require that  
you define the type within the json. Is there anyway to affect all  
types using an index template? I tried a few things here as well but  
no luck.

Thank you,  
Bryan

On May 22, 9:20 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> On Monday, May 23, 2011 at 5:18 AM, Bryan Green wrote:
> 
> Am I incorrect in thinking that this should return an item that has an\> \_id of 40716 in the 'serc' index?
> 
> > curl -XGEThttp://localhost:9200/serc/\_search?pretty=true-d '{"query":  
> > {"term":{"\_id":40716}}}'
> 
> This will not work if \_id is not indexed. But, you can use the ids filter / ids query which do not require the \_id to be indexed (use the internal \_uid and are actually faster).
> 
> > Do I just need to set this field's index property to 'not\_analyzed'?
> 
> You don't really need to if you use the ids filter / query.\> What are the benefits of storing the \_id field?
> 
> Donno, you wanted to do it :). You get the \_id back for all operations without storing it.
> 
> > Would an index template apply to future indexes that are created or  
> > only to existing indexes when the command is issued?
> 
> Only on future ones.
> 
> > I need the \_id because some external records point to unique documents  
> > and link various processes & states to the document(item). I don't  
> > want to use \_uid because I'd like to set the id dynamically although  
> > it's just sequential...
> 
> > I appreciate your quick response.
> 
> > On May 22, 8:20 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> > 
> > > The \_id definition should exists on the same level as the top level properties. Its type is always string btw. Can I ask why do you need it analyzed? What are you missing? Also, 99% chance that you don't really need it to be stored as well (you get it back on all operations without it being stored).
> 
> > > Yes, you can place all mappings in config/mapping/\_default/\*.json. I personally like the index template option that does not really require you to mess with local configuration of each node.
> 
> > > -shay.banon
> 
> > > On Monday, May 23, 2011 at 4:09 AM, Bryan Green wrote:
> > > 
> > > > Hi,
> 
> > > > I'd like to index the '\_id' field for all types across all indexes.  
> > > > How do I do this? I have a clean index from 0.16.1.
> 
> > > > Can I place this in the default-mapping.json file:?  
> > > > {  
> > > > "_default_" : {  
> > > > "properties" : {  
> > > > "\_id": {  
> > > > "type":"long",  
> > > > "index": "not\_analyzed",  
> > > > "store": "yes"  
> > > > }  
> > > > }  
> > > > }  
> > > > }
> 
> > > > It doesn't seem to work.
> 
> > > > Also, I am trying to dynamically create mappings for all types in an  
> > > > index. Is there a way to do this via the /config/mapping/\_default/  
> > > > \*.json route or do I need to specifically define the type for each  
> > > > mapping? I dynamically create the types so I'll never really know  
> > > > every type that could be created.
> 
> > > > Thanks a lot for everyone's effort on this project. A special shout-  
> > > > out to Shay.
> 
> > > > Thanks,  
> > > > Bryan

---

<div class="post-metadata">

**Author:** ![Bryan\_Green](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bryan_green/32/3028_2.png) [@Bryan\_Green](https://discuss.elastic.co/u/Bryan_Green)\
**Post date:** [May 23, 2011, 11:18am UTC](https://discuss.elastic.co/t/-id-and-mappings/4455/6 "2011-05-23T11:18:19Z")

</div>

Well, with luck I think I answered most of my last question.

This is how I get the template to work:  
$ curl -XPUT localhost:9200/\_template/template\_1 -d '  
{  
"template": "\*",  
"mappings": {  
"{type}": {  
"\_id": {  
"type": "string",  
"index": "not\_analyzed"  
}  
}  
}  
}  
'

The document will now be returned searching on the '\_id' term. And in  
only 2ms!

I guess I don't understand why the index param is set to  
"not\_analyzed." I don't understand the English behind this. Why is it  
not being analyzed and now available?

What an _awesome_ system!  
-Bryan

On May 23, 6:04 am, Bryan Green [bryogr...@gmail.com](mailto:bryogr...@gmail.com) wrote:

> Hi,
> 
> I tried using the 'ids' query/filter but it seems to require a type  
> which I don't always know when trying to pull data back via the '\_id'.  
> Is there anyway around this? Define all types?
> 
> If I simply want to have the \_id accessible to the filter and queries  
> what is the right way to map it? just map "index":"not\_analyzed" for  
> '\_id'?
> 
> I tried using an index template as well but this seems to require that  
> you define the type within the json. Is there anyway to affect all  
> types using an index template? I tried a few things here as well but  
> no luck.
> 
> Thank you,  
> Bryan
> 
> On May 22, 9:20 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> 
> > On Monday, May 23, 2011 at 5:18 AM, Bryan Green wrote:
> 
> > Am I incorrect in thinking that this should return an item that has an\> \_id of 40716 in the 'serc' index?
> 
> > > curl -XGEThttp://localhost:9200/serc/\_search?pretty=true-d'{"query":  
> > > {"term":{"\_id":40716}}}'
> 
> > This will not work if \_id is not indexed. But, you can use the ids filter / ids query which do not require the \_id to be indexed (use the internal \_uid and are actually faster).
> 
> > > Do I just need to set this field's index property to 'not\_analyzed'?
> 
> > You don't really need to if you use the ids filter / query.\> What are the benefits of storing the \_id field?
> 
> > Donno, you wanted to do it :). You get the \_id back for all operations without storing it.
> 
> > > Would an index template apply to future indexes that are created or  
> > > only to existing indexes when the command is issued?
> 
> > Only on future ones.
> 
> > > I need the \_id because some external records point to unique documents  
> > > and link various processes & states to the document(item). I don't  
> > > want to use \_uid because I'd like to set the id dynamically although  
> > > it's just sequential...
> 
> > > I appreciate your quick response.
> 
> > > On May 22, 8:20 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> > > 
> > > > The \_id definition should exists on the same level as the top level properties. Its type is always string btw. Can I ask why do you need it analyzed? What are you missing? Also, 99% chance that you don't really need it to be stored as well (you get it back on all operations without it being stored).
> 
> > > > Yes, you can place all mappings in config/mapping/\_default/\*.json. I personally like the index template option that does not really require you to mess with local configuration of each node.
> 
> > > > -shay.banon
> 
> > > > On Monday, May 23, 2011 at 4:09 AM, Bryan Green wrote:
> > > > 
> > > > > Hi,
> 
> > > > > I'd like to index the '\_id' field for all types across all indexes.  
> > > > > How do I do this? I have a clean index from 0.16.1.
> 
> > > > > Can I place this in the default-mapping.json file:?  
> > > > > {  
> > > > > "_default_" : {  
> > > > > "properties" : {  
> > > > > "\_id": {  
> > > > > "type":"long",  
> > > > > "index": "not\_analyzed",  
> > > > > "store": "yes"  
> > > > > }  
> > > > > }  
> > > > > }  
> > > > > }
> 
> > > > > It doesn't seem to work.
> 
> > > > > Also, I am trying to dynamically create mappings for all types in an  
> > > > > index. Is there a way to do this via the /config/mapping/\_default/  
> > > > > \*.json route or do I need to specifically define the type for each  
> > > > > mapping? I dynamically create the types so I'll never really know  
> > > > > every type that could be created.
> 
> > > > > Thanks a lot for everyone's effort on this project. A special shout-  
> > > > > out to Shay.
> 
> > > > > Thanks,  
> > > > > Bryan

---

<div class="post-metadata">

**Author:** ![Bryan\_Green](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bryan_green/32/3028_2.png) [@Bryan\_Green](https://discuss.elastic.co/u/Bryan_Green)\
**Post date:** [May 23, 2011, 1:36pm UTC](https://discuss.elastic.co/t/-id-and-mappings/4455/7 "2011-05-23T13:36:03Z")

</div>

To correct my last post, this is how I got it to work on all types:

--default-mapping.json--  
{  
"_default_":{  
"\_id": {  
"type": "string",  
"index": "not\_analyzed"  
}  
}  
}

I couldn't actually get the templates to work dynamically with  
multiple types.

Back to work 🙂  
-Bryan

On May 23, 6:18 am, Bryan Green [bryogr...@gmail.com](mailto:bryogr...@gmail.com) wrote:

> Well, with luck I think I answered most of my last question.
> 
> This is how I get the template to work:  
> $ curl -XPUT localhost:9200/\_template/template\_1 -d '  
> {  
> "template": "\*",  
> "mappings": {  
> "{type}": {  
> "\_id": {  
> "type": "string",  
> "index": "not\_analyzed"  
> }  
> }  
> }}
> 
> '
> 
> The document will now be returned searching on the '\_id' term. And in  
> only 2ms!
> 
> I guess I don't understand why the index param is set to  
> "not\_analyzed." I don't understand the English behind this. Why is it  
> not being analyzed and now available?
> 
> What an _awesome_ system!  
> -Bryan
> 
> On May 23, 6:04 am, Bryan Green [bryogr...@gmail.com](mailto:bryogr...@gmail.com) wrote:
> 
> > Hi,
> 
> > I tried using the 'ids' query/filter but it seems to require a type  
> > which I don't always know when trying to pull data back via the '\_id'.  
> > Is there anyway around this? Define all types?
> 
> > If I simply want to have the \_id accessible to the filter and queries  
> > what is the right way to map it? just map "index":"not\_analyzed" for  
> > '\_id'?
> 
> > I tried using an index template as well but this seems to require that  
> > you define the type within the json. Is there anyway to affect all  
> > types using an index template? I tried a few things here as well but  
> > no luck.
> 
> > Thank you,  
> > Bryan
> 
> > On May 22, 9:20 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> 
> > > On Monday, May 23, 2011 at 5:18 AM, Bryan Green wrote:
> 
> > > Am I incorrect in thinking that this should return an item that has an\> \_id of 40716 in the 'serc' index?
> 
> > > > curl -XGEThttp://localhost:9200/serc/\_search?pretty=true-d'{"query":  
> > > > {"term":{"\_id":40716}}}'
> 
> > > This will not work if \_id is not indexed. But, you can use the ids filter / ids query which do not require the \_id to be indexed (use the internal \_uid and are actually faster).
> 
> > > > Do I just need to set this field's index property to 'not\_analyzed'?
> 
> > > You don't really need to if you use the ids filter / query.\> What are the benefits of storing the \_id field?
> 
> > > Donno, you wanted to do it :). You get the \_id back for all operations without storing it.
> 
> > > > Would an index template apply to future indexes that are created or  
> > > > only to existing indexes when the command is issued?
> 
> > > Only on future ones.
> 
> > > > I need the \_id because some external records point to unique documents  
> > > > and link various processes & states to the document(item). I don't  
> > > > want to use \_uid because I'd like to set the id dynamically although  
> > > > it's just sequential...
> 
> > > > I appreciate your quick response.
> 
> > > > On May 22, 8:20 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> > > > 
> > > > > The \_id definition should exists on the same level as the top level properties. Its type is always string btw. Can I ask why do you need it analyzed? What are you missing? Also, 99% chance that you don't really need it to be stored as well (you get it back on all operations without it being stored).
> 
> > > > > Yes, you can place all mappings in config/mapping/\_default/\*.json. I personally like the index template option that does not really require you to mess with local configuration of each node.
> 
> > > > > -shay.banon
> 
> > > > > On Monday, May 23, 2011 at 4:09 AM, Bryan Green wrote:
> > > > > 
> > > > > > Hi,
> 
> > > > > > I'd like to index the '\_id' field for all types across all indexes.  
> > > > > > How do I do this? I have a clean index from 0.16.1.
> 
> > > > > > Can I place this in the default-mapping.json file:?  
> > > > > > {  
> > > > > > "_default_" : {  
> > > > > > "properties" : {  
> > > > > > "\_id": {  
> > > > > > "type":"long",  
> > > > > > "index": "not\_analyzed",  
> > > > > > "store": "yes"  
> > > > > > }  
> > > > > > }  
> > > > > > }  
> > > > > > }
> 
> > > > > > It doesn't seem to work.
> 
> > > > > > Also, I am trying to dynamically create mappings for all types in an  
> > > > > > index. Is there a way to do this via the /config/mapping/\_default/  
> > > > > > \*.json route or do I need to specifically define the type for each  
> > > > > > mapping? I dynamically create the types so I'll never really know  
> > > > > > every type that could be created.
> 
> > > > > > Thanks a lot for everyone's effort on this project. A special shout-  
> > > > > > out to Shay.
> 
> > > > > > Thanks,  
> > > > > > Bryan

---

<div class="post-metadata">

**Author:** ![dpilato](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dpilato/32/2449_2.png) [@dpilato](https://discuss.elastic.co/u/dpilato)\
**Post date:** [May 23, 2011, 2:38pm UTC](https://discuss.elastic.co/t/-id-and-mappings/4455/8 "2011-05-23T14:38:40Z")

</div>

Hi,

Just a question about that :  
  
Yes, you can place all mappings in config/mapping/\_default/\*.json. I personally like the index template option that does not really require you to mess with local configuration of each node.

You talk about config/mapping dir but in [documentation](http://www.elasticsearch.org/guide/reference/mapping/conf-mappings.html), it's supposed to be in :

config/mappings/\_default or config/mappings/[index\_name]

There is a s at mapping...

So what is the right name ?

I'm trying to define a mapping for my index but it doesn't work for me...  
I can only define a mapping using curl -XPUT ...

So I'm wondering if :

- defining mapping in config files really works ? I tried it on 0.15.2 and 0.16.1.
- documentation is correct ?
- my own mapping file is correct or not

Thanks for any help.  
Cheers

---

<div class="post-metadata">

**Author:** ![ofavre](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ofavre/32/116819_2.png) [@ofavre](https://discuss.elastic.co/u/ofavre)\
**Post date:** [May 23, 2011, 3:14pm UTC](https://discuss.elastic.co/t/-id-and-mappings/4455/9 "2011-05-23T15:14:19Z")

</div>

My configuration is as follows:

- config
  - elasticsearch.yml
  - mappings
    - indexName
      - typeName.json

I tell nothing peculiar inside elasticsearch.yml. (You can change settings  
of the default file name/path for the default mapping, but I don't use it).

My typeName.json looks as follows (trimmed down):

{  
"typeName" : {  
"\_source" : {"enabled":false},  
"dynamic" : "strict",  
"properties" : {  
"text" : {"type":"string", "index":"analyzed", "store":true,  
"include\_in\_all":false, "analyzer":"simple"}  
}  
}  
}

Hope that helps.

## Cheers

Olivier Favre

[www.yakaz.com](http://www.yakaz.com)

2011/5/23 dpilato [via Elasticsearch Users] \<  
[ml-node+2975551-361198208-393975@n3.nabble.com](mailto:ml-node+2975551-361198208-393975@n3.nabble.com)\>

> Hi,
> 
> Just a question about that :
> 
> kimchy wrote:  
> Yes, you can place all mappings in config/mapping/\_default/\*.json. I  
> personally like the index template option that does not really require you  
> to mess with local configuration of each node.
> 
> You talk about config/mapping dir but in documentation[http://www.elasticsearch.org/guide/reference/mapping/conf-mappings.html](http://www.elasticsearch.org/guide/reference/mapping/conf-mappings.html),  
> it's supposed to be in :
> 
> config/mappings/\_default or config/mappings/[index\_name]
> 
> There is a s at mapping...
> 
> So what is the right name ?
> 
> I'm trying to define a mapping for my index but it doesn't work for me...  
> I can only define a mapping using curl -XPUT ...
> 
> So I'm wondering if :
> 
> - defining mapping in config files really works ? I tried it on 0.15.2 and  
> 0.16.1.
> - documentation is correct ?
> - my own mapping file is correct or not
> 
> Thanks for any help.  
> Cheers
> 
> * * *
> 
> If you reply to this email, your message will be added to the discussion  
> below:
> 
> [http://elasticsearch-users.115913.n3.nabble.com/id-and-mappings-tp2973448p2975551.html](http://elasticsearch-users.115913.n3.nabble.com/id-and-mappings-tp2973448p2975551.html)  
> To start a new topic under Elasticsearch Users, email  
> [ml-node+115913-1699315842-393975@n3.nabble.com](mailto:ml-node+115913-1699315842-393975@n3.nabble.com)  
> To unsubscribe from Elasticsearch Users, click here[http://elasticsearch-users.115913.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe\_by\_code&node=115913&code=b2xpdmllckB5YWthei5jb218MTE1OTEzfDIxMjI2MTYwOTc=](http://elasticsearch-users.115913.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=115913&code=b2xpdmllckB5YWthei5jb218MTE1OTEzfDIxMjI2MTYwOTc=).

---

<div class="post-metadata">

**Author:** ![Bryan\_Green](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bryan_green/32/3028_2.png) [@Bryan\_Green](https://discuss.elastic.co/u/Bryan_Green)\
**Post date:** [May 23, 2011, 3:51pm UTC](https://discuss.elastic.co/t/-id-and-mappings/4455/10 "2011-05-23T15:51:09Z")

</div>

I'm guessing the documentation is correct. I indeed did have my  
mappings in the "mappings" folder.

So far, I've had my best success using the /config/default-  
mapping.json file.

What does "dynamic" : "strict" do?

On May 23, 10:14 am, ofavre [oliv...@yakaz.com](mailto:oliv...@yakaz.com) wrote:

> My configuration is as follows:
> 
> - config
> - elasticsearch.yml
> - mappings
> - indexName
> - typeName.json
> 
> I tell nothing peculiar inside elasticsearch.yml. (You can change settings  
> of the default file name/path for the default mapping, but I don't use it).
> 
> My typeName.json looks as follows (trimmed down):
> 
> {  
> "typeName" : {  
> "\_source" : {"enabled":false},  
> "dynamic" : "strict",  
> "properties" : {  
> "text" : {"type":"string", "index":"analyzed", "store":true,  
> "include\_in\_all":false, "analyzer":"simple"}  
> }  
> }
> 
> }
> 
> Hope that helps.
> 
> ## Cheers
> 
> Olivier Favre
> 
> [www.yakaz.com](http://www.yakaz.com)
> 
> 2011/5/23 dpilato [via Elasticsearch Users] \<  
> [ml-node+2975551-361198208-393...@n3.nabble.com](mailto:ml-node+2975551-361198208-393...@n3.nabble.com)\>
> 
> > Hi,
> 
> > Just a question about that :
> 
> > kimchy wrote:  
> > Yes, you can place all mappings in config/mapping/\_default/\*.json. I  
> > personally like the index template option that does not really require you  
> > to mess with local configuration of each node.
> 
> > You talk about config/mapping dir but in documentation[http://www.elasticsearch.org/guide/reference/mapping/conf-mappings.html](http://www.elasticsearch.org/guide/reference/mapping/conf-mappings.html),  
> > it's supposed to be in :
> 
> > config/mappings/\_default or config/mappings/[index\_name]
> 
> > There is a s at mapping...
> 
> > So what is the right name ?
> 
> > I'm trying to define a mapping for my index but it doesn't work for me...  
> > I can only define a mapping using curl -XPUT ...
> 
> > So I'm wondering if :
> > 
> > - defining mapping in config files really works ? I tried it on 0.15.2 and  
> > 0.16.1.
> > - documentation is correct ?
> > - my own mapping file is correct or not
> 
> > Thanks for any help.  
> > Cheers
> 
> > * * *
> > 
> > If you reply to this email, your message will be added to the discussion  
> > below:
> 
> > [http://elasticsearch-users.115913.n3.nabble.com/id-and-mappings-tp297](http://elasticsearch-users.115913.n3.nabble.com/id-and-mappings-tp297)...  
> > To start a new topic under Elasticsearch Users, email  
> > [ml-node+115913-1699315842-393...@n3.nabble.com](mailto:ml-node+115913-1699315842-393...@n3.nabble.com)  
> > To unsubscribe from Elasticsearch Users, click here[http://elasticsearch-users.115913.n3.nabble.com/template/NamlServlet....](http://elasticsearch-users.115913.n3.nabble.com/template/NamlServlet....).
> 
> --  
> View this message in context:[http://elasticsearch-users.115913.n3.nabble.com/id-and-mappings-tp297](http://elasticsearch-users.115913.n3.nabble.com/id-and-mappings-tp297)...  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![Barsk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/barsk/32/13734_2.png) [@Barsk](https://discuss.elastic.co/u/Barsk)\
**Post date:** [May 24, 2011, 7:03am UTC](https://discuss.elastic.co/t/-id-and-mappings/4455/11 "2011-05-24T07:03:25Z")

</div>

Shay Banon skrev 2011-05-23 04:20:

> > What are the benefits of storing the \_id field?  
> > Donno, you wanted to do it :). You get the \_id back for all  
> > operations without storing it.

Can I sort on \_id without having it indexed?

/Kristian

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [May 24, 2011, 10:06am UTC](https://discuss.elastic.co/t/-id-and-mappings/4455/12 "2011-05-24T10:06:11Z")

</div>

No.  
On Tuesday, May 24, 2011 at 10:03 AM, Kristian JÃ¶rg wrote:

> Shay Banon skrev 2011-05-23 04:20:
> 
> > > What are the benefits of storing the \_id field?  
> > > Donno, you wanted to do it :). You get the \_id back for all  
> > > operations without storing it.
> 
> Can I sort on \_id without having it indexed?
> 
> /Kristian

---

<div class="post-metadata">

**Author:** ![ofavre](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ofavre/32/116819_2.png) [@ofavre](https://discuss.elastic.co/u/ofavre)\
**Post date:** [May 24, 2011, 10:30am UTC](https://discuss.elastic.co/t/-id-and-mappings/4455/13 "2011-05-24T10:30:57Z")

</div>

Bryan Green,

Quote from  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/object-type.html) in the  
_dynamic_ section (between _properties_ and _enabled_):

The dynamic parameter can also be set to strict, meaning that not only new  
fields will not be introduced into the mapping, parsing (indexing) docs with  
such new fields will fail.

Somehow I preferred using dynamic=strict rather than dynamic=false because  
ES did not seem to react to false as it should have (ie: ignore the  
malformed document), but I was beginning with the technology.  
Using strict ensures it will fail indexing it and the malformed document  
won't be stored/indexed/anything.  
\*  
\*  
_Shay: Maybe tests should be done, this might be a bug, now I think about  
it..._

--  
Olivier Favre

[www.yakaz.com](http://www.yakaz.com)

2011/5/23 Bryan Green [bryogreen@gmail.com](mailto:bryogreen@gmail.com)

> I'm guessing the documentation is correct. I indeed did have my  
> mappings in the "mappings" folder.
> 
> So far, I've had my best success using the /config/default-  
> mapping.json file.
> 
> What does "dynamic" : "strict" do?
> 
> On May 23, 10:14 am, ofavre [oliv...@yakaz.com](mailto:oliv...@yakaz.com) wrote:
> 
> > My configuration is as follows:
> > 
> > - config
> > - elasticsearch.yml
> > - mappings
> > - indexName
> > - typeName.json
> > 
> > I tell nothing peculiar inside elasticsearch.yml. (You can change  
> > settings  
> > of the default file name/path for the default mapping, but I don't use  
> > it).
> > 
> > My typeName.json looks as follows (trimmed down):
> > 
> > {  
> > "typeName" : {  
> > "\_source" : {"enabled":false},  
> > "dynamic" : "strict",  
> > "properties" : {  
> > "text" : {"type":"string", "index":"analyzed", "store":true,  
> > "include\_in\_all":false, "analyzer":"simple"}  
> > }  
> > }
> > 
> > }
> > 
> > Hope that helps.
> > 
> > ## Cheers
> > 
> > Olivier Favre
> > 
> > [www.yakaz.com](http://www.yakaz.com)
> > 
> > 2011/5/23 dpilato [via Elasticsearch Users] \<  
> > [ml-node+2975551-361198208-393...@n3.nabble.com](mailto:ml-node+2975551-361198208-393...@n3.nabble.com)\>
> > 
> > > Hi,
> > 
> > > Just a question about that :
> > 
> > > kimchy wrote:  
> > > Yes, you can place all mappings in config/mapping/\_default/\*.json. I  
> > > personally like the index template option that does not really require  
> > > you  
> > > to mess with local configuration of each node.
> > 
> > > You talk about config/mapping dir but in documentation\<  
> > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/conf-mappings.html)\>,  
> > > it's supposed to be in :
> > 
> > > config/mappings/\_default or config/mappings/[index\_name]
> > 
> > > There is a s at mapping...
> > 
> > > So what is the right name ?
> > 
> > > I'm trying to define a mapping for my index but it doesn't work for  
> > > me...  
> > > I can only define a mapping using curl -XPUT ...
> > 
> > > So I'm wondering if :
> > > 
> > > - defining mapping in config files really works ? I tried it on 0.15.2  
> > > and  
> > > 0.16.1.
> > > - documentation is correct ?
> > > - my own mapping file is correct or not
> > 
> > > Thanks for any help.  
> > > Cheers
> > 
> > > * * *
> > > 
> > > If you reply to this email, your message will be added to the  
> > > discussion  
> > > below:
> > 
> > > [http://elasticsearch-users.115913.n3.nabble.com/id-and-mappings-tp297](http://elasticsearch-users.115913.n3.nabble.com/id-and-mappings-tp297).  
> > > ..  
> > > To start a new topic under Elasticsearch Users, email  
> > > [ml-node+115913-1699315842-393...@n3.nabble.com](mailto:ml-node+115913-1699315842-393...@n3.nabble.com)  
> > > To unsubscribe from Elasticsearch Users, click here\<  
> > > [http://elasticsearch-users.115913.n3.nabble.com/template/NamlServlet](http://elasticsearch-users.115913.n3.nabble.com/template/NamlServlet)....\>.
> > 
> > --  
> > View this message in context:  
> > [http://elasticsearch-users.115913.n3.nabble.com/id-and-mappings-tp297](http://elasticsearch-users.115913.n3.nabble.com/id-and-mappings-tp297)...  
> > Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [May 24, 2011, 10:46am UTC](https://discuss.elastic.co/t/-id-and-mappings/4455/14 "2011-05-24T10:46:52Z")

</div>

What is the bug? If you set dynamic to false, it means that new fields will simply be ignored, but indexing of the doc will not fail.  
On Tuesday, May 24, 2011 at 1:30 PM, Olivier Favre wrote:

> Bryan Green,
> 
> Quote from [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/object-type.html) in the dynamic section (between properties and enabled):
> 
> > The dynamic parameter can also be set to strict, meaning that not only new fields will not be introduced into the mapping, parsing (indexing) docs with such new fields will fail.
> 
> Somehow I preferred using dynamic=strict rather than dynamic=false because ES did not seem to react to false as it should have (ie: ignore the malformed document), but I was beginning with the technology.  
> Using strict ensures it will fail indexing it and the malformed document won't be stored/indexed/anything.
> 
> Shay: Maybe tests should be done, this might be a bug, now I think about it...
> 
> --  
> Olivier Favre
> 
> [www.yakaz.com](http://www.yakaz.com)
> 
> 2011/5/23 Bryan Green [bryogreen@gmail.com](mailto:bryogreen@gmail.com)
> 
> > I'm guessing the documentation is correct. I indeed did have my  
> > mappings in the "mappings" folder.
> > 
> > So far, I've had my best success using the /config/default-  
> > mapping.json file.
> > 
> > What does "dynamic" : "strict" do?
> > 
> > On May 23, 10:14 am, ofavre [oliv...@yakaz.com](mailto:oliv...@yakaz.com) wrote:
> > 
> > > My configuration is as follows:
> > > 
> > > - config
> > > - elasticsearch.yml
> > > - mappings
> > > - indexName
> > > - typeName.json
> > > 
> > > I tell nothing peculiar inside elasticsearch.yml. (You can change settings  
> > > of the default file name/path for the default mapping, but I don't use it).
> > > 
> > > My typeName.json looks as follows (trimmed down):
> > > 
> > > {  
> > > "typeName" : {  
> > > "\_source" : {"enabled":false},  
> > > "dynamic" : "strict",  
> > > "properties" : {  
> > > "text" : {"type":"string", "index":"analyzed", "store":true,  
> > > "include\_in\_all":false, "analyzer":"simple"}  
> > > }  
> > > }
> > > 
> > > }
> > > 
> > > Hope that helps.
> > > 
> > > ## Cheers
> > > 
> > > Olivier Favre
> > > 
> > > [www.yakaz.com](http://www.yakaz.com)
> > > 
> > > 2011/5/23 dpilato [via Elasticsearch Users] \<  
> > > [ml-node+2975551-361198208-393...@n3.nabble.com](mailto:ml-node+2975551-361198208-393...@n3.nabble.com)\>
> > > 
> > > > Hi,
> > > 
> > > > Just a question about that :
> > > 
> > > > kimchy wrote:  
> > > > Yes, you can place all mappings in config/mapping/\_default/\*.json. I  
> > > > personally like the index template option that does not really require you  
> > > > to mess with local configuration of each node.
> > > 
> > > > You talk about config/mapping dir but in documentation[http://www.elasticsearch.org/guide/reference/mapping/conf-mappings.html](http://www.elasticsearch.org/guide/reference/mapping/conf-mappings.html),  
> > > > it's supposed to be in :
> > > 
> > > > config/mappings/\_default or config/mappings/[index\_name]
> > > 
> > > > There is a s at mapping...
> > > 
> > > > So what is the right name ?
> > > 
> > > > I'm trying to define a mapping for my index but it doesn't work for me...  
> > > > I can only define a mapping using curl -XPUT ...
> > > 
> > > > So I'm wondering if :
> > > > 
> > > > - defining mapping in config files really works ? I tried it on 0.15.2 and  
> > > > 0.16.1.
> > > > - documentation is correct ?
> > > > - my own mapping file is correct or not
> > > 
> > > > Thanks for any help.  
> > > > Cheers
> > > 
> > > > * * *
> > > > 
> > > > If you reply to this email, your message will be added to the discussion  
> > > > below:
> > > 
> > > > [http://elasticsearch-users.115913.n3.nabble.com/id-and-mappings-tp297](http://elasticsearch-users.115913.n3.nabble.com/id-and-mappings-tp297)...  
> > > > To start a new topic under Elasticsearch Users, email  
> > > > [ml-node+115913-1699315842-393...@n3.nabble.com](mailto:ml-node+115913-1699315842-393...@n3.nabble.com)  
> > > > To unsubscribe from Elasticsearch Users, click here[http://elasticsearch-users.115913.n3.nabble.com/template/NamlServlet....](http://elasticsearch-users.115913.n3.nabble.com/template/NamlServlet....).
> > > 
> > > --  
> > > View this message in context:[http://elasticsearch-users.115913.n3.nabble.com/id-and-mappings-tp297](http://elasticsearch-users.115913.n3.nabble.com/id-and-mappings-tp297)...  
> > > Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![dpilato](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dpilato/32/2449_2.png) [@dpilato](https://discuss.elastic.co/u/dpilato)\
**Post date:** [May 24, 2011, 3:37pm UTC](https://discuss.elastic.co/t/-id-and-mappings/4455/15 "2011-05-24T15:37:29Z")

</div>

Thanks Olivier,

With your help, I found what was wrong.

My use case was :

1. 

```
 Push one document to ES -> so dynamic mapping start

```

2. 

```
 Create json mapping file and put it in

```

mappings/indexName/typeName.json

1. 

```
 Get the json mapping

```

When I ask for the mapping,  
[http://localhost:9200/indexName/typeName/\_mapping](http://localhost:9200/indexName/typeName/_mapping) I get only the first one.

To make it working, I have to :

1. 

```
 Clean my ES cluster

```

2. 

```
 Create json mapping file and put it in

```

mappings/indexName/typeName.json

1. 

```
 Push one document to ES -> so mapping defined in config file is

```

applied

1. 

```
 Get the json mapping

```

So, as Shay told before (If I understood correctly), its really better to  
push the mapping through an http/Rest request than setting up all nodes

Perhaps, it could be useful for others to write in the  
[http://www.elasticsearch.org/guide/reference/mapping/conf-mappings.html](http://www.elasticsearch.org/guide/reference/mapping/conf-mappings.html)  
documentation, that its not a good practice to define mappings with config  
files

Thanks to all

David.

De : ofavre [[mailto:olivier@yakaz.com](mailto:olivier@yakaz.com)]  
Envoyé : lundi 23 mai 2011 17:15  
À : [users@elasticsearch.com](mailto:users@elasticsearch.com)  
Objet : Re: \_id and mappings

My configuration is as follows:

- config

- elasticsearch.yml

- mappings

- indexName

- typeName.json

I tell nothing peculiar inside elasticsearch.yml. (You can change settings  
of the default file name/path for the default mapping, but I don't use it).

My typeName.json looks as follows (trimmed down):

{

Â Â "typeName" : {

Â Â Â Â "\_source" : {"enabled":false},

Â Â Â Â "dynamic" : "strict",

Â Â Â Â "properties" : {

Â Â Â Â Â Â "text" : {"type":"string", "index":"analyzed",  
"store":true, "include\_in\_all":false, "analyzer":"simple"}

Â Â Â Â }

Â Â }

}

Hope that helps.

Cheers

--

Olivier Favre

[http://www.yakaz.com/img/logo\_yakaz\_small.png](http://www.yakaz.com/img/logo_yakaz_small.png)

[http://www.yakaz.com](http://www.yakaz.com) [www.yakaz.com](http://www.yakaz.com)

---

<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 6, 2017, 4:05am UTC](https://discuss.elastic.co/t/-id-and-mappings/4455/16 "2017-07-06T04:05:27Z")

</div>


