The behavior is applied at the creation of the index within the mapping, not during the prepareIndex call. The example you provided is part of the mapping and not part of the document that gets indexed. If you want to override which field will be used as the _id field, you would need to change your mapping.
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-id-field.html Cheers, Ivan On Sun, Jul 27, 2014 at 11:09 AM, Kireet Reddy <[email protected]> wrote: > You should check out the IndexRequestBuilder class. It helps simplify > creating indexing requests and has a setId() method. > > > On Friday, July 25, 2014 4:22:42 PM UTC-7, Chia-Eng Chang wrote: >> >> I want to ask if the unique field _id be assigned by certain field within >> document. I see with Rest, it can achieve by "path": >> >> { >> "tweet" : { >> "_id" : { >> "path" : "post_id" >> } >> } >> } >> >> But if I want to do it with java API, is there any way to achieve it? >> >> Map<String, Object> MapA= new HashMap<String, Object>(); >> MapA=MapProcessor(MapA); >> >> >> client.prepareIndex("index","type").setSource(MapA).execute().actionGet(); >> >> How could I modify my code to assign certain field in Map to become _id >> of this type? >> > -- > 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/66966b06-71dc-4ff9-a863-4371bf9ca368%40googlegroups.com > <https://groups.google.com/d/msgid/elasticsearch/66966b06-71dc-4ff9-a863-4371bf9ca368%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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQAnTcE9BArRFLox7iSuE3nt49dG3y0rC1pB%3DLNqecVtbQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
