JSON document as a value using java api

Hello,

I am trying to add a json document as a value in a field using the
java ap

IndexResponse response = client
.prepareIndex(name, type)
.setSource(
jsonBuilder().startObject().field("user", user)
.field("date", new Date())
.field("doc", json))
.execute().actionGet();

By default elasticsearch assumes json is of type string and index the
whole documents as a single string.
Is there a way I can tell ES that this is a json document and specify
the specific fields to be indexed without having to iterate through
the entire object in code? Can I also store json as a child json
object rather than string?

Thanks

You can do that, requires a bit more coding, here is an example of how the elasticsearch flume integration does it: https://github.com/tallpsmith/elasticflume/blob/master/src/main/java/org/elasticsearch/flume/ElasticSearchSink.java.
On Sunday, March 20, 2011 at 7:34 PM, vgarg wrote:

Hello,

I am trying to add a json document as a value in a field using the
java ap

IndexResponse response = client
.prepareIndex(name, type)
.setSource(
jsonBuilder().startObject().field("user", user)
.field("date", new Date())
.field("doc", json))
.execute().actionGet();

By default elasticsearch assumes json is of type string and index the
whole documents as a single string.
Is there a way I can tell ES that this is a json document and specify
the specific fields to be indexed without having to iterate through
the entire object in code? Can I also store json as a child json
object rather than string?

Thanks