Deprecate types in termvector and mtermvector requests. (#36182)

* Add deprecation warnings to `Rest*TermVectorsAction`, plus tests in `Rest*TermVectorsActionTests`.
* Deprecate relevant methods on the Java HLRC requests/ responses.
* Update documentation (for both the REST API and Java HLRC).
* For each REST yml test, create one version without types, and another legacy version that retains types (called *_with_types.yml).
This commit is contained in:
Julie Tibshirani 2018-12-06 10:23:15 -08:00 committed by GitHub
parent fb697c7442
commit 3f3cde41d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 655 additions and 223 deletions

View File

@ -615,8 +615,18 @@ final class RequestConverters {
}
static Request termVectors(TermVectorsRequest tvrequest) throws IOException {
String endpoint = new EndpointBuilder().addPathPart(
tvrequest.getIndex(), tvrequest.getType(), tvrequest.getId()).addPathPartAsIs("_termvectors").build();
String endpoint;
if (tvrequest.getType() != null) {
endpoint = new EndpointBuilder().addPathPart(tvrequest.getIndex(), tvrequest.getType(), tvrequest.getId())
.addPathPartAsIs("_termvectors")
.build();
} else {
endpoint = new EndpointBuilder().addPathPart(tvrequest.getIndex())
.addPathPartAsIs("_termvectors")
.addPathPart(tvrequest.getId())
.build();
}
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
Params params = new Params(request);
params.withRouting(tvrequest.getRouting());

View File

@ -20,6 +20,7 @@
package org.elasticsearch.client.core;
import org.elasticsearch.client.Validatable;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
@ -31,7 +32,7 @@ import java.util.Map;
public class TermVectorsRequest implements ToXContentObject, Validatable {
private final String index;
private final String type;
@Nullable private final String type;
private String id = null;
private XContentBuilder docBuilder = null;
@ -47,25 +48,57 @@ public class TermVectorsRequest implements ToXContentObject, Validatable {
private Map<String, String> perFieldAnalyzer = null;
private Map<String, Integer> filterSettings = null;
/**
* Constructs TermVectorRequest for the given document
*
* @param index - index of the document
* @param docId - id of the document
*/
public TermVectorsRequest(String index, String docId) {
this.index = index;
this.type = null;
this.id = docId;
}
/**
* Constructs TermVectorRequest for the given document
*
* @param index - index of the document
* @param type - type of the document
* @param docId - id of the document
*
* @deprecated Types are in the process of being removed, use
* {@link #TermVectorsRequest(String, String)} instead.
*/
@Deprecated
public TermVectorsRequest(String index, String type, String docId) {
this.index = index;
this.type = type;
this.id = docId;
}
/**
* Constructs TermVectorRequest for an artificial document
*
* @param index - index of the document
* @param docBuilder - an artificial document
*/
public TermVectorsRequest(String index, XContentBuilder docBuilder) {
this.index = index;
this.type = null;
this.docBuilder = docBuilder;
}
/**
* Constructs TermVectorRequest for an artificial document
* @param index - index of the document
* @param type - type of the document
* @param docBuilder - an artificial document
*
* @deprecated Types are in the process of being removed, use
* {@link TermVectorsRequest(String, XContentBuilder)} instead.
*/
@Deprecated
public TermVectorsRequest(String index, String type, XContentBuilder docBuilder) {
this.index = index;
this.type = type;
@ -104,7 +137,10 @@ public class TermVectorsRequest implements ToXContentObject, Validatable {
/**
* Returns the type of the request
*
* @deprecated Types are in the process of being removed.
*/
@Deprecated
public String getType() {
return type;
}
@ -218,7 +254,9 @@ public class TermVectorsRequest implements ToXContentObject, Validatable {
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
builder.field("_index", index);
builder.field("_type", type);
if (type != null) {
builder.field("_type", type);
}
if (id != null) builder.field("_id", id);
// set values only when different from defaults
if (requestPositions == false) builder.field("positions", false);

View File

@ -94,7 +94,10 @@ public class TermVectorsResponse {
/**
* Returns the type for the response
*
* @deprecated Types are in the process of being removed.
*/
@Deprecated
public String getType() {
return type;
}

View File

@ -1137,7 +1137,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
}
{
// test _termvectors on real documents
TermVectorsRequest tvRequest = new TermVectorsRequest(sourceIndex, "_doc", "1");
TermVectorsRequest tvRequest = new TermVectorsRequest(sourceIndex, "1");
tvRequest.setFields("field");
TermVectorsResponse tvResponse = execute(tvRequest, highLevelClient()::termvectors, highLevelClient()::termvectorsAsync);
@ -1160,7 +1160,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
XContentBuilder docBuilder = XContentFactory.jsonBuilder();
docBuilder.startObject().field("field", "valuex").endObject();
TermVectorsRequest tvRequest = new TermVectorsRequest(sourceIndex, "_doc", docBuilder);
TermVectorsRequest tvRequest = new TermVectorsRequest(sourceIndex, docBuilder);
TermVectorsResponse tvResponse = execute(tvRequest, highLevelClient()::termvectors, highLevelClient()::termvectorsAsync);
TermVectorsResponse.TermVector.Token expectedToken = new TermVectorsResponse.TermVector.Token(0, 6, 0, null);
@ -1180,7 +1180,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
// Not entirely sure if _termvectors belongs to CRUD, and in the absence of a better place, will have it here
public void testTermvectorsWithNonExistentIndex() {
TermVectorsRequest request = new TermVectorsRequest("non-existent", "non-existent", "non-existent");
TermVectorsRequest request = new TermVectorsRequest("non-existent", "non-existent");
ElasticsearchException exception = expectThrows(ElasticsearchException.class,
() -> execute(request, highLevelClient()::termvectors, highLevelClient()::termvectorsAsync));
@ -1214,7 +1214,7 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
{
// test _mtermvectors where MultiTermVectorsRequest is constructed with ids and a template
String[] expectedIds = {"1", "2"};
TermVectorsRequest tvRequestTemplate = new TermVectorsRequest(sourceIndex, "_doc", "fake_id");
TermVectorsRequest tvRequestTemplate = new TermVectorsRequest(sourceIndex, "fake_id");
tvRequestTemplate.setFields("field");
MultiTermVectorsRequest mtvRequest = new MultiTermVectorsRequest(expectedIds, tvRequestTemplate);
@ -1233,13 +1233,13 @@ public class CrudIT extends ESRestHighLevelClientTestCase {
{
// test _mtermvectors where MultiTermVectorsRequest constructed with adding each separate request
MultiTermVectorsRequest mtvRequest = new MultiTermVectorsRequest();
TermVectorsRequest tvRequest1 = new TermVectorsRequest(sourceIndex, "_doc", "1");
TermVectorsRequest tvRequest1 = new TermVectorsRequest(sourceIndex, "1");
tvRequest1.setFields("field");
mtvRequest.add(tvRequest1);
XContentBuilder docBuilder = XContentFactory.jsonBuilder();
docBuilder.startObject().field("field", "valuex").endObject();
TermVectorsRequest tvRequest2 = new TermVectorsRequest(sourceIndex, "_doc", docBuilder);
TermVectorsRequest tvRequest2 = new TermVectorsRequest(sourceIndex, docBuilder);
mtvRequest.add(tvRequest2);
MultiTermVectorsResponse mtvResponse =

View File

@ -53,11 +53,11 @@ import org.elasticsearch.action.support.master.AcknowledgedRequest;
import org.elasticsearch.action.support.master.MasterNodeReadRequest;
import org.elasticsearch.action.support.master.MasterNodeRequest;
import org.elasticsearch.action.support.replication.ReplicationRequest;
import org.elasticsearch.client.core.MultiTermVectorsRequest;
import org.elasticsearch.client.core.TermVectorsRequest;
import org.elasticsearch.action.update.UpdateRequest;
import org.elasticsearch.client.RequestConverters.EndpointBuilder;
import org.elasticsearch.client.core.CountRequest;
import org.elasticsearch.client.core.MultiTermVectorsRequest;
import org.elasticsearch.client.core.TermVectorsRequest;
import org.elasticsearch.common.CheckedBiConsumer;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.bytes.BytesArray;
@ -1266,9 +1266,9 @@ public class RequestConvertersTests extends ESTestCase {
public void testTermVectors() throws IOException {
String index = randomAlphaOfLengthBetween(3, 10);
String type = randomAlphaOfLengthBetween(3, 10);
String id = randomAlphaOfLengthBetween(3, 10);
TermVectorsRequest tvRequest = new TermVectorsRequest(index, type, id);
TermVectorsRequest tvRequest = new TermVectorsRequest(index, id);
Map<String, String> expectedParams = new HashMap<>();
String[] fields;
if (randomBoolean()) {
@ -1289,7 +1289,7 @@ public class RequestConvertersTests extends ESTestCase {
Request request = RequestConverters.termVectors(tvRequest);
StringJoiner endpoint = new StringJoiner("/", "/", "");
endpoint.add(index).add(type).add(id).add("_termvectors");
endpoint.add(index).add("_termvectors").add(id);
assertEquals(HttpGet.METHOD_NAME, request.getMethod());
assertEquals(endpoint.toString(), request.getEndpoint());
@ -1304,13 +1304,27 @@ public class RequestConvertersTests extends ESTestCase {
assertToXContentBody(tvRequest, request.getEntity());
}
public void testTermVectorsWithType() throws IOException {
String index = randomAlphaOfLengthBetween(3, 10);
String type = randomAlphaOfLengthBetween(3, 10);
String id = randomAlphaOfLengthBetween(3, 10);
TermVectorsRequest tvRequest = new TermVectorsRequest(index, type, id);
Request request = RequestConverters.termVectors(tvRequest);
StringJoiner endpoint = new StringJoiner("/", "/", "");
endpoint.add(index).add(type).add(id).add("_termvectors");
assertEquals(HttpGet.METHOD_NAME, request.getMethod());
assertEquals(endpoint.toString(), request.getEndpoint());
}
public void testMultiTermVectors() throws IOException {
MultiTermVectorsRequest mtvRequest = new MultiTermVectorsRequest();
int numberOfRequests = randomIntBetween(0, 5);
for (int i = 0; i < numberOfRequests; i++) {
String index = randomAlphaOfLengthBetween(3, 10);
String type = randomAlphaOfLengthBetween(3, 10);
String type = randomBoolean() ? null : randomAlphaOfLengthBetween(3, 10);
String id = randomAlphaOfLengthBetween(3, 10);
TermVectorsRequest tvRequest = new TermVectorsRequest(index, type, id);
String[] fields = generateRandomStringArray(10, 5, false, false);

View File

@ -1558,18 +1558,16 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
{
// tag::term-vectors-request
TermVectorsRequest request = new TermVectorsRequest("authors", "_doc", "1");
TermVectorsRequest request = new TermVectorsRequest("authors", "1");
request.setFields("user");
// end::term-vectors-request
}
{
// tag::term-vectors-request-artificial
XContentBuilder docBuilder = XContentFactory.jsonBuilder();
docBuilder.startObject().field("user", "guest-user").endObject();
TermVectorsRequest request = new TermVectorsRequest("authors",
"_doc",
docBuilder); // <1>
// end::term-vectors-request-artificial
@ -1600,7 +1598,7 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
// end::term-vectors-request-optional-arguments
}
TermVectorsRequest request = new TermVectorsRequest("authors", "_doc", "1");
TermVectorsRequest request = new TermVectorsRequest("authors", "1");
request.setFields("user");
// tag::term-vectors-execute
@ -1687,21 +1685,21 @@ public class CRUDDocumentationIT extends ESRestHighLevelClientTestCase {
// tag::multi-term-vectors-request
MultiTermVectorsRequest request = new MultiTermVectorsRequest(); // <1>
TermVectorsRequest tvrequest1 =
new TermVectorsRequest("authors", "_doc", "1");
new TermVectorsRequest("authors", "1");
tvrequest1.setFields("user");
request.add(tvrequest1); // <2>
XContentBuilder docBuilder = XContentFactory.jsonBuilder();
docBuilder.startObject().field("user", "guest-user").endObject();
TermVectorsRequest tvrequest2 =
new TermVectorsRequest("authors", "_doc", docBuilder);
new TermVectorsRequest("authors", docBuilder);
request.add(tvrequest2); // <3>
// end::multi-term-vectors-request
}
// tag::multi-term-vectors-request-template
TermVectorsRequest tvrequestTemplate =
new TermVectorsRequest("authors", "_doc", "fake_id"); // <1>
new TermVectorsRequest("authors", "fake_id"); // <1>
tvrequestTemplate.setFields("user");
String[] ids = {"1", "2"};
MultiTermVectorsRequest request =

View File

@ -27,7 +27,7 @@ include-tagged::{doc-tests-file}[{api}-request]
The second way can be used when all term vectors requests share the same
arguments, such as index, type, and other settings. In this case, a template
arguments, such as index and other settings. In this case, a template
+{tvrequest}+ can be created with all necessary settings set, and
this template request can be passed to +{request}+ along with all
documents' ids for which to execute these requests.

View File

@ -2,8 +2,8 @@
== Multi termvectors API
Multi termvectors API allows to get multiple termvectors at once. The
documents from which to retrieve the term vectors are specified by an index,
type and id. But the documents could also be artificially provided in the request itself.
documents from which to retrieve the term vectors are specified by an index and id.
But the documents could also be artificially provided in the request itself.
The response includes a `docs`
array with all the fetched termvectors, each element having the structure
@ -17,13 +17,11 @@ POST /_mtermvectors
"docs": [
{
"_index": "twitter",
"_type": "_doc",
"_id": "2",
"term_statistics": true
},
{
"_index": "twitter",
"_type": "_doc",
"_id": "1",
"fields": [
"message"
@ -43,31 +41,6 @@ is not required in the body):
[source,js]
--------------------------------------------------
POST /twitter/_mtermvectors
{
"docs": [
{
"_type": "_doc",
"_id": "2",
"fields": [
"message"
],
"term_statistics": true
},
{
"_type": "_doc",
"_id": "1"
}
]
}
--------------------------------------------------
// CONSOLE
// TEST[setup:twitter]
And type:
[source,js]
--------------------------------------------------
POST /twitter/_doc/_mtermvectors
{
"docs": [
{
@ -86,11 +59,11 @@ POST /twitter/_doc/_mtermvectors
// CONSOLE
// TEST[setup:twitter]
If all requested documents are on same index and have same type and also the parameters are the same, the request can be simplified:
If all requested documents are on same index and also the parameters are the same, the request can be simplified:
[source,js]
--------------------------------------------------
POST /twitter/_doc/_mtermvectors
POST /twitter/_mtermvectors
{
"ids" : ["1", "2"],
"parameters": {
@ -105,8 +78,8 @@ POST /twitter/_doc/_mtermvectors
// TEST[setup:twitter]
Additionally, just like for the <<docs-termvectors,termvectors>>
API, term vectors could be generated for user provided documents. The mapping used is
determined by `_index` and `_type`.
API, term vectors could be generated for user provided documents.
The mapping used is determined by `_index`.
[source,js]
--------------------------------------------------
@ -115,7 +88,6 @@ POST /_mtermvectors
"docs": [
{
"_index": "twitter",
"_type": "_doc",
"doc" : {
"user" : "John Doe",
"message" : "twitter test test test"
@ -123,7 +95,6 @@ POST /_mtermvectors
},
{
"_index": "twitter",
"_type": "_doc",
"doc" : {
"user" : "Jane Doe",
"message" : "Another twitter test ..."

View File

@ -8,7 +8,7 @@ realtime. This can be changed by setting `realtime` parameter to `false`.
[source,js]
--------------------------------------------------
GET /twitter/_doc/1/_termvectors
GET /twitter/_termvectors/1
--------------------------------------------------
// CONSOLE
// TEST[setup:twitter]
@ -18,7 +18,7 @@ retrieved either with a parameter in the url
[source,js]
--------------------------------------------------
GET /twitter/_doc/1/_termvectors?fields=message
GET /twitter/_termvectors/1?fields=message
--------------------------------------------------
// CONSOLE
// TEST[setup:twitter]
@ -189,7 +189,7 @@ The following request returns all information and statistics for field
[source,js]
--------------------------------------------------
GET /twitter/_doc/1/_termvectors
GET /twitter/_termvectors/1
{
"fields" : ["text"],
"offsets" : true,
@ -277,7 +277,7 @@ Note that for the field `text`, the terms are not re-generated.
[source,js]
--------------------------------------------------
GET /twitter/_doc/1/_termvectors
GET /twitter/_termvectors/1
{
"fields" : ["text", "some_field_without_term_vectors"],
"offsets" : true,
@ -295,15 +295,14 @@ GET /twitter/_doc/1/_termvectors
Term vectors can also be generated for artificial documents,
that is for documents not present in the index. For example, the following request would
return the same results as in example 1. The mapping used is determined by the
`index` and `type`.
return the same results as in example 1. The mapping used is determined by the `index`.
*If dynamic mapping is turned on (default), the document fields not in the original
mapping will be dynamically created.*
[source,js]
--------------------------------------------------
GET /twitter/_doc/_termvectors
GET /twitter/_termvectors
{
"doc" : {
"fullname" : "John Doe",
@ -326,7 +325,7 @@ vectors, the term vectors will be re-generated.
[source,js]
--------------------------------------------------
GET /twitter/_doc/_termvectors
GET /twitter/_termvectors
{
"doc" : {
"fullname" : "John Doe",
@ -393,7 +392,7 @@ their tf-idf must be too low.
[source,js]
--------------------------------------------------
GET /imdb/_doc/_termvectors
GET /imdb/_termvectors
{
"doc": {
"plot": "When wealthy industrialist Tony Stark is forced to build an armored suit after a life-threatening incident, he ultimately decides to use its technology to fight against evil."

View File

@ -3,8 +3,9 @@
"documentation" : "http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-termvectors.html",
"methods" : ["GET", "POST"],
"url" : {
"path" : "/{index}/{type}/_termvectors",
"paths" : ["/{index}/{type}/_termvectors", "/{index}/{type}/{id}/_termvectors"],
"path" : "/{index}/_termvectors/{id}",
"paths" : ["/{index}/_termvectors/{id}", "/{index}/_termvectors/",
"/{index}/{type}/{id}/_termvectors", "/{index}/{type}/_termvectors"],
"parts" : {
"index" : {
"type" : "string",
@ -14,7 +15,7 @@
"type" : {
"type" : "string",
"description" : "The type of the document.",
"required" : true
"required" : false
},
"id" : {
"type" : "string",

View File

@ -1,10 +1,13 @@
setup:
- skip:
version: " - 6.99.99"
reason: types are required in requests before 7.0.0
- do:
indices.create:
index: testidx
body:
mappings:
testtype:
_doc:
properties:
text:
type : "text"
@ -12,7 +15,7 @@ setup:
- do:
index:
index: testidx
type: testtype
type: _doc
id: testing_document
body: {"text" : "The quick brown fox is brown."}
@ -22,19 +25,6 @@ setup:
---
"Basic tests for multi termvector get":
- do:
mtermvectors:
"term_statistics" : true
"body" :
"docs":
-
"_index" : "testidx"
"_type" : "testtype"
"_id" : "testing_document"
- match: {docs.0.term_vectors.text.terms.brown.term_freq: 2}
- match: {docs.0.term_vectors.text.terms.brown.ttf: 2}
- do:
mtermvectors:
"term_statistics" : true
@ -42,7 +32,6 @@ setup:
"docs":
-
"_index" : "testidx"
"_type" : "testtype"
"_id" : "testing_document"
- match: {docs.0.term_vectors.text.terms.brown.term_freq: 2}
@ -55,7 +44,6 @@ setup:
"body" :
"docs":
-
"_type" : "testtype"
"_id" : "testing_document"
- match: {docs.0.term_vectors.text.terms.brown.term_freq: 2}
@ -65,20 +53,6 @@ setup:
mtermvectors:
"term_statistics" : true
"index" : "testidx"
"type" : "testtype"
"body" :
"docs":
-
"_id" : "testing_document"
- match: {docs.0.term_vectors.text.terms.brown.term_freq: 2}
- match: {docs.0.term_vectors.text.terms.brown.ttf: 2}
- do:
mtermvectors:
"term_statistics" : true
"index" : "testidx"
"type" : "testtype"
"ids" : ["testing_document"]
- match: {docs.0.term_vectors.text.terms.brown.term_freq: 2}

View File

@ -0,0 +1,85 @@
setup:
- do:
indices.create:
index: testidx
body:
mappings:
testtype:
properties:
text:
type : "text"
term_vector : "with_positions_offsets"
- do:
index:
index: testidx
type: testtype
id: testing_document
body: {"text" : "The quick brown fox is brown."}
- do:
indices.refresh: {}
---
"Basic tests for multi termvector get":
- do:
mtermvectors:
"term_statistics" : true
"body" :
"docs":
-
"_index" : "testidx"
"_type" : "testtype"
"_id" : "testing_document"
- match: {docs.0.term_vectors.text.terms.brown.term_freq: 2}
- match: {docs.0.term_vectors.text.terms.brown.ttf: 2}
- do:
mtermvectors:
"term_statistics" : true
"body" :
"docs":
-
"_index" : "testidx"
"_type" : "testtype"
"_id" : "testing_document"
- match: {docs.0.term_vectors.text.terms.brown.term_freq: 2}
- match: {docs.0.term_vectors.text.terms.brown.ttf: 2}
- do:
mtermvectors:
"term_statistics" : true
"index" : "testidx"
"body" :
"docs":
-
"_type" : "testtype"
"_id" : "testing_document"
- match: {docs.0.term_vectors.text.terms.brown.term_freq: 2}
- match: {docs.0.term_vectors.text.terms.brown.ttf: 2}
- do:
mtermvectors:
"term_statistics" : true
"index" : "testidx"
"type" : "testtype"
"body" :
"docs":
-
"_id" : "testing_document"
- match: {docs.0.term_vectors.text.terms.brown.term_freq: 2}
- match: {docs.0.term_vectors.text.terms.brown.ttf: 2}
- do:
mtermvectors:
"term_statistics" : true
"index" : "testidx"
"type" : "testtype"
"ids" : ["testing_document"]
- match: {docs.0.term_vectors.text.terms.brown.term_freq: 2}
- match: {docs.0.term_vectors.text.terms.brown.ttf: 2}

View File

@ -1,3 +1,7 @@
setup:
- skip:
version: " - 6.99.99"
reason: types are required in requests before 7.0.0
---
"Deprecated camel case and _ parameters should fail in Term Vectors query":
@ -12,7 +16,7 @@
index: testidx
body:
mappings:
testtype:
_doc:
properties:
text:
type : "text"
@ -21,7 +25,7 @@
- do:
index:
index: testidx
type: testtype
type: _doc
id: testing_document
body: {"text" : "The quick brown fox is brown."}
@ -33,7 +37,6 @@
"docs":
-
"_index" : "testidx"
"_type" : "testtype"
"_id" : "testing_document"
"version" : 1
"versionType" : "external"
@ -46,7 +49,7 @@
"docs":
-
"_index" : "testidx"
"_type" : "testtype"
"_type" : "_doc"
"_id" : "testing_document"
"version" : 1
"_version_type" : "external"

View File

@ -0,0 +1,52 @@
---
"Deprecated camel case and _ parameters should fail in Term Vectors query":
- skip:
version: " - 6.99.99"
reason: camel case and _ parameters (e.g. versionType, _version_type) should fail from 7.0
features: "warnings"
- do:
indices.create:
index: testidx
body:
mappings:
testtype:
properties:
text:
type : "text"
term_vector : "with_positions_offsets"
- do:
index:
index: testidx
type: testtype
id: testing_document
body: {"text" : "The quick brown fox is brown."}
- do:
catch: bad_request
mtermvectors:
"term_statistics" : true
"body" :
"docs":
-
"_index" : "testidx"
"_type" : "testtype"
"_id" : "testing_document"
"version" : 1
"versionType" : "external"
- do:
catch: bad_request
mtermvectors:
"term_statistics" : true
"body" :
"docs":
-
"_index" : "testidx"
"_type" : "testtype"
"_id" : "testing_document"
"version" : 1
"_version_type" : "external"

View File

@ -1,10 +1,14 @@
setup:
- skip:
version: " - 6.99.99"
reason: types are required in requests before 7.0.0
- do:
indices.create:
index: testidx
body:
mappings:
testtype:
_doc:
"properties":
"text":
"type" : "text"
@ -12,7 +16,7 @@ setup:
- do:
index:
index: testidx
type: testtype
type: _doc
id: testing_document
body:
"text" : "The quick brown fox is brown."
@ -25,7 +29,6 @@ setup:
- do:
termvectors:
index: testidx
type: testtype
id: testing_document
"term_statistics" : true

View File

@ -0,0 +1,35 @@
setup:
- do:
indices.create:
index: testidx
body:
mappings:
testtype:
"properties":
"text":
"type" : "text"
"term_vector" : "with_positions_offsets"
- do:
index:
index: testidx
type: testtype
id: testing_document
body:
"text" : "The quick brown fox is brown."
- do:
indices.refresh: {}
---
"Basic tests for termvector get":
- do:
termvectors:
index: testidx
type: testtype
id: testing_document
"term_statistics" : true
- match: {term_vectors.text.field_statistics.sum_doc_freq: 5}
- match: {term_vectors.text.terms.brown.doc_freq: 1}
- match: {term_vectors.text.terms.brown.tokens.0.start_offset: 10}

View File

@ -1,3 +1,9 @@
setup:
- skip:
version: " - 6.99.99"
reason: types are required in requests before 7.0.0
---
"Term vector API should return 'found: false' for docs between index and refresh":
- do:
indices.create:
@ -10,7 +16,7 @@
number_of_replicas: 0
refresh_interval: -1
mappings:
doc:
_doc:
properties:
text:
type : "text"
@ -23,7 +29,7 @@
- do:
index:
index: testidx
type: doc
type: _doc
id: 1
body:
text : "foo bar"
@ -31,11 +37,10 @@
- do:
termvectors:
index: testidx
type: doc
id: 1
realtime: false
- match: { _index: "testidx" }
- match: { _type: "doc" }
- match: { _type: "_doc" }
- match: { _id: "1" }
- is_false: found

View File

@ -0,0 +1,41 @@
"Term vector API should return 'found: false' for docs between index and refresh":
- do:
indices.create:
index: testidx
body:
settings:
index:
translog.flush_threshold_size: "512MB"
number_of_shards: 1
number_of_replicas: 0
refresh_interval: -1
mappings:
doc:
properties:
text:
type : "text"
term_vector : "with_positions_offsets"
- do:
cluster.health:
wait_for_status: green
- do:
index:
index: testidx
type: doc
id: 1
body:
text : "foo bar"
- do:
termvectors:
index: testidx
type: doc
id: 1
realtime: false
- match: { _index: "testidx" }
- match: { _type: "doc" }
- match: { _id: "1" }
- is_false: found

View File

@ -1,3 +1,8 @@
setup:
- skip:
version: " - 6.99.99"
reason: types are required in requests before 7.0.0
---
"Realtime Term Vectors":
@ -17,14 +22,13 @@
- do:
index:
index: test_1
type: test
type: _doc
id: 1
body: { foo: bar }
- do:
termvectors:
index: test_1
type: test
id: 1
realtime: false
@ -33,7 +37,6 @@
- do:
termvectors:
index: test_1
type: test
id: 1
realtime: true

View File

@ -0,0 +1,40 @@
---
"Realtime Term Vectors":
- do:
indices.create:
index: test_1
body:
settings:
index:
refresh_interval: -1
number_of_replicas: 0
- do:
cluster.health:
wait_for_status: green
- do:
index:
index: test_1
type: test
id: 1
body: { foo: bar }
- do:
termvectors:
index: test_1
type: test
id: 1
realtime: false
- is_false: found
- do:
termvectors:
index: test_1
type: test
id: 1
realtime: true
- is_true: found

View File

@ -1,88 +0,0 @@
---
"Versions":
- do:
index:
index: test_1
type: test
id: 1
body: { foo: bar }
- match: { _version: 1}
- do:
index:
index: test_1
type: test
id: 1
body: { foo: bar }
- match: { _version: 2}
- do:
get:
index: test_1
type: test
id: 1
version: 2
- match: { _id: "1" }
- do:
catch: conflict
get:
index: test_1
type: test
id: 1
version: 1
- do:
get:
index: test_1
type: test
id: 1
version: 2
version_type: external
- match: { _id: "1" }
- do:
catch: conflict
get:
index: test_1
type: test
id: 1
version: 10
version_type: external
- do:
catch: conflict
get:
index: test_1
type: test
id: 1
version: 1
version_type: external
- do:
get:
index: test_1
type: test
id: 1
version: 2
version_type: external_gte
- match: { _id: "1" }
- do:
catch: conflict
get:
index: test_1
type: test
id: 1
version: 10
version_type: external_gte
- do:
catch: conflict
get:
index: test_1
type: test
id: 1
version: 1
version_type: external_gte

View File

@ -62,7 +62,10 @@ public class MultiTermVectorsResponse extends ActionResponse implements Iterable
/**
* The type of the action.
*
* @deprecated Types are in the process of being removed.
*/
@Deprecated
public String getType() {
return type;
}

View File

@ -19,6 +19,7 @@
package org.elasticsearch.action.termvectors;
import org.apache.logging.log4j.LogManager;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionRequestValidationException;
@ -32,6 +33,7 @@ import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.lucene.uid.Versions;
import org.elasticsearch.common.util.set.Sets;
import org.elasticsearch.common.xcontent.XContentBuilder;
@ -39,6 +41,7 @@ import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.VersionType;
import org.elasticsearch.rest.action.document.RestTermVectorsAction;
import java.io.IOException;
import java.util.ArrayList;
@ -60,6 +63,8 @@ import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
* required.
*/
public class TermVectorsRequest extends SingleShardRequest<TermVectorsRequest> implements RealtimeRequest {
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(
LogManager.getLogger(TermVectorsRequest.class));
private static final ParseField INDEX = new ParseField("_index");
private static final ParseField TYPE = new ParseField("_type");
@ -621,6 +626,7 @@ public class TermVectorsRequest extends SingleShardRequest<TermVectorsRequest> i
termVectorsRequest.index = parser.text();
} else if (TYPE.match(currentFieldName, parser.getDeprecationHandler())) {
termVectorsRequest.type = parser.text();
deprecationLogger.deprecated(RestTermVectorsAction.TYPES_DEPRECATION_MESSAGE);
} else if (ID.match(currentFieldName, parser.getDeprecationHandler())) {
if (termVectorsRequest.doc != null) {
throw new ElasticsearchParseException("failed to parse term vectors request. " +

View File

@ -19,12 +19,14 @@
package org.elasticsearch.rest.action.document;
import org.apache.logging.log4j.LogManager;
import org.elasticsearch.action.termvectors.MultiTermVectorsRequest;
import org.elasticsearch.action.termvectors.MultiTermVectorsResponse;
import org.elasticsearch.action.termvectors.TermVectorsRequest;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;
@ -36,6 +38,11 @@ import static org.elasticsearch.rest.RestRequest.Method.GET;
import static org.elasticsearch.rest.RestRequest.Method.POST;
public class RestMultiTermVectorsAction extends BaseRestHandler {
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(
LogManager.getLogger(RestTermVectorsAction.class));
static final String TYPES_DEPRECATION_MESSAGE = "[types removal] " +
"Specifying types in multi term vector requests is deprecated.";
public RestMultiTermVectorsAction(Settings settings, RestController controller) {
super(settings);
controller.registerHandler(GET, "/_mtermvectors", this);
@ -54,14 +61,21 @@ public class RestMultiTermVectorsAction extends BaseRestHandler {
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
MultiTermVectorsRequest multiTermVectorsRequest = new MultiTermVectorsRequest();
TermVectorsRequest template = new TermVectorsRequest();
template.index(request.param("index"));
template.type(request.param("type"));
TermVectorsRequest template = new TermVectorsRequest()
.index(request.param("index"));
if (request.hasParam("type")) {
deprecationLogger.deprecated(TYPES_DEPRECATION_MESSAGE);
template.type(request.param("type"));
} else {
template.type(MapperService.SINGLE_MAPPING_NAME);
}
RestTermVectorsAction.readURIParameters(template, request);
multiTermVectorsRequest.ids(Strings.commaDelimitedListToStringArray(request.param("ids")));
request.withContentOrSourceParamParserOrNull(p -> multiTermVectorsRequest.add(template, p));
return channel -> client.multiTermVectors(multiTermVectorsRequest, new RestToXContentListener<MultiTermVectorsResponse>(channel));
return channel -> client.multiTermVectors(multiTermVectorsRequest, new RestToXContentListener<>(channel));
}
}

View File

@ -19,12 +19,15 @@
package org.elasticsearch.rest.action.document;
import org.apache.logging.log4j.LogManager;
import org.elasticsearch.action.termvectors.TermVectorsRequest;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.index.VersionType;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;
@ -43,13 +46,23 @@ import static org.elasticsearch.rest.RestRequest.Method.POST;
* TermVectorsRequest.
*/
public class RestTermVectorsAction extends BaseRestHandler {
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(
LogManager.getLogger(RestTermVectorsAction.class));
public static final String TYPES_DEPRECATION_MESSAGE = "[types removal] " +
"Specifying types in term vector requests is deprecated.";
public RestTermVectorsAction(Settings settings, RestController controller) {
super(settings);
controller.registerHandler(GET, "/{index}/{type}/_termvectors", this);
controller.registerHandler(POST, "/{index}/{type}/_termvectors", this);
controller.registerHandler(GET, "/{index}/{type}/{id}/_termvectors", this);
controller.registerHandler(POST, "/{index}/{type}/{id}/_termvectors", this);
controller.registerHandler(GET, "/{index}/_termvectors", this);
controller.registerHandler(POST, "/{index}/_termvectors", this);
controller.registerHandler(GET, "/{index}/_termvectors/{id}", this);
controller.registerHandler(POST, "/{index}/_termvectors/{id}", this);
}
@Override
@ -59,7 +72,18 @@ public class RestTermVectorsAction extends BaseRestHandler {
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
TermVectorsRequest termVectorsRequest = new TermVectorsRequest(request.param("index"), request.param("type"), request.param("id"));
TermVectorsRequest termVectorsRequest;
if (request.hasParam("type")) {
deprecationLogger.deprecated(TYPES_DEPRECATION_MESSAGE);
termVectorsRequest = new TermVectorsRequest(request.param("index"),
request.param("type"),
request.param("id"));
} else {
termVectorsRequest = new TermVectorsRequest(request.param("index"),
MapperService.SINGLE_MAPPING_NAME,
request.param("id"));
}
if (request.hasContentOrSourceParam()) {
try (XContentParser parser = request.contentOrSourceParamParser()) {
TermVectorsRequest.parseRequest(termVectorsRequest, parser);

View File

@ -300,7 +300,9 @@ public class TermVectorsUnitTests extends ESTestCase {
data = createParser(JsonXContent.jsonXContent, new BytesArray(bytes));
request = new MultiTermVectorsRequest();
request.add(new TermVectorsRequest(), data);
checkParsedParameters(request);
assertWarnings(RestTermVectorsAction.TYPES_DEPRECATION_MESSAGE);
}
void checkParsedParameters(MultiTermVectorsRequest request) {
@ -330,7 +332,9 @@ public class TermVectorsUnitTests extends ESTestCase {
XContentParser data = createParser(JsonXContent.jsonXContent, bytes);
MultiTermVectorsRequest request = new MultiTermVectorsRequest();
request.add(new TermVectorsRequest(), data);
checkParsedFilterParameters(request);
assertWarnings(RestTermVectorsAction.TYPES_DEPRECATION_MESSAGE);
}
void checkParsedFilterParameters(MultiTermVectorsRequest multiRequest) {

View File

@ -0,0 +1,107 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.elasticsearch.rest.action.document;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
import org.elasticsearch.rest.RestChannel;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.RestRequest.Method;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.rest.FakeRestChannel;
import org.elasticsearch.test.rest.FakeRestRequest;
import org.elasticsearch.usage.UsageService;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import static org.mockito.Mockito.mock;
public class RestMultiTermVectorsActionTests extends ESTestCase {
private RestController controller;
public void setUp() throws Exception {
super.setUp();
controller = new RestController(Collections.emptySet(), null,
mock(NodeClient.class),
new NoneCircuitBreakerService(),
new UsageService());
new RestMultiTermVectorsAction(Settings.EMPTY, controller);
}
public void testTypeInPath() {
RestRequest request = new FakeRestRequest.Builder(xContentRegistry())
.withMethod(Method.POST)
.withPath("/some_index/some_type/_mtermvectors")
.build();
performRequest(request);
assertWarnings(RestMultiTermVectorsAction.TYPES_DEPRECATION_MESSAGE);
}
public void testTypeParameter() {
Map<String, String> params = new HashMap<>();
params.put("type", "some_type");
RestRequest request = new FakeRestRequest.Builder(xContentRegistry())
.withMethod(Method.GET)
.withPath("/some_index/_mtermvectors")
.withParams(params)
.build();
performRequest(request);
assertWarnings(RestMultiTermVectorsAction.TYPES_DEPRECATION_MESSAGE);
}
public void testTypeInBody() throws IOException {
XContentBuilder content = XContentFactory.jsonBuilder().startObject()
.startArray("docs")
.startObject()
.field("_type", "some_type")
.field("_id", 1)
.endObject()
.endArray()
.endObject();
RestRequest request = new FakeRestRequest.Builder(xContentRegistry())
.withMethod(Method.GET)
.withPath("/some_index/_mtermvectors")
.withContent(BytesReference.bytes(content), XContentType.JSON)
.build();
performRequest(request);
assertWarnings(RestTermVectorsAction.TYPES_DEPRECATION_MESSAGE);
}
private void performRequest(RestRequest request) {
RestChannel channel = new FakeRestChannel(request, false, 1);
ThreadContext threadContext = new ThreadContext(Settings.EMPTY);
controller.dispatchRequest(request, channel, threadContext);
}
}

View File

@ -0,0 +1,87 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.elasticsearch.rest.action.document;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
import org.elasticsearch.rest.RestChannel;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.RestRequest.Method;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.test.rest.FakeRestChannel;
import org.elasticsearch.test.rest.FakeRestRequest;
import org.elasticsearch.usage.UsageService;
import java.io.IOException;
import java.util.Collections;
import static org.mockito.Mockito.mock;
public class RestTermVectorsActionTests extends ESTestCase {
private RestController controller;
public void setUp() throws Exception {
super.setUp();
controller = new RestController(Collections.emptySet(), null,
mock(NodeClient.class),
new NoneCircuitBreakerService(),
new UsageService());
new RestTermVectorsAction(Settings.EMPTY, controller);
}
public void testTypeInPath() {
RestRequest request = new FakeRestRequest.Builder(xContentRegistry())
.withMethod(Method.POST)
.withPath("/some_index/some_type/some_id/_termvectors")
.build();
performRequest(request);
assertWarnings(RestTermVectorsAction.TYPES_DEPRECATION_MESSAGE);
}
public void testTypeInBody() throws IOException {
XContentBuilder content = XContentFactory.jsonBuilder().startObject()
.field("_type", "some_type")
.field("_id", 1)
.endObject();
RestRequest request = new FakeRestRequest.Builder(xContentRegistry())
.withMethod(Method.GET)
.withPath("/some_index/_termvectors/some_id")
.withContent(BytesReference.bytes(content), XContentType.JSON)
.build();
performRequest(request);
assertWarnings(RestTermVectorsAction.TYPES_DEPRECATION_MESSAGE);
}
private void performRequest(RestRequest request) {
RestChannel channel = new FakeRestChannel(request, false, 1);
ThreadContext threadContext = new ThreadContext(Settings.EMPTY);
controller.dispatchRequest(request, channel, threadContext);
}
}

View File

@ -163,7 +163,7 @@ public class IndexPrivilegeTests extends AbstractPrivilegeTestCase {
assertAccessIsAllowed("u1", "PUT",
"/" + randomIndex() + "/foo/_bulk", "{ \"index\" : { \"_id\" : \"123\" } }\n{ \"foo\" : \"bar\" }\n");
assertAccessIsAllowed("u1",
"GET", "/" + randomIndex() + "/foo/_mtermvectors", "{ \"docs\" : [ { \"_id\": \"1\" }, { \"_id\": \"2\" } ] }");
"GET", "/" + randomIndex() + "/_mtermvectors", "{ \"docs\" : [ { \"_id\": \"1\" }, { \"_id\": \"2\" } ] }");
}
public void testUserU2() throws Exception {
@ -180,7 +180,7 @@ public class IndexPrivilegeTests extends AbstractPrivilegeTestCase {
assertAccessIsAllowed("u2", "PUT",
"/" + randomIndex() + "/foo/_bulk", "{ \"index\" : { \"_id\" : \"123\" } }\n{ \"foo\" : \"bar\" }\n");
assertAccessIsAllowed("u2",
"GET", "/" + randomIndex() + "/foo/_mtermvectors", "{ \"docs\" : [ { \"_id\": \"1\" }, { \"_id\": \"2\" } ] }");
"GET", "/" + randomIndex() + "/_mtermvectors", "{ \"docs\" : [ { \"_id\": \"1\" }, { \"_id\": \"2\" } ] }");
}
public void testUserU3() throws Exception {
@ -194,7 +194,7 @@ public class IndexPrivilegeTests extends AbstractPrivilegeTestCase {
assertAccessIsAllowed("u3", "PUT",
"/" + randomIndex() + "/foo/_bulk", "{ \"index\" : { \"_id\" : \"123\" } }\n{ \"foo\" : \"bar\" }\n");
assertAccessIsAllowed("u3",
"GET", "/" + randomIndex() + "/foo/_mtermvectors", "{ \"docs\" : [ { \"_id\": \"1\" }, { \"_id\": \"2\" } ] }");
"GET", "/" + randomIndex() + "/_mtermvectors", "{ \"docs\" : [ { \"_id\": \"1\" }, { \"_id\": \"2\" } ] }");
}
public void testUserU4() throws Exception {
@ -218,7 +218,7 @@ public class IndexPrivilegeTests extends AbstractPrivilegeTestCase {
assertAccessIsDenied("u4", "PUT",
"/" + randomIndex() + "/foo/_bulk", "{ \"index\" : { \"_id\" : \"123\" } }\n{ \"foo\" : \"bar\" }\n");
assertAccessIsAllowed("u4",
"GET", "/" + randomIndex() + "/foo/_mtermvectors", "{ \"docs\" : [ { \"_id\": \"1\" }, { \"_id\": \"2\" } ] }");
"GET", "/" + randomIndex() + "/_mtermvectors", "{ \"docs\" : [ { \"_id\": \"1\" }, { \"_id\": \"2\" } ] }");
}
public void testUserU5() throws Exception {
@ -237,7 +237,7 @@ public class IndexPrivilegeTests extends AbstractPrivilegeTestCase {
assertAccessIsDenied("u5", "PUT",
"/" + randomIndex() + "/foo/_bulk", "{ \"index\" : { \"_id\" : \"123\" } }\n{ \"foo\" : \"bar\" }\n");
assertAccessIsAllowed("u5",
"GET", "/" + randomIndex() + "/foo/_mtermvectors", "{ \"docs\" : [ { \"_id\": \"1\" }, { \"_id\": \"2\" } ] }");
"GET", "/" + randomIndex() + "/_mtermvectors", "{ \"docs\" : [ { \"_id\": \"1\" }, { \"_id\": \"2\" } ] }");
}
public void testUserU6() throws Exception {
@ -253,7 +253,7 @@ public class IndexPrivilegeTests extends AbstractPrivilegeTestCase {
assertAccessIsAllowed("u6", "PUT",
"/" + randomIndex() + "/foo/_bulk", "{ \"index\" : { \"_id\" : \"123\" } }\n{ \"foo\" : \"bar\" }\n");
assertAccessIsAllowed("u6",
"GET", "/" + randomIndex() + "/foo/_mtermvectors", "{ \"docs\" : [ { \"_id\": \"1\" }, { \"_id\": \"2\" } ] }");
"GET", "/" + randomIndex() + "/_mtermvectors", "{ \"docs\" : [ { \"_id\": \"1\" }, { \"_id\": \"2\" } ] }");
}
public void testUserU7() throws Exception {
@ -267,7 +267,7 @@ public class IndexPrivilegeTests extends AbstractPrivilegeTestCase {
assertAccessIsDenied("u7", "PUT",
"/" + randomIndex() + "/foo/_bulk", "{ \"index\" : { \"_id\" : \"123\" } }\n{ \"foo\" : \"bar\" }\n");
assertAccessIsDenied("u7",
"GET", "/" + randomIndex() + "/foo/_mtermvectors", "{ \"docs\" : [ { \"_id\": \"1\" }, { \"_id\": \"2\" } ] }");
"GET", "/" + randomIndex() + "/_mtermvectors", "{ \"docs\" : [ { \"_id\": \"1\" }, { \"_id\": \"2\" } ] }");
}
public void testUserU8() throws Exception {
@ -281,7 +281,7 @@ public class IndexPrivilegeTests extends AbstractPrivilegeTestCase {
assertAccessIsAllowed("u8", "PUT",
"/" + randomIndex() + "/foo/_bulk", "{ \"index\" : { \"_id\" : \"123\" } }\n{ \"foo\" : \"bar\" }\n");
assertAccessIsAllowed("u8",
"GET", "/" + randomIndex() + "/foo/_mtermvectors", "{ \"docs\" : [ { \"_id\": \"1\" }, { \"_id\": \"2\" } ] }");
"GET", "/" + randomIndex() + "/_mtermvectors", "{ \"docs\" : [ { \"_id\": \"1\" }, { \"_id\": \"2\" } ] }");
}
public void testUserU9() throws Exception {
@ -298,7 +298,7 @@ public class IndexPrivilegeTests extends AbstractPrivilegeTestCase {
assertAccessIsAllowed("u9", "PUT",
"/" + randomIndex() + "/foo/_bulk", "{ \"index\" : { \"_id\" : \"123\" } }\n{ \"foo\" : \"bar\" }\n");
assertAccessIsAllowed("u9",
"GET", "/" + randomIndex() + "/foo/_mtermvectors", "{ \"docs\" : [ { \"_id\": \"1\" }, { \"_id\": \"2\" } ] }");
"GET", "/" + randomIndex() + "/_mtermvectors", "{ \"docs\" : [ { \"_id\": \"1\" }, { \"_id\": \"2\" } ] }");
}
public void testUserU11() throws Exception {
@ -321,7 +321,7 @@ public class IndexPrivilegeTests extends AbstractPrivilegeTestCase {
assertBodyHasAccessIsDenied("u11", "PUT",
"/" + randomIndex() + "/foo/_bulk", "{ \"index\" : { \"_id\" : \"123\" } }\n{ \"foo\" : \"bar\" }\n");
assertAccessIsDenied("u11",
"GET", "/" + randomIndex() + "/foo/_mtermvectors", "{ \"docs\" : [ { \"_id\": \"1\" }, { \"_id\": \"2\" } ] }");
"GET", "/" + randomIndex() + "/_mtermvectors", "{ \"docs\" : [ { \"_id\": \"1\" }, { \"_id\": \"2\" } ] }");
}
public void testUserU12() throws Exception {
@ -338,7 +338,7 @@ public class IndexPrivilegeTests extends AbstractPrivilegeTestCase {
assertAccessIsAllowed("u12", "PUT",
"/" + randomIndex() + "/foo/_bulk", "{ \"index\" : { \"_id\" : \"123\" } }\n{ \"foo\" : \"bar\" }\n");
assertAccessIsAllowed("u12",
"GET", "/" + randomIndex() + "/foo/_mtermvectors", "{ \"docs\" : [ { \"_id\": \"1\" }, { \"_id\": \"2\" } ] }");
"GET", "/" + randomIndex() + "/_mtermvectors", "{ \"docs\" : [ { \"_id\": \"1\" }, { \"_id\": \"2\" } ] }");
}
public void testUserU13() throws Exception {
@ -360,7 +360,7 @@ public class IndexPrivilegeTests extends AbstractPrivilegeTestCase {
assertAccessIsAllowed("u13", "PUT", "/a/foo/_bulk", "{ \"index\" : { \"_id\" : \"123\" } }\n{ \"foo\" : \"bar\" }\n");
assertBodyHasAccessIsDenied("u13", "PUT", "/b/foo/_bulk", "{ \"index\" : { \"_id\" : \"123\" } }\n{ \"foo\" : \"bar\" }\n");
assertAccessIsAllowed("u13",
"GET", "/" + randomIndex() + "/foo/_mtermvectors", "{ \"docs\" : [ { \"_id\": \"1\" }, { \"_id\": \"2\" } ] }");
"GET", "/" + randomIndex() + "/_mtermvectors", "{ \"docs\" : [ { \"_id\": \"1\" }, { \"_id\": \"2\" } ] }");
}
public void testUserU14() throws Exception {
@ -382,7 +382,7 @@ public class IndexPrivilegeTests extends AbstractPrivilegeTestCase {
assertAccessIsDenied("u14", "PUT",
"/" + randomIndex() + "/foo/_bulk", "{ \"index\" : { \"_id\" : \"123\" } }\n{ \"foo\" : \"bar\" }\n");
assertAccessIsAllowed("u14",
"GET", "/" + randomIndex() + "/foo/_mtermvectors", "{ \"docs\" : [ { \"_id\": \"1\" }, { \"_id\": \"2\" } ] }");
"GET", "/" + randomIndex() + "/_mtermvectors", "{ \"docs\" : [ { \"_id\": \"1\" }, { \"_id\": \"2\" } ] }");
}
public void testThatUnknownUserIsRejectedProperly() throws Exception {