From a05b2af9a5699634708f644a62baccd9de3d99f4 Mon Sep 17 00:00:00 2001 From: Julie Tibshirani Date: Mon, 14 May 2018 23:29:38 -0700 Subject: [PATCH] Remove assert statements from field caps documentation. --- .../documentation/SearchDocumentationIT.java | 27 ++++++++++--------- .../high-level/search/field-caps.asciidoc | 8 +++--- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SearchDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SearchDocumentationIT.java index 6fdc60fcb3394..8a12016025c3e 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SearchDocumentationIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SearchDocumentationIT.java @@ -98,7 +98,6 @@ import java.util.concurrent.TimeUnit; import static org.elasticsearch.index.query.QueryBuilders.matchQuery; -import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; @@ -725,22 +724,26 @@ public void testFieldCaps() throws Exception { // end::field-caps-execute // tag::field-caps-response - assertThat(response.get().keySet(), contains("user")); - Map userResponse = response.getField("user"); - - assertThat(userResponse.keySet(), containsInAnyOrder("keyword", "text")); // <1> + Map userResponse = response.getField("user"); // <1> FieldCapabilities textCapabilities = userResponse.get("keyword"); - assertTrue(textCapabilities.isSearchable()); - assertFalse(textCapabilities.isAggregatable()); + boolean isSearchable = textCapabilities.isSearchable(); + boolean isAggregatable = textCapabilities.isAggregatable(); - assertArrayEquals(textCapabilities.indices(), // <2> - new String[]{"authors", "contributors"}); - assertNull(textCapabilities.nonSearchableIndices()); // <3> - assertArrayEquals(textCapabilities.nonAggregatableIndices(), // <4> - new String[]{"authors"}); + String[] indices = textCapabilities.indices(); // <2> + String[] nonSearchableIndices = textCapabilities.nonSearchableIndices(); // <3> + String[] nonAggregatableIndices = textCapabilities.nonAggregatableIndices();//<4> // end::field-caps-response + assertThat(userResponse.keySet(), containsInAnyOrder("keyword", "text")); + + assertTrue(isSearchable); + assertFalse(isAggregatable); + + assertArrayEquals(indices, new String[]{"authors", "contributors"}); + assertNull(nonSearchableIndices); + assertArrayEquals(nonAggregatableIndices, new String[]{"authors"}); + // tag::field-caps-execute-listener ActionListener listener = new ActionListener() { @Override diff --git a/docs/java-rest/high-level/search/field-caps.asciidoc b/docs/java-rest/high-level/search/field-caps.asciidoc index fef30f629ca61..1f5b10ad034df 100644 --- a/docs/java-rest/high-level/search/field-caps.asciidoc +++ b/docs/java-rest/high-level/search/field-caps.asciidoc @@ -76,7 +76,7 @@ information about how each index contributes to the field's capabilities. -------------------------------------------------- include-tagged::{doc-tests}/SearchDocumentationIT.java[field-caps-response] -------------------------------------------------- -<1> The `user` field has two possible types, `keyword` and `text`. -<2> This field only has type `keyword` in the `authors` and `contributors` indices. -<3> Null, since the field is searchable in all indices for which it has the `keyword` type. -<4> The `user` field is not aggregatable in the `authors` index. \ No newline at end of file +<1> A map with entries for the field's possible types, in this case `keyword` and `text`. +<2> All indices where the `user` field has type `keyword`. +<3> The subset of these indices where the `user` field isn't searchable, or null if it's always searchable. +<4> Another subset of these indices where the `user` field isn't aggregatable, or null if it's always aggregatable. \ No newline at end of file