Thanks does it create a new index if it doesn't exist? On Tue, Mar 18, 2014 at 12:35 PM, InquiringMind <brian.from...@gmail.com>wrote:
> 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 elasticsearch+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elasticsearch/c26e586f-3df5-4c22-b239-42dc614bf9af%40googlegroups.com<https://groups.google.com/d/msgid/elasticsearch/c26e586f-3df5-4c22-b239-42dc614bf9af%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 elasticsearch+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAOT3TWq6fcUJNs26X%2BovxsJOvB5kjjTcSOU_ehttj%2BEUWnf6Ug%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.