Skip to content

Commit 1959275

Browse files
committed
Term Vectors: More consistent naming for term vector[s]
We speak of the term vectors of a document, where each field has an associated stored term vector. Since by default we are requesting all the term vectors of a document, the HTTP request endpoint should rather be called `_termvectors` instead of `_termvector`. The usage of `_termvector` is now deprecated, as well as the transport client call to termVector and prepareTermVector. Closes #8484
1 parent a6e6c4e commit 1959275

File tree

57 files changed

+484
-420
lines changed

Some content is hidden

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

57 files changed

+484
-420
lines changed

docs/reference/docs/termvectors.asciidoc

+9-6
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,24 @@ realtime. This can be changed by setting `realtime` parameter to `false`.
88

99
[source,js]
1010
--------------------------------------------------
11-
curl -XGET 'http://localhost:9200/twitter/tweet/1/_termvector?pretty=true'
11+
curl -XGET 'http://localhost:9200/twitter/tweet/1/_termvectors?pretty=true'
1212
--------------------------------------------------
1313

1414
Optionally, you can specify the fields for which the information is
1515
retrieved either with a parameter in the url
1616

1717
[source,js]
1818
--------------------------------------------------
19-
curl -XGET 'http://localhost:9200/twitter/tweet/1/_termvector?fields=text,...'
19+
curl -XGET 'http://localhost:9200/twitter/tweet/1/_termvectors?fields=text,...'
2020
--------------------------------------------------
2121

2222
or by adding the requested fields in the request body (see
2323
example below). Fields can also be specified with wildcards
2424
in similar way to the <<query-dsl-multi-match-query,multi match query>>
2525

26+
[WARNING]
27+
Note that the usage of `/_termvector` is deprecated in 2.0, and replaced by `/_termvectors`.
28+
2629
[float]
2730
=== Return values
2831

@@ -160,7 +163,7 @@ The following request returns all information and statistics for field
160163
[source,js]
161164
--------------------------------------------------
162165
163-
curl -XGET 'http://localhost:9200/twitter/tweet/1/_termvector?pretty=true' -d '{
166+
curl -XGET 'http://localhost:9200/twitter/tweet/1/_termvectors?pretty=true' -d '{
164167
"fields" : ["text"],
165168
"offsets" : true,
166169
"payloads" : true,
@@ -243,7 +246,7 @@ Note that for the field `text`, the terms are not re-generated.
243246

244247
[source,js]
245248
--------------------------------------------------
246-
curl -XGET 'http://localhost:9200/twitter/tweet/1/_termvector?pretty=true' -d '{
249+
curl -XGET 'http://localhost:9200/twitter/tweet/1/_termvectors?pretty=true' -d '{
247250
"fields" : ["text", "some_field_without_term_vectors"],
248251
"offsets" : true,
249252
"positions" : true,
@@ -270,7 +273,7 @@ mapping will be dynamically created.
270273

271274
[source,js]
272275
--------------------------------------------------
273-
curl -XGET 'http://localhost:9200/twitter/tweet/_termvector' -d '{
276+
curl -XGET 'http://localhost:9200/twitter/tweet/_termvectors' -d '{
274277
"doc" : {
275278
"fullname" : "John Doe",
276279
"text" : "twitter test test test"
@@ -290,7 +293,7 @@ vectors, the term vectors will be re-generated.
290293

291294
[source,js]
292295
--------------------------------------------------
293-
curl -XGET 'http://localhost:9200/twitter/tweet/_termvector' -d '{
296+
curl -XGET 'http://localhost:9200/twitter/tweet/_termvectors' -d '{
294297
"doc" : {
295298
"fullname" : "John Doe",
296299
"text" : "twitter test test test"

docs/reference/migration/migrate_2_0.asciidoc

+4
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,7 @@ In addition, the following node settings related to routing have been deprecated
5252
=== Store
5353

5454
The `memory` / `ram` store (`index.store.type`) option was removed in Elasticsearch 2.0.
55+
56+
=== Term Vectors API
57+
58+
Usage of `/_termvector` is deprecated, and replaced in favor of `/_termvectors`.

rest-api-spec/api/termvector.json renamed to rest-api-spec/api/termvectors.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2-
"termvector" : {
2+
"termvectors" : {
33
"documentation" : "http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/docs-termvectors.html",
44
"methods" : ["GET", "POST"],
55
"url" : {
6-
"path" : "/{index}/{type}/{id}/_termvector",
7-
"paths" : ["/{index}/{type}/{id}/_termvector"],
6+
"path" : "/{index}/{type}/{id}/_termvectors",
7+
"paths" : ["/{index}/{type}/{id}/_termvectors"],
88
"parts" : {
99
"index" : {
1010
"type" : "string",

rest-api-spec/test/termvector/10_basic.yaml renamed to rest-api-spec/test/termvectors/10_basic.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ setup:
2323
"Basic tests for termvector get":
2424

2525
- do:
26-
termvector:
26+
termvectors:
2727
index: testidx
2828
type: testtype
2929
id: testing_document

rest-api-spec/test/termvector/20_issue7121.yaml renamed to rest-api-spec/test/termvectors/20_issue7121.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
text : "foo bar"
3030

3131
- do:
32-
termvector:
32+
termvectors:
3333
index: testidx
3434
type: doc
3535
id: 1

rest-api-spec/test/termvector/30_realtime.yaml renamed to rest-api-spec/test/termvectors/30_realtime.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
body: { foo: bar }
2323

2424
- do:
25-
termvector:
25+
termvectors:
2626
index: test_1
2727
type: test
2828
id: 1
@@ -31,7 +31,7 @@
3131
- is_false: found
3232

3333
- do:
34-
termvector:
34+
termvectors:
3535
index: test_1
3636
type: test
3737
id: 1

src/main/java/org/elasticsearch/action/ActionModule.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@
159159
import org.elasticsearch.action.support.ActionFilter;
160160
import org.elasticsearch.action.support.ActionFilters;
161161
import org.elasticsearch.action.support.TransportAction;
162-
import org.elasticsearch.action.termvector.*;
163-
import org.elasticsearch.action.termvector.dfs.TransportDfsOnlyAction;
162+
import org.elasticsearch.action.termvectors.*;
163+
import org.elasticsearch.action.termvectors.dfs.TransportDfsOnlyAction;
164164
import org.elasticsearch.action.update.TransportUpdateAction;
165165
import org.elasticsearch.action.update.UpdateAction;
166166
import org.elasticsearch.common.inject.AbstractModule;
@@ -281,10 +281,10 @@ protected void configure() {
281281

282282
registerAction(IndexAction.INSTANCE, TransportIndexAction.class);
283283
registerAction(GetAction.INSTANCE, TransportGetAction.class);
284-
registerAction(TermVectorAction.INSTANCE, TransportSingleShardTermVectorAction.class,
284+
registerAction(TermVectorsAction.INSTANCE, TransportTermVectorsAction.class,
285285
TransportDfsOnlyAction.class);
286286
registerAction(MultiTermVectorsAction.INSTANCE, TransportMultiTermVectorsAction.class,
287-
TransportSingleShardMultiTermsVectorAction.class);
287+
TransportShardMultiTermsVectorAction.class);
288288
registerAction(DeleteAction.INSTANCE, TransportDeleteAction.class,
289289
TransportIndexDeleteAction.class, TransportShardDeleteAction.class);
290290
registerAction(CountAction.INSTANCE, TransportCountAction.class);

src/main/java/org/elasticsearch/action/termvector/MultiTermVectorsAction.java renamed to src/main/java/org/elasticsearch/action/termvectors/MultiTermVectorsAction.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*/
1919

20-
package org.elasticsearch.action.termvector;
20+
package org.elasticsearch.action.termvectors;
2121

2222
import org.elasticsearch.action.ClientAction;
2323
import org.elasticsearch.client.Client;

src/main/java/org/elasticsearch/action/termvector/MultiTermVectorsItemResponse.java renamed to src/main/java/org/elasticsearch/action/termvectors/MultiTermVectorsItemResponse.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*/
1919

20-
package org.elasticsearch.action.termvector;
20+
package org.elasticsearch.action.termvectors;
2121

2222
import org.elasticsearch.common.io.stream.StreamInput;
2323
import org.elasticsearch.common.io.stream.StreamOutput;
@@ -30,14 +30,14 @@
3030
*/
3131
public class MultiTermVectorsItemResponse implements Streamable {
3232

33-
private TermVectorResponse response;
33+
private TermVectorsResponse response;
3434
private MultiTermVectorsResponse.Failure failure;
3535

3636
MultiTermVectorsItemResponse() {
3737

3838
}
3939

40-
public MultiTermVectorsItemResponse(TermVectorResponse response, MultiTermVectorsResponse.Failure failure) {
40+
public MultiTermVectorsItemResponse(TermVectorsResponse response, MultiTermVectorsResponse.Failure failure) {
4141
assert (((response == null) && (failure != null)) || ((response != null) && (failure == null)));
4242
this.response = response;
4343
this.failure = failure;
@@ -83,7 +83,7 @@ public boolean isFailed() {
8383
/**
8484
* The actual get response, <tt>null</tt> if its a failure.
8585
*/
86-
public TermVectorResponse getResponse() {
86+
public TermVectorsResponse getResponse() {
8787
return this.response;
8888
}
8989

@@ -105,7 +105,7 @@ public void readFrom(StreamInput in) throws IOException {
105105
if (in.readBoolean()) {
106106
failure = MultiTermVectorsResponse.Failure.readFailure(in);
107107
} else {
108-
response = new TermVectorResponse();
108+
response = new TermVectorsResponse();
109109
response.readFrom(in);
110110
}
111111
}

src/main/java/org/elasticsearch/action/termvector/MultiTermVectorsRequest.java renamed to src/main/java/org/elasticsearch/action/termvectors/MultiTermVectorsRequest.java

+19-19
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*/
1919

20-
package org.elasticsearch.action.termvector;
20+
package org.elasticsearch.action.termvectors;
2121

2222
import com.google.common.collect.Iterators;
2323
import org.elasticsearch.ElasticsearchIllegalArgumentException;
@@ -33,20 +33,20 @@
3333
import java.io.IOException;
3434
import java.util.*;
3535

36-
public class MultiTermVectorsRequest extends ActionRequest<MultiTermVectorsRequest> implements Iterable<TermVectorRequest>, CompositeIndicesRequest {
36+
public class MultiTermVectorsRequest extends ActionRequest<MultiTermVectorsRequest> implements Iterable<TermVectorsRequest>, CompositeIndicesRequest {
3737

3838
String preference;
39-
List<TermVectorRequest> requests = new ArrayList<>();
39+
List<TermVectorsRequest> requests = new ArrayList<>();
4040

4141
final Set<String> ids = new HashSet<>();
4242

43-
public MultiTermVectorsRequest add(TermVectorRequest termVectorRequest) {
44-
requests.add(termVectorRequest);
43+
public MultiTermVectorsRequest add(TermVectorsRequest termVectorsRequest) {
44+
requests.add(termVectorsRequest);
4545
return this;
4646
}
4747

4848
public MultiTermVectorsRequest add(String index, @Nullable String type, String id) {
49-
requests.add(new TermVectorRequest(index, type, id));
49+
requests.add(new TermVectorsRequest(index, type, id));
5050
return this;
5151
}
5252

@@ -57,8 +57,8 @@ public ActionRequestValidationException validate() {
5757
validationException = ValidateActions.addValidationError("multi term vectors: no documents requested", validationException);
5858
} else {
5959
for (int i = 0; i < requests.size(); i++) {
60-
TermVectorRequest termVectorRequest = requests.get(i);
61-
ActionRequestValidationException validationExceptionForDoc = termVectorRequest.validate();
60+
TermVectorsRequest termVectorsRequest = requests.get(i);
61+
ActionRequestValidationException validationExceptionForDoc = termVectorsRequest.validate();
6262
if (validationExceptionForDoc != null) {
6363
validationException = ValidateActions.addValidationError("at multi term vectors for doc " + i,
6464
validationExceptionForDoc);
@@ -74,19 +74,19 @@ public List<? extends IndicesRequest> subRequests() {
7474
}
7575

7676
@Override
77-
public Iterator<TermVectorRequest> iterator() {
77+
public Iterator<TermVectorsRequest> iterator() {
7878
return Iterators.unmodifiableIterator(requests.iterator());
7979
}
8080

8181
public boolean isEmpty() {
8282
return requests.isEmpty() && ids.isEmpty();
8383
}
8484

85-
public List<TermVectorRequest> getRequests() {
85+
public List<TermVectorsRequest> getRequests() {
8686
return requests;
8787
}
8888

89-
public void add(TermVectorRequest template, BytesReference data) throws Exception {
89+
public void add(TermVectorsRequest template, BytesReference data) throws Exception {
9090
XContentParser.Token token;
9191
String currentFieldName = null;
9292
if (data.length() > 0) {
@@ -100,9 +100,9 @@ public void add(TermVectorRequest template, BytesReference data) throws Exceptio
100100
if (token != XContentParser.Token.START_OBJECT) {
101101
throw new ElasticsearchIllegalArgumentException("docs array element should include an object");
102102
}
103-
TermVectorRequest termVectorRequest = new TermVectorRequest(template);
104-
TermVectorRequest.parseRequest(termVectorRequest, parser);
105-
add(termVectorRequest);
103+
TermVectorsRequest termVectorsRequest = new TermVectorsRequest(template);
104+
TermVectorsRequest.parseRequest(termVectorsRequest, parser);
105+
add(termVectorsRequest);
106106
}
107107
} else if ("ids".equals(currentFieldName)) {
108108
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
@@ -117,7 +117,7 @@ public void add(TermVectorRequest template, BytesReference data) throws Exceptio
117117
}
118118
} else if (token == XContentParser.Token.START_OBJECT && currentFieldName != null) {
119119
if ("parameters".equals(currentFieldName)) {
120-
TermVectorRequest.parseRequest(template, parser);
120+
TermVectorsRequest.parseRequest(template, parser);
121121
} else {
122122
throw new ElasticsearchParseException(
123123
"No parameter named " + currentFieldName + "and type OBJECT");
@@ -129,7 +129,7 @@ public void add(TermVectorRequest template, BytesReference data) throws Exceptio
129129
}
130130
}
131131
for (String id : ids) {
132-
TermVectorRequest curRequest = new TermVectorRequest(template);
132+
TermVectorsRequest curRequest = new TermVectorsRequest(template);
133133
curRequest.id(id);
134134
requests.add(curRequest);
135135
}
@@ -142,7 +142,7 @@ public void readFrom(StreamInput in) throws IOException {
142142
int size = in.readVInt();
143143
requests = new ArrayList<>(size);
144144
for (int i = 0; i < size; i++) {
145-
requests.add(TermVectorRequest.readTermVectorRequest(in));
145+
requests.add(TermVectorsRequest.readTermVectorsRequest(in));
146146
}
147147
}
148148

@@ -151,8 +151,8 @@ public void writeTo(StreamOutput out) throws IOException {
151151
super.writeTo(out);
152152
out.writeOptionalString(preference);
153153
out.writeVInt(requests.size());
154-
for (TermVectorRequest termVectorRequest : requests) {
155-
termVectorRequest.writeTo(out);
154+
for (TermVectorsRequest termVectorsRequest : requests) {
155+
termVectorsRequest.writeTo(out);
156156
}
157157
}
158158

src/main/java/org/elasticsearch/action/termvector/MultiTermVectorsRequestBuilder.java renamed to src/main/java/org/elasticsearch/action/termvectors/MultiTermVectorsRequestBuilder.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*/
1919

20-
package org.elasticsearch.action.termvector;
20+
package org.elasticsearch.action.termvectors;
2121

2222
import org.elasticsearch.action.ActionListener;
2323
import org.elasticsearch.action.ActionRequestBuilder;
@@ -43,8 +43,8 @@ public MultiTermVectorsRequestBuilder add(String index, @Nullable String type, S
4343
return this;
4444
}
4545

46-
public MultiTermVectorsRequestBuilder add(TermVectorRequest termVectorRequest) {
47-
request.add(termVectorRequest);
46+
public MultiTermVectorsRequestBuilder add(TermVectorsRequest termVectorsRequest) {
47+
request.add(termVectorsRequest);
4848
return this;
4949
}
5050

src/main/java/org/elasticsearch/action/termvector/MultiTermVectorsResponse.java renamed to src/main/java/org/elasticsearch/action/termvectors/MultiTermVectorsResponse.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*/
1919

20-
package org.elasticsearch.action.termvector;
20+
package org.elasticsearch.action.termvectors;
2121

2222
import com.google.common.collect.Iterators;
2323
import org.elasticsearch.action.ActionResponse;
@@ -135,7 +135,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
135135
builder.field(Fields.ERROR, failure.getMessage());
136136
builder.endObject();
137137
} else {
138-
TermVectorResponse getResponse = response.getResponse();
138+
TermVectorsResponse getResponse = response.getResponse();
139139
builder.startObject();
140140
getResponse.toXContent(builder, params);
141141
builder.endObject();

src/main/java/org/elasticsearch/action/termvector/MultiTermVectorsShardRequest.java renamed to src/main/java/org/elasticsearch/action/termvectors/MultiTermVectorsShardRequest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* under the License.
1818
*/
1919

20-
package org.elasticsearch.action.termvector;
20+
package org.elasticsearch.action.termvectors;
2121

2222
import com.carrotsearch.hppc.IntArrayList;
2323
import org.elasticsearch.action.support.single.shard.SingleShardOperationRequest;
@@ -34,7 +34,7 @@ public class MultiTermVectorsShardRequest extends SingleShardOperationRequest<Mu
3434
private String preference;
3535

3636
IntArrayList locations;
37-
List<TermVectorRequest> requests;
37+
List<TermVectorsRequest> requests;
3838

3939
MultiTermVectorsShardRequest() {
4040

@@ -66,7 +66,7 @@ public String preference() {
6666
}
6767

6868

69-
public void add(int location, TermVectorRequest request) {
69+
public void add(int location, TermVectorsRequest request) {
7070
this.locations.add(location);
7171
this.requests.add(request);
7272
}
@@ -88,7 +88,7 @@ public void readFrom(StreamInput in) throws IOException {
8888
requests = new ArrayList<>(size);
8989
for (int i = 0; i < size; i++) {
9090
locations.add(in.readVInt());
91-
requests.add(TermVectorRequest.readTermVectorRequest(in));
91+
requests.add(TermVectorsRequest.readTermVectorsRequest(in));
9292
}
9393

9494
preference = in.readOptionalString();

0 commit comments

Comments
 (0)