@Andre might be a stupid question, but why are you trying to set a format 
for a string field and set 'index' on a long field? Afaics from the guide 
(http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/mapping-core-types.html)
 
neither of these things are supported, so is it that surprising that 
elasticsearch drops the invalid attributes?

On Wednesday, February 26, 2014 11:51:32 PM UTC, Andre Encarnacao wrote:
>
> I am trying to use the Java API (v1.0.0) to create a custom mapping for my 
> index but have run into a problem. More specifically, some of my mapping 
> fields (for example, "format" and "index") are not being stored as part of 
> the mapping in Elastic Search. In fact, the only field that is being stored 
> is the "type" field. However, if I use the CURL API, everything works as 
> expected and all fields are stored properly in my mapping. Has anyone seen 
> this problem when using the Java API? Is this a bug? I put together a very 
> simple example that demonstrates my bug below:
>
>
> --- SOURCE CODE ---
>
> Client client = new TransportClient().addTransportAddress(new 
> InetSocketTransportAddress(_hostname,_port));
>
> XContentBuilder mapping = XContentFactory.jsonBuilder()
>                     .startObject().startObject("type_name")
>                         .startObject("properties")
>                             .startObject("ATTRIBUTE1")
>                                 .field("type","string")
>                                 .field("format","dateOptionalTime")
>                             .endObject()
>                             .startObject("ATTRIBUTE2")
>                                 .field("type","long")
>                                 .field("index","not_analyzed")
>                                 .endObject()
>                             .endObject()
>                         .endObject()
>                     .endObject();
>             
>
> client.admin().indices().preparePutMapping("index_name").setType("type_name").setSource(mapping).execute().actionGet();
>             
>
> --- OUTPUT ---
>
> Below is the mapping created in ES after running the code snippet above 
> (from http://localhost:9200/index_name/_mapping?pretty). Notice that only 
> the "type" fields were stored in the mapping.
> {
>   "index_name" : {
>     "mappings" : {
>       "type_name" : {
>         "properties" : {
>           "ATTRIBUTE1" : {
>             "type" : "string"
>           },
>           "ATTRIBUTE2" : {
>             "type" : "long"
>           }
>         }
>       }
>     }
>   }
> }
>
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/fae41878-ce9d-41ea-9f84-24acd0657095%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to