From c812e6aea6a66092188d56090ff5a77a48a81a8b Mon Sep 17 00:00:00 2001 From: Przemyslaw Gomulka Date: Thu, 10 Jan 2019 15:23:34 +0100 Subject: [PATCH] Fix line length in org.elasticsearch.routing (#37253) Remove the line length suppression for this package and fix offending lines relates: #34884 --- .../resources/checkstyle_suppressions.xml | 2 - .../elasticsearch/routing/AliasRoutingIT.java | 372 +++++++++++++++--- .../routing/SimpleRoutingIT.java | 340 +++++++++++++--- 3 files changed, 588 insertions(+), 126 deletions(-) diff --git a/buildSrc/src/main/resources/checkstyle_suppressions.xml b/buildSrc/src/main/resources/checkstyle_suppressions.xml index 4d587263948..370a6bbcac9 100644 --- a/buildSrc/src/main/resources/checkstyle_suppressions.xml +++ b/buildSrc/src/main/resources/checkstyle_suppressions.xml @@ -53,8 +53,6 @@ - - diff --git a/server/src/test/java/org/elasticsearch/routing/AliasRoutingIT.java b/server/src/test/java/org/elasticsearch/routing/AliasRoutingIT.java index eceef54ccac..1919b7e6a9a 100644 --- a/server/src/test/java/org/elasticsearch/routing/AliasRoutingIT.java +++ b/server/src/test/java/org/elasticsearch/routing/AliasRoutingIT.java @@ -71,7 +71,12 @@ public class AliasRoutingIT extends ESIntegTestCase { .execute().actionGet(); for (int i = 0; i < 5; i++) { assertThat(client().prepareGet("alias0", "type1", "1").execute().actionGet().isExists(), equalTo(true)); - assertThat(client().prepareGet("alias0", "type1", "1").execute().actionGet().getSourceAsMap().get("field").toString(), equalTo("value2")); + assertThat(client().prepareGet("alias0", "type1", "1") + .execute() + .actionGet() + .getSourceAsMap() + .get("field") + .toString(), equalTo("value2")); } @@ -108,10 +113,10 @@ public class AliasRoutingIT extends ESIntegTestCase { createIndex("test"); ensureGreen(); assertAcked(admin().indices().prepareAliases() - .addAliasAction(AliasActions.add().index("test").alias("alias")) - .addAliasAction(AliasActions.add().index("test").alias("alias0").routing("0")) - .addAliasAction(AliasActions.add().index("test").alias("alias1").routing("1")) - .addAliasAction(AliasActions.add().index("test").alias("alias01").searchRouting("0,1"))); + .addAliasAction(AliasActions.add().index("test").alias("alias")) + .addAliasAction(AliasActions.add().index("test").alias("alias0").routing("0")) + .addAliasAction(AliasActions.add().index("test").alias("alias1").routing("1")) + .addAliasAction(AliasActions.add().index("test").alias("alias01").searchRouting("0,1"))); logger.info("--> indexing with id [1], and routing [0] using alias"); client().prepareIndex("alias0", "type1", "1").setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get(); @@ -126,23 +131,80 @@ public class AliasRoutingIT extends ESIntegTestCase { logger.info("--> search with no routing, should fine one"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch().setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(1L)); + assertThat(client().prepareSearch() + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(1L)); } logger.info("--> search with wrong routing, should not find"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch().setRouting("1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(0L)); - assertThat(client().prepareSearch().setSize(0).setRouting("1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(0L)); - assertThat(client().prepareSearch("alias1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(0L)); - assertThat(client().prepareSearch("alias1").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(0L)); + assertThat(client().prepareSearch() + .setRouting("1") + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(0L)); + + assertThat(client().prepareSearch() + .setSize(0) + .setRouting("1") + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(0L)); + + assertThat(client().prepareSearch("alias1") + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(0L)); + + assertThat(client().prepareSearch("alias1") + .setSize(0) + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(0L)); } logger.info("--> search with correct routing, should find"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch().setRouting("0").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(1L)); - assertThat(client().prepareSearch().setSize(0).setRouting("0").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(1L)); - assertThat(client().prepareSearch("alias0").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(1L)); - assertThat(client().prepareSearch("alias0").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(1L)); + + assertThat(client().prepareSearch() + .setRouting("0") + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(1L)); + assertThat(client().prepareSearch() + .setSize(0) + .setRouting("0") + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(1L)); + assertThat(client().prepareSearch("alias0") + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(1L)); + assertThat(client().prepareSearch("alias0") + .setSize(0) + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(1L)); } logger.info("--> indexing with id [2], and routing [1] using alias"); @@ -150,50 +212,166 @@ public class AliasRoutingIT extends ESIntegTestCase { logger.info("--> search with no routing, should fine two"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch().setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(2L)); - assertThat(client().prepareSearch().setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(2L)); + assertThat(client().prepareSearch() + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(2L)); + assertThat(client().prepareSearch() + .setSize(0) + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(2L)); } logger.info("--> search with 0 routing, should find one"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch().setRouting("0").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(1L)); - assertThat(client().prepareSearch().setSize(0).setRouting("0").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(1L)); - assertThat(client().prepareSearch("alias0").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(1L)); - assertThat(client().prepareSearch("alias0").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(1L)); + assertThat(client().prepareSearch() + .setRouting("0") + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(1L)); + assertThat(client().prepareSearch() + .setSize(0) + .setRouting("0") + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(1L)); + assertThat(client().prepareSearch("alias0") + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(1L)); + assertThat(client().prepareSearch("alias0") + .setSize(0) + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(1L)); } logger.info("--> search with 1 routing, should find one"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch().setRouting("1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(1L)); - assertThat(client().prepareSearch().setSize(0).setRouting("1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(1L)); - assertThat(client().prepareSearch("alias1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(1L)); - assertThat(client().prepareSearch("alias1").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(1L)); + assertThat(client().prepareSearch() + .setRouting("1") + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(1L)); + assertThat(client().prepareSearch() + .setSize(0) + .setRouting("1") + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(1L)); + assertThat(client().prepareSearch("alias1") + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(1L)); + assertThat(client().prepareSearch("alias1") + .setSize(0) + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(1L)); } logger.info("--> search with 0,1 indexRoutings , should find two"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch().setRouting("0", "1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(2L)); - assertThat(client().prepareSearch().setSize(0).setRouting("0", "1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(2L)); - assertThat(client().prepareSearch("alias01").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(2L)); - assertThat(client().prepareSearch("alias01").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(2L)); + assertThat(client().prepareSearch() + .setRouting("0", "1") + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(2L)); + assertThat(client().prepareSearch() + .setSize(0) + .setRouting("0", "1") + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(2L)); + assertThat(client().prepareSearch("alias01") + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(2L)); + assertThat(client().prepareSearch("alias01") + .setSize(0) + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(2L)); } logger.info("--> search with two routing aliases , should find two"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch("alias0", "alias1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(2L)); - assertThat(client().prepareSearch("alias0", "alias1").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(2L)); + assertThat(client().prepareSearch("alias0", "alias1") + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(2L)); + assertThat(client().prepareSearch("alias0", "alias1") + .setSize(0) + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(2L)); } logger.info("--> search with alias0, alias1 and alias01, should find two"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch("alias0", "alias1", "alias01").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(2L)); - assertThat(client().prepareSearch("alias0", "alias1", "alias01").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(2L)); + assertThat(client().prepareSearch("alias0", "alias1", "alias01") + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(2L)); + assertThat(client().prepareSearch("alias0", "alias1", "alias01") + .setSize(0) + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(2L)); } logger.info("--> search with test, alias0 and alias1, should find two"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch("test", "alias0", "alias1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(2L)); - assertThat(client().prepareSearch("test", "alias0", "alias1").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(2L)); + assertThat(client().prepareSearch("test", "alias0", "alias1") + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(2L)); + assertThat(client().prepareSearch("test", "alias0", "alias1") + .setSize(0) + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(2L)); } } @@ -210,12 +388,12 @@ public class AliasRoutingIT extends ESIntegTestCase { createIndex("test-b"); ensureGreen(); assertAcked(admin().indices().prepareAliases() - .addAliasAction(AliasActions.add().index("test-a").alias("alias-a0").routing("0")) - .addAliasAction(AliasActions.add().index("test-a").alias("alias-a1").routing("1")) - .addAliasAction(AliasActions.add().index("test-b").alias("alias-b0").routing("0")) - .addAliasAction(AliasActions.add().index("test-b").alias("alias-b1").routing("1")) - .addAliasAction(AliasActions.add().index("test-a").alias("alias-ab").searchRouting("0")) - .addAliasAction(AliasActions.add().index("test-b").alias("alias-ab").searchRouting("1"))); + .addAliasAction(AliasActions.add().index("test-a").alias("alias-a0").routing("0")) + .addAliasAction(AliasActions.add().index("test-a").alias("alias-a1").routing("1")) + .addAliasAction(AliasActions.add().index("test-b").alias("alias-b0").routing("0")) + .addAliasAction(AliasActions.add().index("test-b").alias("alias-b1").routing("1")) + .addAliasAction(AliasActions.add().index("test-a").alias("alias-ab").searchRouting("0")) + .addAliasAction(AliasActions.add().index("test-b").alias("alias-ab").searchRouting("1"))); ensureGreen(); // wait for events again to make sure we got the aliases on all nodes logger.info("--> indexing with id [1], and routing [0] using alias to test-a"); client().prepareIndex("alias-a0", "type1", "1").setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get(); @@ -242,20 +420,53 @@ public class AliasRoutingIT extends ESIntegTestCase { logger.info("--> search with alias-a1,alias-b0, should not find"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch("alias-a1", "alias-b0").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(0L)); - assertThat(client().prepareSearch("alias-a1", "alias-b0").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(0L)); + assertThat(client().prepareSearch("alias-a1", "alias-b0") + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(0L)); + assertThat(client().prepareSearch("alias-a1", "alias-b0") + .setSize(0) + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(0L)); } logger.info("--> search with alias-ab, should find two"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch("alias-ab").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(2L)); - assertThat(client().prepareSearch("alias-ab").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(2L)); + assertThat(client().prepareSearch("alias-ab") + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(2L)); + assertThat(client().prepareSearch("alias-ab") + .setSize(0) + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(2L)); } logger.info("--> search with alias-a0,alias-b1 should find two"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch("alias-a0", "alias-b1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(2L)); - assertThat(client().prepareSearch("alias-a0", "alias-b1").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(2L)); + assertThat(client().prepareSearch("alias-a0", "alias-b1") + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(2L)); + assertThat(client().prepareSearch("alias-a0", "alias-b1") + .setSize(0) + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(2L)); } } @@ -269,7 +480,7 @@ public class AliasRoutingIT extends ESIntegTestCase { createIndex("index", "index_2"); ensureGreen(); assertAcked(admin().indices().prepareAliases() - .addAliasAction(AliasActions.add().index("index").alias("index_1").routing("1"))); + .addAliasAction(AliasActions.add().index("index").alias("index_1").routing("1"))); logger.info("--> indexing on index_1 which is an alias for index with routing [1]"); client().prepareIndex("index_1", "type1", "1").setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get(); @@ -279,7 +490,12 @@ public class AliasRoutingIT extends ESIntegTestCase { logger.info("--> search all on index_* should find two"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch("index_*").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(2L)); + assertThat(client().prepareSearch("index_*") + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(2L)); } } @@ -294,14 +510,19 @@ public class AliasRoutingIT extends ESIntegTestCase { createIndex("index", "index_2"); ensureGreen(); assertAcked(admin().indices().prepareAliases() - .addAliasAction(AliasActions.add().index("index").alias("index_1").routing("1"))); + .addAliasAction(AliasActions.add().index("index").alias("index_1").routing("1"))); logger.info("--> indexing on index_1 which is an alias for index with routing [1]"); client().prepareIndex("index_1", "type1", "1").setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get(); logger.info("--> indexing on index_2 which is a concrete index"); client().prepareIndex("index_2", "type2", "2").setSource("field", "value2").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get(); - SearchResponse searchResponse = client().prepareSearch("index_*").setSearchType(SearchType.QUERY_THEN_FETCH).setSize(1).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet(); + SearchResponse searchResponse = client().prepareSearch("index_*") + .setSearchType(SearchType.QUERY_THEN_FETCH) + .setSize(1) + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet(); logger.info("--> search all on index_* should find two"); assertThat(searchResponse.getHits().getTotalHits().value, equalTo(2L)); @@ -315,7 +536,7 @@ public class AliasRoutingIT extends ESIntegTestCase { ensureGreen(); logger.info("--> creating alias with routing [3]"); assertAcked(admin().indices().prepareAliases() - .addAliasAction(AliasActions.add().index("test").alias("alias").routing("3"))); + .addAliasAction(AliasActions.add().index("test").alias("alias").routing("3"))); logger.info("--> indexing with id [0], and routing [3]"); client().prepareIndex("alias", "type1", "0").setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get(); @@ -324,23 +545,45 @@ public class AliasRoutingIT extends ESIntegTestCase { logger.info("--> verifying get and search with routing, should find"); for (int i = 0; i < 5; i++) { assertThat(client().prepareGet("test", "type1", "0").setRouting("3").execute().actionGet().isExists(), equalTo(true)); - assertThat(client().prepareSearch("alias").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(1L)); - assertThat(client().prepareSearch("alias").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(1L)); + assertThat(client().prepareSearch("alias") + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(1L)); + assertThat(client().prepareSearch("alias") + .setSize(0) + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(1L)); } logger.info("--> creating alias with routing [4]"); assertAcked(admin().indices().prepareAliases() - .addAliasAction(AliasActions.add().index("test").alias("alias").routing("4"))); + .addAliasAction(AliasActions.add().index("test").alias("alias").routing("4"))); logger.info("--> verifying search with wrong routing should not find"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch("alias").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(0L)); - assertThat(client().prepareSearch("alias").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(0L)); + assertThat(client().prepareSearch("alias") + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(0L)); + assertThat(client().prepareSearch("alias") + .setSize(0) + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(0L)); } logger.info("--> creating alias with search routing [3,4] and index routing 4"); assertAcked(client().admin().indices().prepareAliases() - .addAliasAction(AliasActions.add().index("test").alias("alias").searchRouting("3,4").indexRouting("4"))); + .addAliasAction(AliasActions.add().index("test").alias("alias").searchRouting("3,4").indexRouting("4"))); logger.info("--> indexing with id [1], and routing [4]"); client().prepareIndex("alias", "type1", "1").setSource("field", "value2").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get(); @@ -350,8 +593,19 @@ public class AliasRoutingIT extends ESIntegTestCase { for (int i = 0; i < 5; i++) { assertThat(client().prepareGet("test", "type1", "0").setRouting("3").execute().actionGet().isExists(), equalTo(true)); assertThat(client().prepareGet("test", "type1", "1").setRouting("4").execute().actionGet().isExists(), equalTo(true)); - assertThat(client().prepareSearch("alias").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(2L)); - assertThat(client().prepareSearch("alias").setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(2L)); + assertThat(client().prepareSearch("alias") + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(2L)); + assertThat(client().prepareSearch("alias") + .setSize(0) + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits().value, equalTo(2L)); } } diff --git a/server/src/test/java/org/elasticsearch/routing/SimpleRoutingIT.java b/server/src/test/java/org/elasticsearch/routing/SimpleRoutingIT.java index ad8024e76b4..b383a802962 100644 --- a/server/src/test/java/org/elasticsearch/routing/SimpleRoutingIT.java +++ b/server/src/test/java/org/elasticsearch/routing/SimpleRoutingIT.java @@ -78,7 +78,10 @@ public class SimpleRoutingIT extends ESIntegTestCase { ensureGreen(); String routingValue = findNonMatchingRoutingValue("test", "1"); logger.info("--> indexing with id [1], and routing [{}]", routingValue); - client().prepareIndex("test", "type1", "1").setRouting(routingValue).setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE) + client().prepareIndex("test", "type1", "1") + .setRouting(routingValue) + .setSource("field", "value1") + .setRefreshPolicy(RefreshPolicy.IMMEDIATE) .get(); logger.info("--> verifying get with no routing, should not find anything"); for (int i = 0; i < 5; i++) { @@ -86,25 +89,40 @@ public class SimpleRoutingIT extends ESIntegTestCase { } logger.info("--> verifying get with routing, should find"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareGet("test", "type1", "1").setRouting(routingValue).execute().actionGet().isExists(), equalTo(true)); + assertThat(client().prepareGet("test", "type1", "1") + .setRouting(routingValue) + .execute() + .actionGet() + .isExists(), equalTo(true)); } logger.info("--> deleting with no routing, should not delete anything"); client().prepareDelete("test", "type1", "1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get(); for (int i = 0; i < 5; i++) { assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().isExists(), equalTo(false)); - assertThat(client().prepareGet("test", "type1", "1").setRouting(routingValue).execute().actionGet().isExists(), equalTo(true)); + assertThat(client().prepareGet("test", "type1", "1") + .setRouting(routingValue) + .execute() + .actionGet() + .isExists(), equalTo(true)); } logger.info("--> deleting with routing, should delete"); client().prepareDelete("test", "type1", "1").setRouting(routingValue).setRefreshPolicy(RefreshPolicy.IMMEDIATE).get(); for (int i = 0; i < 5; i++) { assertThat(client().prepareGet("test", "type1", "1").execute().actionGet().isExists(), equalTo(false)); - assertThat(client().prepareGet("test", "type1", "1").setRouting(routingValue).execute().actionGet().isExists(), equalTo(false)); + assertThat(client().prepareGet("test", "type1", "1") + .setRouting(routingValue) + .execute() + .actionGet() + .isExists(), equalTo(false)); } logger.info("--> indexing with id [1], and routing [0]"); - client().prepareIndex("test", "type1", "1").setRouting(routingValue).setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE) + client().prepareIndex("test", "type1", "1") + .setRouting(routingValue) + .setSource("field", "value1") + .setRefreshPolicy(RefreshPolicy.IMMEDIATE) .get(); logger.info("--> verifying get with no routing, should not find anything"); for (int i = 0; i < 5; i++) { @@ -112,7 +130,11 @@ public class SimpleRoutingIT extends ESIntegTestCase { } logger.info("--> verifying get with routing, should find"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareGet("test", "type1", "1").setRouting(routingValue).execute().actionGet().isExists(), equalTo(true)); + assertThat(client().prepareGet("test", "type1", "1") + .setRouting(routingValue) + .execute() + .actionGet() + .isExists(), equalTo(true)); } } @@ -122,7 +144,10 @@ public class SimpleRoutingIT extends ESIntegTestCase { String routingValue = findNonMatchingRoutingValue("test", "1"); logger.info("--> indexing with id [1], and routing [{}]", routingValue); - client().prepareIndex("test", "type1", "1").setRouting(routingValue).setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE) + client().prepareIndex("test", "type1", "1") + .setRouting(routingValue) + .setSource("field", "value1") + .setRefreshPolicy(RefreshPolicy.IMMEDIATE) .get(); logger.info("--> verifying get with no routing, should not find anything"); for (int i = 0; i < 5; i++) { @@ -130,65 +155,193 @@ public class SimpleRoutingIT extends ESIntegTestCase { } logger.info("--> verifying get with routing, should find"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareGet("test", "type1", "1").setRouting(routingValue).execute().actionGet().isExists(), equalTo(true)); + assertThat(client().prepareGet("test", "type1", "1") + .setRouting(routingValue) + .execute() + .actionGet() + .isExists(), equalTo(true)); } logger.info("--> search with no routing, should fine one"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch().setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(1L)); + assertThat(client().prepareSearch() + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits() + .value, equalTo(1L)); } logger.info("--> search with wrong routing, should not find"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch().setRouting("1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(0L)); - assertThat(client().prepareSearch().setSize(0).setRouting("1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(0L)); + assertThat(client().prepareSearch() + .setRouting("1") + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits() + .value, equalTo(0L)); + assertThat(client().prepareSearch() + .setSize(0) + .setRouting("1") + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits() + .value, equalTo(0L)); } logger.info("--> search with correct routing, should find"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch().setRouting(routingValue).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(1L)); - assertThat(client().prepareSearch().setSize(0).setRouting(routingValue).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(1L)); + assertThat(client().prepareSearch() + .setRouting(routingValue) + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits() + .value, equalTo(1L)); + assertThat(client().prepareSearch() + .setSize(0) + .setRouting(routingValue) + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits() + .value, equalTo(1L)); } String secondRoutingValue = "1"; logger.info("--> indexing with id [{}], and routing [{}]", routingValue, secondRoutingValue); - client().prepareIndex("test", "type1", routingValue).setRouting(secondRoutingValue).setSource("field", "value1").setRefreshPolicy(RefreshPolicy.IMMEDIATE).get(); + client().prepareIndex("test", "type1", routingValue) + .setRouting(secondRoutingValue) + .setSource("field", "value1") + .setRefreshPolicy(RefreshPolicy.IMMEDIATE) + .get(); logger.info("--> search with no routing, should fine two"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch().setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(2L)); - assertThat(client().prepareSearch().setSize(0).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(2L)); + assertThat(client().prepareSearch() + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits() + .value, equalTo(2L)); + assertThat(client().prepareSearch() + .setSize(0) + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits() + .value, equalTo(2L)); } logger.info("--> search with {} routing, should find one", routingValue); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch().setRouting(routingValue).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(1L)); - assertThat(client().prepareSearch().setSize(0).setRouting(routingValue).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(1L)); + assertThat(client().prepareSearch() + .setRouting(routingValue) + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits() + .value, equalTo(1L)); + assertThat(client().prepareSearch() + .setSize(0) + .setRouting(routingValue) + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits() + .value, equalTo(1L)); } logger.info("--> search with {} routing, should find one", secondRoutingValue); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch().setRouting("1").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(1L)); - assertThat(client().prepareSearch().setSize(0).setRouting(secondRoutingValue).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(1L)); + assertThat(client().prepareSearch() + .setRouting("1") + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits() + .value, equalTo(1L)); + assertThat(client().prepareSearch() + .setSize(0) + .setRouting(secondRoutingValue) + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits() + .value, equalTo(1L)); } logger.info("--> search with {},{} indexRoutings , should find two", routingValue, "1"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch().setRouting(routingValue, secondRoutingValue).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(2L)); - assertThat(client().prepareSearch().setSize(0).setRouting(routingValue, secondRoutingValue).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(2L)); + assertThat(client().prepareSearch() + .setRouting(routingValue, secondRoutingValue) + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits() + .value, equalTo(2L)); + assertThat(client().prepareSearch() + .setSize(0) + .setRouting(routingValue, secondRoutingValue) + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits() + .value, equalTo(2L)); } logger.info("--> search with {},{},{} indexRoutings , should find two", routingValue, secondRoutingValue, routingValue); for (int i = 0; i < 5; i++) { - assertThat(client().prepareSearch().setRouting(routingValue, secondRoutingValue, routingValue).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(2L)); - assertThat(client().prepareSearch().setSize(0).setRouting(routingValue, secondRoutingValue,routingValue).setQuery(QueryBuilders.matchAllQuery()).execute().actionGet().getHits().getTotalHits().value, equalTo(2L)); + assertThat(client().prepareSearch() + .setRouting(routingValue, secondRoutingValue, routingValue) + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits() + .value, equalTo(2L)); + assertThat(client().prepareSearch() + .setSize(0) + .setRouting(routingValue, secondRoutingValue, routingValue) + .setQuery(QueryBuilders.matchAllQuery()) + .execute() + .actionGet() + .getHits() + .getTotalHits() + .value, equalTo(2L)); } } public void testRequiredRoutingCrudApis() throws Exception { - client().admin().indices().prepareCreate("test").addAlias(new Alias("alias")) - .addMapping("type1", XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("_routing").field("required", true).endObject().endObject().endObject()) - .execute().actionGet(); + client().admin() + .indices() + .prepareCreate("test") + .addAlias(new Alias("alias")) + .addMapping("type1", XContentFactory.jsonBuilder() + .startObject() + .startObject("type1") + .startObject("_routing") + .field("required", true) + .endObject() + .endObject() + .endObject()) + .execute() + .actionGet(); ensureGreen(); String routingValue = findNonMatchingRoutingValue("test", "1"); @@ -207,7 +360,12 @@ public class SimpleRoutingIT extends ESIntegTestCase { logger.info("--> verifying get with routing, should find"); for (int i = 0; i < 5; i++) { - assertThat(client().prepareGet(indexOrAlias(), "type1", "1").setRouting(routingValue).execute().actionGet().isExists(), equalTo(true)); + assertThat(client() + .prepareGet(indexOrAlias(), "type1", "1") + .setRouting(routingValue) + .execute() + .actionGet() + .isExists(), equalTo(true)); } logger.info("--> deleting with no routing, should fail"); @@ -226,17 +384,28 @@ public class SimpleRoutingIT extends ESIntegTestCase { assertThat(e.status(), equalTo(RestStatus.BAD_REQUEST)); assertThat(e.getMessage(), equalTo("routing is required for [test]/[type1]/[1]")); } - assertThat(client().prepareGet(indexOrAlias(), "type1", "1").setRouting(routingValue).execute().actionGet().isExists(), equalTo(true)); + assertThat(client() + .prepareGet(indexOrAlias(), "type1", "1") + .setRouting(routingValue) + .execute() + .actionGet() + .isExists(), equalTo(true)); } try { - client().prepareUpdate(indexOrAlias(), "type1", "1").setDoc(Requests.INDEX_CONTENT_TYPE, "field", "value2").execute().actionGet(); + client().prepareUpdate(indexOrAlias(), "type1", "1") + .setDoc(Requests.INDEX_CONTENT_TYPE, "field", "value2") + .execute() + .actionGet(); fail("update with missing routing when routing is required should fail"); - } catch(ElasticsearchException e) { + } catch (ElasticsearchException e) { assertThat(e.unwrapCause(), instanceOf(RoutingMissingException.class)); } - client().prepareUpdate(indexOrAlias(), "type1", "1").setRouting(routingValue).setDoc(Requests.INDEX_CONTENT_TYPE, "field", "value2").get(); + client().prepareUpdate(indexOrAlias(), "type1", "1") + .setRouting(routingValue) + .setDoc(Requests.INDEX_CONTENT_TYPE, "field", "value2") + .get(); client().admin().indices().prepareRefresh().execute().actionGet(); for (int i = 0; i < 5; i++) { @@ -262,21 +431,32 @@ public class SimpleRoutingIT extends ESIntegTestCase { assertThat(e.status(), equalTo(RestStatus.BAD_REQUEST)); assertThat(e.getMessage(), equalTo("routing is required for [test]/[type1]/[1]")); } - assertThat(client().prepareGet(indexOrAlias(), "type1", "1").setRouting(routingValue).execute().actionGet().isExists(), equalTo(false)); + assertThat(client() + .prepareGet(indexOrAlias(), "type1", "1") + .setRouting(routingValue) + .execute() + .actionGet() + .isExists(), equalTo(false)); } } public void testRequiredRoutingBulk() throws Exception { client().admin().indices().prepareCreate("test") - .addAlias(new Alias("alias")) - .addMapping("type1", XContentFactory.jsonBuilder().startObject().startObject("type1") - .startObject("_routing").field("required", true).endObject() - .endObject().endObject()) - .execute().actionGet(); + .addAlias(new Alias("alias")) + .addMapping("type1", XContentFactory.jsonBuilder().startObject().startObject("type1") + .startObject("_routing").field("required", true).endObject() + .endObject().endObject()) + .execute().actionGet(); ensureGreen(); { - BulkResponse bulkResponse = client().prepareBulk().add(Requests.indexRequest(indexOrAlias()).type("type1").id("1") - .source(Requests.INDEX_CONTENT_TYPE, "field", "value")).execute().actionGet(); + BulkResponse bulkResponse = client() + .prepareBulk() + .add(Requests.indexRequest(indexOrAlias()) + .type("type1") + .id("1") + .source(Requests.INDEX_CONTENT_TYPE, "field", "value")) + .execute() + .actionGet(); assertThat(bulkResponse.getItems().length, equalTo(1)); assertThat(bulkResponse.hasFailures(), equalTo(true)); @@ -290,15 +470,22 @@ public class SimpleRoutingIT extends ESIntegTestCase { } { - BulkResponse bulkResponse = client().prepareBulk().add(Requests.indexRequest(indexOrAlias()).type("type1").id("1").routing("0") - .source(Requests.INDEX_CONTENT_TYPE, "field", "value")).execute().actionGet(); + BulkResponse bulkResponse = client() + .prepareBulk() + .add(Requests.indexRequest(indexOrAlias()) + .type("type1") + .id("1") + .routing("0") + .source(Requests.INDEX_CONTENT_TYPE, "field", "value")) + .execute() + .actionGet(); assertThat(bulkResponse.hasFailures(), equalTo(false)); } { BulkResponse bulkResponse = client().prepareBulk().add(new UpdateRequest(indexOrAlias(), "type1", "1") .doc(Requests.INDEX_CONTENT_TYPE, "field", "value2")) - .execute().actionGet(); + .execute().actionGet(); assertThat(bulkResponse.getItems().length, equalTo(1)); assertThat(bulkResponse.hasFailures(), equalTo(true)); @@ -320,7 +507,7 @@ public class SimpleRoutingIT extends ESIntegTestCase { { BulkResponse bulkResponse = client().prepareBulk().add(Requests.deleteRequest(indexOrAlias()).type("type1").id("1")) - .execute().actionGet(); + .execute().actionGet(); assertThat(bulkResponse.getItems().length, equalTo(1)); assertThat(bulkResponse.hasFailures(), equalTo(true)); @@ -335,7 +522,7 @@ public class SimpleRoutingIT extends ESIntegTestCase { { BulkResponse bulkResponse = client().prepareBulk().add(Requests.deleteRequest(indexOrAlias()).type("type1").id("1") - .routing("0")).execute().actionGet(); + .routing("0")).execute().actionGet(); assertThat(bulkResponse.getItems().length, equalTo(1)); assertThat(bulkResponse.hasFailures(), equalTo(false)); } @@ -343,10 +530,20 @@ public class SimpleRoutingIT extends ESIntegTestCase { public void testRequiredRoutingMappingVariousAPIs() throws Exception { - client().admin().indices().prepareCreate("test").addAlias(new Alias("alias")) - .addMapping("type1", XContentFactory.jsonBuilder().startObject().startObject("type1") - .startObject("_routing").field("required", true).endObject().endObject().endObject()) - .execute().actionGet(); + client().admin() + .indices() + .prepareCreate("test") + .addAlias(new Alias("alias")) + .addMapping("type1", XContentFactory.jsonBuilder() + .startObject() + .startObject("type1") + .startObject("_routing") + .field("required", true) + .endObject() + .endObject() + .endObject()) + .execute() + .actionGet(); ensureGreen(); String routingValue = findNonMatchingRoutingValue("test", "1"); logger.info("--> indexing with id [1], and routing [{}]", routingValue); @@ -356,7 +553,11 @@ public class SimpleRoutingIT extends ESIntegTestCase { .setRefreshPolicy(RefreshPolicy.IMMEDIATE).get(); logger.info("--> verifying get with id [1] with routing [0], should succeed"); - assertThat(client().prepareGet(indexOrAlias(), "type1", "1").setRouting(routingValue).execute().actionGet().isExists(), equalTo(true)); + assertThat(client().prepareGet(indexOrAlias(), "type1", "1") + .setRouting(routingValue) + .execute() + .actionGet() + .isExists(), equalTo(true)); logger.info("--> verifying get with id [1], with no routing, should fail"); try { @@ -368,8 +569,8 @@ public class SimpleRoutingIT extends ESIntegTestCase { logger.info("--> verifying explain with id [2], with routing [0], should succeed"); ExplainResponse explainResponse = client().prepareExplain(indexOrAlias(), "type1", "2") - .setQuery(QueryBuilders.matchAllQuery()) - .setRouting(routingValue).get(); + .setQuery(QueryBuilders.matchAllQuery()) + .setRouting(routingValue).get(); assertThat(explainResponse.isExists(), equalTo(true)); assertThat(explainResponse.isMatch(), equalTo(true)); @@ -383,7 +584,9 @@ public class SimpleRoutingIT extends ESIntegTestCase { } logger.info("--> verifying term vector with id [1], with routing [0], should succeed"); - TermVectorsResponse termVectorsResponse = client().prepareTermVectors(indexOrAlias(), "type1", "1").setRouting(routingValue).get(); + TermVectorsResponse termVectorsResponse = client().prepareTermVectors(indexOrAlias(), "type1", "1") + .setRouting(routingValue) + .get(); assertThat(termVectorsResponse.isExists(), equalTo(true)); assertThat(termVectorsResponse.getId(), equalTo("1")); @@ -395,7 +598,7 @@ public class SimpleRoutingIT extends ESIntegTestCase { } UpdateResponse updateResponse = client().prepareUpdate(indexOrAlias(), "type1", "1").setRouting(routingValue) - .setDoc(Requests.INDEX_CONTENT_TYPE, "field1", "value1").get(); + .setDoc(Requests.INDEX_CONTENT_TYPE, "field1", "value1").get(); assertThat(updateResponse.getId(), equalTo("1")); assertThat(updateResponse.getVersion(), equalTo(2L)); @@ -408,8 +611,8 @@ public class SimpleRoutingIT extends ESIntegTestCase { logger.info("--> verifying mget with ids [1,2], with routing [0], should succeed"); MultiGetResponse multiGetResponse = client().prepareMultiGet() - .add(new MultiGetRequest.Item(indexOrAlias(), "type1", "1").routing("0")) - .add(new MultiGetRequest.Item(indexOrAlias(), "type1", "2").routing("0")).get(); + .add(new MultiGetRequest.Item(indexOrAlias(), "type1", "1").routing("0")) + .add(new MultiGetRequest.Item(indexOrAlias(), "type1", "2").routing("0")).get(); assertThat(multiGetResponse.getResponses().length, equalTo(2)); assertThat(multiGetResponse.getResponses()[0].isFailed(), equalTo(false)); assertThat(multiGetResponse.getResponses()[0].getResponse().getId(), equalTo("1")); @@ -418,8 +621,8 @@ public class SimpleRoutingIT extends ESIntegTestCase { logger.info("--> verifying mget with ids [1,2], with no routing, should fail"); multiGetResponse = client().prepareMultiGet() - .add(new MultiGetRequest.Item(indexOrAlias(), "type1", "1")) - .add(new MultiGetRequest.Item(indexOrAlias(), "type1", "2")).get(); + .add(new MultiGetRequest.Item(indexOrAlias(), "type1", "1")) + .add(new MultiGetRequest.Item(indexOrAlias(), "type1", "2")).get(); assertThat(multiGetResponse.getResponses().length, equalTo(2)); assertThat(multiGetResponse.getResponses()[0].isFailed(), equalTo(true)); assertThat(multiGetResponse.getResponses()[0].getFailure().getId(), equalTo("1")); @@ -429,8 +632,11 @@ public class SimpleRoutingIT extends ESIntegTestCase { assertThat(multiGetResponse.getResponses()[1].getFailure().getMessage(), equalTo("routing is required for [test]/[type1]/[2]")); MultiTermVectorsResponse multiTermVectorsResponse = client().prepareMultiTermVectors() - .add(new TermVectorsRequest(indexOrAlias(), "type1", "1").routing(routingValue)) - .add(new TermVectorsRequest(indexOrAlias(), "type1", "2").routing(routingValue)).get(); + .add(new TermVectorsRequest(indexOrAlias(), "type1", "1") + .routing(routingValue)) + .add(new TermVectorsRequest(indexOrAlias(), "type1", "2") + .routing(routingValue)) + .get(); assertThat(multiTermVectorsResponse.getResponses().length, equalTo(2)); assertThat(multiTermVectorsResponse.getResponses()[0].getId(), equalTo("1")); assertThat(multiTermVectorsResponse.getResponses()[0].isFailed(), equalTo(false)); @@ -442,17 +648,21 @@ public class SimpleRoutingIT extends ESIntegTestCase { assertThat(multiTermVectorsResponse.getResponses()[1].getResponse().isExists(), equalTo(true)); multiTermVectorsResponse = client().prepareMultiTermVectors() - .add(new TermVectorsRequest(indexOrAlias(), "type1", "1")) - .add(new TermVectorsRequest(indexOrAlias(), "type1", "2")).get(); + .add(new TermVectorsRequest(indexOrAlias(), "type1", "1")) + .add(new TermVectorsRequest(indexOrAlias(), "type1", "2")).get(); assertThat(multiTermVectorsResponse.getResponses().length, equalTo(2)); assertThat(multiTermVectorsResponse.getResponses()[0].getId(), equalTo("1")); assertThat(multiTermVectorsResponse.getResponses()[0].isFailed(), equalTo(true)); - assertThat(multiTermVectorsResponse.getResponses()[0].getFailure().getCause().getMessage(), equalTo("routing is required for [test]/[type1]/[1]")); + assertThat(multiTermVectorsResponse.getResponses()[0].getFailure() + .getCause() + .getMessage(), equalTo("routing is required for [test]/[type1]/[1]")); assertThat(multiTermVectorsResponse.getResponses()[0].getResponse(), nullValue()); assertThat(multiTermVectorsResponse.getResponses()[1].getId(), equalTo("2")); assertThat(multiTermVectorsResponse.getResponses()[1].isFailed(), equalTo(true)); - assertThat(multiTermVectorsResponse.getResponses()[1].getResponse(),nullValue()); - assertThat(multiTermVectorsResponse.getResponses()[1].getFailure().getCause().getMessage(), equalTo("routing is required for [test]/[type1]/[2]")); + assertThat(multiTermVectorsResponse.getResponses()[1].getResponse(), nullValue()); + assertThat(multiTermVectorsResponse.getResponses()[1].getFailure() + .getCause() + .getMessage(), equalTo("routing is required for [test]/[type1]/[2]")); } private static String indexOrAlias() {