Here is my code for the INDEX action. Similar code (not shown) exists for
the CREATE action. This is for ES 1.0.0 GA, though it hasn't changed since
its 0.90.X versions:
>
>
IndexResponse response = null;
try
{
IndexRequestBuilder irb = client.prepareIndex(index, type, id);
irb.setSource(json).setOpType(IndexRequest.OpType.INDEX);
irb.setRefresh(refresh);
/* Set the version number and version type (internal or external) */
if (rec.hasVersion())
{
irb.setVersion(rec.getVersion());
if (rec.isVersionExternal())
irb.setVersionType(VersionType.EXTERNAL);
}
/* Set the TTL (time to live) if there is one */
TimeValue ttl = rec.getTTL();
if (ttl != null)
irb.setTTL(ttl.getMillis());
response = irb.execute().actionGet();
}
catch (Exception e)
{
...
}
Don't worry about rec. It's just a class that generically describes the
documents and contains various attributes and field values, and can
serialize itself to JSON.
Hope this helps.
Brian
--
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/c26e586f-3df5-4c22-b239-42dc614bf9af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.