Skip to content

Commit b733f9e

Browse files
authored
Remove types from explain API (#46926)
We no longer need a type to get the source of a document, so we can remove it from the explain API as well. Relates to #41059
1 parent 88a4a86 commit b733f9e

File tree

27 files changed

+65
-458
lines changed

27 files changed

+65
-458
lines changed

client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,7 @@ static Request count(CountRequest countRequest) throws IOException {
504504
}
505505

506506
static Request explain(ExplainRequest explainRequest) throws IOException {
507-
String endpoint = explainRequest.type().equals(MapperService.SINGLE_MAPPING_NAME)
508-
? endpoint(explainRequest.index(), "_explain", explainRequest.id())
509-
: endpoint(explainRequest.index(), explainRequest.type(), explainRequest.id(), "_explain");
507+
String endpoint = endpoint(explainRequest.index(), "_explain", explainRequest.id());
510508
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
511509

512510
Params params = new Params();

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

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,21 +1415,6 @@ public void testExplain() throws IOException {
14151415
assertToXContentBody(explainRequest, request.getEntity());
14161416
}
14171417

1418-
public void testExplainWithType() throws IOException {
1419-
String index = randomAlphaOfLengthBetween(3, 10);
1420-
String type = randomAlphaOfLengthBetween(3, 10);
1421-
String id = randomAlphaOfLengthBetween(3, 10);
1422-
1423-
ExplainRequest explainRequest = new ExplainRequest(index, type, id);
1424-
explainRequest.query(QueryBuilders.termQuery(randomAlphaOfLengthBetween(3, 10), randomAlphaOfLengthBetween(3, 10)));
1425-
1426-
Request request = RequestConverters.explain(explainRequest);
1427-
assertEquals(HttpGet.METHOD_NAME, request.getMethod());
1428-
assertEquals("/" + index + "/" + type + "/" + id + "/_explain", request.getEndpoint());
1429-
1430-
assertToXContentBody(explainRequest, request.getEntity());
1431-
}
1432-
14331418
public void testTermVectors() throws IOException {
14341419
String index = randomAlphaOfLengthBetween(3, 10);
14351420
String id = randomAlphaOfLengthBetween(3, 10);

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,6 @@ public void testExplain() throws IOException {
10931093
ExplainResponse explainResponse = execute(explainRequest, highLevelClient()::explain, highLevelClient()::explainAsync);
10941094

10951095
assertThat(explainResponse.getIndex(), equalTo("index1"));
1096-
assertThat(explainResponse.getType(), equalTo("_doc"));
10971096
assertThat(Integer.valueOf(explainResponse.getId()), equalTo(1));
10981097
assertTrue(explainResponse.isExists());
10991098
assertTrue(explainResponse.isMatch());
@@ -1108,7 +1107,6 @@ public void testExplain() throws IOException {
11081107
ExplainResponse explainResponse = execute(explainRequest, highLevelClient()::explain, highLevelClient()::explainAsync);
11091108

11101109
assertThat(explainResponse.getIndex(), equalTo("index1"));
1111-
assertThat(explainResponse.getType(), equalTo("_doc"));
11121110
assertThat(Integer.valueOf(explainResponse.getId()), equalTo(1));
11131111
assertTrue(explainResponse.isExists());
11141112
assertTrue(explainResponse.isMatch());
@@ -1123,7 +1121,6 @@ public void testExplain() throws IOException {
11231121
ExplainResponse explainResponse = execute(explainRequest, highLevelClient()::explain, highLevelClient()::explainAsync);
11241122

11251123
assertThat(explainResponse.getIndex(), equalTo("index1"));
1126-
assertThat(explainResponse.getType(), equalTo("_doc"));
11271124
assertThat(Integer.valueOf(explainResponse.getId()), equalTo(1));
11281125
assertTrue(explainResponse.isExists());
11291126
assertFalse(explainResponse.isMatch());
@@ -1139,7 +1136,6 @@ public void testExplain() throws IOException {
11391136
ExplainResponse explainResponse = execute(explainRequest, highLevelClient()::explain, highLevelClient()::explainAsync);
11401137

11411138
assertThat(explainResponse.getIndex(), equalTo("index1"));
1142-
assertThat(explainResponse.getType(), equalTo("_doc"));
11431139
assertThat(Integer.valueOf(explainResponse.getId()), equalTo(1));
11441140
assertTrue(explainResponse.isExists());
11451141
assertFalse(explainResponse.isMatch());
@@ -1167,7 +1163,6 @@ public void testExplainNonExistent() throws IOException {
11671163
ExplainResponse explainResponse = execute(explainRequest, highLevelClient()::explain, highLevelClient()::explainAsync);
11681164

11691165
assertThat(explainResponse.getIndex(), equalTo("index1"));
1170-
assertThat(explainResponse.getType(), equalTo("_doc"));
11711166
assertThat(explainResponse.getId(), equalTo("999"));
11721167
assertFalse(explainResponse.isExists());
11731168
assertFalse(explainResponse.isMatch());

docs/reference/search/explain.asciidoc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ The API returns the following response:
103103
--------------------------------------------------
104104
{
105105
"_index":"twitter",
106-
"_type":"_doc",
107106
"_id":"0",
108107
"matched":true,
109108
"explanation":{

modules/parent-join/src/test/java/org/elasticsearch/join/query/ChildQuerySearchIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ public void testExplainUsage() throws Exception {
564564
assertHitCount(searchResponse, 1L);
565565
assertThat(searchResponse.getHits().getAt(0).getExplanation().getDescription(), containsString("join value p1"));
566566

567-
ExplainResponse explainResponse = client().prepareExplain("test", "doc", parentId)
567+
ExplainResponse explainResponse = client().prepareExplain("test", parentId)
568568
.setQuery(hasChildQuery("child", termQuery("c_field", "1"), ScoreMode.Max))
569569
.get();
570570
assertThat(explainResponse.isExists(), equalTo(true));

rest-api-spec/src/main/resources/rest-api-spec/api/explain.json

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,6 @@
2323
"description":"The name of the index"
2424
}
2525
}
26-
},
27-
{
28-
"path":"/{index}/{type}/{id}/_explain",
29-
"methods":[
30-
"GET",
31-
"POST"
32-
],
33-
"parts":{
34-
"id":{
35-
"type":"string",
36-
"description":"The document ID"
37-
},
38-
"index":{
39-
"type":"string",
40-
"description":"The name of the index"
41-
},
42-
"type":{
43-
"type":"string",
44-
"description":"The type of the document",
45-
"deprecated":true
46-
}
47-
},
48-
"deprecated":{
49-
"version":"7.0.0",
50-
"description":"Specifying types in urls has been deprecated"
51-
}
5226
}
5327
]
5428
},

rest-api-spec/src/main/resources/rest-api-spec/test/explain/10_basic.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ setup:
3232
- is_true: matched
3333
- match: { explanation.value: 1 }
3434
- match: { _index: test_1 }
35-
- match: { _type: _doc }
3635
- match: { _id: id_1 }
3736

3837
---
@@ -49,7 +48,6 @@ setup:
4948
- is_true: matched
5049
- match: { explanation.value: 1 }
5150
- match: { _index: test_1 }
52-
- match: { _type: _doc }
5351
- match: { _id: id_1 }
5452

5553
---

rest-api-spec/src/main/resources/rest-api-spec/test/explain/11_basic_with_types.yml

Lines changed: 0 additions & 66 deletions
This file was deleted.

rest-api-spec/src/main/resources/rest-api-spec/test/explain/20_source_filtering.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
- do:
1515
explain: { index: test_1, id: 1, _source: false, body: { query: { match_all: {}} } }
1616
- match: { _index: test_1 }
17-
- match: { _type: _doc }
1817
- match: { _id: "1" }
1918
- is_false: get._source
2019

rest-api-spec/src/main/resources/rest-api-spec/test/explain/21_source_filtering_with_types.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)