Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Remove] Type parameter from TermVectors API #2104

Merged
merged 5 commits into from
Feb 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,14 @@

public class TermVectorsResponse {
private final String index;
private final String type;
private final String id;
private final long docVersion;
private final boolean found;
private final long tookInMillis;
private final List<TermVector> termVectorList;

public TermVectorsResponse(
String index,
String type,
String id,
long version,
boolean found,
long tookInMillis,
List<TermVector> termVectorList
) {
public TermVectorsResponse(String index, String id, long version, boolean found, long tookInMillis, List<TermVector> termVectorList) {
this.index = index;
this.type = type;
this.id = id;
this.docVersion = version;
this.found = found;
Expand All @@ -75,27 +65,25 @@ public TermVectorsResponse(
"term_vectors",
true,
args -> {
// as the response comes from server, we are sure that args[6] will be a list of TermVector
// as the response comes from server, we are sure that args[5] will be a list of TermVector
@SuppressWarnings("unchecked")
List<TermVector> termVectorList = (List<TermVector>) args[6];
List<TermVector> termVectorList = (List<TermVector>) args[5];
if (termVectorList != null) {
Collections.sort(termVectorList, Comparator.comparing(TermVector::getFieldName));
}
return new TermVectorsResponse(
(String) args[0],
(String) args[1],
(String) args[2],
(long) args[3],
(boolean) args[4],
(long) args[5],
(long) args[2],
(boolean) args[3],
(long) args[4],
termVectorList
);
}
);

static {
PARSER.declareString(constructorArg(), new ParseField("_index"));
PARSER.declareString(constructorArg(), new ParseField("_type"));
PARSER.declareString(optionalConstructorArg(), new ParseField("_id"));
PARSER.declareLong(constructorArg(), new ParseField("_version"));
PARSER.declareBoolean(constructorArg(), new ParseField("found"));
Expand All @@ -118,16 +106,6 @@ public String getIndex() {
return index;
}

/**
* Returns the type for the response
*
* @deprecated Types are in the process of being removed.
*/
@Deprecated
public String getType() {
return type;
}

/**
* Returns the id of the request
* can be NULL if there is no document ID
Expand Down Expand Up @@ -171,7 +149,6 @@ public boolean equals(Object obj) {
if (!(obj instanceof TermVectorsResponse)) return false;
TermVectorsResponse other = (TermVectorsResponse) obj;
return index.equals(other.index)
&& type.equals(other.type)
&& Objects.equals(id, other.id)
&& docVersion == other.docVersion
&& found == other.found
Expand All @@ -181,7 +158,7 @@ public boolean equals(Object obj) {

@Override
public int hashCode() {
return Objects.hash(index, type, id, docVersion, found, tookInMillis, termVectorList);
return Objects.hash(index, id, docVersion, found, tookInMillis, termVectorList);
}

public static final class TermVector {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public void testFromXContent() throws IOException {
static void toXContent(TermVectorsResponse response, XContentBuilder builder) throws IOException {
builder.startObject();
builder.field("_index", response.getIndex());
builder.field("_type", response.getType());
if (response.getId() != null) {
builder.field("_id", response.getId());
}
Expand Down Expand Up @@ -130,7 +129,6 @@ private static void toXContent(TermVectorsResponse.TermVector tv, XContentBuilde

static TermVectorsResponse createTestInstance() {
String index = randomAlphaOfLength(5);
String type = randomAlphaOfLength(5);
String id = String.valueOf(randomIntBetween(1, 100));
long version = randomNonNegativeLong();
long tookInMillis = randomNonNegativeLong();
Expand All @@ -154,7 +152,7 @@ static TermVectorsResponse createTestInstance() {
);
}
}
TermVectorsResponse tvresponse = new TermVectorsResponse(index, type, id, version, found, tookInMillis, tvList);
TermVectorsResponse tvresponse = new TermVectorsResponse(index, id, version, found, tookInMillis, tvList);
return tvresponse;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1719,9 +1719,8 @@ public void testTermVectors() throws Exception {

// tag::term-vectors-response
String index = response.getIndex(); // <1>
String type = response.getType(); // <2>
String id = response.getId(); // <3>
boolean found = response.getFound(); // <4>
String id = response.getId(); // <2>
boolean found = response.getFound(); // <3>
// end::term-vectors-response

if (response.getTermVectorsList() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,10 @@
like:
-
_index: test_1
_type: _doc
doc:
foo: bar
-
_index: test_1
_type: _doc
_id: 2
-
_id: 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,9 @@
more_like_this:
like:
_index: test_1
_type: _doc
_id: 1
unlike:
_index: test_1
_type: _doc
_id: 3
include: true
min_doc_freq: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ setup:
"docs":
-
"_index" : "testidx"
"_type" : "_doc"
"_id" : "testing_document"
"version" : 1
"_version_type" : "external"
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,5 @@ setup:
realtime: false

- match: { _index: "testidx" }
- match: { _type: "_doc" }
- match: { _id: "1" }
- is_false: found
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ public void testTermVector() {
String termVectorShardAction = TermVectorsAction.NAME + "[s]";
interceptTransportActions(termVectorShardAction);

TermVectorsRequest termVectorsRequest = new TermVectorsRequest(randomIndexOrAlias(), "type", "id");
TermVectorsRequest termVectorsRequest = new TermVectorsRequest(randomIndexOrAlias(), "id");
internalCluster().coordOnlyNodeClient().termVectors(termVectorsRequest).actionGet();

clearInterceptedActions();
Expand All @@ -376,7 +376,7 @@ public void testMultiTermVector() {
int numDocs = iterations(1, 30);
for (int i = 0; i < numDocs; i++) {
String indexOrAlias = randomIndexOrAlias();
multiTermVectorsRequest.add(indexOrAlias, "type", Integer.toString(i));
multiTermVectorsRequest.add(indexOrAlias, Integer.toString(i));
indices.add(indexOrAlias);
}
internalCluster().coordOnlyNodeClient().multiTermVectors(multiTermVectorsRequest).actionGet();
Expand Down
Loading