# Re: How to put mappings and still get dynamic mappings

**URL:** <https://discuss.elastic.co/t/re-how-to-put-mappings-and-still-get-dynamic-mappings/3658>\
**Category:** Elasticsearch\
**Created:** [December 14, 2010, 2:31am UTC](https://discuss.elastic.co/t/re-how-to-put-mappings-and-still-get-dynamic-mappings/3658 "2010-12-14T02:31:48Z")\
**Posts on this page:** 20\
**Page:** 1

<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:** [December 14, 2010, 2:31am UTC](https://discuss.elastic.co/t/re-how-to-put-mappings-and-still-get-dynamic-mappings/3658/1 "2010-12-14T02:31:48Z")

</div>

Setting the mapping in advance for those fields, and indexing will retain the dynamic nature for the rest of the document. Can you maybe gist your put mapping code, and how you detect the other fields are not being indexed?  
On Tuesday, December 14, 2010 at 12:40 AM, Pete Aykroyd wrote:

> Hi,
> 
> I think I'm probably missing something obvious but I can't figure how to set a few mappings manually on my schema and retain the automatic mappings.
> 
> The exact problem is that I've been using elastic for the past week or so completely with the dynamic schema mappings and everything was fine. But I now want to sometimes return a field with my query... So there are a few fields in the schema that I want to set stored to true on. For the rest of the fields, I want them to continue to get their mappings dynamically, since there are a lot of them and more may be added in the future.
> 
> If try to put a mapping for just that the field with data already indexed, obviously there is a merge conflict because it has already had indexed those fields with stored = false.  
> If I set ignore\_conflicts to true and then re-index my data, it doesn't seem to have any effect and checking the \_mapping shows that stored still isn't set.  
> I've tried blowing away the index completely, then setting a mapping with the two fields I care about being stored in it, and then re-indexing, but then nothing else is mapped.
> 
> What's the right way to do this?
> 
> Thanks,
> 
> Pete

---

<div class="post-metadata">

**Author:** ![medcl\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/medcl_2/32/3297_2.png) [@medcl\_2](https://discuss.elastic.co/u/medcl_2)\
**Post date:** [December 14, 2010, 9:39am UTC](https://discuss.elastic.co/t/re-how-to-put-mappings-and-still-get-dynamic-mappings/3658/2 "2010-12-14T09:39:14Z")

</div>

as i know,es now can direct use \_source's item as field's value,check  
it out,[Search Fields: If a field is not stored, automatically extract it from \_source (without the need for \_source prefix) · Issue #562 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/issue/562)

On 12月14日, 上午10时31分, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> Setting the mapping in advance for those fields, and indexing will retain the dynamic nature for the rest of the document. Can you maybe gist your put mapping code, and how you detect the other fields are not being indexed?
> 
> On Tuesday, December 14, 2010 at 12:40 AM, Pete Aykroyd wrote:
> 
> > Hi,
> 
> > I think I'm probably missing something obvious but I can't figure how to set a few mappings manually on my schema and retain the automatic mappings.
> 
> > The exact problem is that I've been using elastic for the past week or so completely with the dynamic schema mappings and everything was fine. But I now want to sometimes return a field with my query... So there are a few fields in the schema that I want to set stored to true on. For the rest of the fields, I want them to continue to get their mappings dynamically, since there are a lot of them and more may be added in the future.
> 
> > If try to put a mapping for just that the field with data already indexed, obviously there is a merge conflict because it has already had indexed those fields with stored = false.  
> > If I set ignore\_conflicts to true and then re-index my data, it doesn't seem to have any effect and checking the \_mapping shows that stored still isn't set.  
> > I've tried blowing away the index completely, then setting a mapping with the two fields I care about being stored in it, and then re-indexing, but then nothing else is mapped.
> 
> > What's the right way to do this?
> 
> > Thanks,
> 
> > Pete

---

<div class="post-metadata">

**Author:** ![Pete\_Aykroyd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pete_aykroyd/32/3293_2.png) [@Pete\_Aykroyd](https://discuss.elastic.co/u/Pete_Aykroyd)\
**Post date:** [December 14, 2010, 11:10pm UTC](https://discuss.elastic.co/t/re-how-to-put-mappings-and-still-get-dynamic-mappings/3658/3 "2010-12-14T23:10:50Z")

</div>

Hmm... I've definitely screwed something up then.

So I set the code mapping like:

curl -XPUT '[http://localhost:9200/blocks/block/\_mapping](http://localhost:9200/blocks/block/_mapping)' -d '  
{  
"block": {  
"properties": {  
"system": {  
"store": "yes",  
"type": "string"  
},  
"user": {  
"store": "yes",  
"type": "string"  
}

```
    }
}

```

}'

Start elastic and my server. And then reindex the users (starting with all  
the data deleted). I should say here just to confirm that when I index  
without having done this... everything works perfectly. I just can't tell it  
to store the fields I want it to. So I think that I'm indexing the data ok.  
So, after indexing, I run the mapping call and get this:

$ curl -XGET [http://localhost:9200/\_mapping](http://localhost:9200/_mapping) | pp  
% Total % Received % Xferd Average Speed Time Time Time  
Current  
Dload Upload Total Spent Left  
Speed  
128 128 128 128 0 0 22483 0 --:--:-- --:--:-- --:--:--  
32000  
{  
"blocks": {  
"block": {  
"properties": {  
"system": {  
"store": "yes",  
"type": "string"  
},  
"user": {  
"store": "yes",  
"type": "string"  
}  
}  
}  
},  
"users": {}  
}

Normally, after indexing these will be filled out with a bunch of  
properties. When I run a search, I get exceptions on the client side and the  
elastic logs have a number of exceptions along the lines of:

_Parse Failure [No mapping found for [created\_dt]]_

Thanks for your help,

Pete

On Mon, Dec 13, 2010 at 6:31 PM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)wrote:

> Setting the mapping in advance for those fields, and indexing will retain  
> the dynamic nature for the rest of the document. Can you maybe gist your put  
> mapping code, and how you detect the other fields are not being indexed?
> 
> On Tuesday, December 14, 2010 at 12:40 AM, Pete Aykroyd wrote:
> 
> Hi,
> 
> I think I'm probably missing something obvious but I can't figure how to  
> set a few mappings manually on my schema and retain the automatic mappings.
> 
> The exact problem is that I've been using elastic for the past week or so  
> completely with the dynamic schema mappings and everything was fine. But I  
> now want to sometimes return a field with my query... So there are a few  
> fields in the schema that I want to set stored to true on. For the rest of  
> the fields, I want them to continue to get their mappings dynamically, since  
> there are a lot of them and more may be added in the future.
> 
> If try to put a mapping for just that the field with data already indexed,  
> obviously there is a merge conflict because it has already had indexed those  
> fields with stored = false.  
> If I set ignore\_conflicts to true and then re-index my data, it doesn't  
> seem to have any effect and checking the \_mapping shows that stored still  
> isn't set.  
> I've tried blowing away the index completely, then setting a mapping with  
> the two fields I care about being stored in it, and then re-indexing, but  
> then nothing else is mapped.
> 
> What's the right way to do this?
> 
> Thanks,
> 
> Pete

---

<div class="post-metadata">

**Author:** ![Pete\_Aykroyd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pete_aykroyd/32/3293_2.png) [@Pete\_Aykroyd](https://discuss.elastic.co/u/Pete_Aykroyd)\
**Post date:** [December 14, 2010, 11:12pm UTC](https://discuss.elastic.co/t/re-how-to-put-mappings-and-still-get-dynamic-mappings/3658/4 "2010-12-14T23:12:24Z")

</div>

Thanks... that's a great pointer. I'm not seeing that because I've been  
using 0.13.0. Still curious about this mapping issue though.

Pete

On Tue, Dec 14, 2010 at 1:39 AM, Medcl [medcl@163.com](mailto:medcl@163.com) wrote:

> as i know,es now can direct use \_source's item as field's value,check  
> it out,[Search Fields: If a field is not stored, automatically extract it from \_source (without the need for \_source prefix) · Issue #562 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/issue/562)
> 
> On 12月14日, 上午10时31分, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> 
> > Setting the mapping in advance for those fields, and indexing will  
> > retain the dynamic nature for the rest of the document. Can you maybe gist  
> > your put mapping code, and how you detect the other fields are not being  
> > indexed?
> > 
> > On Tuesday, December 14, 2010 at 12:40 AM, Pete Aykroyd wrote:
> > 
> > > Hi,
> > 
> > > I think I'm probably missing something obvious but I can't figure how  
> > > to set a few mappings manually on my schema and retain the automatic  
> > > mappings.
> > 
> > > The exact problem is that I've been using elastic for the past week or  
> > > so completely with the dynamic schema mappings and everything was fine. But  
> > > I now want to sometimes return a field with my query... So there are a few  
> > > fields in the schema that I want to set stored to true on. For the rest of  
> > > the fields, I want them to continue to get their mappings dynamically, since  
> > > there are a lot of them and more may be added in the future.
> > 
> > > If try to put a mapping for just that the field with data already  
> > > indexed, obviously there is a merge conflict because it has already had  
> > > indexed those fields with stored = false.  
> > > If I set ignore\_conflicts to true and then re-index my data, it doesn't  
> > > seem to have any effect and checking the \_mapping shows that stored still  
> > > isn't set.  
> > > I've tried blowing away the index completely, then setting a mapping  
> > > with the two fields I care about being stored in it, and then re-indexing,  
> > > but then nothing else is mapped.
> > 
> > > What's the right way to do this?
> > 
> > > Thanks,
> > 
> > > Pete

---

<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:** [December 15, 2010, 5:42pm UTC](https://discuss.elastic.co/t/re-how-to-put-mappings-and-still-get-dynamic-mappings/3658/5 "2010-12-15T17:42:19Z")

</div>

Can you gist a full recreation?

On Wednesday, December 15, 2010 at 1:12 AM, Pete Aykroyd wrote:

Thanks... that's a great pointer. I'm not seeing that because I've been  
using 0.13.0. Still curious about this mapping issue though.

Pete

On Tue, Dec 14, 2010 at 1:39 AM, Medcl [medcl@163.com](mailto:medcl@163.com) wrote:

as i know,es now can direct use \_source's item as field's value,check  
it out,[Search Fields: If a field is not stored, automatically extract it from \_source (without the need for \_source prefix) · Issue #562 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/issue/562)

On 12月14日, 上午10时31分, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> Setting the mapping in advance for those fields, and indexing will retain  
> the dynamic nature for the rest of the document. Can you maybe gist your put  
> mapping code, and how you detect the other fields are not being indexed?
> 
> On Tuesday, December 14, 2010 at 12:40 AM, Pete Aykroyd wrote:
> 
> > Hi,
> 
> > I think I'm probably missing something obvious but I can't figure how to  
> > set a few mappings manually on my schema and retain the automatic mappings.
> 
> > The exact problem is that I've been using elastic for the past week or  
> > so completely with the dynamic schema mappings and everything was fine. But  
> > I now want to sometimes return a field with my query... So there are a few  
> > fields in the schema that I want to set stored to true on. For the rest of  
> > the fields, I want them to continue to get their mappings dynamically, since  
> > there are a lot of them and more may be added in the future.
> 
> > If try to put a mapping for just that the field with data already  
> > indexed, obviously there is a merge conflict because it has already had  
> > indexed those fields with stored = false.  
> > If I set ignore\_conflicts to true and then re-index my data, it doesn't  
> > seem to have any effect and checking the \_mapping shows that stored still  
> > isn't set.  
> > I've tried blowing away the index completely, then setting a mapping  
> > with the two fields I care about being stored in it, and then re-indexing,  
> > but then nothing else is mapped.
> 
> > What's the right way to do this?
> 
> > Thanks,
> 
> > Pete

---

<div class="post-metadata">

**Author:** ![Pete\_Aykroyd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pete_aykroyd/32/3293_2.png) [@Pete\_Aykroyd](https://discuss.elastic.co/u/Pete_Aykroyd)\
**Post date:** [December 15, 2010, 8:01pm UTC](https://discuss.elastic.co/t/re-how-to-put-mappings-and-still-get-dynamic-mappings/3658/6 "2010-12-15T20:01:36Z")

</div>

Not sure exactly what you want. This gist has the mapping that is generated  
dynamically and the code that does the indexing.

[https://gist.github.com/742513](https://gist.github.com/742513)

2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)

> Can you gist a full recreation?
> 
> On Wednesday, December 15, 2010 at 1:12 AM, Pete Aykroyd wrote:
> 
> Thanks... that's a great pointer. I'm not seeing that because I've been  
> using 0.13.0. Still curious about this mapping issue though.
> 
> Pete
> 
> On Tue, Dec 14, 2010 at 1:39 AM, Medcl [medcl@163.com](mailto:medcl@163.com) wrote:
> 
> as i know,es now can direct use \_source's item as field's value,check  
> it out,[Search Fields: If a field is not stored, automatically extract it from \_source (without the need for \_source prefix) · Issue #562 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/issue/562)
> 
> On 12月14日, 上午10时31分, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> 
> > Setting the mapping in advance for those fields, and indexing will  
> > retain the dynamic nature for the rest of the document. Can you maybe gist  
> > your put mapping code, and how you detect the other fields are not being  
> > indexed?
> > 
> > On Tuesday, December 14, 2010 at 12:40 AM, Pete Aykroyd wrote:
> > 
> > > Hi,
> > 
> > > I think I'm probably missing something obvious but I can't figure how  
> > > to set a few mappings manually on my schema and retain the automatic  
> > > mappings.
> > 
> > > The exact problem is that I've been using elastic for the past week or  
> > > so completely with the dynamic schema mappings and everything was fine. But  
> > > I now want to sometimes return a field with my query... So there are a few  
> > > fields in the schema that I want to set stored to true on. For the rest of  
> > > the fields, I want them to continue to get their mappings dynamically, since  
> > > there are a lot of them and more may be added in the future.
> > 
> > > If try to put a mapping for just that the field with data already  
> > > indexed, obviously there is a merge conflict because it has already had  
> > > indexed those fields with stored = false.  
> > > If I set ignore\_conflicts to true and then re-index my data, it doesn't  
> > > seem to have any effect and checking the \_mapping shows that stored still  
> > > isn't set.  
> > > I've tried blowing away the index completely, then setting a mapping  
> > > with the two fields I care about being stored in it, and then re-indexing,  
> > > but then nothing else is mapped.
> > 
> > > What's the right way to do this?
> > 
> > > Thanks,
> > 
> > > Pete

---

<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:** [December 15, 2010, 10:38pm UTC](https://discuss.elastic.co/t/re-how-to-put-mappings-and-still-get-dynamic-mappings/3658/7 "2010-12-15T22:38:55Z")

</div>

I don't see where you put the mapping. You can explicitly set mappings for  
specific fields, and those mappings will apply for them, the rest will be  
dynamic.

2010/12/15 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)

> Not sure exactly what you want. This gist has the mapping that is generated  
> dynamically and the code that does the indexing.
> 
> [https://gist.github.com/742513](https://gist.github.com/742513)
> 
> 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> 
> Can you gist a full recreation?
> 
> > On Wednesday, December 15, 2010 at 1:12 AM, Pete Aykroyd wrote:
> > 
> > Thanks... that's a great pointer. I'm not seeing that because I've been  
> > using 0.13.0. Still curious about this mapping issue though.
> > 
> > Pete
> > 
> > On Tue, Dec 14, 2010 at 1:39 AM, Medcl [medcl@163.com](mailto:medcl@163.com) wrote:
> > 
> > as i know,es now can direct use \_source's item as field's value,check  
> > it out,[Search Fields: If a field is not stored, automatically extract it from \_source (without the need for \_source prefix) · Issue #562 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/issue/562)
> > 
> > On 12月14日, 上午10时31分, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> > 
> > > Setting the mapping in advance for those fields, and indexing will  
> > > retain the dynamic nature for the rest of the document. Can you maybe gist  
> > > your put mapping code, and how you detect the other fields are not being  
> > > indexed?
> > > 
> > > On Tuesday, December 14, 2010 at 12:40 AM, Pete Aykroyd wrote:
> > > 
> > > > Hi,
> > > 
> > > > I think I'm probably missing something obvious but I can't figure how  
> > > > to set a few mappings manually on my schema and retain the automatic  
> > > > mappings.
> > > 
> > > > The exact problem is that I've been using elastic for the past week or  
> > > > so completely with the dynamic schema mappings and everything was fine. But  
> > > > I now want to sometimes return a field with my query... So there are a few  
> > > > fields in the schema that I want to set stored to true on. For the rest of  
> > > > the fields, I want them to continue to get their mappings dynamically, since  
> > > > there are a lot of them and more may be added in the future.
> > > 
> > > > If try to put a mapping for just that the field with data already  
> > > > indexed, obviously there is a merge conflict because it has already had  
> > > > indexed those fields with stored = false.  
> > > > If I set ignore\_conflicts to true and then re-index my data, it  
> > > > doesn't seem to have any effect and checking the \_mapping shows that stored  
> > > > still isn't set.  
> > > > I've tried blowing away the index completely, then setting a mapping  
> > > > with the two fields I care about being stored in it, and then re-indexing,  
> > > > but then nothing else is mapped.
> > > 
> > > > What's the right way to do this?
> > > 
> > > > Thanks,
> > > 
> > > > Pete

---

<div class="post-metadata">

**Author:** ![Pete\_Aykroyd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pete_aykroyd/32/3293_2.png) [@Pete\_Aykroyd](https://discuss.elastic.co/u/Pete_Aykroyd)\
**Post date:** [December 15, 2010, 11:38pm UTC](https://discuss.elastic.co/t/re-how-to-put-mappings-and-still-get-dynamic-mappings/3658/8 "2010-12-15T23:38:20Z")

</div>

Oh, I see. Sorry for the confusion. I added the mappings for the fields that  
I cared about with the curl command from the previous email (pasted below).  
Does it make a difference whether I do it in java versus with the REST API?

Thanks,

Pete

curl -XPUT '[http://localhost:9200/blocks/block/\_mapping](http://localhost:9200/blocks/block/_mapping)' -d '  
{  
"block": {  
"properties": {  
"system": {  
"store": "yes",  
"type": "string"  
},  
"user": {  
"store": "yes",  
"type": "string"  
}

```
    }
}

```

}'

2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)

> I don't see where you put the mapping. You can explicitly set mappings for  
> specific fields, and those mappings will apply for them, the rest will be  
> dynamic.
> 
> 2010/12/15 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> 
> Not sure exactly what you want. This gist has the mapping that is generated
> 
> > dynamically and the code that does the indexing.
> > 
> > [https://gist.github.com/742513](https://gist.github.com/742513)
> > 
> > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > 
> > Can you gist a full recreation?
> > 
> > > On Wednesday, December 15, 2010 at 1:12 AM, Pete Aykroyd wrote:
> > > 
> > > Thanks... that's a great pointer. I'm not seeing that because I've been  
> > > using 0.13.0. Still curious about this mapping issue though.
> > > 
> > > Pete
> > > 
> > > On Tue, Dec 14, 2010 at 1:39 AM, Medcl [medcl@163.com](mailto:medcl@163.com) wrote:
> > > 
> > > as i know,es now can direct use \_source's item as field's value,check  
> > > it out,[Search Fields: If a field is not stored, automatically extract it from \_source (without the need for \_source prefix) · Issue #562 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/issue/562)
> > > 
> > > On 12月14日, 上午10时31分, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> > > 
> > > > Setting the mapping in advance for those fields, and indexing will  
> > > > retain the dynamic nature for the rest of the document. Can you maybe gist  
> > > > your put mapping code, and how you detect the other fields are not being  
> > > > indexed?
> > > > 
> > > > On Tuesday, December 14, 2010 at 12:40 AM, Pete Aykroyd wrote:
> > > > 
> > > > > Hi,
> > > > 
> > > > > I think I'm probably missing something obvious but I can't figure how  
> > > > > to set a few mappings manually on my schema and retain the automatic  
> > > > > mappings.
> > > > 
> > > > > The exact problem is that I've been using elastic for the past week  
> > > > > or so completely with the dynamic schema mappings and everything was fine.  
> > > > > But I now want to sometimes return a field with my query... So there are a  
> > > > > few fields in the schema that I want to set stored to true on. For the rest  
> > > > > of the fields, I want them to continue to get their mappings dynamically,  
> > > > > since there are a lot of them and more may be added in the future.
> > > > 
> > > > > If try to put a mapping for just that the field with data already  
> > > > > indexed, obviously there is a merge conflict because it has already had  
> > > > > indexed those fields with stored = false.  
> > > > > If I set ignore\_conflicts to true and then re-index my data, it  
> > > > > doesn't seem to have any effect and checking the \_mapping shows that stored  
> > > > > still isn't set.  
> > > > > I've tried blowing away the index completely, then setting a mapping  
> > > > > with the two fields I care about being stored in it, and then re-indexing,  
> > > > > but then nothing else is mapped.
> > > > 
> > > > > What's the right way to do this?
> > > > 
> > > > > Thanks,
> > > > 
> > > > > Pete

---

<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:** [December 15, 2010, 11:53pm UTC](https://discuss.elastic.co/t/re-how-to-put-mappings-and-still-get-dynamic-mappings/3658/9 "2010-12-15T23:53:27Z")

</div>

It doesn't make a difference, but note that those mappings will only be  
applied if there was no previous docs before indexed with that field. So,  
delete the index, create a new one with the mappings, and then start  
indexing.

2010/12/16 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)

> Oh, I see. Sorry for the confusion. I added the mappings for the fields  
> that I cared about with the curl command from the previous email (pasted  
> below). Does it make a difference whether I do it in java versus with the  
> REST API?
> 
> Thanks,
> 
> Pete
> 
> curl -XPUT '[http://localhost:9200/blocks/block/\_mapping](http://localhost:9200/blocks/block/_mapping)' -d '  
> {
> 
> ```
> "block": {
> "properties": {
> "system": {
> "store": "yes",
> "type": "string"
> },
> "user": {
> "store": "yes",
> "type": "string"
> }
> 
> }
> }
> 
> ```
> 
> }'
> 
> 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> 
> > I don't see where you put the mapping. You can explicitly set mappings for  
> > specific fields, and those mappings will apply for them, the rest will be  
> > dynamic.
> > 
> > 2010/12/15 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > 
> > Not sure exactly what you want. This gist has the mapping that is
> > 
> > > generated dynamically and the code that does the indexing.
> > > 
> > > [https://gist.github.com/742513](https://gist.github.com/742513)
> > > 
> > > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > > 
> > > Can you gist a full recreation?
> > > 
> > > > On Wednesday, December 15, 2010 at 1:12 AM, Pete Aykroyd wrote:
> > > > 
> > > > Thanks... that's a great pointer. I'm not seeing that because I've been  
> > > > using 0.13.0. Still curious about this mapping issue though.
> > > > 
> > > > Pete
> > > > 
> > > > On Tue, Dec 14, 2010 at 1:39 AM, Medcl [medcl@163.com](mailto:medcl@163.com) wrote:
> > > > 
> > > > as i know,es now can direct use \_source's item as field's value,check  
> > > > it out,[Search Fields: If a field is not stored, automatically extract it from \_source (without the need for \_source prefix) · Issue #562 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/issue/562)
> > > > 
> > > > On 12月14日, 上午10时31分, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> > > > 
> > > > > Setting the mapping in advance for those fields, and indexing will  
> > > > > retain the dynamic nature for the rest of the document. Can you maybe gist  
> > > > > your put mapping code, and how you detect the other fields are not being  
> > > > > indexed?
> > > > > 
> > > > > On Tuesday, December 14, 2010 at 12:40 AM, Pete Aykroyd wrote:
> > > > > 
> > > > > > Hi,
> > > > > 
> > > > > > I think I'm probably missing something obvious but I can't figure  
> > > > > > how to set a few mappings manually on my schema and retain the automatic  
> > > > > > mappings.
> > > > > 
> > > > > > The exact problem is that I've been using elastic for the past week  
> > > > > > or so completely with the dynamic schema mappings and everything was fine.  
> > > > > > But I now want to sometimes return a field with my query... So there are a  
> > > > > > few fields in the schema that I want to set stored to true on. For the rest  
> > > > > > of the fields, I want them to continue to get their mappings dynamically,  
> > > > > > since there are a lot of them and more may be added in the future.
> > > > > 
> > > > > > If try to put a mapping for just that the field with data already  
> > > > > > indexed, obviously there is a merge conflict because it has already had  
> > > > > > indexed those fields with stored = false.  
> > > > > > If I set ignore\_conflicts to true and then re-index my data, it  
> > > > > > doesn't seem to have any effect and checking the \_mapping shows that stored  
> > > > > > still isn't set.  
> > > > > > I've tried blowing away the index completely, then setting a mapping  
> > > > > > with the two fields I care about being stored in it, and then re-indexing,  
> > > > > > but then nothing else is mapped.
> > > > > 
> > > > > > What's the right way to do this?
> > > > > 
> > > > > > Thanks,
> > > > > 
> > > > > > Pete

---

<div class="post-metadata">

**Author:** ![Pete\_Aykroyd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pete_aykroyd/32/3293_2.png) [@Pete\_Aykroyd](https://discuss.elastic.co/u/Pete_Aykroyd)\
**Post date:** [December 16, 2010, 12:44am UTC](https://discuss.elastic.co/t/re-how-to-put-mappings-and-still-get-dynamic-mappings/3658/10 "2010-12-16T00:44:25Z")

</div>

So that's what I did:

1. I deleted data/\*
2. started elastic
3. created the index with curl
4. used that curl command to put the mappings
5. and then indexed my docs

There were no errors while indexing, but the new fields weren't added. I  
just updated to 0.13.1 to see if that would help. Sorry, if I'm being obtuse  
here but it seems like I'm doing the right thing.

2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)

> It doesn't make a difference, but note that those mappings will only be  
> applied if there was no previous docs before indexed with that field. So,  
> delete the index, create a new one with the mappings, and then start  
> indexing.
> 
> 2010/12/16 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> 
> Oh, I see. Sorry for the confusion. I added the mappings for the fields
> 
> > that I cared about with the curl command from the previous email (pasted  
> > below). Does it make a difference whether I do it in java versus with the  
> > REST API?
> > 
> > Thanks,
> > 
> > Pete
> > 
> > curl -XPUT '[http://localhost:9200/blocks/block/\_mapping](http://localhost:9200/blocks/block/_mapping)' -d '  
> > {
> > 
> > ```
> > "block": {
> > "properties": {
> > "system": {
> > "store": "yes",
> > "type": "string"
> > },
> > "user": {
> > "store": "yes",
> > "type": "string"
> > }
> > 
> > }
> > }
> > 
> > ```
> > 
> > }'
> > 
> > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > 
> > > I don't see where you put the mapping. You can explicitly set mappings  
> > > for specific fields, and those mappings will apply for them, the rest will  
> > > be dynamic.
> > > 
> > > 2010/12/15 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > > 
> > > Not sure exactly what you want. This gist has the mapping that is
> > > 
> > > > generated dynamically and the code that does the indexing.
> > > > 
> > > > [https://gist.github.com/742513](https://gist.github.com/742513)
> > > > 
> > > > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > > > 
> > > > Can you gist a full recreation?
> > > > 
> > > > > On Wednesday, December 15, 2010 at 1:12 AM, Pete Aykroyd wrote:
> > > > > 
> > > > > Thanks... that's a great pointer. I'm not seeing that because I've been  
> > > > > using 0.13.0. Still curious about this mapping issue though.
> > > > > 
> > > > > Pete
> > > > > 
> > > > > On Tue, Dec 14, 2010 at 1:39 AM, Medcl [medcl@163.com](mailto:medcl@163.com) wrote:
> > > > > 
> > > > > as i know,es now can direct use \_source's item as field's value,check  
> > > > > it out,[Search Fields: If a field is not stored, automatically extract it from \_source (without the need for \_source prefix) · Issue #562 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/issue/562)
> > > > > 
> > > > > On 12月14日, 上午10时31分, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> > > > > 
> > > > > > Setting the mapping in advance for those fields, and indexing will  
> > > > > > retain the dynamic nature for the rest of the document. Can you maybe gist  
> > > > > > your put mapping code, and how you detect the other fields are not being  
> > > > > > indexed?
> > > > > > 
> > > > > > On Tuesday, December 14, 2010 at 12:40 AM, Pete Aykroyd wrote:
> > > > > > 
> > > > > > > Hi,
> > > > > > 
> > > > > > > I think I'm probably missing something obvious but I can't figure  
> > > > > > > how to set a few mappings manually on my schema and retain the automatic  
> > > > > > > mappings.
> > > > > > 
> > > > > > > The exact problem is that I've been using elastic for the past week  
> > > > > > > or so completely with the dynamic schema mappings and everything was fine.  
> > > > > > > But I now want to sometimes return a field with my query... So there are a  
> > > > > > > few fields in the schema that I want to set stored to true on. For the rest  
> > > > > > > of the fields, I want them to continue to get their mappings dynamically,  
> > > > > > > since there are a lot of them and more may be added in the future.
> > > > > > 
> > > > > > > If try to put a mapping for just that the field with data already  
> > > > > > > indexed, obviously there is a merge conflict because it has already had  
> > > > > > > indexed those fields with stored = false.  
> > > > > > > If I set ignore\_conflicts to true and then re-index my data, it  
> > > > > > > doesn't seem to have any effect and checking the \_mapping shows that stored  
> > > > > > > still isn't set.  
> > > > > > > I've tried blowing away the index completely, then setting a  
> > > > > > > mapping with the two fields I care about being stored in it, and then  
> > > > > > > re-indexing, but then nothing else is mapped.
> > > > > > 
> > > > > > > What's the right way to do this?
> > > > > > 
> > > > > > > Thanks,
> > > > > > 
> > > > > > > Pete

---

<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:** [December 16, 2010, 1:11am UTC](https://discuss.elastic.co/t/re-how-to-put-mappings-and-still-get-dynamic-mappings/3658/11 "2010-12-16T01:11:43Z")

</div>

Sounds good. And if you get the mapping back do you see the stored mapping  
def for those fields?

2010/12/16 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)

> So that's what I did:
> 
> 1. I deleted data/\*
> 2. started elastic
> 3. created the index with curl
> 4. used that curl command to put the mappings
> 5. and then indexed my docs
> 
> There were no errors while indexing, but the new fields weren't added. I  
> just updated to 0.13.1 to see if that would help. Sorry, if I'm being obtuse  
> here but it seems like I'm doing the right thing.
> 
> 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> 
> > It doesn't make a difference, but note that those mappings will only be  
> > applied if there was no previous docs before indexed with that field. So,  
> > delete the index, create a new one with the mappings, and then start  
> > indexing.
> > 
> > 2010/12/16 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > 
> > Oh, I see. Sorry for the confusion. I added the mappings for the fields
> > 
> > > that I cared about with the curl command from the previous email (pasted  
> > > below). Does it make a difference whether I do it in java versus with the  
> > > REST API?
> > > 
> > > Thanks,
> > > 
> > > Pete
> > > 
> > > curl -XPUT '[http://localhost:9200/blocks/block/\_mapping](http://localhost:9200/blocks/block/_mapping)' -d '  
> > > {
> > > 
> > > ```
> > > "block": {
> > > "properties": {
> > > "system": {
> > > "store": "yes",
> > > "type": "string"
> > > },
> > > "user": {
> > > "store": "yes",
> > > "type": "string"
> > > }
> > > 
> > > }
> > > }
> > > 
> > > ```
> > > 
> > > }'
> > > 
> > > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > > 
> > > > I don't see where you put the mapping. You can explicitly set mappings  
> > > > for specific fields, and those mappings will apply for them, the rest will  
> > > > be dynamic.
> > > > 
> > > > 2010/12/15 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > > > 
> > > > Not sure exactly what you want. This gist has the mapping that is
> > > > 
> > > > > generated dynamically and the code that does the indexing.
> > > > > 
> > > > > [https://gist.github.com/742513](https://gist.github.com/742513)
> > > > > 
> > > > > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > > > > 
> > > > > Can you gist a full recreation?
> > > > > 
> > > > > > On Wednesday, December 15, 2010 at 1:12 AM, Pete Aykroyd wrote:
> > > > > > 
> > > > > > Thanks... that's a great pointer. I'm not seeing that because I've  
> > > > > > been using 0.13.0. Still curious about this mapping issue though.
> > > > > > 
> > > > > > Pete
> > > > > > 
> > > > > > On Tue, Dec 14, 2010 at 1:39 AM, Medcl [medcl@163.com](mailto:medcl@163.com) wrote:
> > > > > > 
> > > > > > as i know,es now can direct use \_source's item as field's value,check  
> > > > > > it out,  
> > > > > > [Search Fields: If a field is not stored, automatically extract it from \_source (without the need for \_source prefix) · Issue #562 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/issue/562)
> > > > > > 
> > > > > > On 12月14日, 上午10时31分, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> > > > > > 
> > > > > > > Setting the mapping in advance for those fields, and indexing will  
> > > > > > > retain the dynamic nature for the rest of the document. Can you maybe gist  
> > > > > > > your put mapping code, and how you detect the other fields are not being  
> > > > > > > indexed?
> > > > > > > 
> > > > > > > On Tuesday, December 14, 2010 at 12:40 AM, Pete Aykroyd wrote:
> > > > > > > 
> > > > > > > > Hi,
> > > > > > > 
> > > > > > > > I think I'm probably missing something obvious but I can't figure  
> > > > > > > > how to set a few mappings manually on my schema and retain the automatic  
> > > > > > > > mappings.
> > > > > > > 
> > > > > > > > The exact problem is that I've been using elastic for the past  
> > > > > > > > week or so completely with the dynamic schema mappings and everything was  
> > > > > > > > fine. But I now want to sometimes return a field with my query... So there  
> > > > > > > > are a few fields in the schema that I want to set stored to true on. For the  
> > > > > > > > rest of the fields, I want them to continue to get their mappings  
> > > > > > > > dynamically, since there are a lot of them and more may be added in the  
> > > > > > > > future.
> > > > > > > 
> > > > > > > > If try to put a mapping for just that the field with data already  
> > > > > > > > indexed, obviously there is a merge conflict because it has already had  
> > > > > > > > indexed those fields with stored = false.  
> > > > > > > > If I set ignore\_conflicts to true and then re-index my data, it  
> > > > > > > > doesn't seem to have any effect and checking the \_mapping shows that stored  
> > > > > > > > still isn't set.  
> > > > > > > > I've tried blowing away the index completely, then setting a  
> > > > > > > > mapping with the two fields I care about being stored in it, and then  
> > > > > > > > re-indexing, but then nothing else is mapped.
> > > > > > > 
> > > > > > > > What's the right way to do this?
> > > > > > > 
> > > > > > > > Thanks,
> > > > > > > 
> > > > > > > > Pete

---

<div class="post-metadata">

**Author:** ![Pete\_Aykroyd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pete_aykroyd/32/3293_2.png) [@Pete\_Aykroyd](https://discuss.elastic.co/u/Pete_Aykroyd)\
**Post date:** [December 16, 2010, 2:27am UTC](https://discuss.elastic.co/t/re-how-to-put-mappings-and-still-get-dynamic-mappings/3658/12 "2010-12-16T02:27:08Z")

</div>

Hey,

I got it working... it looks like the mistake I was making was naming my  
mapping the same thing as the type. I don't know if that matters or not, but  
that appears to be the only difference.

Thanks for all the help!

Pete

2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)

> Sounds good. And if you get the mapping back do you see the stored mapping  
> def for those fields?
> 
> 2010/12/16 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> 
> > So that's what I did:
> > 
> > 1. I deleted data/\*
> > 2. started elastic
> > 3. created the index with curl
> > 4. used that curl command to put the mappings
> > 5. and then indexed my docs
> > 
> > There were no errors while indexing, but the new fields weren't added. I  
> > just updated to 0.13.1 to see if that would help. Sorry, if I'm being obtuse  
> > here but it seems like I'm doing the right thing.
> > 
> > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > 
> > > It doesn't make a difference, but note that those mappings will only be  
> > > applied if there was no previous docs before indexed with that field. So,  
> > > delete the index, create a new one with the mappings, and then start  
> > > indexing.
> > > 
> > > 2010/12/16 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > > 
> > > Oh, I see. Sorry for the confusion. I added the mappings for the fields
> > > 
> > > > that I cared about with the curl command from the previous email (pasted  
> > > > below). Does it make a difference whether I do it in java versus with the  
> > > > REST API?
> > > > 
> > > > Thanks,
> > > > 
> > > > Pete
> > > > 
> > > > curl -XPUT '[http://localhost:9200/blocks/block/\_mapping](http://localhost:9200/blocks/block/_mapping)' -d '  
> > > > {
> > > > 
> > > > ```
> > > > "block": {
> > > > "properties": {
> > > > "system": {
> > > > "store": "yes",
> > > > "type": "string"
> > > > },
> > > > "user": {
> > > > "store": "yes",
> > > > "type": "string"
> > > > }
> > > > 
> > > > }
> > > > }
> > > > 
> > > > ```
> > > > 
> > > > }'
> > > > 
> > > > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > > > 
> > > > > I don't see where you put the mapping. You can explicitly set mappings  
> > > > > for specific fields, and those mappings will apply for them, the rest will  
> > > > > be dynamic.
> > > > > 
> > > > > 2010/12/15 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > > > > 
> > > > > Not sure exactly what you want. This gist has the mapping that is
> > > > > 
> > > > > > generated dynamically and the code that does the indexing.
> > > > > > 
> > > > > > [https://gist.github.com/742513](https://gist.github.com/742513)
> > > > > > 
> > > > > > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > > > > > 
> > > > > > Can you gist a full recreation?
> > > > > > 
> > > > > > > On Wednesday, December 15, 2010 at 1:12 AM, Pete Aykroyd wrote:
> > > > > > > 
> > > > > > > Thanks... that's a great pointer. I'm not seeing that because I've  
> > > > > > > been using 0.13.0. Still curious about this mapping issue though.
> > > > > > > 
> > > > > > > Pete
> > > > > > > 
> > > > > > > On Tue, Dec 14, 2010 at 1:39 AM, Medcl [medcl@163.com](mailto:medcl@163.com) wrote:
> > > > > > > 
> > > > > > > as i know,es now can direct use \_source's item as field's  
> > > > > > > value,check  
> > > > > > > it out,  
> > > > > > > [Search Fields: If a field is not stored, automatically extract it from \_source (without the need for \_source prefix) · Issue #562 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/issue/562)
> > > > > > > 
> > > > > > > On 12月14日, 上午10时31分, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com)  
> > > > > > > wrote:
> > > > > > > 
> > > > > > > > Setting the mapping in advance for those fields, and indexing will  
> > > > > > > > retain the dynamic nature for the rest of the document. Can you maybe gist  
> > > > > > > > your put mapping code, and how you detect the other fields are not being  
> > > > > > > > indexed?
> > > > > > > > 
> > > > > > > > On Tuesday, December 14, 2010 at 12:40 AM, Pete Aykroyd wrote:
> > > > > > > > 
> > > > > > > > > Hi,
> > > > > > > > 
> > > > > > > > > I think I'm probably missing something obvious but I can't figure  
> > > > > > > > > how to set a few mappings manually on my schema and retain the automatic  
> > > > > > > > > mappings.
> > > > > > > > 
> > > > > > > > > The exact problem is that I've been using elastic for the past  
> > > > > > > > > week or so completely with the dynamic schema mappings and everything was  
> > > > > > > > > fine. But I now want to sometimes return a field with my query... So there  
> > > > > > > > > are a few fields in the schema that I want to set stored to true on. For the  
> > > > > > > > > rest of the fields, I want them to continue to get their mappings  
> > > > > > > > > dynamically, since there are a lot of them and more may be added in the  
> > > > > > > > > future.
> > > > > > > > 
> > > > > > > > > If try to put a mapping for just that the field with data already  
> > > > > > > > > indexed, obviously there is a merge conflict because it has already had  
> > > > > > > > > indexed those fields with stored = false.  
> > > > > > > > > If I set ignore\_conflicts to true and then re-index my data, it  
> > > > > > > > > doesn't seem to have any effect and checking the \_mapping shows that stored  
> > > > > > > > > still isn't set.  
> > > > > > > > > I've tried blowing away the index completely, then setting a  
> > > > > > > > > mapping with the two fields I care about being stored in it, and then  
> > > > > > > > > re-indexing, but then nothing else is mapped.
> > > > > > > > 
> > > > > > > > > What's the right way to do this?
> > > > > > > > 
> > > > > > > > > Thanks,
> > > > > > > > 
> > > > > > > > > Pete

---

<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:** [December 16, 2010, 2:29am UTC](https://discuss.elastic.co/t/re-how-to-put-mappings-and-still-get-dynamic-mappings/3658/13 "2010-12-16T02:29:51Z")

</div>

Great that its working. What do you mean that you named the mapping same  
thing as the type?

2010/12/16 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)

> Hey,
> 
> I got it working... it looks like the mistake I was making was naming my  
> mapping the same thing as the type. I don't know if that matters or not, but  
> that appears to be the only difference.
> 
> Thanks for all the help!
> 
> Pete
> 
> 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> 
> > Sounds good. And if you get the mapping back do you see the stored mapping  
> > def for those fields?
> > 
> > 2010/12/16 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > 
> > > So that's what I did:
> > > 
> > > 1. I deleted data/\*
> > > 2. started elastic
> > > 3. created the index with curl
> > > 4. used that curl command to put the mappings
> > > 5. and then indexed my docs
> > > 
> > > There were no errors while indexing, but the new fields weren't added. I  
> > > just updated to 0.13.1 to see if that would help. Sorry, if I'm being obtuse  
> > > here but it seems like I'm doing the right thing.
> > > 
> > > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > > 
> > > > It doesn't make a difference, but note that those mappings will only be  
> > > > applied if there was no previous docs before indexed with that field. So,  
> > > > delete the index, create a new one with the mappings, and then start  
> > > > indexing.
> > > > 
> > > > 2010/12/16 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > > > 
> > > > Oh, I see. Sorry for the confusion. I added the mappings for the fields
> > > > 
> > > > > that I cared about with the curl command from the previous email (pasted  
> > > > > below). Does it make a difference whether I do it in java versus with the  
> > > > > REST API?
> > > > > 
> > > > > Thanks,
> > > > > 
> > > > > Pete
> > > > > 
> > > > > curl -XPUT '[http://localhost:9200/blocks/block/\_mapping](http://localhost:9200/blocks/block/_mapping)' -d '  
> > > > > {
> > > > > 
> > > > > ```
> > > > > "block": {
> > > > > "properties": {
> > > > > "system": {
> > > > > "store": "yes",
> > > > > "type": "string"
> > > > > },
> > > > > "user": {
> > > > > "store": "yes",
> > > > > "type": "string"
> > > > > }
> > > > > 
> > > > > }
> > > > > }
> > > > > 
> > > > > ```
> > > > > 
> > > > > }'
> > > > > 
> > > > > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > > > > 
> > > > > > I don't see where you put the mapping. You can explicitly set mappings  
> > > > > > for specific fields, and those mappings will apply for them, the rest will  
> > > > > > be dynamic.
> > > > > > 
> > > > > > 2010/12/15 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > > > > > 
> > > > > > Not sure exactly what you want. This gist has the mapping that is
> > > > > > 
> > > > > > > generated dynamically and the code that does the indexing.
> > > > > > > 
> > > > > > > [https://gist.github.com/742513](https://gist.github.com/742513)
> > > > > > > 
> > > > > > > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > > > > > > 
> > > > > > > Can you gist a full recreation?
> > > > > > > 
> > > > > > > > On Wednesday, December 15, 2010 at 1:12 AM, Pete Aykroyd wrote:
> > > > > > > > 
> > > > > > > > Thanks... that's a great pointer. I'm not seeing that because I've  
> > > > > > > > been using 0.13.0. Still curious about this mapping issue though.
> > > > > > > > 
> > > > > > > > Pete
> > > > > > > > 
> > > > > > > > On Tue, Dec 14, 2010 at 1:39 AM, Medcl [medcl@163.com](mailto:medcl@163.com) wrote:
> > > > > > > > 
> > > > > > > > as i know,es now can direct use \_source's item as field's  
> > > > > > > > value,check  
> > > > > > > > it out,  
> > > > > > > > [Search Fields: If a field is not stored, automatically extract it from \_source (without the need for \_source prefix) · Issue #562 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/issue/562)
> > > > > > > > 
> > > > > > > > On 12月14日, 上午10时31分, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com)  
> > > > > > > > wrote:
> > > > > > > > 
> > > > > > > > > Setting the mapping in advance for those fields, and indexing  
> > > > > > > > > will retain the dynamic nature for the rest of the document. Can you maybe  
> > > > > > > > > gist your put mapping code, and how you detect the other fields are not  
> > > > > > > > > being indexed?
> > > > > > > > > 
> > > > > > > > > On Tuesday, December 14, 2010 at 12:40 AM, Pete Aykroyd wrote:
> > > > > > > > > 
> > > > > > > > > > Hi,
> > > > > > > > > 
> > > > > > > > > > I think I'm probably missing something obvious but I can't  
> > > > > > > > > > figure how to set a few mappings manually on my schema and retain the  
> > > > > > > > > > automatic mappings.
> > > > > > > > > 
> > > > > > > > > > The exact problem is that I've been using elastic for the past  
> > > > > > > > > > week or so completely with the dynamic schema mappings and everything was  
> > > > > > > > > > fine. But I now want to sometimes return a field with my query... So there  
> > > > > > > > > > are a few fields in the schema that I want to set stored to true on. For the  
> > > > > > > > > > rest of the fields, I want them to continue to get their mappings  
> > > > > > > > > > dynamically, since there are a lot of them and more may be added in the  
> > > > > > > > > > future.
> > > > > > > > > 
> > > > > > > > > > If try to put a mapping for just that the field with data  
> > > > > > > > > > already indexed, obviously there is a merge conflict because it has already  
> > > > > > > > > > had indexed those fields with stored = false.  
> > > > > > > > > > If I set ignore\_conflicts to true and then re-index my data, it  
> > > > > > > > > > doesn't seem to have any effect and checking the \_mapping shows that stored  
> > > > > > > > > > still isn't set.  
> > > > > > > > > > I've tried blowing away the index completely, then setting a  
> > > > > > > > > > mapping with the two fields I care about being stored in it, and then  
> > > > > > > > > > re-indexing, but then nothing else is mapped.
> > > > > > > > > 
> > > > > > > > > > What's the right way to do this?
> > > > > > > > > 
> > > > > > > > > > Thanks,
> > > > > > > > > 
> > > > > > > > > > Pete

---

<div class="post-metadata">

**Author:** ![Pete\_Aykroyd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pete_aykroyd/32/3293_2.png) [@Pete\_Aykroyd](https://discuss.elastic.co/u/Pete_Aykroyd)\
**Post date:** [December 16, 2010, 4:04am UTC](https://discuss.elastic.co/t/re-how-to-put-mappings-and-still-get-dynamic-mappings/3658/14 "2010-12-16T04:04:14Z")

</div>

So I was doing something like

curl -XPUT $ES\_HOST/blocks/block/\_mapping -d '  
{  
"block" : { ....

The only change that I think I made was to change the "block" in the json  
body to something like "initial-block-mapping".

2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)

> Great that its working. What do you mean that you named the mapping same  
> thing as the type?
> 
> 2010/12/16 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> 
> > Hey,
> > 
> > I got it working... it looks like the mistake I was making was naming my  
> > mapping the same thing as the type. I don't know if that matters or not, but  
> > that appears to be the only difference.
> > 
> > Thanks for all the help!
> > 
> > Pete
> > 
> > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > 
> > > Sounds good. And if you get the mapping back do you see the stored  
> > > mapping def for those fields?
> > > 
> > > 2010/12/16 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > > 
> > > > So that's what I did:
> > > > 
> > > > 1. I deleted data/\*
> > > > 2. started elastic
> > > > 3. created the index with curl
> > > > 4. used that curl command to put the mappings
> > > > 5. and then indexed my docs
> > > > 
> > > > There were no errors while indexing, but the new fields weren't added. I  
> > > > just updated to 0.13.1 to see if that would help. Sorry, if I'm being obtuse  
> > > > here but it seems like I'm doing the right thing.
> > > > 
> > > > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > > > 
> > > > > It doesn't make a difference, but note that those mappings will only be  
> > > > > applied if there was no previous docs before indexed with that field. So,  
> > > > > delete the index, create a new one with the mappings, and then start  
> > > > > indexing.
> > > > > 
> > > > > 2010/12/16 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > > > > 
> > > > > Oh, I see. Sorry for the confusion. I added the mappings for the fields
> > > > > 
> > > > > > that I cared about with the curl command from the previous email (pasted  
> > > > > > below). Does it make a difference whether I do it in java versus with the  
> > > > > > REST API?
> > > > > > 
> > > > > > Thanks,
> > > > > > 
> > > > > > Pete
> > > > > > 
> > > > > > curl -XPUT '[http://localhost:9200/blocks/block/\_mapping](http://localhost:9200/blocks/block/_mapping)' -d '  
> > > > > > {
> > > > > > 
> > > > > > ```
> > > > > > "block": {
> > > > > > "properties": {
> > > > > > "system": {
> > > > > > "store": "yes",
> > > > > > "type": "string"
> > > > > > },
> > > > > > "user": {
> > > > > > "store": "yes",
> > > > > > "type": "string"
> > > > > > }
> > > > > > 
> > > > > > }
> > > > > > }
> > > > > > 
> > > > > > ```
> > > > > > 
> > > > > > }'
> > > > > > 
> > > > > > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > > > > > 
> > > > > > > I don't see where you put the mapping. You can explicitly set  
> > > > > > > mappings for specific fields, and those mappings will apply for them, the  
> > > > > > > rest will be dynamic.
> > > > > > > 
> > > > > > > 2010/12/15 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > > > > > > 
> > > > > > > Not sure exactly what you want. This gist has the mapping that is
> > > > > > > 
> > > > > > > > generated dynamically and the code that does the indexing.
> > > > > > > > 
> > > > > > > > [https://gist.github.com/742513](https://gist.github.com/742513)
> > > > > > > > 
> > > > > > > > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > > > > > > > 
> > > > > > > > Can you gist a full recreation?
> > > > > > > > 
> > > > > > > > > On Wednesday, December 15, 2010 at 1:12 AM, Pete Aykroyd wrote:
> > > > > > > > > 
> > > > > > > > > Thanks... that's a great pointer. I'm not seeing that because I've  
> > > > > > > > > been using 0.13.0. Still curious about this mapping issue though.
> > > > > > > > > 
> > > > > > > > > Pete
> > > > > > > > > 
> > > > > > > > > On Tue, Dec 14, 2010 at 1:39 AM, Medcl [medcl@163.com](mailto:medcl@163.com) wrote:
> > > > > > > > > 
> > > > > > > > > as i know,es now can direct use \_source's item as field's  
> > > > > > > > > value,check  
> > > > > > > > > it out,  
> > > > > > > > > [Search Fields: If a field is not stored, automatically extract it from \_source (without the need for \_source prefix) · Issue #562 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/issue/562)
> > > > > > > > > 
> > > > > > > > > On 12月14日, 上午10时31分, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com)  
> > > > > > > > > wrote:
> > > > > > > > > 
> > > > > > > > > > Setting the mapping in advance for those fields, and indexing  
> > > > > > > > > > will retain the dynamic nature for the rest of the document. Can you maybe  
> > > > > > > > > > gist your put mapping code, and how you detect the other fields are not  
> > > > > > > > > > being indexed?
> > > > > > > > > > 
> > > > > > > > > > On Tuesday, December 14, 2010 at 12:40 AM, Pete Aykroyd wrote:
> > > > > > > > > > 
> > > > > > > > > > > Hi,
> > > > > > > > > > 
> > > > > > > > > > > I think I'm probably missing something obvious but I can't  
> > > > > > > > > > > figure how to set a few mappings manually on my schema and retain the  
> > > > > > > > > > > automatic mappings.
> > > > > > > > > > 
> > > > > > > > > > > The exact problem is that I've been using elastic for the past  
> > > > > > > > > > > week or so completely with the dynamic schema mappings and everything was  
> > > > > > > > > > > fine. But I now want to sometimes return a field with my query... So there  
> > > > > > > > > > > are a few fields in the schema that I want to set stored to true on. For the  
> > > > > > > > > > > rest of the fields, I want them to continue to get their mappings  
> > > > > > > > > > > dynamically, since there are a lot of them and more may be added in the  
> > > > > > > > > > > future.
> > > > > > > > > > 
> > > > > > > > > > > If try to put a mapping for just that the field with data  
> > > > > > > > > > > already indexed, obviously there is a merge conflict because it has already  
> > > > > > > > > > > had indexed those fields with stored = false.  
> > > > > > > > > > > If I set ignore\_conflicts to true and then re-index my data, it  
> > > > > > > > > > > doesn't seem to have any effect and checking the \_mapping shows that stored  
> > > > > > > > > > > still isn't set.  
> > > > > > > > > > > I've tried blowing away the index completely, then setting a  
> > > > > > > > > > > mapping with the two fields I care about being stored in it, and then  
> > > > > > > > > > > re-indexing, but then nothing else is mapped.
> > > > > > > > > > 
> > > > > > > > > > > What's the right way to do this?
> > > > > > > > > > 
> > > > > > > > > > > Thanks,
> > > > > > > > > > 
> > > > > > > > > > > Pete

---

<div class="post-metadata">

**Author:** ![Pete\_Aykroyd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pete_aykroyd/32/3293_2.png) [@Pete\_Aykroyd](https://discuss.elastic.co/u/Pete_Aykroyd)\
**Post date:** [December 16, 2010, 4:11am UTC](https://discuss.elastic.co/t/re-how-to-put-mappings-and-still-get-dynamic-mappings/3658/15 "2010-12-16T04:11:12Z")

</div>

Actually, I take that back. I just had the problem recur. I had switched the  
number of replicas to be zero since I'm testing on only 1 node anyway. When  
I switched it to 2 replicas, blew away the data, and re-indexed, I ran into  
the same problem. I just switched back to 0 replicas and it's fine again.

2010/12/15 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)

> So I was doing something like
> 
> curl -XPUT $ES\_HOST/blocks/block/\_mapping -d '  
> {  
> "block" : { ....
> 
> The only change that I think I made was to change the "block" in the json  
> body to something like "initial-block-mapping".
> 
> 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> 
> > Great that its working. What do you mean that you named the mapping same  
> > thing as the type?
> > 
> > 2010/12/16 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > 
> > > Hey,
> > > 
> > > I got it working... it looks like the mistake I was making was naming my  
> > > mapping the same thing as the type. I don't know if that matters or not, but  
> > > that appears to be the only difference.
> > > 
> > > Thanks for all the help!
> > > 
> > > Pete
> > > 
> > > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > > 
> > > > Sounds good. And if you get the mapping back do you see the stored  
> > > > mapping def for those fields?
> > > > 
> > > > 2010/12/16 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > > > 
> > > > > So that's what I did:
> > > > > 
> > > > > 1. I deleted data/\*
> > > > > 2. started elastic
> > > > > 3. created the index with curl
> > > > > 4. used that curl command to put the mappings
> > > > > 5. and then indexed my docs
> > > > > 
> > > > > There were no errors while indexing, but the new fields weren't added.  
> > > > > I just updated to 0.13.1 to see if that would help. Sorry, if I'm being  
> > > > > obtuse here but it seems like I'm doing the right thing.
> > > > > 
> > > > > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > > > > 
> > > > > > It doesn't make a difference, but note that those mappings will only  
> > > > > > be applied if there was no previous docs before indexed with that field. So,  
> > > > > > delete the index, create a new one with the mappings, and then start  
> > > > > > indexing.
> > > > > > 
> > > > > > 2010/12/16 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > > > > > 
> > > > > > Oh, I see. Sorry for the confusion. I added the mappings for the
> > > > > > 
> > > > > > > fields that I cared about with the curl command from the previous email  
> > > > > > > (pasted below). Does it make a difference whether I do it in java versus  
> > > > > > > with the REST API?
> > > > > > > 
> > > > > > > Thanks,
> > > > > > > 
> > > > > > > Pete
> > > > > > > 
> > > > > > > curl -XPUT '[http://localhost:9200/blocks/block/\_mapping](http://localhost:9200/blocks/block/_mapping)' -d '  
> > > > > > > {
> > > > > > > 
> > > > > > > ```
> > > > > > > "block": {
> > > > > > > "properties": {
> > > > > > > "system": {
> > > > > > > "store": "yes",
> > > > > > > "type": "string"
> > > > > > > },
> > > > > > > "user": {
> > > > > > > "store": "yes",
> > > > > > > "type": "string"
> > > > > > > }
> > > > > > > 
> > > > > > > }
> > > > > > > }
> > > > > > > 
> > > > > > > ```
> > > > > > > 
> > > > > > > }'
> > > > > > > 
> > > > > > > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > > > > > > 
> > > > > > > > I don't see where you put the mapping. You can explicitly set  
> > > > > > > > mappings for specific fields, and those mappings will apply for them, the  
> > > > > > > > rest will be dynamic.
> > > > > > > > 
> > > > > > > > 2010/12/15 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > > > > > > > 
> > > > > > > > Not sure exactly what you want. This gist has the mapping that is
> > > > > > > > 
> > > > > > > > > generated dynamically and the code that does the indexing.
> > > > > > > > > 
> > > > > > > > > [https://gist.github.com/742513](https://gist.github.com/742513)
> > > > > > > > > 
> > > > > > > > > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > > > > > > > > 
> > > > > > > > > Can you gist a full recreation?
> > > > > > > > > 
> > > > > > > > > > On Wednesday, December 15, 2010 at 1:12 AM, Pete Aykroyd wrote:
> > > > > > > > > > 
> > > > > > > > > > Thanks... that's a great pointer. I'm not seeing that because I've  
> > > > > > > > > > been using 0.13.0. Still curious about this mapping issue though.
> > > > > > > > > > 
> > > > > > > > > > Pete
> > > > > > > > > > 
> > > > > > > > > > On Tue, Dec 14, 2010 at 1:39 AM, Medcl [medcl@163.com](mailto:medcl@163.com) wrote:
> > > > > > > > > > 
> > > > > > > > > > as i know,es now can direct use \_source's item as field's  
> > > > > > > > > > value,check  
> > > > > > > > > > it out,  
> > > > > > > > > > [Search Fields: If a field is not stored, automatically extract it from \_source (without the need for \_source prefix) · Issue #562 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/issue/562)
> > > > > > > > > > 
> > > > > > > > > > On 12月14日, 上午10时31分, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com)  
> > > > > > > > > > wrote:
> > > > > > > > > > 
> > > > > > > > > > > Setting the mapping in advance for those fields, and indexing  
> > > > > > > > > > > will retain the dynamic nature for the rest of the document. Can you maybe  
> > > > > > > > > > > gist your put mapping code, and how you detect the other fields are not  
> > > > > > > > > > > being indexed?
> > > > > > > > > > > 
> > > > > > > > > > > On Tuesday, December 14, 2010 at 12:40 AM, Pete Aykroyd wrote:
> > > > > > > > > > > 
> > > > > > > > > > > > Hi,
> > > > > > > > > > > 
> > > > > > > > > > > > I think I'm probably missing something obvious but I can't  
> > > > > > > > > > > > figure how to set a few mappings manually on my schema and retain the  
> > > > > > > > > > > > automatic mappings.
> > > > > > > > > > > 
> > > > > > > > > > > > The exact problem is that I've been using elastic for the past  
> > > > > > > > > > > > week or so completely with the dynamic schema mappings and everything was  
> > > > > > > > > > > > fine. But I now want to sometimes return a field with my query... So there  
> > > > > > > > > > > > are a few fields in the schema that I want to set stored to true on. For the  
> > > > > > > > > > > > rest of the fields, I want them to continue to get their mappings  
> > > > > > > > > > > > dynamically, since there are a lot of them and more may be added in the  
> > > > > > > > > > > > future.
> > > > > > > > > > > 
> > > > > > > > > > > > If try to put a mapping for just that the field with data  
> > > > > > > > > > > > already indexed, obviously there is a merge conflict because it has already  
> > > > > > > > > > > > had indexed those fields with stored = false.  
> > > > > > > > > > > > If I set ignore\_conflicts to true and then re-index my data,  
> > > > > > > > > > > > it doesn't seem to have any effect and checking the \_mapping shows that  
> > > > > > > > > > > > stored still isn't set.  
> > > > > > > > > > > > I've tried blowing away the index completely, then setting a  
> > > > > > > > > > > > mapping with the two fields I care about being stored in it, and then  
> > > > > > > > > > > > re-indexing, but then nothing else is mapped.
> > > > > > > > > > > 
> > > > > > > > > > > > What's the right way to do this?
> > > > > > > > > > > 
> > > > > > > > > > > > Thanks,
> > > > > > > > > > > 
> > > > > > > > > > > > Pete

---

<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:** [December 16, 2010, 3:48pm UTC](https://discuss.elastic.co/t/re-how-to-put-mappings-and-still-get-dynamic-mappings/3658/16 "2010-12-16T15:48:28Z")

</div>

The number of replicas should not be relevant to what you do. Can you "curl"  
recreate this?

2010/12/16 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)

> Actually, I take that back. I just had the problem recur. I had switched  
> the number of replicas to be zero since I'm testing on only 1 node anyway.  
> When I switched it to 2 replicas, blew away the data, and re-indexed, I ran  
> into the same problem. I just switched back to 0 replicas and it's fine  
> again.
> 
> 2010/12/15 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> 
> > So I was doing something like
> > 
> > curl -XPUT $ES\_HOST/blocks/block/\_mapping -d '  
> > {  
> > "block" : { ....
> > 
> > The only change that I think I made was to change the "block" in the json  
> > body to something like "initial-block-mapping".
> > 
> > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > 
> > > Great that its working. What do you mean that you named the mapping same  
> > > thing as the type?
> > > 
> > > 2010/12/16 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > > 
> > > > Hey,
> > > > 
> > > > I got it working... it looks like the mistake I was making was naming my  
> > > > mapping the same thing as the type. I don't know if that matters or not, but  
> > > > that appears to be the only difference.
> > > > 
> > > > Thanks for all the help!
> > > > 
> > > > Pete
> > > > 
> > > > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > > > 
> > > > > Sounds good. And if you get the mapping back do you see the stored  
> > > > > mapping def for those fields?
> > > > > 
> > > > > 2010/12/16 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > > > > 
> > > > > > So that's what I did:
> > > > > > 
> > > > > > 1. I deleted data/\*
> > > > > > 2. started elastic
> > > > > > 3. created the index with curl
> > > > > > 4. used that curl command to put the mappings
> > > > > > 5. and then indexed my docs
> > > > > > 
> > > > > > There were no errors while indexing, but the new fields weren't added.  
> > > > > > I just updated to 0.13.1 to see if that would help. Sorry, if I'm being  
> > > > > > obtuse here but it seems like I'm doing the right thing.
> > > > > > 
> > > > > > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > > > > > 
> > > > > > > It doesn't make a difference, but note that those mappings will only  
> > > > > > > be applied if there was no previous docs before indexed with that field. So,  
> > > > > > > delete the index, create a new one with the mappings, and then start  
> > > > > > > indexing.
> > > > > > > 
> > > > > > > 2010/12/16 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > > > > > > 
> > > > > > > Oh, I see. Sorry for the confusion. I added the mappings for the
> > > > > > > 
> > > > > > > > fields that I cared about with the curl command from the previous email  
> > > > > > > > (pasted below). Does it make a difference whether I do it in java versus  
> > > > > > > > with the REST API?
> > > > > > > > 
> > > > > > > > Thanks,
> > > > > > > > 
> > > > > > > > Pete
> > > > > > > > 
> > > > > > > > curl -XPUT '[http://localhost:9200/blocks/block/\_mapping](http://localhost:9200/blocks/block/_mapping)' -d '  
> > > > > > > > {
> > > > > > > > 
> > > > > > > > ```
> > > > > > > > "block": {
> > > > > > > > "properties": {
> > > > > > > > "system": {
> > > > > > > > "store": "yes",
> > > > > > > > "type": "string"
> > > > > > > > },
> > > > > > > > "user": {
> > > > > > > > "store": "yes",
> > > > > > > > "type": "string"
> > > > > > > > }
> > > > > > > > 
> > > > > > > > }
> > > > > > > > }
> > > > > > > > 
> > > > > > > > ```
> > > > > > > > 
> > > > > > > > }'
> > > > > > > > 
> > > > > > > > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > > > > > > > 
> > > > > > > > > I don't see where you put the mapping. You can explicitly set  
> > > > > > > > > mappings for specific fields, and those mappings will apply for them, the  
> > > > > > > > > rest will be dynamic.
> > > > > > > > > 
> > > > > > > > > 2010/12/15 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > > > > > > > > 
> > > > > > > > > Not sure exactly what you want. This gist has the mapping that is
> > > > > > > > > 
> > > > > > > > > > generated dynamically and the code that does the indexing.
> > > > > > > > > > 
> > > > > > > > > > [https://gist.github.com/742513](https://gist.github.com/742513)
> > > > > > > > > > 
> > > > > > > > > > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > > > > > > > > > 
> > > > > > > > > > Can you gist a full recreation?
> > > > > > > > > > 
> > > > > > > > > > > On Wednesday, December 15, 2010 at 1:12 AM, Pete Aykroyd wrote:
> > > > > > > > > > > 
> > > > > > > > > > > Thanks... that's a great pointer. I'm not seeing that because  
> > > > > > > > > > > I've been using 0.13.0. Still curious about this mapping issue though.
> > > > > > > > > > > 
> > > > > > > > > > > Pete
> > > > > > > > > > > 
> > > > > > > > > > > On Tue, Dec 14, 2010 at 1:39 AM, Medcl [medcl@163.com](mailto:medcl@163.com) wrote:
> > > > > > > > > > > 
> > > > > > > > > > > as i know,es now can direct use \_source's item as field's  
> > > > > > > > > > > value,check  
> > > > > > > > > > > it out,  
> > > > > > > > > > > [Search Fields: If a field is not stored, automatically extract it from \_source (without the need for \_source prefix) · Issue #562 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/issue/562)
> > > > > > > > > > > 
> > > > > > > > > > > On 12月14日, 上午10时31分, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com)  
> > > > > > > > > > > wrote:
> > > > > > > > > > > 
> > > > > > > > > > > > Setting the mapping in advance for those fields, and indexing  
> > > > > > > > > > > > will retain the dynamic nature for the rest of the document. Can you maybe  
> > > > > > > > > > > > gist your put mapping code, and how you detect the other fields are not  
> > > > > > > > > > > > being indexed?
> > > > > > > > > > > > 
> > > > > > > > > > > > On Tuesday, December 14, 2010 at 12:40 AM, Pete Aykroyd wrote:
> > > > > > > > > > > > 
> > > > > > > > > > > > > Hi,
> > > > > > > > > > > > 
> > > > > > > > > > > > > I think I'm probably missing something obvious but I can't  
> > > > > > > > > > > > > figure how to set a few mappings manually on my schema and retain the  
> > > > > > > > > > > > > automatic mappings.
> > > > > > > > > > > > 
> > > > > > > > > > > > > The exact problem is that I've been using elastic for the  
> > > > > > > > > > > > > past week or so completely with the dynamic schema mappings and everything  
> > > > > > > > > > > > > was fine. But I now want to sometimes return a field with my query... So  
> > > > > > > > > > > > > there are a few fields in the schema that I want to set stored to true on.  
> > > > > > > > > > > > > For the rest of the fields, I want them to continue to get their mappings  
> > > > > > > > > > > > > dynamically, since there are a lot of them and more may be added in the  
> > > > > > > > > > > > > future.
> > > > > > > > > > > > 
> > > > > > > > > > > > > If try to put a mapping for just that the field with data  
> > > > > > > > > > > > > already indexed, obviously there is a merge conflict because it has already  
> > > > > > > > > > > > > had indexed those fields with stored = false.  
> > > > > > > > > > > > > If I set ignore\_conflicts to true and then re-index my data,  
> > > > > > > > > > > > > it doesn't seem to have any effect and checking the \_mapping shows that  
> > > > > > > > > > > > > stored still isn't set.  
> > > > > > > > > > > > > I've tried blowing away the index completely, then setting a  
> > > > > > > > > > > > > mapping with the two fields I care about being stored in it, and then  
> > > > > > > > > > > > > re-indexing, but then nothing else is mapped.
> > > > > > > > > > > > 
> > > > > > > > > > > > > What's the right way to do this?
> > > > > > > > > > > > 
> > > > > > > > > > > > > Thanks,
> > > > > > > > > > > > 
> > > > > > > > > > > > > Pete

---

<div class="post-metadata">

**Author:** ![Pete\_Aykroyd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pete_aykroyd/32/3293_2.png) [@Pete\_Aykroyd](https://discuss.elastic.co/u/Pete_Aykroyd)\
**Post date:** [December 16, 2010, 9:41pm UTC](https://discuss.elastic.co/t/re-how-to-put-mappings-and-still-get-dynamic-mappings/3658/17 "2010-12-16T21:41:38Z")

</div>

Sure. I was able to re-create a problem with commands in this  
gist[https://gist.github.com/744065](https://gist.github.com/744065)  
.

2010/12/16 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)

> The number of replicas should not be relevant to what you do. Can you  
> "curl" recreate this?
> 
> 2010/12/16 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> 
> > Actually, I take that back. I just had the problem recur. I had switched  
> > the number of replicas to be zero since I'm testing on only 1 node anyway.  
> > When I switched it to 2 replicas, blew away the data, and re-indexed, I ran  
> > into the same problem. I just switched back to 0 replicas and it's fine  
> > again.
> > 
> > 2010/12/15 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > 
> > > So I was doing something like
> > > 
> > > curl -XPUT $ES\_HOST/blocks/block/\_mapping -d '  
> > > {  
> > > "block" : { ....
> > > 
> > > The only change that I think I made was to change the "block" in the json  
> > > body to something like "initial-block-mapping".
> > > 
> > > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > > 
> > > > Great that its working. What do you mean that you named the mapping same  
> > > > thing as the type?
> > > > 
> > > > 2010/12/16 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > > > 
> > > > > Hey,
> > > > > 
> > > > > I got it working... it looks like the mistake I was making was naming  
> > > > > my mapping the same thing as the type. I don't know if that matters or not,  
> > > > > but that appears to be the only difference.
> > > > > 
> > > > > Thanks for all the help!
> > > > > 
> > > > > Pete
> > > > > 
> > > > > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > > > > 
> > > > > > Sounds good. And if you get the mapping back do you see the stored  
> > > > > > mapping def for those fields?
> > > > > > 
> > > > > > 2010/12/16 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > > > > > 
> > > > > > > So that's what I did:
> > > > > > > 
> > > > > > > 1. I deleted data/\*
> > > > > > > 2. started elastic
> > > > > > > 3. created the index with curl
> > > > > > > 4. used that curl command to put the mappings
> > > > > > > 5. and then indexed my docs
> > > > > > > 
> > > > > > > There were no errors while indexing, but the new fields weren't  
> > > > > > > added. I just updated to 0.13.1 to see if that would help. Sorry, if I'm  
> > > > > > > being obtuse here but it seems like I'm doing the right thing.
> > > > > > > 
> > > > > > > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > > > > > > 
> > > > > > > > It doesn't make a difference, but note that those mappings will only  
> > > > > > > > be applied if there was no previous docs before indexed with that field. So,  
> > > > > > > > delete the index, create a new one with the mappings, and then start  
> > > > > > > > indexing.
> > > > > > > > 
> > > > > > > > 2010/12/16 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > > > > > > > 
> > > > > > > > Oh, I see. Sorry for the confusion. I added the mappings for the
> > > > > > > > 
> > > > > > > > > fields that I cared about with the curl command from the previous email  
> > > > > > > > > (pasted below). Does it make a difference whether I do it in java versus  
> > > > > > > > > with the REST API?
> > > > > > > > > 
> > > > > > > > > Thanks,
> > > > > > > > > 
> > > > > > > > > Pete
> > > > > > > > > 
> > > > > > > > > curl -XPUT '[http://localhost:9200/blocks/block/\_mapping](http://localhost:9200/blocks/block/_mapping)' -d '  
> > > > > > > > > {
> > > > > > > > > 
> > > > > > > > > ```
> > > > > > > > > "block": {
> > > > > > > > > "properties": {
> > > > > > > > > "system": {
> > > > > > > > > "store": "yes",
> > > > > > > > > "type": "string"
> > > > > > > > > },
> > > > > > > > > "user": {
> > > > > > > > > "store": "yes",
> > > > > > > > > "type": "string"
> > > > > > > > > }
> > > > > > > > > 
> > > > > > > > > }
> > > > > > > > > }
> > > > > > > > > 
> > > > > > > > > ```
> > > > > > > > > 
> > > > > > > > > }'
> > > > > > > > > 
> > > > > > > > > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > > > > > > > > 
> > > > > > > > > > I don't see where you put the mapping. You can explicitly set  
> > > > > > > > > > mappings for specific fields, and those mappings will apply for them, the  
> > > > > > > > > > rest will be dynamic.
> > > > > > > > > > 
> > > > > > > > > > 2010/12/15 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > > > > > > > > > 
> > > > > > > > > > Not sure exactly what you want. This gist has the mapping that is
> > > > > > > > > > 
> > > > > > > > > > > generated dynamically and the code that does the indexing.
> > > > > > > > > > > 
> > > > > > > > > > > [https://gist.github.com/742513](https://gist.github.com/742513)
> > > > > > > > > > > 
> > > > > > > > > > > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > > > > > > > > > > 
> > > > > > > > > > > Can you gist a full recreation?
> > > > > > > > > > > 
> > > > > > > > > > > > On Wednesday, December 15, 2010 at 1:12 AM, Pete Aykroyd wrote:
> > > > > > > > > > > > 
> > > > > > > > > > > > Thanks... that's a great pointer. I'm not seeing that because  
> > > > > > > > > > > > I've been using 0.13.0. Still curious about this mapping issue though.
> > > > > > > > > > > > 
> > > > > > > > > > > > Pete
> > > > > > > > > > > > 
> > > > > > > > > > > > On Tue, Dec 14, 2010 at 1:39 AM, Medcl [medcl@163.com](mailto:medcl@163.com) wrote:
> > > > > > > > > > > > 
> > > > > > > > > > > > as i know,es now can direct use \_source's item as field's  
> > > > > > > > > > > > value,check  
> > > > > > > > > > > > it out,  
> > > > > > > > > > > > [Search Fields: If a field is not stored, automatically extract it from \_source (without the need for \_source prefix) · Issue #562 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/issue/562)
> > > > > > > > > > > > 
> > > > > > > > > > > > On 12月14日, 上午10时31分, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com)  
> > > > > > > > > > > > wrote:
> > > > > > > > > > > > 
> > > > > > > > > > > > > Setting the mapping in advance for those fields, and indexing  
> > > > > > > > > > > > > will retain the dynamic nature for the rest of the document. Can you maybe  
> > > > > > > > > > > > > gist your put mapping code, and how you detect the other fields are not  
> > > > > > > > > > > > > being indexed?
> > > > > > > > > > > > > 
> > > > > > > > > > > > > On Tuesday, December 14, 2010 at 12:40 AM, Pete Aykroyd wrote:
> > > > > > > > > > > > > 
> > > > > > > > > > > > > > Hi,
> > > > > > > > > > > > > 
> > > > > > > > > > > > > > I think I'm probably missing something obvious but I can't  
> > > > > > > > > > > > > > figure how to set a few mappings manually on my schema and retain the  
> > > > > > > > > > > > > > automatic mappings.
> > > > > > > > > > > > > 
> > > > > > > > > > > > > > The exact problem is that I've been using elastic for the  
> > > > > > > > > > > > > > past week or so completely with the dynamic schema mappings and everything  
> > > > > > > > > > > > > > was fine. But I now want to sometimes return a field with my query... So  
> > > > > > > > > > > > > > there are a few fields in the schema that I want to set stored to true on.  
> > > > > > > > > > > > > > For the rest of the fields, I want them to continue to get their mappings  
> > > > > > > > > > > > > > dynamically, since there are a lot of them and more may be added in the  
> > > > > > > > > > > > > > future.
> > > > > > > > > > > > > 
> > > > > > > > > > > > > > If try to put a mapping for just that the field with data  
> > > > > > > > > > > > > > already indexed, obviously there is a merge conflict because it has already  
> > > > > > > > > > > > > > had indexed those fields with stored = false.  
> > > > > > > > > > > > > > If I set ignore\_conflicts to true and then re-index my data,  
> > > > > > > > > > > > > > it doesn't seem to have any effect and checking the \_mapping shows that  
> > > > > > > > > > > > > > stored still isn't set.  
> > > > > > > > > > > > > > I've tried blowing away the index completely, then setting a  
> > > > > > > > > > > > > > mapping with the two fields I care about being stored in it, and then  
> > > > > > > > > > > > > > re-indexing, but then nothing else is mapped.
> > > > > > > > > > > > > 
> > > > > > > > > > > > > > What's the right way to do this?
> > > > > > > > > > > > > 
> > > > > > > > > > > > > > Thanks,
> > > > > > > > > > > > > 
> > > > > > > > > > > > > > Pete

---

<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:** [December 16, 2010, 10:24pm UTC](https://discuss.elastic.co/t/re-how-to-put-mappings-and-still-get-dynamic-mappings/3658/18 "2010-12-16T22:24:25Z")

</div>

I don't really understand how this recreates the mapping problem? The reason  
you can't index is that you created 2 replicas in the index, and started one  
nodes, and, by default, a write (index) only works when there is a quorum of  
shards active within the shard replication group. In your case, there is 1  
shard active per replication groups, and 2 replicas not allocated (because  
replicas are not allocated on the same node), and the quorum is 2.

2010/12/16 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)

> Sure. I was able to re-create a problem with commands in this gist[https://gist.github.com/744065](https://gist.github.com/744065)  
> .
> 
> 2010/12/16 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> 
> The number of replicas should not be relevant to what you do. Can you
> 
> > "curl" recreate this?
> > 
> > 2010/12/16 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > 
> > > Actually, I take that back. I just had the problem recur. I had switched  
> > > the number of replicas to be zero since I'm testing on only 1 node anyway.  
> > > When I switched it to 2 replicas, blew away the data, and re-indexed, I ran  
> > > into the same problem. I just switched back to 0 replicas and it's fine  
> > > again.
> > > 
> > > 2010/12/15 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > > 
> > > > So I was doing something like
> > > > 
> > > > curl -XPUT $ES\_HOST/blocks/block/\_mapping -d '  
> > > > {  
> > > > "block" : { ....
> > > > 
> > > > The only change that I think I made was to change the "block" in the  
> > > > json body to something like "initial-block-mapping".
> > > > 
> > > > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > > > 
> > > > > Great that its working. What do you mean that you named the mapping  
> > > > > same thing as the type?
> > > > > 
> > > > > 2010/12/16 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > > > > 
> > > > > > Hey,
> > > > > > 
> > > > > > I got it working... it looks like the mistake I was making was naming  
> > > > > > my mapping the same thing as the type. I don't know if that matters or not,  
> > > > > > but that appears to be the only difference.
> > > > > > 
> > > > > > Thanks for all the help!
> > > > > > 
> > > > > > Pete
> > > > > > 
> > > > > > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > > > > > 
> > > > > > > Sounds good. And if you get the mapping back do you see the stored  
> > > > > > > mapping def for those fields?
> > > > > > > 
> > > > > > > 2010/12/16 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > > > > > > 
> > > > > > > > So that's what I did:
> > > > > > > > 
> > > > > > > > 1. I deleted data/\*
> > > > > > > > 2. started elastic
> > > > > > > > 3. created the index with curl
> > > > > > > > 4. used that curl command to put the mappings
> > > > > > > > 5. and then indexed my docs
> > > > > > > > 
> > > > > > > > There were no errors while indexing, but the new fields weren't  
> > > > > > > > added. I just updated to 0.13.1 to see if that would help. Sorry, if I'm  
> > > > > > > > being obtuse here but it seems like I'm doing the right thing.
> > > > > > > > 
> > > > > > > > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > > > > > > > 
> > > > > > > > > It doesn't make a difference, but note that those mappings will  
> > > > > > > > > only be applied if there was no previous docs before indexed with that  
> > > > > > > > > field. So, delete the index, create a new one with the mappings, and then  
> > > > > > > > > start indexing.
> > > > > > > > > 
> > > > > > > > > 2010/12/16 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > > > > > > > > 
> > > > > > > > > Oh, I see. Sorry for the confusion. I added the mappings for the
> > > > > > > > > 
> > > > > > > > > > fields that I cared about with the curl command from the previous email  
> > > > > > > > > > (pasted below). Does it make a difference whether I do it in java versus  
> > > > > > > > > > with the REST API?
> > > > > > > > > > 
> > > > > > > > > > Thanks,
> > > > > > > > > > 
> > > > > > > > > > Pete
> > > > > > > > > > 
> > > > > > > > > > curl -XPUT '[http://localhost:9200/blocks/block/\_mapping](http://localhost:9200/blocks/block/_mapping)' -d '  
> > > > > > > > > > {
> > > > > > > > > > 
> > > > > > > > > > ```
> > > > > > > > > > "block": {
> > > > > > > > > > "properties": {
> > > > > > > > > > "system": {
> > > > > > > > > > "store": "yes",
> > > > > > > > > > "type": "string"
> > > > > > > > > > },
> > > > > > > > > > "user": {
> > > > > > > > > > "store": "yes",
> > > > > > > > > > "type": "string"
> > > > > > > > > > }
> > > > > > > > > > 
> > > > > > > > > > }
> > > > > > > > > > }
> > > > > > > > > > 
> > > > > > > > > > ```
> > > > > > > > > > 
> > > > > > > > > > }'
> > > > > > > > > > 
> > > > > > > > > > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > > > > > > > > > 
> > > > > > > > > > > I don't see where you put the mapping. You can explicitly set  
> > > > > > > > > > > mappings for specific fields, and those mappings will apply for them, the  
> > > > > > > > > > > rest will be dynamic.
> > > > > > > > > > > 
> > > > > > > > > > > 2010/12/15 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > > > > > > > > > > 
> > > > > > > > > > > Not sure exactly what you want. This gist has the mapping that is
> > > > > > > > > > > 
> > > > > > > > > > > > generated dynamically and the code that does the indexing.
> > > > > > > > > > > > 
> > > > > > > > > > > > [https://gist.github.com/742513](https://gist.github.com/742513)
> > > > > > > > > > > > 
> > > > > > > > > > > > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > > > > > > > > > > > 
> > > > > > > > > > > > Can you gist a full recreation?
> > > > > > > > > > > > 
> > > > > > > > > > > > > On Wednesday, December 15, 2010 at 1:12 AM, Pete Aykroyd wrote:
> > > > > > > > > > > > > 
> > > > > > > > > > > > > Thanks... that's a great pointer. I'm not seeing that because  
> > > > > > > > > > > > > I've been using 0.13.0. Still curious about this mapping issue though.
> > > > > > > > > > > > > 
> > > > > > > > > > > > > Pete
> > > > > > > > > > > > > 
> > > > > > > > > > > > > On Tue, Dec 14, 2010 at 1:39 AM, Medcl [medcl@163.com](mailto:medcl@163.com) wrote:
> > > > > > > > > > > > > 
> > > > > > > > > > > > > as i know,es now can direct use \_source's item as field's  
> > > > > > > > > > > > > value,check  
> > > > > > > > > > > > > it out,  
> > > > > > > > > > > > > [Search Fields: If a field is not stored, automatically extract it from \_source (without the need for \_source prefix) · Issue #562 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/issue/562)
> > > > > > > > > > > > > 
> > > > > > > > > > > > > On 12月14日, 上午10时31分, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com)  
> > > > > > > > > > > > > wrote:
> > > > > > > > > > > > > 
> > > > > > > > > > > > > > Setting the mapping in advance for those fields, and  
> > > > > > > > > > > > > > indexing will retain the dynamic nature for the rest of the document. Can  
> > > > > > > > > > > > > > you maybe gist your put mapping code, and how you detect the other fields  
> > > > > > > > > > > > > > are not being indexed?
> > > > > > > > > > > > > > 
> > > > > > > > > > > > > > On Tuesday, December 14, 2010 at 12:40 AM, Pete Aykroyd  
> > > > > > > > > > > > > > wrote:
> > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > Hi,
> > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > I think I'm probably missing something obvious but I can't  
> > > > > > > > > > > > > > > figure how to set a few mappings manually on my schema and retain the  
> > > > > > > > > > > > > > > automatic mappings.
> > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > The exact problem is that I've been using elastic for the  
> > > > > > > > > > > > > > > past week or so completely with the dynamic schema mappings and everything  
> > > > > > > > > > > > > > > was fine. But I now want to sometimes return a field with my query... So  
> > > > > > > > > > > > > > > there are a few fields in the schema that I want to set stored to true on.  
> > > > > > > > > > > > > > > For the rest of the fields, I want them to continue to get their mappings  
> > > > > > > > > > > > > > > dynamically, since there are a lot of them and more may be added in the  
> > > > > > > > > > > > > > > future.
> > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > If try to put a mapping for just that the field with data  
> > > > > > > > > > > > > > > already indexed, obviously there is a merge conflict because it has already  
> > > > > > > > > > > > > > > had indexed those fields with stored = false.  
> > > > > > > > > > > > > > > If I set ignore\_conflicts to true and then re-index my  
> > > > > > > > > > > > > > > data, it doesn't seem to have any effect and checking the \_mapping shows  
> > > > > > > > > > > > > > > that stored still isn't set.  
> > > > > > > > > > > > > > > I've tried blowing away the index completely, then setting  
> > > > > > > > > > > > > > > a mapping with the two fields I care about being stored in it, and then  
> > > > > > > > > > > > > > > re-indexing, but then nothing else is mapped.
> > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > What's the right way to do this?
> > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > Thanks,
> > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > Pete

---

<div class="post-metadata">

**Author:** ![Pete\_Aykroyd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pete_aykroyd/32/3293_2.png) [@Pete\_Aykroyd](https://discuss.elastic.co/u/Pete_Aykroyd)\
**Post date:** [December 16, 2010, 10:50pm UTC](https://discuss.elastic.co/t/re-how-to-put-mappings-and-still-get-dynamic-mappings/3658/19 "2010-12-16T22:50:12Z")

</div>

Yeah, I didn't realize that, although it makes sense. I'm assuming that an  
exception would have also been thrown in java then. It must have gotten  
swallowed somewhere. In any case, thanks for your help.

Pete

2010/12/16 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)

> I don't really understand how this recreates the mapping problem? The  
> reason you can't index is that you created 2 replicas in the index, and  
> started one nodes, and, by default, a write (index) only works when there is  
> a quorum of shards active within the shard replication group. In your case,  
> there is 1 shard active per replication groups, and 2 replicas not allocated  
> (because replicas are not allocated on the same node), and the quorum is 2.
> 
> 2010/12/16 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> 
> > Sure. I was able to re-create a problem with commands in this gist[https://gist.github.com/744065](https://gist.github.com/744065)  
> > .
> > 
> > 2010/12/16 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > 
> > The number of replicas should not be relevant to what you do. Can you
> > 
> > > "curl" recreate this?
> > > 
> > > 2010/12/16 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > > 
> > > > Actually, I take that back. I just had the problem recur. I had switched  
> > > > the number of replicas to be zero since I'm testing on only 1 node anyway.  
> > > > When I switched it to 2 replicas, blew away the data, and re-indexed, I ran  
> > > > into the same problem. I just switched back to 0 replicas and it's fine  
> > > > again.
> > > > 
> > > > 2010/12/15 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > > > 
> > > > > So I was doing something like
> > > > > 
> > > > > curl -XPUT $ES\_HOST/blocks/block/\_mapping -d '  
> > > > > {  
> > > > > "block" : { ....
> > > > > 
> > > > > The only change that I think I made was to change the "block" in the  
> > > > > json body to something like "initial-block-mapping".
> > > > > 
> > > > > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > > > > 
> > > > > > Great that its working. What do you mean that you named the mapping  
> > > > > > same thing as the type?
> > > > > > 
> > > > > > 2010/12/16 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > > > > > 
> > > > > > > Hey,
> > > > > > > 
> > > > > > > I got it working... it looks like the mistake I was making was naming  
> > > > > > > my mapping the same thing as the type. I don't know if that matters or not,  
> > > > > > > but that appears to be the only difference.
> > > > > > > 
> > > > > > > Thanks for all the help!
> > > > > > > 
> > > > > > > Pete
> > > > > > > 
> > > > > > > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > > > > > > 
> > > > > > > > Sounds good. And if you get the mapping back do you see the stored  
> > > > > > > > mapping def for those fields?
> > > > > > > > 
> > > > > > > > 2010/12/16 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > > > > > > > 
> > > > > > > > > So that's what I did:
> > > > > > > > > 
> > > > > > > > > 1. I deleted data/\*
> > > > > > > > > 2. started elastic
> > > > > > > > > 3. created the index with curl
> > > > > > > > > 4. used that curl command to put the mappings
> > > > > > > > > 5. and then indexed my docs
> > > > > > > > > 
> > > > > > > > > There were no errors while indexing, but the new fields weren't  
> > > > > > > > > added. I just updated to 0.13.1 to see if that would help. Sorry, if I'm  
> > > > > > > > > being obtuse here but it seems like I'm doing the right thing.
> > > > > > > > > 
> > > > > > > > > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > > > > > > > > 
> > > > > > > > > > It doesn't make a difference, but note that those mappings will  
> > > > > > > > > > only be applied if there was no previous docs before indexed with that  
> > > > > > > > > > field. So, delete the index, create a new one with the mappings, and then  
> > > > > > > > > > start indexing.
> > > > > > > > > > 
> > > > > > > > > > 2010/12/16 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > > > > > > > > > 
> > > > > > > > > > Oh, I see. Sorry for the confusion. I added the mappings for the
> > > > > > > > > > 
> > > > > > > > > > > fields that I cared about with the curl command from the previous email  
> > > > > > > > > > > (pasted below). Does it make a difference whether I do it in java versus  
> > > > > > > > > > > with the REST API?
> > > > > > > > > > > 
> > > > > > > > > > > Thanks,
> > > > > > > > > > > 
> > > > > > > > > > > Pete
> > > > > > > > > > > 
> > > > > > > > > > > curl -XPUT '[http://localhost:9200/blocks/block/\_mapping](http://localhost:9200/blocks/block/_mapping)' -d '  
> > > > > > > > > > > {
> > > > > > > > > > > 
> > > > > > > > > > > ```
> > > > > > > > > > > "block": {
> > > > > > > > > > > "properties": {
> > > > > > > > > > > "system": {
> > > > > > > > > > > "store": "yes",
> > > > > > > > > > > "type": "string"
> > > > > > > > > > > },
> > > > > > > > > > > "user": {
> > > > > > > > > > > "store": "yes",
> > > > > > > > > > > "type": "string"
> > > > > > > > > > > }
> > > > > > > > > > > 
> > > > > > > > > > > }
> > > > > > > > > > > }
> > > > > > > > > > > 
> > > > > > > > > > > ```
> > > > > > > > > > > 
> > > > > > > > > > > }'
> > > > > > > > > > > 
> > > > > > > > > > > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > > > > > > > > > > 
> > > > > > > > > > > > I don't see where you put the mapping. You can explicitly set  
> > > > > > > > > > > > mappings for specific fields, and those mappings will apply for them, the  
> > > > > > > > > > > > rest will be dynamic.
> > > > > > > > > > > > 
> > > > > > > > > > > > 2010/12/15 Pete Aykroyd [aykroyd@gmail.com](mailto:aykroyd@gmail.com)
> > > > > > > > > > > > 
> > > > > > > > > > > > Not sure exactly what you want. This gist has the mapping that
> > > > > > > > > > > > 
> > > > > > > > > > > > > is generated dynamically and the code that does the indexing.
> > > > > > > > > > > > > 
> > > > > > > > > > > > > [https://gist.github.com/742513](https://gist.github.com/742513)
> > > > > > > > > > > > > 
> > > > > > > > > > > > > 2010/12/15 Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)
> > > > > > > > > > > > > 
> > > > > > > > > > > > > Can you gist a full recreation?
> > > > > > > > > > > > > 
> > > > > > > > > > > > > > On Wednesday, December 15, 2010 at 1:12 AM, Pete Aykroyd  
> > > > > > > > > > > > > > wrote:
> > > > > > > > > > > > > > 
> > > > > > > > > > > > > > Thanks... that's a great pointer. I'm not seeing that because  
> > > > > > > > > > > > > > I've been using 0.13.0. Still curious about this mapping issue though.
> > > > > > > > > > > > > > 
> > > > > > > > > > > > > > Pete
> > > > > > > > > > > > > > 
> > > > > > > > > > > > > > On Tue, Dec 14, 2010 at 1:39 AM, Medcl [medcl@163.com](mailto:medcl@163.com) wrote:
> > > > > > > > > > > > > > 
> > > > > > > > > > > > > > as i know,es now can direct use \_source's item as field's  
> > > > > > > > > > > > > > value,check  
> > > > > > > > > > > > > > it out,  
> > > > > > > > > > > > > > [Search Fields: If a field is not stored, automatically extract it from \_source (without the need for \_source prefix) · Issue #562 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/issue/562)
> > > > > > > > > > > > > > 
> > > > > > > > > > > > > > On 12月14日, 上午10时31分, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com)  
> > > > > > > > > > > > > > wrote:
> > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > Setting the mapping in advance for those fields, and  
> > > > > > > > > > > > > > > indexing will retain the dynamic nature for the rest of the document. Can  
> > > > > > > > > > > > > > > you maybe gist your put mapping code, and how you detect the other fields  
> > > > > > > > > > > > > > > are not being indexed?
> > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > On Tuesday, December 14, 2010 at 12:40 AM, Pete Aykroyd  
> > > > > > > > > > > > > > > wrote:
> > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > > Hi,
> > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > > I think I'm probably missing something obvious but I can't  
> > > > > > > > > > > > > > > > figure how to set a few mappings manually on my schema and retain the  
> > > > > > > > > > > > > > > > automatic mappings.
> > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > > The exact problem is that I've been using elastic for the  
> > > > > > > > > > > > > > > > past week or so completely with the dynamic schema mappings and everything  
> > > > > > > > > > > > > > > > was fine. But I now want to sometimes return a field with my query... So  
> > > > > > > > > > > > > > > > there are a few fields in the schema that I want to set stored to true on.  
> > > > > > > > > > > > > > > > For the rest of the fields, I want them to continue to get their mappings  
> > > > > > > > > > > > > > > > dynamically, since there are a lot of them and more may be added in the  
> > > > > > > > > > > > > > > > future.
> > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > > If try to put a mapping for just that the field with data  
> > > > > > > > > > > > > > > > already indexed, obviously there is a merge conflict because it has already  
> > > > > > > > > > > > > > > > had indexed those fields with stored = false.  
> > > > > > > > > > > > > > > > If I set ignore\_conflicts to true and then re-index my  
> > > > > > > > > > > > > > > > data, it doesn't seem to have any effect and checking the \_mapping shows  
> > > > > > > > > > > > > > > > that stored still isn't set.  
> > > > > > > > > > > > > > > > I've tried blowing away the index completely, then setting  
> > > > > > > > > > > > > > > > a mapping with the two fields I care about being stored in it, and then  
> > > > > > > > > > > > > > > > re-indexing, but then nothing else is mapped.
> > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > > What's the right way to do this?
> > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > > Thanks,
> > > > > > > > > > > > > > > 
> > > > > > > > > > > > > > > > Pete

---

<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:15am UTC](https://discuss.elastic.co/t/re-how-to-put-mappings-and-still-get-dynamic-mappings/3658/20 "2017-07-06T04:15:13Z")

</div>


