Skip to content

Commit ab0be39

Browse files
authored
Remove assert statements from field caps documentation. (#30601)
Reorganize the test in `SearchDocumentationIT` so the assertions aren't shown in the generated documentation.
1 parent 801973f commit ab0be39

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/SearchDocumentationIT.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@
9898
import java.util.concurrent.TimeUnit;
9999

100100
import static org.elasticsearch.index.query.QueryBuilders.matchQuery;
101-
import static org.hamcrest.Matchers.contains;
102101
import static org.hamcrest.Matchers.containsInAnyOrder;
103102
import static org.hamcrest.Matchers.containsString;
104103
import static org.hamcrest.Matchers.equalTo;
@@ -725,22 +724,26 @@ public void testFieldCaps() throws Exception {
725724
// end::field-caps-execute
726725

727726
// tag::field-caps-response
728-
assertThat(response.get().keySet(), contains("user"));
729-
Map<String, FieldCapabilities> userResponse = response.getField("user");
730-
731-
assertThat(userResponse.keySet(), containsInAnyOrder("keyword", "text")); // <1>
727+
Map<String, FieldCapabilities> userResponse = response.getField("user"); // <1>
732728
FieldCapabilities textCapabilities = userResponse.get("keyword");
733729

734-
assertTrue(textCapabilities.isSearchable());
735-
assertFalse(textCapabilities.isAggregatable());
730+
boolean isSearchable = textCapabilities.isSearchable();
731+
boolean isAggregatable = textCapabilities.isAggregatable();
736732

737-
assertArrayEquals(textCapabilities.indices(), // <2>
738-
new String[]{"authors", "contributors"});
739-
assertNull(textCapabilities.nonSearchableIndices()); // <3>
740-
assertArrayEquals(textCapabilities.nonAggregatableIndices(), // <4>
741-
new String[]{"authors"});
733+
String[] indices = textCapabilities.indices(); // <2>
734+
String[] nonSearchableIndices = textCapabilities.nonSearchableIndices(); // <3>
735+
String[] nonAggregatableIndices = textCapabilities.nonAggregatableIndices();//<4>
742736
// end::field-caps-response
743737

738+
assertThat(userResponse.keySet(), containsInAnyOrder("keyword", "text"));
739+
740+
assertTrue(isSearchable);
741+
assertFalse(isAggregatable);
742+
743+
assertArrayEquals(indices, new String[]{"authors", "contributors"});
744+
assertNull(nonSearchableIndices);
745+
assertArrayEquals(nonAggregatableIndices, new String[]{"authors"});
746+
744747
// tag::field-caps-execute-listener
745748
ActionListener<FieldCapabilitiesResponse> listener = new ActionListener<FieldCapabilitiesResponse>() {
746749
@Override

docs/java-rest/high-level/search/field-caps.asciidoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ information about how each index contributes to the field's capabilities.
7676
--------------------------------------------------
7777
include-tagged::{doc-tests}/SearchDocumentationIT.java[field-caps-response]
7878
--------------------------------------------------
79-
<1> The `user` field has two possible types, `keyword` and `text`.
80-
<2> This field only has type `keyword` in the `authors` and `contributors` indices.
81-
<3> Null, since the field is searchable in all indices for which it has the `keyword` type.
82-
<4> The `user` field is not aggregatable in the `authors` index.
79+
<1> A map with entries for the field's possible types, in this case `keyword` and `text`.
80+
<2> All indices where the `user` field has type `keyword`.
81+
<3> The subset of these indices where the `user` field isn't searchable, or null if it's always searchable.
82+
<4> Another subset of these indices where the `user` field isn't aggregatable, or null if it's always aggregatable.

0 commit comments

Comments
 (0)