Hi, I'm new to elasticsearch so there might be an obvious answer to this
question.
What's the best way to check the status of an update operation that changed
the value of an existing property?
I'm using a doc to update an existing indexed document using the java
update api:
updateResponse.isCreated() only returns true if the doc was inserted using
an upsert operation and updateResponse.getGetResult() returns null null.
I've looked in the ES tests source code and the way the test is performed
there is by issuing a new get request for the updated fields and comparing
the values from ES with the values set in the update:
// change existing field
updateResponse = client().prepareUpdate(indexOrAlias(), "type1",
"1").setDoc(XContentFactory.jsonBuilder().startObject().field("field",
3).endObject()).execute().actionGet();
for (int i = 0; i < 5; i++) {
getResponse = client().prepareGet("test", "type1",
"1").execute().actionGet();
You must issue a new get request after the write. The reason is that update
works like a write but with a previous get (not with a get after the
write).
If data is written, the write action is asynchronously executed, the
previous doc versions become obsolete, and eventually the action has to be
forwarded to other nodes where the shard(s) for this doc live.
Only when issuing a new get request, ES can route this read request again
to the primary shard node and open a new reader for this doc. Using the
"near real-time" (NRT) feature, ES ensures the last version of the doc from
the cache ca be taken, even if it is not flushed to the index.
Hi, I'm new to elasticsearch so there might be an obvious answer to this
question.
What's the best way to check the status of an update operation that
changed the value of an existing property?
I'm using a doc to update an existing indexed document using the java
update api:
updateResponse.isCreated() only returns true if the doc was inserted using
an upsert operation and updateResponse.getGetResult() returns null null.
I've looked in the ES tests source code and the way the test is performed
there is by issuing a new get request for the updated fields and comparing
the values from ES with the values set in the update:
// change existing field
updateResponse = client().prepareUpdate(indexOrAlias(), "type1",
"1").setDoc(XContentFactory.jsonBuilder().startObject().field("field",
3).endObject()).execute().actionGet();
for (int i = 0; i < 5; i++) {
getResponse = client().prepareGet("test", "type1",
"1").execute().actionGet();
Jörg - thanks for the thoughtful reply. Rephrasing my question a bit: how
can the code be sure that an update request was at least submitted to ES
without an error? Surely, an update request may fail due to various runtime
issues.
On Wednesday, October 1, 2014 12:21:15 PM UTC+3, Aviv Eyal wrote:
Hi, I'm new to elasticsearch so there might be an obvious answer to this
question.
What's the best way to check the status of an update operation that
changed the value of an existing property?
I'm using a doc to update an existing indexed document using the java
update api:
updateResponse.isCreated() only returns true if the doc was inserted using
an upsert operation and updateResponse.getGetResult() returns null null.
I've looked in the ES tests source code and the way the test is performed
there is by issuing a new get request for the updated fields and comparing
the values from ES with the values set in the update:
// change existing field
updateResponse = client().prepareUpdate(indexOrAlias(), "type1",
"1").setDoc(XContentFactory.jsonBuilder().startObject().field("field",
3).endObject()).execute().actionGet();
for (int i = 0; i < 5; i++) {
getResponse = client().prepareGet("test", "type1",
"1").execute().actionGet();
Jörg - thanks for the thoughtful reply. Rephrasing my question a bit: how
can the code be sure that an update request was at least submitted to ES
without an error? Surely, an update request may fail due to various runtime
issues.
On Wednesday, October 1, 2014 12:21:15 PM UTC+3, Aviv Eyal wrote:
Hi, I'm new to elasticsearch so there might be an obvious answer to this
question.
What's the best way to check the status of an update operation that
changed the value of an existing property?
I'm using a doc to update an existing indexed document using the java
update api:
updateResponse.isCreated() only returns true if the doc was inserted
using an upsert operation and updateResponse.getGetResult() returns null
null.
I've looked in the ES tests source code and the way the test is performed
there is by issuing a new get request for the updated fields and comparing
the values from ES with the values set in the update:
// change existing field
updateResponse = client().prepareUpdate(indexOrAlias(), "type1",
"1").setDoc(XContentFactory.jsonBuilder().startObject().field("field",
3).endObject()).execute().actionGet();
for (int i = 0; i < 5; i++) {
getResponse = client().prepareGet("test", "type1",
"1").execute().actionGet();
assertThat(getResponse.getSourceAsMap().get("field").toString(),
equalTo("3"));
assertThat(getResponse.getSourceAsMap().get("field2").toString(),
equalTo("2"));
}
I'm curious if this can be done just by using UpdateResponse and without
using another get.
On Wed, Oct 1, 2014 at 2:59 PM, Aviv Eyal <avive...@gmail.com
<javascript:>> wrote:
Jörg - thanks for the thoughtful reply. Rephrasing my question a bit: how
can the code be sure that an update request was at least submitted to ES
without an error? Surely, an update request may fail due to various runtime
issues.
On Wednesday, October 1, 2014 12:21:15 PM UTC+3, Aviv Eyal wrote:
Hi, I'm new to elasticsearch so there might be an obvious answer to this
question.
What's the best way to check the status of an update operation that
changed the value of an existing property?
I'm using a doc to update an existing indexed document using the java
update api:
updateResponse.isCreated() only returns true if the doc was inserted
using an upsert operation and updateResponse.getGetResult() returns
null null.
I've looked in the ES tests source code and the way the test is
performed there is by issuing a new get request for the updated fields and
comparing the values from ES with the values set in the update:
// change existing field
updateResponse = client().prepareUpdate(indexOrAlias(),
"type1", "1").setDoc(XContentFactory.jsonBuilder().startObject().field("field",
3).endObject()).execute().actionGet();
for (int i = 0; i < 5; i++) {
getResponse = client().prepareGet("test", "type1",
"1").execute().actionGet();
assertThat(getResponse.getSourceAsMap().get("field").toString(),
equalTo("3"));
assertThat(getResponse.getSourceAsMap().get("field2").toString(),
equalTo("2"));
}
I'm curious if this can be done just by using UpdateResponse and without
using another get.
Jörg - thanks for the thoughtful reply. Rephrasing my question a bit: how
can the code be sure that an update request was at least submitted to ES
without an error? Surely, an update request may fail due to various runtime
issues.
On Wednesday, October 1, 2014 12:21:15 PM UTC+3, Aviv Eyal wrote:
Hi, I'm new to elasticsearch so there might be an obvious answer to this
question.
What's the best way to check the status of an update operation that
changed the value of an existing property?
I'm using a doc to update an existing indexed document using the java
update api:
updateResponse.isCreated() only returns true if the doc was inserted
using an upsert operation and updateResponse.getGetResult() returns null
null.
I've looked in the ES tests source code and the way the test is performed
there is by issuing a new get request for the updated fields and comparing
the values from ES with the values set in the update:
// change existing field
updateResponse = client().prepareUpdate(indexOrAlias(), "type1",
"1").setDoc(XContentFactory.jsonBuilder().startObject().field("field",
3).endObject()).execute().actionGet();
for (int i = 0; i < 5; i++) {
getResponse = client().prepareGet("test", "type1",
"1").execute().actionGet();
assertThat(getResponse.getSourceAsMap().get("field").toString(),
equalTo("3"));
assertThat(getResponse.getSourceAsMap().get("field2").toString(),
equalTo("2"));
}
I'm curious if this can be done just by using UpdateResponse and without
using another get.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.