Skip to content

Commit 795fa81

Browse files
authored
Removes type from TermVectors APIs (#42198)
1 parent 5246bd5 commit 795fa81

File tree

48 files changed

+299
-433
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+299
-433
lines changed

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

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,14 @@
3333

3434
public class TermVectorsResponse {
3535
private final String index;
36-
private final String type;
3736
private final String id;
3837
private final long docVersion;
3938
private final boolean found;
4039
private final long tookInMillis;
4140
private final List<TermVector> termVectorList;
4241

43-
public TermVectorsResponse(
44-
String index, String type, String id, long version, boolean found, long tookInMillis, List<TermVector> termVectorList) {
42+
public TermVectorsResponse(String index, String id, long version, boolean found, long tookInMillis, List<TermVector> termVectorList) {
4543
this.index = index;
46-
this.type = type;
4744
this.id = id;
4845
this.docVersion = version;
4946
this.found = found;
@@ -53,26 +50,24 @@ public TermVectorsResponse(
5350

5451
private static ConstructingObjectParser<TermVectorsResponse, Void> PARSER = new ConstructingObjectParser<>("term_vectors", true,
5552
args -> {
56-
// as the response comes from server, we are sure that args[6] will be a list of TermVector
57-
@SuppressWarnings("unchecked") List<TermVector> termVectorList = (List<TermVector>) args[6];
53+
// as the response comes from server, we are sure that args[5] will be a list of TermVector
54+
@SuppressWarnings("unchecked") List<TermVector> termVectorList = (List<TermVector>) args[5];
5855
if (termVectorList != null) {
5956
Collections.sort(termVectorList, Comparator.comparing(TermVector::getFieldName));
6057
}
6158
return new TermVectorsResponse(
6259
(String) args[0],
6360
(String) args[1],
64-
(String) args[2],
65-
(long) args[3],
66-
(boolean) args[4],
67-
(long) args[5],
61+
(long) args[2],
62+
(boolean) args[3],
63+
(long) args[4],
6864
termVectorList
6965
);
7066
}
7167
);
7268

7369
static {
7470
PARSER.declareString(constructorArg(), new ParseField("_index"));
75-
PARSER.declareString(constructorArg(), new ParseField("_type"));
7671
PARSER.declareString(optionalConstructorArg(), new ParseField("_id"));
7772
PARSER.declareLong(constructorArg(), new ParseField("_version"));
7873
PARSER.declareBoolean(constructorArg(), new ParseField("found"));
@@ -92,16 +87,6 @@ public String getIndex() {
9287
return index;
9388
}
9489

95-
/**
96-
* Returns the type for the response
97-
*
98-
* @deprecated Types are in the process of being removed.
99-
*/
100-
@Deprecated
101-
public String getType() {
102-
return type;
103-
}
104-
10590
/**
10691
* Returns the id of the request
10792
* can be NULL if there is no document ID
@@ -145,7 +130,6 @@ public boolean equals(Object obj) {
145130
if (!(obj instanceof TermVectorsResponse)) return false;
146131
TermVectorsResponse other = (TermVectorsResponse) obj;
147132
return index.equals(other.index)
148-
&& type.equals(other.type)
149133
&& Objects.equals(id, other.id)
150134
&& docVersion == other.docVersion
151135
&& found == other.found
@@ -155,7 +139,7 @@ public boolean equals(Object obj) {
155139

156140
@Override
157141
public int hashCode() {
158-
return Objects.hash(index, type, id, docVersion, found, tookInMillis, termVectorList);
142+
return Objects.hash(index, id, docVersion, found, tookInMillis, termVectorList);
159143
}
160144

161145

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
import org.elasticsearch.common.xcontent.XContentBuilder;
2323
import org.elasticsearch.test.ESTestCase;
2424

25-
import java.util.ArrayList;
26-
import java.util.List;
2725
import java.io.IOException;
26+
import java.util.ArrayList;
2827
import java.util.Collections;
2928
import java.util.Comparator;
29+
import java.util.List;
3030

3131
import static org.elasticsearch.test.AbstractXContentTestCase.xContentTester;
3232

@@ -47,7 +47,6 @@ public void testFromXContent() throws IOException {
4747
static void toXContent(TermVectorsResponse response, XContentBuilder builder) throws IOException {
4848
builder.startObject();
4949
builder.field("_index", response.getIndex());
50-
builder.field("_type", response.getType());
5150
if (response.getId() != null) {
5251
builder.field("_id", response.getId());
5352
}
@@ -119,7 +118,6 @@ private static void toXContent(TermVectorsResponse.TermVector tv, XContentBuilde
119118

120119
static TermVectorsResponse createTestInstance() {
121120
String index = randomAlphaOfLength(5);
122-
String type = randomAlphaOfLength(5);
123121
String id = String.valueOf(randomIntBetween(1,100));
124122
long version = randomNonNegativeLong();
125123
long tookInMillis = randomNonNegativeLong();
@@ -142,7 +140,7 @@ static TermVectorsResponse createTestInstance() {
142140
fieldName, hasFieldStatistics, hasTermStatistics, hasScores, hasOffsets, hasPositions, hasPayloads));
143141
}
144142
}
145-
TermVectorsResponse tvresponse = new TermVectorsResponse(index, type, id, version, found, tookInMillis, tvList);
143+
TermVectorsResponse tvresponse = new TermVectorsResponse(index, id, version, found, tookInMillis, tvList);
146144
return tvresponse;
147145
}
148146

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ public void testBulk() throws Exception {
703703
request.add(new IndexRequest("posts").id("4") // <3>
704704
.source(XContentType.JSON,"field", "baz"));
705705
// end::bulk-request-with-mixed-operations
706-
BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT);
706+
BulkResponse bulkResponse = client.bulk(request, RequestOptions.DEFAULT);
707707
assertSame(RestStatus.OK, bulkResponse.status());
708708
assertFalse(bulkResponse.hasFailures());
709709

@@ -1614,9 +1614,8 @@ public void testTermVectors() throws Exception {
16141614

16151615
// tag::term-vectors-response
16161616
String index = response.getIndex(); // <1>
1617-
String type = response.getType(); // <2>
1618-
String id = response.getId(); // <3>
1619-
boolean found = response.getFound(); // <4>
1617+
String id = response.getId(); // <2>
1618+
boolean found = response.getFound(); // <3>
16201619
// end::term-vectors-response
16211620

16221621
if (response.getTermVectorsList() != null) {

docs/java-rest/high-level/document/term-vectors.asciidoc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ artificially provided by the user.
1515
[id="{upid}-{api}-request"]
1616
==== Term Vectors Request
1717

18-
A +{request}+ expects an `index`, a `type` and an `id` to specify
18+
A +{request}+ expects an `index` and an `id` to specify
1919
a certain document, and fields for which the information is retrieved.
2020

2121
["source","java",subs="attributes,callouts,macros"]
@@ -71,9 +71,8 @@ include::../execution.asciidoc[]
7171
include-tagged::{doc-tests-file}[{api}-response]
7272
--------------------------------------------------
7373
<1> The index name of the document.
74-
<2> The type name of the document.
75-
<3> The id of the document.
76-
<4> Indicates whether or not the document found.
74+
<2> The id of the document.
75+
<3> Indicates whether or not the document found.
7776

7877

7978
===== Inspecting Term Vectors

docs/reference/docs/termvectors.asciidoc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ Response:
207207
{
208208
"_id": "1",
209209
"_index": "twitter",
210-
"_type": "_doc",
211210
"_version": 1,
212211
"found": true,
213212
"took": 6,
@@ -344,7 +343,6 @@ Response:
344343
--------------------------------------------------
345344
{
346345
"_index": "twitter",
347-
"_type": "_doc",
348346
"_version": 0,
349347
"found": true,
350348
"took": 6,
@@ -415,7 +413,6 @@ Response:
415413
--------------------------------------------------
416414
{
417415
"_index": "imdb",
418-
"_type": "_doc",
419416
"_version": 0,
420417
"found": true,
421418
"term_vectors": {

plugins/mapper-annotated-text/src/test/java/org/elasticsearch/index/mapper/annotatedtext/AnnotatedTextFieldMapperTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ public void testAgainstTermVectorsAPI() throws IOException {
226226
}
227227
bulk.get();
228228

229-
TermVectorsRequest request = new TermVectorsRequest("test", "type", "0").termStatistics(true);
229+
TermVectorsRequest request = new TermVectorsRequest("test", "0").termStatistics(true);
230230

231231
IndicesService indicesService = getInstanceFromNode(IndicesService.class);
232232
IndexService test = indicesService.indexService(resolveIndex("test"));

rest-api-spec/src/main/resources/rest-api-spec/test/mlt/20_docs.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,10 @@
4141
like:
4242
-
4343
_index: test_1
44-
_type: _doc
4544
doc:
4645
foo: bar
4746
-
4847
_index: test_1
49-
_type: _doc
5048
_id: 2
5149
-
5250
_id: 3

rest-api-spec/src/main/resources/rest-api-spec/test/mlt/30_unlike.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,9 @@
4040
more_like_this:
4141
like:
4242
_index: test_1
43-
_type: _doc
4443
_id: 1
4544
unlike:
4645
_index: test_1
47-
_type: _doc
4846
_id: 3
4947
include: true
5048
min_doc_freq: 0

rest-api-spec/src/main/resources/rest-api-spec/test/mtermvectors/20_deprecated.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
"docs":
4141
-
4242
"_index" : "testidx"
43-
"_type" : "_doc"
4443
"_id" : "testing_document"
4544
"version" : 1
4645
"_version_type" : "external"

rest-api-spec/src/main/resources/rest-api-spec/test/termvectors/20_issue7121.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,5 @@
3333
realtime: false
3434

3535
- match: { _index: "testidx" }
36-
- match: { _type: "_doc" }
3736
- match: { _id: "1" }
3837
- is_false: found

0 commit comments

Comments
 (0)