diff options
author | Nik Everett <nik9000@gmail.com> | 2016-06-06 13:18:32 -0400 |
---|---|---|
committer | Nik Everett <nik9000@gmail.com> | 2016-06-08 13:50:59 -0400 |
commit | 4b211579065487120f33b1b23cd5a91419993df0 (patch) | |
tree | a6884595da5720ca26fcb6ecf87aa17d3e4a1dfb /core/src | |
parent | 92349f70e22894b08000636b4d8a48c1d93782c6 (diff) |
Remove setRefresh
It has been replaced with `setRefreshPolicy` which has support for
waiting until refresh with `setRefreshPolicy(WAIT_FOR)`.
Related to #1063
Diffstat (limited to 'core/src')
30 files changed, 161 insertions, 124 deletions
diff --git a/core/src/main/java/org/elasticsearch/action/support/WriteRequestBuilder.java b/core/src/main/java/org/elasticsearch/action/support/WriteRequestBuilder.java index a87fd04345..eaaf90fd53 100644 --- a/core/src/main/java/org/elasticsearch/action/support/WriteRequestBuilder.java +++ b/core/src/main/java/org/elasticsearch/action/support/WriteRequestBuilder.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.support; -import org.elasticsearch.Version; import org.elasticsearch.action.support.WriteRequest.RefreshPolicy; public interface WriteRequestBuilder<B extends WriteRequestBuilder<B>> { @@ -36,15 +35,11 @@ public interface WriteRequestBuilder<B extends WriteRequestBuilder<B>> { } /** - * If set to true then this request will force an immediate refresh. Backwards compatibility layer for Elasticsearch's old - * {@code setRefresh} calls. - * - * @deprecated use {@link #setRefreshPolicy(RefreshPolicy)} with {@link RefreshPolicy#IMMEDIATE} or {@link RefreshPolicy#NONE} instead. - * Will be removed in 6.0. + * Parse the refresh policy from a string, only modifying it if the string is non null. Convenient to use with request parsing. */ - @Deprecated - default B setRefresh(boolean refresh) { - assert Version.CURRENT.major < 6 : "Remove setRefresh(boolean) in 6.0"; - return setRefreshPolicy(refresh ? RefreshPolicy.IMMEDIATE : RefreshPolicy.NONE); + @SuppressWarnings("unchecked") + default B setRefreshPolicy(String refreshPolicy) { + request().setRefreshPolicy(refreshPolicy); + return (B) this; } } diff --git a/core/src/test/java/org/elasticsearch/document/DocumentActionsIT.java b/core/src/test/java/org/elasticsearch/document/DocumentActionsIT.java index 6f002e8404..065128af91 100644 --- a/core/src/test/java/org/elasticsearch/document/DocumentActionsIT.java +++ b/core/src/test/java/org/elasticsearch/document/DocumentActionsIT.java @@ -28,6 +28,7 @@ import org.elasticsearch.action.delete.DeleteResponse; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.action.support.WriteRequest.RefreshPolicy; import org.elasticsearch.cluster.health.ClusterHealthStatus; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; @@ -45,7 +46,7 @@ import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.nullValue; /** - * + * Integration test for document action like index, bulk, and get. It has a very long history: it was in the second commit of Elasticsearch. */ public class DocumentActionsIT extends ESIntegTestCase { protected void createIndex() { @@ -62,7 +63,8 @@ public class DocumentActionsIT extends ESIntegTestCase { logger.info("Running Cluster Health"); ensureGreen(); logger.info("Indexing [type1/1]"); - IndexResponse indexResponse = client().prepareIndex().setIndex("test").setType("type1").setId("1").setSource(source("1", "test")).setRefresh(true).execute().actionGet(); + IndexResponse indexResponse = client().prepareIndex().setIndex("test").setType("type1").setId("1").setSource(source("1", "test")) + .setRefreshPolicy(RefreshPolicy.IMMEDIATE).get(); assertThat(indexResponse.getIndex(), equalTo(getConcreteIndexName())); assertThat(indexResponse.getId(), equalTo("1")); assertThat(indexResponse.getType(), equalTo("type1")); diff --git a/core/src/test/java/org/elasticsearch/gateway/GatewayIndexStateIT.java b/core/src/test/java/org/elasticsearch/gateway/GatewayIndexStateIT.java index ebf1085cfb..d5dee3c1bd 100644 --- a/core/src/test/java/org/elasticsearch/gateway/GatewayIndexStateIT.java +++ b/core/src/test/java/org/elasticsearch/gateway/GatewayIndexStateIT.java @@ -53,6 +53,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.List; +import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.index.query.QueryBuilders.matchQuery; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; @@ -245,7 +246,7 @@ public class GatewayIndexStateIT extends ESIntegTestCase { internalCluster().startNodesAsync(2).get(); logger.info("--> indexing a simple document"); - client().prepareIndex("test", "type1", "1").setSource("field1", "value1").setRefresh(true).execute().actionGet(); + client().prepareIndex("test", "type1", "1").setSource("field1", "value1").setRefreshPolicy(IMMEDIATE).get(); logger.info("--> waiting for green status"); ClusterHealthResponse health = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus() @@ -285,7 +286,7 @@ public class GatewayIndexStateIT extends ESIntegTestCase { final String node_1 = internalCluster().startNodesAsync(2).get().get(0); logger.info("--> indexing a simple document"); - client().prepareIndex("test", "type1", "1").setSource("field1", "value1").setRefresh(true).execute().actionGet(); + client().prepareIndex("test", "type1", "1").setSource("field1", "value1").setRefreshPolicy(IMMEDIATE).get(); logger.info("--> waiting for green status"); ensureGreen(); @@ -408,7 +409,7 @@ public class GatewayIndexStateIT extends ESIntegTestCase { logger.info("--> starting one node"); internalCluster().startNode(); logger.info("--> indexing a simple document"); - client().prepareIndex("test", "type1", "1").setSource("field1", "value1").setRefresh(true).execute().actionGet(); + client().prepareIndex("test", "type1", "1").setSource("field1", "value1").setRefreshPolicy(IMMEDIATE).get(); logger.info("--> waiting for green status"); if (usually()) { ensureYellow(); @@ -477,7 +478,7 @@ public class GatewayIndexStateIT extends ESIntegTestCase { " }\n" + " }}").get(); logger.info("--> indexing a simple document"); - client().prepareIndex("test", "type1", "1").setSource("field1", "value one").setRefresh(true).execute().actionGet(); + client().prepareIndex("test", "type1", "1").setSource("field1", "value one").setRefreshPolicy(IMMEDIATE).get(); logger.info("--> waiting for green status"); if (usually()) { ensureYellow(); @@ -521,7 +522,7 @@ public class GatewayIndexStateIT extends ESIntegTestCase { public void testArchiveBrokenClusterSettings() throws Exception { logger.info("--> starting one node"); internalCluster().startNode(); - client().prepareIndex("test", "type1", "1").setSource("field1", "value1").setRefresh(true).execute().actionGet(); + client().prepareIndex("test", "type1", "1").setSource("field1", "value1").setRefreshPolicy(IMMEDIATE).get(); logger.info("--> waiting for green status"); if (usually()) { ensureYellow(); diff --git a/core/src/test/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapperTests.java b/core/src/test/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapperTests.java index c7142be3c6..a1fdb7ec60 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapperTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/geo/GeoPointFieldMapperTests.java @@ -47,6 +47,7 @@ import java.util.Map; import java.lang.NumberFormatException; import static org.apache.lucene.spatial.util.GeoEncodingUtils.mortonHash; +import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.elasticsearch.common.geo.GeoHashUtils.stringEncode; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; @@ -812,7 +813,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase { mappingRequest.execute().actionGet(); client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet(); client().prepareIndex("test", "pin", "1").setSource(jsonBuilder().startObject().startObject("location").field("lat", 40.7143528) - .field("lon", -74.0059731).endObject().endObject()).setRefresh(true).execute().actionGet(); + .field("lon", -74.0059731).endObject().endObject()).setRefreshPolicy(IMMEDIATE).get(); // match all search with geohash field SearchResponse searchResponse = client().prepareSearch().addField("location.geohash").setQuery(matchAllQuery()).execute().actionGet(); @@ -837,7 +838,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase { mappingRequest.execute().actionGet(); client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet(); client().prepareIndex("test", "pin", "1").setSource(jsonBuilder().startObject().startObject("location").field("lat", 40.7143528) - .field("lon", -74.0059731).endObject().endObject()).setRefresh(true).execute().actionGet(); + .field("lon", -74.0059731).endObject().endObject()).setRefreshPolicy(IMMEDIATE).get(); // match all search with geohash field (includes prefixes) SearchResponse searchResponse = client().prepareSearch().addField("location.geohash").setQuery(matchAllQuery()).execute().actionGet(); @@ -867,7 +868,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase { for (int i=0; i<numDocs; ++i) { final GeoPoint pt = RandomGeoGenerator.randomPoint(random()); client().prepareIndex("test", "pin").setSource(jsonBuilder().startObject().startObject("location").field("lat", pt.lat()) - .field("lon", pt.lon()).endObject().endObject()).setRefresh(true).execute().actionGet(); + .field("lon", pt.lon()).endObject().endObject()).setRefreshPolicy(IMMEDIATE).get(); } // query by geohash subfield diff --git a/core/src/test/java/org/elasticsearch/index/mapper/multifield/MultiFieldsIntegrationIT.java b/core/src/test/java/org/elasticsearch/index/mapper/multifield/MultiFieldsIntegrationIT.java index a1f6929fad..8e10ba9f00 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/multifield/MultiFieldsIntegrationIT.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/multifield/MultiFieldsIntegrationIT.java @@ -32,6 +32,7 @@ import org.elasticsearch.test.ESIntegTestCase; import java.io.IOException; import java.util.Map; +import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.elasticsearch.index.query.QueryBuilders.constantScoreQuery; import static org.elasticsearch.index.query.QueryBuilders.geoDistanceQuery; import static org.elasticsearch.index.query.QueryBuilders.matchQuery; @@ -61,7 +62,7 @@ public class MultiFieldsIntegrationIT extends ESIntegTestCase { client().prepareIndex("my-index", "my-type", "1") .setSource("title", "Multi fields") - .setRefresh(true) + .setRefreshPolicy(IMMEDIATE) .get(); SearchResponse searchResponse = client().prepareSearch("my-index") @@ -92,7 +93,7 @@ public class MultiFieldsIntegrationIT extends ESIntegTestCase { client().prepareIndex("my-index", "my-type", "1") .setSource("title", "Multi fields") - .setRefresh(true) + .setRefreshPolicy(IMMEDIATE) .get(); searchResponse = client().prepareSearch("my-index") @@ -122,7 +123,7 @@ public class MultiFieldsIntegrationIT extends ESIntegTestCase { assertThat(bField.get("type").toString(), equalTo("keyword")); GeoPoint point = new GeoPoint(51, 19); - client().prepareIndex("my-index", "my-type", "1").setSource("a", point.toString()).setRefresh(true).get(); + client().prepareIndex("my-index", "my-type", "1").setSource("a", point.toString()).setRefreshPolicy(IMMEDIATE).get(); SearchResponse countResponse = client().prepareSearch("my-index").setSize(0) .setQuery(constantScoreQuery(geoDistanceQuery("a").point(51, 19).distance(50, DistanceUnit.KILOMETERS))) .get(); @@ -162,7 +163,7 @@ public class MultiFieldsIntegrationIT extends ESIntegTestCase { assertThat(bField.size(), equalTo(1)); assertThat(bField.get("type").toString(), equalTo("keyword")); - client().prepareIndex("my-index", "my-type", "1").setSource("a", "my tokens").setRefresh(true).get(); + client().prepareIndex("my-index", "my-type", "1").setSource("a", "my tokens").setRefreshPolicy(IMMEDIATE).get(); SearchResponse countResponse = client().prepareSearch("my-index").setSize(0).setQuery(matchQuery("a.b", "my tokens")).get(); assertThat(countResponse.getHits().totalHits(), equalTo(1L)); } @@ -186,7 +187,7 @@ public class MultiFieldsIntegrationIT extends ESIntegTestCase { assertThat(bField.size(), equalTo(1)); assertThat(bField.get("type").toString(), equalTo("keyword")); - client().prepareIndex("my-index", "my-type", "1").setSource("a", "complete me").setRefresh(true).get(); + client().prepareIndex("my-index", "my-type", "1").setSource("a", "complete me").setRefreshPolicy(IMMEDIATE).get(); SearchResponse countResponse = client().prepareSearch("my-index").setSize(0).setQuery(matchQuery("a.b", "complete me")).get(); assertThat(countResponse.getHits().totalHits(), equalTo(1L)); } @@ -210,7 +211,7 @@ public class MultiFieldsIntegrationIT extends ESIntegTestCase { assertThat(bField.size(), equalTo(1)); assertThat(bField.get("type").toString(), equalTo("keyword")); - client().prepareIndex("my-index", "my-type", "1").setSource("a", "127.0.0.1").setRefresh(true).get(); + client().prepareIndex("my-index", "my-type", "1").setSource("a", "127.0.0.1").setRefreshPolicy(IMMEDIATE).get(); SearchResponse countResponse = client().prepareSearch("my-index").setSize(0).setQuery(matchQuery("a.b", "127.0.0.1")).get(); assertThat(countResponse.getHits().totalHits(), equalTo(1L)); } diff --git a/core/src/test/java/org/elasticsearch/index/mapper/string/StringFieldMapperPositionIncrementGapTests.java b/core/src/test/java/org/elasticsearch/index/mapper/string/StringFieldMapperPositionIncrementGapTests.java index 91a926805b..88f815611e 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/string/StringFieldMapperPositionIncrementGapTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/string/StringFieldMapperPositionIncrementGapTests.java @@ -35,6 +35,7 @@ import java.io.IOException; import java.util.Arrays; import java.util.Collection; +import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.elasticsearch.index.query.QueryBuilders.matchPhraseQuery; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; import static org.hamcrest.Matchers.containsString; @@ -160,19 +161,22 @@ public class StringFieldMapperPositionIncrementGapTests extends ESSingleNodeTest } private static void testGap(Client client, String indexName, String type, int positionIncrementGap) throws IOException { - client.prepareIndex(indexName, type, "position_gap_test").setSource("string", Arrays.asList("one", "two three")).setRefresh(true).get(); + client.prepareIndex(indexName, type, "position_gap_test").setSource("string", Arrays.asList("one", "two three")) + .setRefreshPolicy(IMMEDIATE).get(); // Baseline - phrase query finds matches in the same field value assertHitCount(client.prepareSearch(indexName).setQuery(matchPhraseQuery("string", "two three")).get(), 1); if (positionIncrementGap > 0) { // No match across gaps when slop < position gap - assertHitCount(client.prepareSearch(indexName).setQuery(matchPhraseQuery("string", "one two").slop(positionIncrementGap - 1)).get(), + assertHitCount( + client.prepareSearch(indexName).setQuery(matchPhraseQuery("string", "one two").slop(positionIncrementGap - 1)).get(), 0); } // Match across gaps when slop >= position gap assertHitCount(client.prepareSearch(indexName).setQuery(matchPhraseQuery("string", "one two").slop(positionIncrementGap)).get(), 1); - assertHitCount(client.prepareSearch(indexName).setQuery(matchPhraseQuery("string", "one two").slop(positionIncrementGap + 1)).get(), 1); + assertHitCount(client.prepareSearch(indexName).setQuery(matchPhraseQuery("string", "one two").slop(positionIncrementGap + 1)).get(), + 1); } } diff --git a/core/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java b/core/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java index e7a7eb4637..8889ebfb91 100644 --- a/core/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java +++ b/core/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java @@ -49,8 +49,6 @@ import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.InternalClusterInfoService; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.MappingMetaData; -import org.elasticsearch.common.UUIDs; -import org.elasticsearch.snapshots.SnapshotId; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.routing.AllocationId; import org.elasticsearch.cluster.routing.RestoreSource; @@ -60,6 +58,7 @@ import org.elasticsearch.cluster.routing.ShardRoutingState; import org.elasticsearch.cluster.routing.TestShardRouting; import org.elasticsearch.cluster.routing.UnassignedInfo; import org.elasticsearch.cluster.service.ClusterService; +import org.elasticsearch.common.UUIDs; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.collect.ImmutableOpenMap; @@ -99,6 +98,7 @@ import org.elasticsearch.indices.IndicesService; import org.elasticsearch.indices.recovery.RecoveryState; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.snapshots.Snapshot; +import org.elasticsearch.snapshots.SnapshotId; import org.elasticsearch.test.DummyShardLock; import org.elasticsearch.test.ESSingleNodeTestCase; import org.elasticsearch.test.FieldMaskingReader; @@ -128,6 +128,8 @@ import java.util.function.BiConsumer; import static java.util.Collections.emptyMap; import static java.util.Collections.emptySet; +import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; +import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.NONE; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_VERSION_CREATED; @@ -524,7 +526,7 @@ public class IndexShardTests extends ESSingleNodeTestCase { public void testRecoverIntoLeftover() throws IOException { createIndex("test"); ensureGreen("test"); - client().prepareIndex("test", "bar", "1").setSource("{}").setRefresh(true).get(); + client().prepareIndex("test", "bar", "1").setSource("{}").setRefreshPolicy(IMMEDIATE).get(); client().admin().indices().prepareFlush("test").get(); SearchResponse response = client().prepareSearch("test").get(); assertHitCount(response, 1L); @@ -554,7 +556,7 @@ public class IndexShardTests extends ESSingleNodeTestCase { .build(); createIndex("test", idxSettings); ensureGreen("test"); - client().prepareIndex("test", "bar", "1").setSource("{}").setRefresh(true).get(); + client().prepareIndex("test", "bar", "1").setSource("{}").setRefreshPolicy(IMMEDIATE).get(); SearchResponse response = client().prepareSearch("test").get(); assertHitCount(response, 1L); client().admin().indices().prepareDelete("test").get(); @@ -601,7 +603,7 @@ public class IndexShardTests extends ESSingleNodeTestCase { logger.info("--> creating an index with data_path [{}]", startDir.toAbsolutePath().toString()); createIndex(INDEX, sb); ensureGreen(INDEX); - client().prepareIndex(INDEX, "bar", "1").setSource("{}").setRefresh(true).get(); + client().prepareIndex(INDEX, "bar", "1").setSource("{}").setRefreshPolicy(IMMEDIATE).get(); SearchResponse resp = client().prepareSearch(INDEX).setQuery(matchAllQuery()).get(); assertThat("found the hit", resp.getHits().getTotalHits(), equalTo(1L)); @@ -689,7 +691,7 @@ public class IndexShardTests extends ESSingleNodeTestCase { public void testIndexingOperationsListeners() throws IOException { createIndex("test_iol"); ensureGreen(); - client().prepareIndex("test_iol", "test", "0").setSource("{\"foo\" : \"bar\"}").setRefresh(true).get(); + client().prepareIndex("test_iol", "test", "0").setSource("{\"foo\" : \"bar\"}").setRefreshPolicy(IMMEDIATE).get(); IndicesService indicesService = getInstanceFromNode(IndicesService.class); IndexService test = indicesService.indexService(resolveIndex("test_iol")); IndexShard shard = test.getShardOrNull(0); @@ -812,14 +814,14 @@ public class IndexShardTests extends ESSingleNodeTestCase { IndexShard shard = test.getShardOrNull(0); assertFalse(shard.shouldFlush()); client().admin().indices().prepareUpdateSettings("test").setSettings(Settings.builder().put(IndexSettings.INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING.getKey(), new ByteSizeValue(133 /* size of the operation + header&footer*/, ByteSizeUnit.BYTES)).build()).get(); - client().prepareIndex("test", "test", "0").setSource("{}").setRefresh(randomBoolean()).get(); + client().prepareIndex("test", "test", "0").setSource("{}").setRefreshPolicy(randomBoolean() ? IMMEDIATE : NONE).get(); assertFalse(shard.shouldFlush()); ParsedDocument doc = testParsedDocument("1", "1", "test", null, -1, -1, new ParseContext.Document(), new BytesArray(new byte[]{1}), null); Engine.Index index = new Engine.Index(new Term("_uid", "1"), doc); shard.index(index); assertTrue(shard.shouldFlush()); assertEquals(2, shard.getEngine().getTranslog().totalOperations()); - client().prepareIndex("test", "test", "2").setSource("{}").setRefresh(randomBoolean()).get(); + client().prepareIndex("test", "test", "2").setSource("{}").setRefreshPolicy(randomBoolean() ? IMMEDIATE : NONE).get(); assertBusy(() -> { // this is async assertFalse(shard.shouldFlush()); }); @@ -846,7 +848,7 @@ public class IndexShardTests extends ESSingleNodeTestCase { final IndexShard shard = test.getShardOrNull(0); assertFalse(shard.shouldFlush()); client().admin().indices().prepareUpdateSettings("test").setSettings(Settings.builder().put(IndexSettings.INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE_SETTING.getKey(), new ByteSizeValue(133/* size of the operation + header&footer*/, ByteSizeUnit.BYTES)).build()).get(); - client().prepareIndex("test", "test", "0").setSource("{}").setRefresh(randomBoolean()).get(); + client().prepareIndex("test", "test", "0").setSource("{}").setRefreshPolicy(randomBoolean() ? IMMEDIATE : NONE).get(); assertFalse(shard.shouldFlush()); final AtomicBoolean running = new AtomicBoolean(true); final int numThreads = randomIntBetween(2, 4); @@ -972,7 +974,7 @@ public class IndexShardTests extends ESSingleNodeTestCase { IndexService test = indicesService.indexService(resolveIndex("test")); final IndexShard shard = test.getShardOrNull(0); int translogOps = 1; - client().prepareIndex("test", "test", "0").setSource("{}").setRefresh(randomBoolean()).get(); + client().prepareIndex("test", "test", "0").setSource("{}").setRefreshPolicy(randomBoolean() ? IMMEDIATE : NONE).get(); if (randomBoolean()) { client().admin().indices().prepareFlush().get(); translogOps = 0; @@ -1000,7 +1002,7 @@ public class IndexShardTests extends ESSingleNodeTestCase { IndicesService indicesService = getInstanceFromNode(IndicesService.class); IndexService test = indicesService.indexService(resolveIndex("test")); final IndexShard shard = test.getShardOrNull(0); - client().prepareIndex("test", "test", "0").setSource("{}").setRefresh(randomBoolean()).get(); + client().prepareIndex("test", "test", "0").setSource("{}").setRefreshPolicy(randomBoolean() ? IMMEDIATE : NONE).get(); if (randomBoolean()) { client().admin().indices().prepareFlush().get(); } @@ -1030,7 +1032,7 @@ public class IndexShardTests extends ESSingleNodeTestCase { IndexService test = indicesService.indexService(resolveIndex("test")); final IndexShard shard = test.getShardOrNull(0); - client().prepareIndex("test", "test", "0").setSource("{}").setRefresh(randomBoolean()).get(); + client().prepareIndex("test", "test", "0").setSource("{}").setRefreshPolicy(randomBoolean() ? IMMEDIATE : NONE).get(); if (randomBoolean()) { client().admin().indices().prepareFlush().get(); } @@ -1107,8 +1109,8 @@ public class IndexShardTests extends ESSingleNodeTestCase { IndexService test_target = indicesService.indexService(resolveIndex("test_target")); final IndexShard test_shard = test.getShardOrNull(0); - client().prepareIndex("test", "test", "0").setSource("{}").setRefresh(randomBoolean()).get(); - client().prepareIndex("test_target", "test", "1").setSource("{}").setRefresh(true).get(); + client().prepareIndex("test", "test", "0").setSource("{}").setRefreshPolicy(randomBoolean() ? IMMEDIATE : NONE).get(); + client().prepareIndex("test_target", "test", "1").setSource("{}").setRefreshPolicy(IMMEDIATE).get(); assertHitCount(client().prepareSearch("test_target").get(), 1); assertSearchHits(client().prepareSearch("test_target").get(), "1"); client().admin().indices().prepareFlush("test").get(); // only flush test @@ -1165,8 +1167,8 @@ public class IndexShardTests extends ESSingleNodeTestCase { IndicesService indicesService = getInstanceFromNode(IndicesService.class); IndexService indexService = indicesService.indexService(resolveIndex("test")); IndexShard shard = indexService.getShardOrNull(0); - client().prepareIndex("test", "test", "0").setSource("{\"foo\" : \"bar\"}").setRefresh(true).get(); - client().prepareIndex("test", "test", "1").setSource("{\"foobar\" : \"bar\"}").setRefresh(true).get(); + client().prepareIndex("test", "test", "0").setSource("{\"foo\" : \"bar\"}").setRefreshPolicy(IMMEDIATE).get(); + client().prepareIndex("test", "test", "1").setSource("{\"foobar\" : \"bar\"}").setRefreshPolicy(IMMEDIATE).get(); Engine.GetResult getResult = shard.get(new Engine.Get(false, new Term(UidFieldMapper.NAME, Uid.createUid("test", "1")))); assertTrue(getResult.exists()); @@ -1215,8 +1217,8 @@ public class IndexShardTests extends ESSingleNodeTestCase { IndexService indexService = indicesService.indexService(resolveIndex("test")); IndexShard shard = indexService.getShardOrNull(0); client().admin().indices().preparePutMapping("test").setType("test").setSource("foo", "type=text,fielddata=true").get(); - client().prepareIndex("test", "test", "0").setSource("{\"foo\" : \"bar\"}").setRefresh(true).get(); - client().prepareIndex("test", "test", "1").setSource("{\"foobar\" : \"bar\"}").setRefresh(true).get(); + client().prepareIndex("test", "test", "0").setSource("{\"foo\" : \"bar\"}").setRefreshPolicy(IMMEDIATE).get(); + client().prepareIndex("test", "test", "1").setSource("{\"foobar\" : \"bar\"}").setRefreshPolicy(IMMEDIATE).get(); IndexSearcherWrapper wrapper = new IndexSearcherWrapper() { @Override @@ -1266,7 +1268,7 @@ public class IndexShardTests extends ESSingleNodeTestCase { IndexShard shard = indexService.getShardOrNull(0); client().prepareIndex("test", "test", "0").setSource("{\"foo\" : \"bar\"}").get(); client().prepareDelete("test", "test", "0").get(); - client().prepareIndex("test", "test", "1").setSource("{\"foo\" : \"bar\"}").setRefresh(true).get(); + client().prepareIndex("test", "test", "1").setSource("{\"foo\" : \"bar\"}").setRefreshPolicy(IMMEDIATE).get(); IndexSearcherWrapper wrapper = new IndexSearcherWrapper() {}; shard.close("simon says", false); @@ -1324,7 +1326,7 @@ public class IndexShardTests extends ESSingleNodeTestCase { IndexShard shard = indexService.getShardOrNull(0); client().prepareIndex("test", "test", "0").setSource("{\"foo\" : \"bar\"}").get(); client().prepareDelete("test", "test", "0").get(); - client().prepareIndex("test", "test", "1").setSource("{\"foo\" : \"bar\"}").setRefresh(true).get(); + client().prepareIndex("test", "test", "1").setSource("{\"foo\" : \"bar\"}").setRefreshPolicy(IMMEDIATE).get(); IndexSearcherWrapper wrapper = new IndexSearcherWrapper() {}; shard.close("simon says", false); @@ -1376,7 +1378,7 @@ public class IndexShardTests extends ESSingleNodeTestCase { IndicesService indicesService = getInstanceFromNode(IndicesService.class); IndexService indexService = indicesService.indexService(resolveIndex("test")); IndexShard shard = indexService.getShardOrNull(0); - client().prepareIndex("test", "test", "0").setSource("{\"foo\" : \"bar\"}").setRefresh(true).get(); + client().prepareIndex("test", "test", "0").setSource("{\"foo\" : \"bar\"}").setRefreshPolicy(IMMEDIATE).get(); IndexSearcherWrapper wrapper = new IndexSearcherWrapper() { @Override public DirectoryReader wrap(DirectoryReader reader) throws IOException { @@ -1529,8 +1531,8 @@ public class IndexShardTests extends ESSingleNodeTestCase { .field("type", "text") .endObject() .endObject().endObject().endObject()).get(); - client().prepareIndex("index", "test", "0").setSource("{\"foo\" : \"bar\"}").setRefresh(true).get(); - client().prepareIndex("index", "test", "1").setSource("{\"foo\" : \"bar\"}").setRefresh(true).get(); + client().prepareIndex("index", "test", "0").setSource("{\"foo\" : \"bar\"}").setRefreshPolicy(IMMEDIATE).get(); + client().prepareIndex("index", "test", "1").setSource("{\"foo\" : \"bar\"}").setRefreshPolicy(IMMEDIATE).get(); IndicesService indicesService = getInstanceFromNode(IndicesService.class); diff --git a/core/src/test/java/org/elasticsearch/index/termvectors/TermVectorsServiceTests.java b/core/src/test/java/org/elasticsearch/index/termvectors/TermVectorsServiceTests.java index a4b8057792..c79a61a22b 100644 --- a/core/src/test/java/org/elasticsearch/index/termvectors/TermVectorsServiceTests.java +++ b/core/src/test/java/org/elasticsearch/index/termvectors/TermVectorsServiceTests.java @@ -34,6 +34,7 @@ import java.util.stream.Stream; import static java.lang.Math.abs; import static java.util.stream.Collectors.toList; +import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.notNullValue; @@ -55,7 +56,7 @@ public class TermVectorsServiceTests extends ESSingleNodeTestCase { createIndex("test", Settings.EMPTY, "type1", mapping); ensureGreen(); - client().prepareIndex("test", "type1", "0").setSource("field", "foo bar").setRefresh(true).execute().get(); + client().prepareIndex("test", "type1", "0").setSource("field", "foo bar").setRefreshPolicy(IMMEDIATE).get(); IndicesService indicesService = getInstanceFromNode(IndicesService.class); IndexService test = indicesService.indexService(resolveIndex("test")); diff --git a/core/src/test/java/org/elasticsearch/indices/IndicesOptionsIntegrationIT.java b/core/src/test/java/org/elasticsearch/indices/IndicesOptionsIntegrationIT.java index e0446fe329..0256fab1b7 100644 --- a/core/src/test/java/org/elasticsearch/indices/IndicesOptionsIntegrationIT.java +++ b/core/src/test/java/org/elasticsearch/indices/IndicesOptionsIntegrationIT.java @@ -53,6 +53,7 @@ import org.elasticsearch.test.ESIntegTestCase; import java.util.Collection; import java.util.function.Function; +import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; @@ -332,7 +333,7 @@ public class IndicesOptionsIntegrationIT extends ESIntegTestCase { verify(getSettings(indices).setIndicesOptions(options), false); assertAcked(prepareCreate("foobar")); - client().prepareIndex("foobar", "type", "1").setSource("k", "v").setRefresh(true).execute().actionGet(); + client().prepareIndex("foobar", "type", "1").setSource("k", "v").setRefreshPolicy(IMMEDIATE).get(); // Verify defaults for wildcards, with one wildcard expression and one existing index indices = new String[]{"foo*"}; @@ -422,7 +423,7 @@ public class IndicesOptionsIntegrationIT extends ESIntegTestCase { public void testAllMissingLenient() throws Exception { createIndex("test1"); - client().prepareIndex("test1", "type", "1").setSource("k", "v").setRefresh(true).execute().actionGet(); + client().prepareIndex("test1", "type", "1").setSource("k", "v").setRefreshPolicy(IMMEDIATE).get(); SearchResponse response = client().prepareSearch("test2") .setIndicesOptions(IndicesOptions.lenientExpandOpen()) .setQuery(matchAllQuery()) diff --git a/core/src/test/java/org/elasticsearch/indices/IndicesServiceTests.java b/core/src/test/java/org/elasticsearch/indices/IndicesServiceTests.java index 5761997ed4..75c968e1d6 100644 --- a/core/src/test/java/org/elasticsearch/indices/IndicesServiceTests.java +++ b/core/src/test/java/org/elasticsearch/indices/IndicesServiceTests.java @@ -49,6 +49,7 @@ import java.util.Arrays; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; import static org.hamcrest.Matchers.containsString; @@ -131,7 +132,7 @@ public class IndicesServiceTests extends ESSingleNodeTestCase { test = createIndex("test"); - client().prepareIndex("test", "type", "1").setSource("field", "value").setRefresh(true).get(); + client().prepareIndex("test", "type", "1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get(); client().admin().indices().prepareFlush("test").get(); assertHitCount(client().prepareSearch("test").get(), 1); IndexMetaData secondMetaData = clusterService.state().metaData().index("test"); diff --git a/core/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java b/core/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java index 416dbd1976..298cb9cd9e 100644 --- a/core/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java +++ b/core/src/test/java/org/elasticsearch/indices/template/SimpleIndexTemplateIT.java @@ -45,6 +45,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.elasticsearch.index.query.QueryBuilders.termQuery; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; @@ -110,7 +111,7 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase { // index something into test_index, will match on both templates - client().prepareIndex("test_index", "type1", "1").setSource("field1", "value1", "field2", "value 2").setRefresh(true).execute().actionGet(); + client().prepareIndex("test_index", "type1", "1").setSource("field1", "value1", "field2", "value 2").setRefreshPolicy(IMMEDIATE).get(); ensureGreen(); SearchResponse searchResponse = client().prepareSearch("test_index") @@ -123,7 +124,7 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase { // field2 is not stored. assertThat(searchResponse.getHits().getAt(0).field("field2"), nullValue()); - client().prepareIndex("text_index", "type1", "1").setSource("field1", "value1", "field2", "value 2").setRefresh(true).execute().actionGet(); + client().prepareIndex("text_index", "type1", "1").setSource("field1", "value1", "field2", "value 2").setRefreshPolicy(IMMEDIATE).get(); ensureGreen(); // now only match on one template (template_1) diff --git a/core/src/test/java/org/elasticsearch/mget/SimpleMgetIT.java b/core/src/test/java/org/elasticsearch/mget/SimpleMgetIT.java index 21be585862..e710186969 100644 --- a/core/src/test/java/org/elasticsearch/mget/SimpleMgetIT.java +++ b/core/src/test/java/org/elasticsearch/mget/SimpleMgetIT.java @@ -33,6 +33,7 @@ import org.elasticsearch.test.ESIntegTestCase; import java.io.IOException; import java.util.Map; +import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.hamcrest.Matchers.equalTo; @@ -45,7 +46,8 @@ public class SimpleMgetIT extends ESIntegTestCase { createIndex("test"); ensureYellow(); - client().prepareIndex("test", "test", "1").setSource(jsonBuilder().startObject().field("foo", "bar").endObject()).setRefresh(true).execute().actionGet(); + client().prepareIndex("test", "test", "1").setSource(jsonBuilder().startObject().field("foo", "bar").endObject()) + .setRefreshPolicy(IMMEDIATE).get(); MultiGetResponse mgetResponse = client().prepareMultiGet() .add(new MultiGetRequest.Item("test", "test", "1")) @@ -86,9 +88,9 @@ public class SimpleMgetIT extends ESIntegTestCase { .endObject())); ensureYellow(); - client().prepareIndex("test", "test", "1").setParent("4").setRefresh(true) + client().prepareIndex("test", "test", "1").setParent("4").setRefreshPolicy(IMMEDIATE) .setSource(jsonBuilder().startObject().field("foo", "bar").endObject()) - .execute().actionGet(); + .get(); MultiGetResponse mgetResponse = client().prepareMultiGet() .add(new MultiGetRequest.Item(indexOrAlias(), "test", "1").parent("4")) @@ -154,9 +156,9 @@ public class SimpleMgetIT extends ESIntegTestCase { final String id = routingKeyForShard("test", "test", 0); final String routingOtherShard = routingKeyForShard("test", "test", 1); - client().prepareIndex("test", "test", id).setRefresh(true).setRouting(routingOtherShard) + client().prepareIndex("test", "test", id).setRefreshPolicy(IMMEDIATE).setRouting(routingOtherShard) .setSource(jsonBuilder().startObject().field("foo", "bar").endObject()) - .execute().actionGet(); + .get(); MultiGetResponse mgetResponse = client().prepareMultiGet() .add(new MultiGetRequest.Item(indexOrAlias(), "test", id).routing(routingOtherShard)) diff --git a/core/src/test/java/org/elasticsearch/search/SearchServiceTests.java b/core/src/test/java/org/elasticsearch/search/SearchServiceTests.java index 2ac00b541a..b465d25043 100644 --- a/core/src/test/java/org/elasticsearch/search/SearchServiceTests.java +++ b/core/src/test/java/org/elasticsearch/search/SearchServiceTests.java @@ -40,6 +40,7 @@ import java.io.IOException; import java.util.Collection; import java.util.concurrent.ExecutionException; +import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; @@ -58,7 +59,7 @@ public class SearchServiceTests extends ESSingleNodeTestCase { public void testClearOnClose() throws ExecutionException, InterruptedException { createIndex("index"); - client().prepareIndex("index", "type", "1").setSource("field", "value").setRefresh(true).get(); + client().prepareIndex("index", "type", "1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get(); SearchResponse searchResponse = client().prepareSearch("index").setSize(1).setScroll("1m").get(); assertThat(searchResponse.getScrollId(), is(notNullValue())); SearchService service = getInstanceFromNode(SearchService.class); @@ -70,7 +71,7 @@ public class SearchServiceTests extends ESSingleNodeTestCase { public void testClearOnStop() throws ExecutionException, InterruptedException { createIndex("index"); - client().prepareIndex("index", "type", "1").setSource("field", "value").setRefresh(true).get(); + client().prepareIndex("index", "type", "1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get(); SearchResponse searchResponse = client().prepareSearch("index").setSize(1).setScroll("1m").get(); assertThat(searchResponse.getScrollId(), is(notNullValue())); SearchService service = getInstanceFromNode(SearchService.class); @@ -82,7 +83,7 @@ public class SearchServiceTests extends ESSingleNodeTestCase { public void testClearIndexDelete() throws ExecutionException, InterruptedException { createIndex("index"); - client().prepareIndex("index", "type", "1").setSource("field", "value").setRefresh(true).get(); + client().prepareIndex("index", "type", "1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get(); SearchResponse searchResponse = client().prepareSearch("index").setSize(1).setScroll("1m").get(); assertThat(searchResponse.getScrollId(), is(notNullValue())); SearchService service = getInstanceFromNode(SearchService.class); @@ -94,7 +95,7 @@ public class SearchServiceTests extends ESSingleNodeTestCase { public void testCloseSearchContextOnRewriteException() { createIndex("index"); - client().prepareIndex("index", "type", "1").setSource("field", "value").setRefresh(true).get(); + client().prepareIndex("index", "type", "1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get(); SearchService service = getInstanceFromNode(SearchService.class); IndicesService indicesService = getInstanceFromNode(IndicesService.class); diff --git a/core/src/test/java/org/elasticsearch/search/SearchTimeoutIT.java b/core/src/test/java/org/elasticsearch/search/SearchTimeoutIT.java index ef922e8404..b2eb12159f 100644 --- a/core/src/test/java/org/elasticsearch/search/SearchTimeoutIT.java +++ b/core/src/test/java/org/elasticsearch/search/SearchTimeoutIT.java @@ -36,6 +36,7 @@ import java.util.Collections; import java.util.Map; import java.util.concurrent.TimeUnit; +import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.elasticsearch.index.query.QueryBuilders.scriptQuery; import static org.hamcrest.Matchers.equalTo; @@ -55,7 +56,7 @@ public class SearchTimeoutIT extends ESIntegTestCase { } public void testSimpleTimeout() throws Exception { - client().prepareIndex("test", "type", "1").setSource("field", "value").setRefresh(true).execute().actionGet(); + client().prepareIndex("test", "type", "1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get(); SearchResponse searchResponse = client().prepareSearch("test").setTimeout(new TimeValue(10, TimeUnit.MILLISECONDS)) .setQuery(scriptQuery(new Script(NativeTestScriptedTimeout.TEST_NATIVE_SCRIPT_TIMEOUT, ScriptType.INLINE, "native", null))) diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ReverseNestedIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ReverseNestedIT.java index 93e6536e47..21b4a74fe4 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ReverseNestedIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/bucket/ReverseNestedIT.java @@ -35,6 +35,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; @@ -509,7 +510,7 @@ public class ReverseNestedIT extends ESIntegTestCase { .addMapping("product", mapping) ); - client().prepareIndex("idx3", "product", "1").setRefresh(true).setSource( + client().prepareIndex("idx3", "product", "1").setRefreshPolicy(IMMEDIATE).setSource( jsonBuilder().startObject() .startArray("sku") .startObject() diff --git a/core/src/test/java/org/elasticsearch/search/functionscore/DecayFunctionScoreIT.java b/core/src/test/java/org/elasticsearch/search/functionscore/DecayFunctionScoreIT.java index 83e6207268..e17f7bb3ef 100644 --- a/core/src/test/java/org/elasticsearch/search/functionscore/DecayFunctionScoreIT.java +++ b/core/src/test/java/org/elasticsearch/search/functionscore/DecayFunctionScoreIT.java @@ -51,6 +51,7 @@ import java.util.Collection; import java.util.List; import java.util.Locale; +import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.elasticsearch.client.Requests.indexRequest; import static org.elasticsearch.client.Requests.searchRequest; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; @@ -318,8 +319,13 @@ public class DecayFunctionScoreIT extends ESIntegTestCase { .setId("1") .setIndex("test") .setSource( - jsonBuilder().startObject().field("test", "value").startObject("loc").field("lat", 20).field("lon", 11).endObject() - .endObject()).setRefresh(true).get(); + jsonBuilder().startObject() + .field("test", "value") + .startObject("loc") + .field("lat", 20) + .field("lon", 11) + .endObject() + .endObject()).setRefreshPolicy(IMMEDIATE).get(); FunctionScoreQueryBuilder baseQuery = functionScoreQuery(constantScoreQuery(termQuery("test", "value")), ScoreFunctionBuilders.weightFactorFunction(randomIntBetween(1, 10))); GeoPoint point = new GeoPoint(20, 11); @@ -354,8 +360,8 @@ public class DecayFunctionScoreIT extends ESIntegTestCase { .endObject().startObject("num").field("type", "double").endObject().endObject().endObject().endObject())); ensureYellow(); - client().prepareIndex().setType("type1").setId("1").setIndex("test") - .setSource(jsonBuilder().startObject().field("test", "value value").field("num", 1.0).endObject()).setRefresh(true).get(); + client().prepareIndex().setType("type1").setId("1").setIndex("test").setRefreshPolicy(IMMEDIATE) + .setSource(jsonBuilder().startObject().field("test", "value value").field("num", 1.0).endObject()).get(); FunctionScoreQueryBuilder baseQuery = functionScoreQuery(constantScoreQuery(termQuery("test", "value")), ScoreFunctionBuilders.weightFactorFunction(2)); // decay score should return 0.5 for this function and baseQuery should return 2.0f as it's score diff --git a/core/src/test/java/org/elasticsearch/search/geo/GeoBoundingBoxIT.java b/core/src/test/java/org/elasticsearch/search/geo/GeoBoundingBoxIT.java index 46704410bd..7e01f57582 100644 --- a/core/src/test/java/org/elasticsearch/search/geo/GeoBoundingBoxIT.java +++ b/core/src/test/java/org/elasticsearch/search/geo/GeoBoundingBoxIT.java @@ -34,6 +34,7 @@ import org.elasticsearch.test.VersionUtils; import java.util.Collection; +import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.QueryBuilders.boolQuery; import static org.elasticsearch.index.query.QueryBuilders.geoBoundingBoxQuery; @@ -249,16 +250,16 @@ public class GeoBoundingBoxIT extends ESIntegTestCase { .field("title", "Place in Stockholm") .startObject("location").field("lat", 59.328355000000002).field("lon", 18.036842).endObject() .endObject()) - .setRefresh(true) - .execute().actionGet(); + .setRefreshPolicy(IMMEDIATE) + .get(); client().prepareIndex("test", "type1", "2").setSource(jsonBuilder().startObject() .field("userid", 534) .field("title", "Place in Montreal") .startObject("location").field("lat", 45.509526999999999).field("lon", -73.570986000000005).endObject() .endObject()) - .setRefresh(true) - .execute().actionGet(); + .setRefreshPolicy(IMMEDIATE) + .get(); SearchResponse searchResponse = client().prepareSearch() .setQuery( @@ -304,16 +305,16 @@ public class GeoBoundingBoxIT extends ESIntegTestCase { .field("title", "Place in Stockholm") .startObject("location").field("lat", 59.328355000000002).field("lon", 18.036842).endObject() .endObject()) - .setRefresh(true) - .execute().actionGet(); + .setRefreshPolicy(IMMEDIATE) + .get(); client().prepareIndex("test", "type1", "2").setSource(jsonBuilder().startObject() .field("userid", 534) .field("title", "Place in Montreal") .startObject("location").field("lat", 45.509526999999999).field("lon", -73.570986000000005).endObject() .endObject()) - .setRefresh(true) - .execute().actionGet(); + .setRefreshPolicy(IMMEDIATE) + .get(); SearchResponse searchResponse = client().prepareSearch() .setQuery( diff --git a/core/src/test/java/org/elasticsearch/search/geo/GeoShapeQueryTests.java b/core/src/test/java/org/elasticsearch/search/geo/GeoShapeQueryTests.java index 0fe90f133b..7da18342ed 100644 --- a/core/src/test/java/org/elasticsearch/search/geo/GeoShapeQueryTests.java +++ b/core/src/test/java/org/elasticsearch/search/geo/GeoShapeQueryTests.java @@ -42,6 +42,7 @@ import org.elasticsearch.test.geo.RandomShapeGenerator; import java.io.IOException; import java.util.Locale; +import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.QueryBuilders.geoIntersectionQuery; import static org.elasticsearch.index.query.QueryBuilders.geoShapeQuery; @@ -65,8 +66,7 @@ public class GeoShapeQueryTests extends ESSingleNodeTestCase { client().admin().indices().prepareCreate("test").addMapping("type1", mapping).execute().actionGet(); ensureGreen(); - client().prepareIndex("test", "type1", "aNullshape").setSource("{\"location\": null}").setRefresh(true) - .execute().actionGet(); + client().prepareIndex("test", "type1", "aNullshape").setSource("{\"location\": null}").setRefreshPolicy(IMMEDIATE).get(); GetResponse result = client().prepareGet("test", "type1", "aNullshape").execute().actionGet(); assertThat(result.getField("location"), nullValue()); } @@ -87,7 +87,7 @@ public class GeoShapeQueryTests extends ESSingleNodeTestCase { .field("type", "point") .startArray("coordinates").value(-30).value(-30).endArray() .endObject() - .endObject()).setRefresh(true).execute().actionGet(); + .endObject()).setRefreshPolicy(IMMEDIATE).get(); client().prepareIndex("test", "type1", "2").setSource(jsonBuilder().startObject() .field("name", "Document 2") @@ -95,7 +95,7 @@ public class GeoShapeQueryTests extends ESSingleNodeTestCase { .field("type", "point") .startArray("coordinates").value(-45).value(-50).endArray() .endObject() - .endObject()).setRefresh(true).execute().actionGet(); + .endObject()).setRefreshPolicy(IMMEDIATE).get(); ShapeBuilder shape = ShapeBuilders.newEnvelope(new Coordinate(-45, 45), new Coordinate(45, -45)); @@ -139,7 +139,7 @@ public class GeoShapeQueryTests extends ESSingleNodeTestCase { .startArray().value(-122.83).value(48.57).endArray() // close the polygon .endArray().endArray() .endObject() - .endObject()).setRefresh(true).execute().actionGet(); + .endObject()).setRefreshPolicy(IMMEDIATE).get(); ShapeBuilder query = ShapeBuilders.newEnvelope(new Coordinate(-122.88, 48.62), new Coordinate(-122.82, 48.54)); @@ -169,14 +169,14 @@ public class GeoShapeQueryTests extends ESSingleNodeTestCase { ShapeBuilder shape = ShapeBuilders.newEnvelope(new Coordinate(-45, 45), new Coordinate(45, -45)); client().prepareIndex("shapes", "shape_type", "Big_Rectangle").setSource(jsonBuilder().startObject() - .field("shape", shape).endObject()).setRefresh(true).execute().actionGet(); + .field("shape", shape).endObject()).setRefreshPolicy(IMMEDIATE).get(); client().prepareIndex("test", "type1", "1").setSource(jsonBuilder().startObject() .field("name", "Document 1") .startObject("location") .field("type", "point") .startArray("coordinates").value(-30).value(-30).endArray() .endObject() - .endObject()).setRefresh(true).execute().actionGet(); + .endObject()).setRefreshPolicy(IMMEDIATE).get(); SearchResponse searchResponse = client().prepareSearch("test").setTypes("type1") .setQuery(geoIntersectionQuery("location", "Big_Rectangle", "shape_type")) @@ -226,7 +226,7 @@ public class GeoShapeQueryTests extends ESSingleNodeTestCase { String.format( Locale.ROOT, "{ %s, \"1\" : { %s, \"2\" : { %s, \"3\" : { %s } }} }", location, location, location, location ) - ).setRefresh(true).execute().actionGet(); + ).setRefreshPolicy(IMMEDIATE).get(); client().prepareIndex("test", "type", "1") .setSource(jsonBuilder().startObject().startObject("location") .field("type", "polygon") @@ -237,7 +237,7 @@ public class GeoShapeQueryTests extends ESSingleNodeTestCase { .startArray().value(-20).value(20).endArray() .startArray().value(-20).value(-20).endArray() .endArray().endArray() - .endObject().endObject()).setRefresh(true).execute().actionGet(); + .endObject().endObject()).setRefreshPolicy(IMMEDIATE).get(); GeoShapeQueryBuilder filter = QueryBuilders.geoShapeQuery("location", "1", "type").relation(ShapeRelation.INTERSECTS) .indexedShapeIndex("shapes") @@ -305,7 +305,7 @@ public class GeoShapeQueryTests extends ESSingleNodeTestCase { .execute().actionGet(); XContentBuilder docSource = gcb.toXContent(jsonBuilder().startObject().field("location"), null).endObject(); - client().prepareIndex("test", "type", "1").setSource(docSource).setRefresh(true).execute().actionGet(); + client().prepareIndex("test", "type", "1").setSource(docSource).setRefreshPolicy(IMMEDIATE).get(); ShapeBuilder filterShape = (gcb.getShapeAt(randomIntBetween(0, gcb.numShapes() - 1))); @@ -326,12 +326,12 @@ public class GeoShapeQueryTests extends ESSingleNodeTestCase { .execute().actionGet(); XContentBuilder docSource = gcb.toXContent(jsonBuilder().startObject().field("location"), null).endObject(); - client().prepareIndex("test", "type", "1").setSource(docSource).setRefresh(true).execute().actionGet(); + client().prepareIndex("test", "type", "1").setSource(docSource).setRefreshPolicy(IMMEDIATE).get(); // index the mbr of the collection EnvelopeBuilder env = new EnvelopeBuilder(new Coordinate(mbr.getMinX(), mbr.getMaxY()), new Coordinate(mbr.getMaxX(), mbr.getMinY())); docSource = env.toXContent(jsonBuilder().startObject().field("location"), null).endObject(); - client().prepareIndex("test", "type", "2").setSource(docSource).setRefresh(true).execute().actionGet(); + client().prepareIndex("test", "type", "2").setSource(docSource).setRefreshPolicy(IMMEDIATE).get(); ShapeBuilder filterShape = (gcb.getShapeAt(randomIntBetween(0, gcb.numShapes() - 1))); GeoShapeQueryBuilder filter = QueryBuilders.geoShapeQuery("location", filterShape) @@ -371,7 +371,7 @@ public class GeoShapeQueryTests extends ESSingleNodeTestCase { .endArray() .endObject().endObject(); client().prepareIndex("test", "type", "1") - .setSource(docSource).setRefresh(true).execute().actionGet(); + .setSource(docSource).setRefreshPolicy(IMMEDIATE).get(); GeoShapeQueryBuilder filter = QueryBuilders.geoShapeQuery( "location", @@ -427,7 +427,7 @@ public class GeoShapeQueryTests extends ESSingleNodeTestCase { try { client().prepareIndex("geo_points_only", "type1", "1") .setSource(jsonBuilder().startObject().field("location", shape).endObject()) - .setRefresh(true).execute().actionGet(); + .setRefreshPolicy(IMMEDIATE).get(); } catch (MapperParsingException e) { // RandomShapeGenerator created something other than a POINT type, verify the correct exception is thrown assertThat(e.getCause().getMessage(), containsString("is configured for points only")); diff --git a/core/src/test/java/org/elasticsearch/search/innerhits/InnerHitsIT.java b/core/src/test/java/org/elasticsearch/search/innerhits/InnerHitsIT.java index 0d1ba43659..01f9856481 100644 --- a/core/src/test/java/org/elasticsearch/search/innerhits/InnerHitsIT.java +++ b/core/src/test/java/org/elasticsearch/search/innerhits/InnerHitsIT.java @@ -48,6 +48,7 @@ import java.util.Collections; import java.util.List; import java.util.Locale; +import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.common.xcontent.support.XContentMapValues.extractValue; import static org.elasticsearch.index.query.QueryBuilders.boolQuery; @@ -920,7 +921,7 @@ public class InnerHitsIT extends ESIntegTestCase { .endObject() .endArray() .endObject()) - .setRefresh(true) + .setRefreshPolicy(IMMEDIATE) .get(); response = client().prepareSearch("index2") diff --git a/core/src/test/java/org/elasticsearch/search/nested/SimpleNestedIT.java b/core/src/test/java/org/elasticsearch/search/nested/SimpleNestedIT.java index 4d2f92c3c6..ba378a3c40 100644 --- a/core/src/test/java/org/elasticsearch/search/nested/SimpleNestedIT.java +++ b/core/src/test/java/org/elasticsearch/search/nested/SimpleNestedIT.java @@ -38,6 +38,7 @@ import org.elasticsearch.search.sort.SortMode; import org.elasticsearch.search.sort.SortOrder; import org.elasticsearch.test.ESIntegTestCase; +import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.QueryBuilders.boolQuery; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; @@ -306,7 +307,7 @@ public class SimpleNestedIT extends ESIntegTestCase { .endObject() .endArray() .endObject()) - .setRefresh(true) + .setRefreshPolicy(IMMEDIATE) .execute().actionGet(); SearchResponse searchResponse = client().prepareSearch("test") diff --git a/core/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java b/core/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java index d7d4a3fd18..5e4a7d6f77 100644 --- a/core/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java +++ b/core/src/test/java/org/elasticsearch/search/query/SearchQueryIT.java @@ -55,6 +55,7 @@ import java.io.IOException; import java.util.Random; import java.util.concurrent.ExecutionException; +import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.QueryBuilders.boolQuery; @@ -731,7 +732,7 @@ public class SearchQueryIT extends ESIntegTestCase { public void testPassQueryOrFilterAsJSONString() throws Exception { createIndex("test"); - client().prepareIndex("test", "type1", "1").setSource("field1", "value1_1", "field2", "value2_1").setRefresh(true).get(); + client().prepareIndex("test", "type1", "1").setSource("field1", "value1_1", "field2", "value2_1").setRefreshPolicy(IMMEDIATE).get(); WrapperQueryBuilder wrapper = new WrapperQueryBuilder("{ \"term\" : { \"field1\" : \"value1_1\" } }"); assertHitCount(client().prepareSearch().setQuery(wrapper).get(), 1L); @@ -1548,7 +1549,7 @@ public class SearchQueryIT extends ESIntegTestCase { } public void testMultiFieldQueryString() { - client().prepareIndex("test", "s", "1").setSource("field1", "value1", "field2", "value2").setRefresh(true).get(); + client().prepareIndex("test", "s", "1").setSource("field1", "value1", "field2", "value2").setRefreshPolicy(IMMEDIATE).get(); logger.info("regular"); assertHitCount(client().prepareSearch("test").setQuery(queryStringQuery("value1").field("field1").field("field2")).get(), 1); @@ -1702,7 +1703,7 @@ public class SearchQueryIT extends ESIntegTestCase { } public void testAllFieldEmptyMapping() throws Exception { - client().prepareIndex("myindex", "mytype").setId("1").setSource("{}").setRefresh(true).get(); + client().prepareIndex("myindex", "mytype").setId("1").setSource("{}").setRefreshPolicy(IMMEDIATE).get(); SearchResponse response = client().prepareSearch("myindex").setQuery(matchQuery("_all", "foo")).get(); assertNoFailures(response); } @@ -1712,7 +1713,7 @@ public class SearchQueryIT extends ESIntegTestCase { assertAcked(client().admin().indices().preparePutMapping("myindex").setType("mytype").setSource( jsonBuilder().startObject().startObject("mytype").startObject("_all").field("enabled", false) .endObject().endObject().endObject())); - client().prepareIndex("myindex", "mytype").setId("1").setSource("bar", "foo").setRefresh(true).get(); + client().prepareIndex("myindex", "mytype").setId("1").setSource("bar", "foo").setRefreshPolicy(IMMEDIATE).get(); SearchResponse response = client().prepareSearch("myindex").setQuery(matchQuery("_all", "foo")).get(); assertNoFailures(response); assertHitCount(response, 0); @@ -2025,7 +2026,7 @@ public class SearchQueryIT extends ESIntegTestCase { client().prepareIndex("test", "test", "1").setSource("origin", "C.A1234.5678") - .setRefresh(true) + .setRefreshPolicy(IMMEDIATE) .get(); SearchResponse searchResponse = client().prepareSearch("test") diff --git a/core/src/test/java/org/elasticsearch/search/scroll/SearchScrollIT.java b/core/src/test/java/org/elasticsearch/search/scroll/SearchScrollIT.java index 9ee9e0841c..3bce6e10f8 100644 --- a/core/src/test/java/org/elasticsearch/search/scroll/SearchScrollIT.java +++ b/core/src/test/java/org/elasticsearch/search/scroll/SearchScrollIT.java @@ -48,6 +48,7 @@ import org.elasticsearch.test.hamcrest.ElasticsearchAssertions; import java.io.IOException; import java.util.Map; +import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.index.query.QueryBuilders.queryStringQuery; @@ -421,7 +422,7 @@ public class SearchScrollIT extends ESIntegTestCase { public void testDeepScrollingDoesNotBlowUp() throws Exception { client().prepareIndex("index", "type", "1") .setSource("field", "value") - .setRefresh(true) + .setRefreshPolicy(IMMEDIATE) .execute().get(); for (SearchType searchType : SearchType.values()) { diff --git a/core/src/test/java/org/elasticsearch/search/simple/SimpleSearchIT.java b/core/src/test/java/org/elasticsearch/search/simple/SimpleSearchIT.java index 4220bcb453..9751df2632 100644 --- a/core/src/test/java/org/elasticsearch/search/simple/SimpleSearchIT.java +++ b/core/src/test/java/org/elasticsearch/search/simple/SimpleSearchIT.java @@ -36,6 +36,7 @@ import org.elasticsearch.rest.RestStatus; import org.elasticsearch.search.rescore.QueryRescorerBuilder; import org.elasticsearch.test.ESIntegTestCase; +import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; @@ -101,7 +102,8 @@ public class SimpleSearchIT extends ESIntegTestCase { .endObject().endObject().endObject()) .execute().actionGet(); - client().prepareIndex("test", "type1", "1").setSource("from", "192.168.0.5", "to", "192.168.0.10").setRefresh(true).execute().actionGet(); + client().prepareIndex("test", "type1", "1").setSource("from", "192.168.0.5", "to", "192.168.0.10").setRefreshPolicy(IMMEDIATE) + .get(); SearchResponse search = client().prepareSearch() .setQuery(boolQuery().must(rangeQuery("from").lte("192.168.0.7")).must(rangeQuery("to").gte("192.168.0.7"))) @@ -185,7 +187,7 @@ public class SimpleSearchIT extends ESIntegTestCase { public void testSimpleId() { createIndex("test"); - client().prepareIndex("test", "type", "XXX1").setSource("field", "value").setRefresh(true).execute().actionGet(); + client().prepareIndex("test", "type", "XXX1").setSource("field", "value").setRefreshPolicy(IMMEDIATE).get(); // id is not indexed, but lets see that we automatically convert to SearchResponse searchResponse = client().prepareSearch().setQuery(QueryBuilders.termQuery("_id", "XXX1")).execute().actionGet(); assertHitCount(searchResponse, 1L); diff --git a/core/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchIT.java b/core/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchIT.java index 9ef3c898ca..0c6179e069 100644 --- a/core/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchIT.java +++ b/core/src/test/java/org/elasticsearch/search/suggest/CompletionSuggestSearchIT.java @@ -64,6 +64,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; +import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; import static org.elasticsearch.common.util.CollectionUtils.iterableAsArrayList; @@ -622,7 +623,8 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase { .endObject() .endObject(); assertAcked(prepareCreate(INDEX).addMapping(TYPE, mapping)); - client().prepareIndex(INDEX, TYPE, "1").setRefresh(true).setSource(jsonBuilder().startObject().field(FIELD, "Foo Fighters").endObject()).get(); + client().prepareIndex(INDEX, TYPE, "1").setRefreshPolicy(IMMEDIATE) + .setSource(jsonBuilder().startObject().field(FIELD, "Foo Fighters").endObject()).get(); ensureGreen(INDEX); PutMappingResponse putMappingResponse = client().admin().indices().preparePutMapping(INDEX).setType(TYPE).setSource(jsonBuilder().startObject() @@ -643,7 +645,8 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase { ).execute().actionGet(); assertSuggestions(searchResponse, "suggs"); - client().prepareIndex(INDEX, TYPE, "1").setRefresh(true).setSource(jsonBuilder().startObject().field(FIELD, "Foo Fighters").endObject()).get(); + client().prepareIndex(INDEX, TYPE, "1").setRefreshPolicy(IMMEDIATE) + .setSource(jsonBuilder().startObject().field(FIELD, "Foo Fighters").endObject()).get(); ensureGreen(INDEX); SearchResponse afterReindexingResponse = client().prepareSearch(INDEX).suggest( @@ -1089,7 +1092,7 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase { .startObject().startObject(FIELD) .startArray("input").value(longString).endArray() .endObject().endObject() - ).setRefresh(true).get(); + ).setRefreshPolicy(IMMEDIATE).get(); } @@ -1111,7 +1114,7 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase { .startArray("input").value(string).endArray() .field("output", "foobar") .endObject().endObject() - ).setRefresh(true).get(); + ).get(); fail("Expected MapperParsingException"); } catch (MapperParsingException e) { assertThat(e.getMessage(), containsString("failed to parse")); @@ -1133,7 +1136,7 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase { .startObject() .field(FIELD, string) .endObject() - ).setRefresh(true).get(); + ).setRefreshPolicy(IMMEDIATE).get(); try { client().prepareSearch(INDEX).addAggregation(AggregationBuilders.terms("suggest_agg").field(FIELD) @@ -1163,11 +1166,10 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase { ensureGreen(); client().prepareIndex(INDEX, TYPE, "1").setSource(FIELD, "strings make me happy", FIELD + "_1", "nulls make me sad") - .setRefresh(true).get(); + .setRefreshPolicy(IMMEDIATE).get(); try { - client().prepareIndex(INDEX, TYPE, "2").setSource(FIELD, null, FIELD + "_1", "nulls make me sad") - .setRefresh(true).get(); + client().prepareIndex(INDEX, TYPE, "2").setSource(FIELD, null, FIELD + "_1", "nulls make me sad").get(); fail("Expected MapperParsingException for null value"); } catch (MapperParsingException e) { // make sure that the exception has the name of the field causing the error diff --git a/core/src/test/java/org/elasticsearch/search/suggest/ContextSuggestSearch2xIT.java b/core/src/test/java/org/elasticsearch/search/suggest/ContextSuggestSearch2xIT.java index 9152fe6184..f5726622f6 100644 --- a/core/src/test/java/org/elasticsearch/search/suggest/ContextSuggestSearch2xIT.java +++ b/core/src/test/java/org/elasticsearch/search/suggest/ContextSuggestSearch2xIT.java @@ -53,6 +53,7 @@ import java.util.Map; import java.util.Set; import static com.carrotsearch.randomizedtesting.RandomizedTest.getRandom; +import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertSuggestion; @@ -504,7 +505,7 @@ public class ContextSuggestSearch2xIT extends ESIntegTestCase { ensureGreen(); client().prepareIndex(INDEX, TYPE, "1").setSource(FIELD, "") - .setRefresh(true).get(); + .setRefreshPolicy(IMMEDIATE).get(); } diff --git a/core/src/test/java/org/elasticsearch/search/suggest/CustomSuggesterSearchIT.java b/core/src/test/java/org/elasticsearch/search/suggest/CustomSuggesterSearchIT.java index 4f97a5179e..28f8ec49a5 100644 --- a/core/src/test/java/org/elasticsearch/search/suggest/CustomSuggesterSearchIT.java +++ b/core/src/test/java/org/elasticsearch/search/suggest/CustomSuggesterSearchIT.java @@ -45,6 +45,7 @@ import java.util.Locale; import java.util.Map; import java.util.Objects; +import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.is; @@ -65,7 +66,7 @@ public class CustomSuggesterSearchIT extends ESIntegTestCase { .startObject() .field("name", "arbitrary content") .endObject()) - .setRefresh(true).execute().actionGet(); + .setRefreshPolicy(IMMEDIATE).get(); ensureYellow(); String randomText = randomAsciiOfLength(10); diff --git a/core/src/test/java/org/elasticsearch/similarity/SimilarityIT.java b/core/src/test/java/org/elasticsearch/similarity/SimilarityIT.java index a123f7133b..66c3509c76 100644 --- a/core/src/test/java/org/elasticsearch/similarity/SimilarityIT.java +++ b/core/src/test/java/org/elasticsearch/similarity/SimilarityIT.java @@ -23,6 +23,7 @@ import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.test.ESIntegTestCase; +import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.index.query.QueryBuilders.matchQuery; import static org.hamcrest.Matchers.equalTo; @@ -61,7 +62,7 @@ public class SimilarityIT extends ESIntegTestCase { client().prepareIndex("test", "type1", "1").setSource("field1", "the quick brown fox jumped over the lazy dog", "field2", "the quick brown fox jumped over the lazy dog") - .setRefresh(true).execute().actionGet(); + .setRefreshPolicy(IMMEDIATE).execute().actionGet(); SearchResponse bm25SearchResponse = client().prepareSearch().setQuery(matchQuery("field1", "quick brown fox")).execute().actionGet(); assertThat(bm25SearchResponse.getHits().totalHits(), equalTo(1L)); diff --git a/core/src/test/java/org/elasticsearch/timestamp/SimpleTimestampIT.java b/core/src/test/java/org/elasticsearch/timestamp/SimpleTimestampIT.java index 21408e7b1d..2fa94bc235 100644 --- a/core/src/test/java/org/elasticsearch/timestamp/SimpleTimestampIT.java +++ b/core/src/test/java/org/elasticsearch/timestamp/SimpleTimestampIT.java @@ -29,6 +29,7 @@ import org.elasticsearch.test.ESIntegTestCase; import java.util.Locale; +import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.hamcrest.Matchers.equalTo; @@ -48,7 +49,7 @@ public class SimpleTimestampIT extends ESIntegTestCase { logger.info("--> check with automatic timestamp"); long now1 = System.currentTimeMillis(); - client().prepareIndex("test", "type1", "1").setSource("field1", "value1").setRefresh(true).execute().actionGet(); + client().prepareIndex("test", "type1", "1").setSource("field1", "value1").setRefreshPolicy(IMMEDIATE).get(); long now2 = System.currentTimeMillis(); // we check both realtime get and non realtime get @@ -70,7 +71,7 @@ public class SimpleTimestampIT extends ESIntegTestCase { assertThat(((Number) getResponse.getField("_timestamp").getValue()).longValue(), equalTo(timestamp)); logger.info("--> check with custom timestamp (numeric)"); - client().prepareIndex("test", "type1", "1").setSource("field1", "value1").setTimestamp("10").setRefresh(true).execute().actionGet(); + client().prepareIndex("test", "type1", "1").setSource("field1", "value1").setTimestamp("10").setRefreshPolicy(IMMEDIATE).get(); getResponse = client().prepareGet("test", "type1", "1").setFields("_timestamp").setRealtime(false).execute().actionGet(); timestamp = ((Number) getResponse.getField("_timestamp").getValue()).longValue(); @@ -80,7 +81,8 @@ public class SimpleTimestampIT extends ESIntegTestCase { assertThat(((Number) getResponse.getField("_timestamp").getValue()).longValue(), equalTo(timestamp)); logger.info("--> check with custom timestamp (string)"); - client().prepareIndex("test", "type1", "1").setSource("field1", "value1").setTimestamp("1970-01-01T00:00:00.020").setRefresh(true).execute().actionGet(); + client().prepareIndex("test", "type1", "1").setSource("field1", "value1").setTimestamp("1970-01-01T00:00:00.020") + .setRefreshPolicy(IMMEDIATE).get(); getResponse = client().prepareGet("test", "type1", "1").setFields("_timestamp").setRealtime(false).execute().actionGet(); timestamp = ((Number) getResponse.getField("_timestamp").getValue()).longValue(); diff --git a/core/src/test/java/org/elasticsearch/ttl/SimpleTTLIT.java b/core/src/test/java/org/elasticsearch/ttl/SimpleTTLIT.java index f6a74faac3..003c08134b 100644 --- a/core/src/test/java/org/elasticsearch/ttl/SimpleTTLIT.java +++ b/core/src/test/java/org/elasticsearch/ttl/SimpleTTLIT.java @@ -38,6 +38,7 @@ import java.util.Locale; import java.util.Map; import java.util.concurrent.TimeUnit; +import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.hamcrest.Matchers.both; @@ -92,10 +93,10 @@ public class SimpleTTLIT extends ESIntegTestCase { // Index one doc without routing, one doc with routing, one doc with not TTL and no default and one doc with default TTL long now = System.currentTimeMillis(); IndexResponse indexResponse = client().prepareIndex("test", "type1", "1").setSource("field1", "value1") - .setTimestamp(String.valueOf(now)).setTTL(providedTTLValue).setRefresh(true).get(); + .setTimestamp(String.valueOf(now)).setTTL(providedTTLValue).setRefreshPolicy(IMMEDIATE).get(); assertThat(indexResponse.isCreated(), is(true)); indexResponse = client().prepareIndex("test", "type1", "with_routing").setSource("field1", "value1") - .setTimestamp(String.valueOf(now)).setTTL(providedTTLValue).setRouting("routing").setRefresh(true).get(); + .setTimestamp(String.valueOf(now)).setTTL(providedTTLValue).setRouting("routing").setRefreshPolicy(IMMEDIATE).get(); assertThat(indexResponse.isCreated(), is(true)); indexResponse = client().prepareIndex("test", "type1", "no_ttl").setSource("field1", "value1").get(); assertThat(indexResponse.isCreated(), is(true)); @@ -245,7 +246,7 @@ public class SimpleTTLIT extends ESIntegTestCase { long secondTtl = aLongTime * 2; long thirdTtl = aLongTime * 1; IndexResponse indexResponse = client().prepareIndex("test", "type1", "1").setSource("field1", "value1") - .setTTL(firstTtl).setRefresh(true).get(); + .setTTL(firstTtl).setRefreshPolicy(IMMEDIATE).get(); assertTrue(indexResponse.isCreated()); assertThat(getTtl("type1", 1), both(lessThanOrEqualTo(firstTtl)).and(greaterThan(secondTtl))); diff --git a/core/src/test/java/org/elasticsearch/update/UpdateIT.java b/core/src/test/java/org/elasticsearch/update/UpdateIT.java index 0445da6109..078bcd8cc3 100644 --- a/core/src/test/java/org/elasticsearch/update/UpdateIT.java +++ b/core/src/test/java/org/elasticsearch/update/UpdateIT.java @@ -63,6 +63,7 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; +import static org.elasticsearch.action.support.WriteRequest.RefreshPolicy.IMMEDIATE; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertThrows; @@ -694,7 +695,7 @@ public class UpdateIT extends ESIntegTestCase { } // check TTL is kept after an update without TTL - client().prepareIndex("test", "type1", "2").setSource("field", 1).setTTL(86400000L).setRefresh(true).execute().actionGet(); + client().prepareIndex("test", "type1", "2").setSource("field", 1).setTTL(86400000L).setRefreshPolicy(IMMEDIATE).get(); GetResponse getResponse = client().prepareGet("test", "type1", "2").setFields("_ttl").execute().actionGet(); long ttl = ((Number) getResponse.getField("_ttl").getValue()).longValue(); assertThat(ttl, greaterThan(0L)); @@ -713,7 +714,7 @@ public class UpdateIT extends ESIntegTestCase { assertThat(ttl, lessThanOrEqualTo(3600000L)); // check timestamp update - client().prepareIndex("test", "type1", "3").setSource("field", 1).setRefresh(true).execute().actionGet(); + client().prepareIndex("test", "type1", "3").setSource("field", 1).setRefreshPolicy(IMMEDIATE).get(); client().prepareUpdate(indexOrAlias(), "type1", "3") .setScript(new Script("", ScriptService.ScriptType.INLINE, "put_values", Collections.singletonMap("_ctx", Collections.singletonMap("_timestamp", "2009-11-15T14:12:12")))).execute() .actionGet(); |