# Mapping problem

**URL:** <https://discuss.elastic.co/t/mapping-problem/3884>\
**Category:** Elasticsearch\
**Created:** [February 4, 2011, 5:15pm UTC](https://discuss.elastic.co/t/mapping-problem/3884 "2011-02-04T17:15:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![stelios](https://avatars.discourse-cdn.com/v4/letter/s/8dc957/32.png) [@stelios](https://discuss.elastic.co/u/stelios)\
**Post date:** [February 4, 2011, 5:15pm UTC](https://discuss.elastic.co/t/mapping-problem/3884/1 "2011-02-04T17:15:36Z")

</div>

Hi,

weird behaviour on mapping....

## In a JUnit test I create an index like this:

## // 1) Create the index CreateIndexResponse indexResponse = client.admin().indices().create( createIndexRequest(IDX\_NAME) ).actionGet(); assertTrue(indexResponse.acknowledged());

## then add a mapping for it like this:

## // 2) Create the mapping // NB. This will fail if no such INDEX exists PutMappingRequestBuilder mappBuilder = new PutMappingRequestBuilder(client.admin().indices()); mappBuilder.setSource(mapData); mappBuilder.setIndices(IDX\_NAME); PutMappingResponse mappResponse = mappBuilder.execute().actionGet(); // Double check checkMapping(client); assertTrue(mappResponse.acknowledged());

## here is the mapping

## // The mapping def // FIXME: if using "analyzed" instead of "not\_analyzed" it doesn't work... String mapData = "{ \n" + " "file" : { \n " + " "properties" : { \n" + " "name" : {"type" : "string", "index" : "not\_analyzed", "store" : "yes"} \n" + " }\n" + " }\n" + "}";

What happens is that this only works when using "index" :  
"not\_analyzed"  
I can retrieve the mapping (through the ClusterAdminClient) and see  
it's all there.

when using "index" : "not\_analyzed" it just won't get the mapping I've  
put (although acknowledged() returns true...)  
The mapping that is created is this:  
MAPPING =========\> {"file":{"properties":{"name":  
{"type":"string","store":"yes"}}}}

is this a bug a something wrong in my implementation?

ES version: 0.14.2  
In general I have default settings for everything but I can post the  
whole file if needed.

Thanks  
Stelios

---

<div class="post-metadata">

**Author:** ![stelios](https://avatars.discourse-cdn.com/v4/letter/s/8dc957/32.png) [@stelios](https://discuss.elastic.co/u/stelios)\
**Post date:** [February 4, 2011, 5:55pm UTC](https://discuss.elastic.co/t/mapping-problem/3884/2 "2011-02-04T17:55:08Z")

</div>

Just found in the docs that "index":analyzed is the default.  
Tested with ommiting the index definition (so it should use the  
default) and the mapping is put correctly.

stelios

On Feb 4, 6:15 pm, stelios [stetog...@gmail.com](mailto:stetog...@gmail.com) wrote:

> Hi,
> 
> weird behaviour on mapping....
> 
> ## In a JUnit test I create an index like this:
> 
> ## // 1) Create the index CreateIndexResponse indexResponse = client.admin().indices().create( createIndexRequest(IDX\_NAME) ).actionGet(); assertTrue(indexResponse.acknowledged());
> 
> ## then add a mapping for it like this:
> 
> ## // 2) Create the mapping // NB. This will fail if no such INDEX exists PutMappingRequestBuilder mappBuilder = new PutMappingRequestBuilder(client.admin().indices()); mappBuilder.setSource(mapData); mappBuilder.setIndices(IDX\_NAME); PutMappingResponse mappResponse = mappBuilder.execute().actionGet(); // Double check checkMapping(client); assertTrue(mappResponse.acknowledged());
> 
> ## here is the mapping
> 
> ## // The mapping def // FIXME: if using "analyzed" instead of "not\_analyzed" it doesn't work... String mapData = "{ \n" + " "file" : { \n " + " "properties" : { \n" + " "name" : {"type" : "string", "index" : "not\_analyzed", "store" : "yes"} \n" + " }\n" + " }\n" + "}";
> 
> What happens is that this only works when using "index" :  
> "not\_analyzed"  
> I can retrieve the mapping (through the ClusterAdminClient) and see  
> it's all there.
> 
> when using "index" : "not\_analyzed" it just won't get the mapping I've  
> put (although acknowledged() returns true...)  
> The mapping that is created is this:  
> MAPPING =========\> {"file":{"properties":{"name":  
> {"type":"string","store":"yes"}}}}
> 
> is this a bug a something wrong in my implementation?
> 
> ES version: 0.14.2  
> In general I have default settings for everything but I can post the  
> whole file if needed.
> 
> Thanks  
> Stelios

---

<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:** [February 7, 2011, 6:06pm UTC](https://discuss.elastic.co/t/mapping-problem/3884/3 "2011-02-07T18:06:38Z")

</div>

Just a note regarding your usage of the API, nicer to use this:

client.admin().indices().preparePutMapping(...).set(...).execute().actionGet();  
On Friday, February 4, 2011 at 7:55 PM, stelios wrote:

> Just found in the docs that "index":analyzed is the default.  
> Tested with ommiting the index definition (so it should use the  
> default) and the mapping is put correctly.
> 
> stelios
> 
> On Feb 4, 6:15 pm, stelios [stetog...@gmail.com](mailto:stetog...@gmail.com) wrote:
> 
> > Hi,
> > 
> > weird behaviour on mapping....
> > 
> > ## In a JUnit test I create an index like this:
> > 
> > ## // 1) Create the index CreateIndexResponse indexResponse = client.admin().indices().create( createIndexRequest(IDX\_NAME) ).actionGet(); assertTrue(indexResponse.acknowledged());
> > 
> > ## then add a mapping for it like this:
> > 
> > ## // 2) Create the mapping // NB. This will fail if no such INDEX exists PutMappingRequestBuilder mappBuilder = new PutMappingRequestBuilder(client.admin().indices()); mappBuilder.setSource(mapData); mappBuilder.setIndices(IDX\_NAME); PutMappingResponse mappResponse = mappBuilder.execute().actionGet(); // Double check checkMapping(client); assertTrue(mappResponse.acknowledged());
> > 
> > ## here is the mapping
> > 
> > ## // The mapping def // FIXME: if using "analyzed" instead of "not\_analyzed" it doesn't work... String mapData = "{ \n" + " "file" : { \n " + " "properties" : { \n" + " "name" : {"type" : "string", "index" : "not\_analyzed", "store" : "yes"} \n" + " }\n" + " }\n" + "}";
> > 
> > What happens is that this only works when using "index" :  
> > "not\_analyzed"  
> > I can retrieve the mapping (through the ClusterAdminClient) and see  
> > it's all there.
> > 
> > when using "index" : "not\_analyzed" it just won't get the mapping I've  
> > put (although acknowledged() returns true...)  
> > The mapping that is created is this:  
> > MAPPING =========\> {"file":{"properties":{"name":  
> > {"type":"string","store":"yes"}}}}
> > 
> > is this a bug a something wrong in my implementation?
> > 
> > ES version: 0.14.2  
> > In general I have default settings for everything but I can post the  
> > whole file if needed.
> > 
> > Thanks  
> > Stelios

---

<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:12am UTC](https://discuss.elastic.co/t/mapping-problem/3884/4 "2017-07-06T04:12:31Z")

</div>


