From a 10.000 feet point of view, your code looks good to me.
The only for mapping to change as you described is that type has been removed between the two run.
I don't see any other explanation.
What can you see in elasticsearch node logs? Before the first test, after the first test and after the second test?
--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr
Le 27 avril 2014 à 12:49:10, Ho-sang Jeon (jhsbeat@gmail.com) a écrit:
Thank you very much David Pilato.
OK. Here is my GIST https://gist.github.com/jhsbeat/11342294
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
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
Le 27 avr. 2014 à 11:36, Ho-sang Jeon jhs...@gmail.com 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.
I'm using Elasticsearch version 0.90.0.
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
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 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.
--
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/etPan.535ec3a2.2d1d5ae9.16bd1%40MacBook-Air-de-David.local.
For more options, visit https://groups.google.com/d/optout.