Elasticsearch Java API prepareIndex overwrites existing mapping

Thank you very much David Pilato.

OK. Here is my GIST Elasticsearch overwriting mapping problem GIST · GitHub

In GistTest.java, after I exectued "testPutMappingTemplate()" method, I can
get the mapping below.

{"my_type":{"properties":{"dataId":{"type":"long"},"myFieldList":{"properties":{"myFieldExact":{"type":"string","index":"not_analyzed","omit_norms":true,"index_options":"docs"}}}}}}

However, after I ran "testIndexNewObject()" method, I got the mapping below.

{"my_type":{"properties":{"dataId":{"type":"long"},"myFieldList":{"properties":{"myFieldExact":{"type":"string"}}}}}}

Do I have to remove my whole index and recreate it?

On Sunday, April 27, 2014 6:51:00 PM UTC+9, David Pilato wrote:

I think you are pasting here your actual data.

So it's hard to tell where you are doing something wrong.

May be you could GIST a full curl/SENSE recreation?

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 27 avr. 2014 à 11:36, Ho-sang Jeon <jhs...@gmail.com <javascript:>> a
écrit :

Thanks David Pilato.

However, as I mentioned, I could see the correct mappings for the correct
index and type like below.

curl -XGET http://{my_ip_address}:9200/my_index/my_type/_mapping/

{"my_type":{"properties":{........ "myFieldExact":{"type":"string","index"
:"not_analyzed","omit_norms":true,"index_options":"docs"},...... }}}

After I index a new document into the index I got the changed mapping
result for the exactly same GET url.

curl -XGET http://{my_ip_address}:9200/my_index/my_type/_mapping/

{"my_type":{"properties":{........ "myFieldExact":{"type":"string"},......
}}}

Here are some more detailed information.

  1. I'm using Elasticsearch version 0.90.0.
  2. The field "myFieldExact" is actually in an array. The real
    documents seem like below.

myFieldList: [
{
myFieldExact: "ABCD-1"
},
{
myFieldExact: "ABCD-2"
},
{
myFieldExact: "ABCD-2"
}
]

On Sunday, April 27, 2014 5:52:03 PM UTC+9, David Pilato wrote:

Probably your first mapping is incorrect or applied to another type or
index.

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 27 avr. 2014 à 09:45, Ho-sang Jeon jhs...@gmail.com a écrit :

I'm in trouble with the overwriting action of prepareIndex method in
Elasticsearch Java API.

The problem is that my mapping definition has changed after new
document has indexed.

First of all, I defined an mapping to set "not_analyzed" index for a
particular field.

String json = myMethodToGetMapping();
PutMappingResponse pmrs = client.admin().indices().preparePutMapping(
"my_index").setType("my_type").setSource(json).setIgnoreConflicts(true).
execute().actionGet();

if (pmrs == null || !pmrs.isAcknowledged()) {
System.out.println("Put Mapping Failure.");
} else {
System.out.println("Put Mapping Success.");
}

In my mapping string(json), there is a field has settings like below.

"myFieldExact":{
"type":"string",
"index": "not_analyzed",
"dynamic": false
}

After the code has executed, I could see the proper mapping which I want
to get.

curl -XGET http://{my_ip_address}:9200/my_index/my_type/_mapping/

{"my_type":{"properties":{........ "myFieldExact":{"type":"string",
"index":"not_analyzed","omit_norms":true,"index_options":"docs"},......
}}}

HOWEVER, this mapping has been changed after I put some data using
Java API prepareIndex.

MyObject myObject = new MyObject();
myObject.setMyFieldExact("some-value");
String json = new org.codehaus.jackson.map.ObjectMapper().
writeValueAsString(myObject);
client.prepareIndex("my_index", "my_type", "my_id")
.setSource(json).execute().actionGet();

The document successfully indexed into "my_index/my_type/my_id".

Here is the problem I have.

After the new record has been indexed, the original mapping definition
has changed like below.

curl -XGET http://{my_ip_address}:9200/my_index/my_type/_mapping/

{"my_type":{"properties":{........ "myFieldExact":{"type":"string"
},...... }}}

In short, the "index":"not_analyzed" property has been gone after the
new document has indexed.

Is there anyone can help me?

Thank you very much in advance.

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearc...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/5ee40a83-272b-4843-ba6f-f79b78737942%40googlegroups.comhttps://groups.google.com/d/msgid/elasticsearch/5ee40a83-272b-4843-ba6f-f79b78737942%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearc...@googlegroups.com <javascript:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/fb95c354-b1ad-4920-940d-e678d430e9fc%40googlegroups.comhttps://groups.google.com/d/msgid/elasticsearch/fb95c354-b1ad-4920-940d-e678d430e9fc%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/e9099a04-6b73-4eb0-b43a-dbc836067005%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.