Fixes issue that in some cases the doc_as_upsert option is ignored.
Closes #3265
This commit is contained in:
parent
40cd549c37
commit
e815f257cc
|
@ -571,9 +571,6 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
|
|||
|
||||
public void docAsUpsert(boolean shouldUpsertDoc) {
|
||||
this.docAsUpsert = shouldUpsertDoc;
|
||||
if (this.doc != null && this.upsertRequest == null) {
|
||||
upsert(doc);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -183,6 +183,20 @@ public class UpdateTests extends AbstractSharedClusterTest {
|
|||
assertThat(updateResponse.getGetResult().sourceAsMap().get("bar").toString(), equalTo("baz"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotUpsertDoc() throws Exception {
|
||||
createIndex();
|
||||
ClusterHealthResponse clusterHealth = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
|
||||
assertThat(clusterHealth.isTimedOut(), equalTo(false));
|
||||
assertThat(clusterHealth.getStatus(), equalTo(ClusterHealthStatus.GREEN));
|
||||
|
||||
assertThrows(client().prepareUpdate("test", "type1", "1")
|
||||
.setDoc(XContentFactory.jsonBuilder().startObject().field("bar", "baz").endObject())
|
||||
.setDocAsUpsert(false)
|
||||
.setFields("_source")
|
||||
.execute(), DocumentMissingException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpsertFields() throws Exception {
|
||||
createIndex();
|
||||
|
|
Loading…
Reference in New Issue