Enforce Content-Type requirement on the rest layer and remove deprecated methods (#23146)
This commit enforces the requirement of Content-Type for the REST layer and removes the deprecated methods in transport requests and their usages. While doing this, it turns out that there are many places where *Entity classes are used from the apache http client libraries and many of these usages did not specify the content type. The methods that do not specify a content type explicitly have been added to forbidden apis to prevent more of these from entering our code base. Relates #19388
This commit is contained in:
parent
3bd1d46fc7
commit
b234644035
|
@ -91,6 +91,7 @@ class PrecommitTasks {
|
|||
if (testForbidden != null) {
|
||||
testForbidden.configure {
|
||||
signaturesURLs += getClass().getResource('/forbidden/es-test-signatures.txt')
|
||||
signaturesURLs += getClass().getResource('/forbidden/http-signatures.txt')
|
||||
}
|
||||
}
|
||||
Task forbiddenApis = project.tasks.findByName('forbiddenApis')
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
# 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.
|
||||
|
||||
@defaultMessage Explicitly specify the ContentType of HTTP entities when creating
|
||||
org.apache.http.entity.StringEntity#<init>(java.lang.String)
|
||||
org.apache.http.entity.StringEntity#<init>(java.lang.String,java.lang.String)
|
||||
org.apache.http.entity.StringEntity#<init>(java.lang.String,java.nio.charset.Charset)
|
||||
org.apache.http.entity.ByteArrayEntity#<init>(byte[])
|
||||
org.apache.http.entity.ByteArrayEntity#<init>(byte[],int,int)
|
||||
org.apache.http.entity.FileEntity#<init>(java.io.File)
|
||||
org.apache.http.entity.InputStreamEntity#<init>(java.io.InputStream)
|
||||
org.apache.http.entity.InputStreamEntity#<init>(java.io.InputStream,long)
|
||||
org.apache.http.nio.entity.NByteArrayEntity#<init>(byte[])
|
||||
org.apache.http.nio.entity.NByteArrayEntity#<init>(byte[],int,int)
|
||||
org.apache.http.nio.entity.NFileEntity#<init>(java.io.File)
|
||||
org.apache.http.nio.entity.NStringEntity#<init>(java.lang.String)
|
||||
org.apache.http.nio.entity.NStringEntity#<init>(java.lang.String,java.lang.String)
|
||||
|
||||
@defaultMessage Use non-deprecated constructors
|
||||
org.apache.http.nio.entity.NFileEntity#<init>(java.io.File,java.lang.String)
|
||||
org.apache.http.nio.entity.NFileEntity#<init>(java.io.File,java.lang.String,boolean)
|
||||
org.apache.http.entity.FileEntity#<init>(java.io.File,java.lang.String)
|
||||
org.apache.http.entity.StringEntity#<init>(java.lang.String,java.lang.String,java.lang.String)
|
||||
|
||||
@defaultMessage BasicEntity is easy to mess up and forget to set content type
|
||||
org.apache.http.entity.BasicHttpEntity#<init>()
|
||||
|
||||
@defaultMessage EntityTemplate is easy to mess up and forget to set content type
|
||||
org.apache.http.entity.EntityTemplate#<init>(org.apache.http.entity.ContentProducer)
|
||||
|
||||
@defaultMessage SerializableEntity uses java serialization and makes it easy to forget to set content type
|
||||
org.apache.http.entity.SerializableEntity#<init>(java.io.Serializable)
|
|
@ -1,3 +1,5 @@
|
|||
import org.elasticsearch.gradle.precommit.PrecommitTasks
|
||||
|
||||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
|
@ -39,3 +41,9 @@ dependencyLicenses {
|
|||
it.group.startsWith('org.elasticsearch') == false
|
||||
}
|
||||
}
|
||||
|
||||
forbiddenApisMain {
|
||||
// core does not depend on the httpclient for compile so we add the signatures here. We don't add them for test as they are already
|
||||
// specified
|
||||
signaturesURLs += [PrecommitTasks.getResource('/forbidden/http-signatures.txt')]
|
||||
}
|
|
@ -27,7 +27,6 @@ import org.apache.http.HttpResponse;
|
|||
import org.apache.http.ProtocolVersion;
|
||||
import org.apache.http.RequestLine;
|
||||
import org.apache.http.StatusLine;
|
||||
import org.apache.http.entity.BasicHttpEntity;
|
||||
import org.apache.http.entity.ByteArrayEntity;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
|
@ -144,7 +143,7 @@ public class RestHighLevelClientTests extends ESTestCase {
|
|||
}
|
||||
{
|
||||
IllegalStateException ise = expectThrows(IllegalStateException.class,
|
||||
() -> RestHighLevelClient.parseEntity(new BasicHttpEntity(), null));
|
||||
() -> RestHighLevelClient.parseEntity(new StringEntity("", (ContentType) null), null));
|
||||
assertEquals("Elasticsearch didn't return the [Content-Type] header, unable to parse response body", ise.getMessage());
|
||||
}
|
||||
{
|
||||
|
|
|
@ -49,8 +49,9 @@ dependencies {
|
|||
}
|
||||
|
||||
forbiddenApisMain {
|
||||
//client does not depend on core, so only jdk signatures should be checked
|
||||
signaturesURLs = [PrecommitTasks.getResource('/forbidden/jdk-signatures.txt')]
|
||||
//client does not depend on core, so only jdk and http signatures should be checked
|
||||
signaturesURLs = [PrecommitTasks.getResource('/forbidden/jdk-signatures.txt'),
|
||||
PrecommitTasks.getResource('/forbidden/http-signatures.txt')]
|
||||
}
|
||||
|
||||
forbiddenApisTest {
|
||||
|
@ -58,7 +59,8 @@ forbiddenApisTest {
|
|||
bundledSignatures -= 'jdk-non-portable'
|
||||
bundledSignatures += 'jdk-internal'
|
||||
//client does not depend on core, so only jdk signatures should be checked
|
||||
signaturesURLs = [PrecommitTasks.getResource('/forbidden/jdk-signatures.txt')]
|
||||
signaturesURLs = [PrecommitTasks.getResource('/forbidden/jdk-signatures.txt'),
|
||||
PrecommitTasks.getResource('/forbidden/http-signatures.txt')]
|
||||
}
|
||||
|
||||
dependencyLicenses {
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package org.elasticsearch.client;
|
||||
|
||||
import org.apache.http.ContentTooLongException;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.ProtocolVersion;
|
||||
import org.apache.http.StatusLine;
|
||||
|
@ -32,6 +33,8 @@ import org.apache.http.nio.ContentDecoder;
|
|||
import org.apache.http.nio.IOControl;
|
||||
import org.apache.http.protocol.HttpContext;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
@ -56,7 +59,7 @@ public class HeapBufferedAsyncResponseConsumerTests extends RestClientTestCase {
|
|||
ProtocolVersion protocolVersion = new ProtocolVersion("HTTP", 1, 1);
|
||||
StatusLine statusLine = new BasicStatusLine(protocolVersion, 200, "OK");
|
||||
HttpResponse httpResponse = new BasicHttpResponse(statusLine);
|
||||
httpResponse.setEntity(new StringEntity("test"));
|
||||
httpResponse.setEntity(new StringEntity("test", ContentType.TEXT_PLAIN));
|
||||
|
||||
//everything goes well
|
||||
consumer.responseReceived(httpResponse);
|
||||
|
@ -99,11 +102,17 @@ public class HeapBufferedAsyncResponseConsumerTests extends RestClientTestCase {
|
|||
StatusLine statusLine = new BasicStatusLine(protocolVersion, 200, "OK");
|
||||
consumer.onResponseReceived(new BasicHttpResponse(statusLine));
|
||||
|
||||
BasicHttpEntity entity = new BasicHttpEntity();
|
||||
entity.setContentLength(randomInt(bufferLimit));
|
||||
final AtomicReference<Long> contentLength = new AtomicReference<>();
|
||||
HttpEntity entity = new StringEntity("", ContentType.APPLICATION_JSON) {
|
||||
@Override
|
||||
public long getContentLength() {
|
||||
return contentLength.get();
|
||||
}
|
||||
};
|
||||
contentLength.set(randomLong(bufferLimit));
|
||||
consumer.onEntityEnclosed(entity, ContentType.APPLICATION_JSON);
|
||||
|
||||
entity.setContentLength(randomIntBetween(bufferLimit + 1, MAX_TEST_BUFFER_SIZE));
|
||||
contentLength.set(randomLongBetween(bufferLimit + 1, MAX_TEST_BUFFER_SIZE));
|
||||
try {
|
||||
consumer.onEntityEnclosed(entity, ContentType.APPLICATION_JSON);
|
||||
} catch(ContentTooLongException e) {
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.apache.http.client.methods.HttpPost;
|
|||
import org.apache.http.client.methods.HttpPut;
|
||||
import org.apache.http.client.methods.HttpTrace;
|
||||
import org.apache.http.client.methods.HttpUriRequest;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.InputStreamEntity;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.message.BasicHeader;
|
||||
|
@ -71,20 +72,21 @@ public class RequestLoggerTests extends RestClientTestCase {
|
|||
HttpEntity entity;
|
||||
switch(randomIntBetween(0, 4)) {
|
||||
case 0:
|
||||
entity = new StringEntity(requestBody, StandardCharsets.UTF_8);
|
||||
entity = new StringEntity(requestBody, ContentType.APPLICATION_JSON);
|
||||
break;
|
||||
case 1:
|
||||
entity = new InputStreamEntity(new ByteArrayInputStream(requestBody.getBytes(StandardCharsets.UTF_8)));
|
||||
entity = new InputStreamEntity(new ByteArrayInputStream(requestBody.getBytes(StandardCharsets.UTF_8)),
|
||||
ContentType.APPLICATION_JSON);
|
||||
break;
|
||||
case 2:
|
||||
entity = new NStringEntity(requestBody, StandardCharsets.UTF_8);
|
||||
entity = new NStringEntity(requestBody, ContentType.APPLICATION_JSON);
|
||||
break;
|
||||
case 3:
|
||||
entity = new NByteArrayEntity(requestBody.getBytes(StandardCharsets.UTF_8));
|
||||
entity = new NByteArrayEntity(requestBody.getBytes(StandardCharsets.UTF_8), ContentType.APPLICATION_JSON);
|
||||
break;
|
||||
case 4:
|
||||
// Evil entity without a charset
|
||||
entity = new StringEntity(requestBody, (Charset) null);
|
||||
entity = new StringEntity(requestBody, ContentType.create("application/json", (Charset) null));
|
||||
break;
|
||||
default:
|
||||
throw new UnsupportedOperationException();
|
||||
|
@ -122,15 +124,16 @@ public class RequestLoggerTests extends RestClientTestCase {
|
|||
HttpEntity entity;
|
||||
switch(randomIntBetween(0, 2)) {
|
||||
case 0:
|
||||
entity = new StringEntity(responseBody, StandardCharsets.UTF_8);
|
||||
entity = new StringEntity(responseBody, ContentType.APPLICATION_JSON);
|
||||
break;
|
||||
case 1:
|
||||
//test a non repeatable entity
|
||||
entity = new InputStreamEntity(new ByteArrayInputStream(responseBody.getBytes(StandardCharsets.UTF_8)));
|
||||
entity = new InputStreamEntity(new ByteArrayInputStream(responseBody.getBytes(StandardCharsets.UTF_8)),
|
||||
ContentType.APPLICATION_JSON);
|
||||
break;
|
||||
case 2:
|
||||
// Evil entity without a charset
|
||||
entity = new StringEntity(responseBody, (Charset) null);
|
||||
entity = new StringEntity(responseBody, ContentType.create("application/json", (Charset) null));
|
||||
break;
|
||||
default:
|
||||
throw new UnsupportedOperationException();
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.apache.http.HttpResponse;
|
|||
import org.apache.http.ProtocolVersion;
|
||||
import org.apache.http.RequestLine;
|
||||
import org.apache.http.StatusLine;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.InputStreamEntity;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.message.BasicHttpResponse;
|
||||
|
@ -52,10 +53,11 @@ public class ResponseExceptionTests extends RestClientTestCase {
|
|||
if (hasBody) {
|
||||
HttpEntity entity;
|
||||
if (getRandom().nextBoolean()) {
|
||||
entity = new StringEntity(responseBody, StandardCharsets.UTF_8);
|
||||
entity = new StringEntity(responseBody, ContentType.APPLICATION_JSON);
|
||||
} else {
|
||||
//test a non repeatable entity
|
||||
entity = new InputStreamEntity(new ByteArrayInputStream(responseBody.getBytes(StandardCharsets.UTF_8)));
|
||||
entity = new InputStreamEntity(new ByteArrayInputStream(responseBody.getBytes(StandardCharsets.UTF_8)),
|
||||
ContentType.APPLICATION_JSON);
|
||||
}
|
||||
httpResponse.setEntity(entity);
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.apache.http.Header;
|
|||
import org.apache.http.HttpHost;
|
||||
import org.apache.http.auth.AuthScope;
|
||||
import org.apache.http.auth.UsernamePasswordCredentials;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.BasicCredentialsProvider;
|
||||
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
|
||||
|
@ -249,7 +250,7 @@ public class RestClientSingleHostIntegTests extends RestClientTestCase {
|
|||
|
||||
private Response bodyTest(final RestClient restClient, final String method) throws IOException {
|
||||
String requestBody = "{ \"field\": \"value\" }";
|
||||
StringEntity entity = new StringEntity(requestBody);
|
||||
StringEntity entity = new StringEntity(requestBody, ContentType.APPLICATION_JSON);
|
||||
int statusCode = randomStatusCode(getRandom());
|
||||
Response esResponse;
|
||||
try {
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.apache.http.client.protocol.HttpClientContext;
|
|||
import org.apache.http.client.utils.URIBuilder;
|
||||
import org.apache.http.concurrent.FutureCallback;
|
||||
import org.apache.http.conn.ConnectTimeoutException;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.auth.BasicScheme;
|
||||
import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
|
||||
|
@ -293,7 +294,7 @@ public class RestClientSingleHostTests extends RestClientTestCase {
|
|||
*/
|
||||
public void testBody() throws IOException {
|
||||
String body = "{ \"field\": \"value\" }";
|
||||
StringEntity entity = new StringEntity(body);
|
||||
StringEntity entity = new StringEntity(body, ContentType.APPLICATION_JSON);
|
||||
for (String method : Arrays.asList("DELETE", "GET", "PATCH", "POST", "PUT")) {
|
||||
for (int okStatusCode : getOkStatusCodes()) {
|
||||
Response response = restClient.performRequest(method, "/" + okStatusCode, Collections.<String, String>emptyMap(), entity);
|
||||
|
@ -431,7 +432,7 @@ public class RestClientSingleHostTests extends RestClientTestCase {
|
|||
HttpEntity entity = null;
|
||||
boolean hasBody = request instanceof HttpEntityEnclosingRequest && getRandom().nextBoolean();
|
||||
if (hasBody) {
|
||||
entity = new StringEntity(randomAsciiOfLengthBetween(10, 100));
|
||||
entity = new StringEntity(randomAsciiOfLengthBetween(10, 100), ContentType.APPLICATION_JSON);
|
||||
((HttpEntityEnclosingRequest) request).setEntity(entity);
|
||||
}
|
||||
|
||||
|
|
|
@ -139,19 +139,6 @@ public class PutRepositoryRequest extends AcknowledgedRequest<PutRepositoryReque
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the repository settings.
|
||||
*
|
||||
* @param source repository settings in json or yaml format
|
||||
* @return this request
|
||||
* @deprecated use {@link #settings(String, XContentType)} to avoid content type auto-detection
|
||||
*/
|
||||
@Deprecated
|
||||
public PutRepositoryRequest settings(String source) {
|
||||
this.settings = Settings.builder().loadFromSource(source).build();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the repository settings.
|
||||
*
|
||||
|
|
|
@ -89,19 +89,6 @@ public class PutRepositoryRequestBuilder extends AcknowledgedRequestBuilder<PutR
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the repository settings in Json or Yaml format
|
||||
*
|
||||
* @param source repository settings
|
||||
* @return this builder
|
||||
* @deprecated use {@link #setSettings(String, XContentType)} instead to avoid content type auto detection
|
||||
*/
|
||||
@Deprecated
|
||||
public PutRepositoryRequestBuilder setSettings(String source) {
|
||||
request.settings(source);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the repository settings in Json or Yaml format
|
||||
*
|
||||
|
|
|
@ -81,16 +81,6 @@ public class ClusterUpdateSettingsRequest extends AcknowledgedRequest<ClusterUpd
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the source containing the transient settings to be updated. They will not survive a full cluster restart
|
||||
* @deprecated use {@link #transientSettings(String, XContentType)} to avoid content type detection
|
||||
*/
|
||||
@Deprecated
|
||||
public ClusterUpdateSettingsRequest transientSettings(String source) {
|
||||
this.transientSettings = Settings.builder().loadFromSource(source).build();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the source containing the transient settings to be updated. They will not survive a full cluster restart
|
||||
*/
|
||||
|
@ -130,16 +120,6 @@ public class ClusterUpdateSettingsRequest extends AcknowledgedRequest<ClusterUpd
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the source containing the persistent settings to be updated. They will get applied cross restarts
|
||||
* @deprecated use {@link #persistentSettings(String, XContentType)} to avoid content type detection
|
||||
*/
|
||||
@Deprecated
|
||||
public ClusterUpdateSettingsRequest persistentSettings(String source) {
|
||||
this.persistentSettings = Settings.builder().loadFromSource(source).build();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the source containing the persistent settings to be updated. They will get applied cross restarts
|
||||
*/
|
||||
|
|
|
@ -51,16 +51,6 @@ public class ClusterUpdateSettingsRequestBuilder extends AcknowledgedRequestBuil
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the source containing the transient settings to be updated. They will not survive a full cluster restart
|
||||
* @deprecated use {@link #setTransientSettings(String, XContentType)} to avoid content type detection
|
||||
*/
|
||||
@Deprecated
|
||||
public ClusterUpdateSettingsRequestBuilder setTransientSettings(String settings) {
|
||||
request.transientSettings(settings);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the source containing the transient settings to be updated. They will not survive a full cluster restart
|
||||
*/
|
||||
|
@ -93,16 +83,6 @@ public class ClusterUpdateSettingsRequestBuilder extends AcknowledgedRequestBuil
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the source containing the persistent settings to be updated. They will get applied cross restarts
|
||||
* @deprecated use {@link #setPersistentSettings(String, XContentType)} to avoid content type detection
|
||||
*/
|
||||
@Deprecated
|
||||
public ClusterUpdateSettingsRequestBuilder setPersistentSettings(String settings) {
|
||||
request.persistentSettings(settings);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the source containing the persistent settings to be updated. They will get applied cross restarts
|
||||
*/
|
||||
|
|
|
@ -287,21 +287,6 @@ public class CreateSnapshotRequest extends MasterNodeRequest<CreateSnapshotReque
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets repository-specific snapshot settings in JSON or YAML format
|
||||
* <p>
|
||||
* See repository documentation for more information.
|
||||
*
|
||||
* @param source repository-specific snapshot settings
|
||||
* @return this request
|
||||
* @deprecated use {@link #settings(String, XContentType)} to avoid content type detection
|
||||
*/
|
||||
@Deprecated
|
||||
public CreateSnapshotRequest settings(String source) {
|
||||
this.settings = Settings.builder().loadFromSource(source).build();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets repository-specific snapshot settings in JSON or YAML format
|
||||
* <p>
|
||||
|
|
|
@ -141,21 +141,6 @@ public class CreateSnapshotRequestBuilder extends MasterNodeOperationRequestBuil
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets repository-specific snapshot settings in YAML, JSON or properties format
|
||||
* <p>
|
||||
* See repository documentation for more information.
|
||||
*
|
||||
* @param source repository-specific snapshot settings
|
||||
* @return this builder
|
||||
* @deprecated use {@link #setSettings(String, XContentType)} to avoid content type detection
|
||||
*/
|
||||
@Deprecated
|
||||
public CreateSnapshotRequestBuilder setSettings(String source) {
|
||||
request.settings(source);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets repository-specific snapshot settings in YAML or JSON format
|
||||
* <p>
|
||||
|
|
|
@ -312,21 +312,6 @@ public class RestoreSnapshotRequest extends MasterNodeRequest<RestoreSnapshotReq
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets repository-specific restore settings in JSON or YAML format
|
||||
* <p>
|
||||
* See repository documentation for more information.
|
||||
*
|
||||
* @param source repository-specific snapshot settings
|
||||
* @return this request
|
||||
* @deprecated use {@link #settings(String, XContentType)} to avoid content type detection
|
||||
*/
|
||||
@Deprecated
|
||||
public RestoreSnapshotRequest settings(String source) {
|
||||
this.settings = Settings.builder().loadFromSource(source).build();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets repository-specific restore settings in JSON or YAML format
|
||||
* <p>
|
||||
|
@ -450,16 +435,6 @@ public class RestoreSnapshotRequest extends MasterNodeRequest<RestoreSnapshotReq
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets settings that should be added/changed in all restored indices
|
||||
* @deprecated use {@link #indexSettings(String, XContentType)} to avoid content type detection
|
||||
*/
|
||||
@Deprecated
|
||||
public RestoreSnapshotRequest indexSettings(String source) {
|
||||
this.indexSettings = Settings.builder().loadFromSource(source).build();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets settings that should be added/changed in all restored indices
|
||||
*/
|
||||
|
|
|
@ -153,21 +153,6 @@ public class RestoreSnapshotRequestBuilder extends MasterNodeOperationRequestBui
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets repository-specific restore settings in JSON or YAML format
|
||||
* <p>
|
||||
* See repository documentation for more information.
|
||||
*
|
||||
* @param source repository-specific snapshot settings
|
||||
* @return this builder
|
||||
* @deprecated use {@link #setSettings(String, XContentType)} to avoid content type detection
|
||||
*/
|
||||
@Deprecated
|
||||
public RestoreSnapshotRequestBuilder setSettings(String source) {
|
||||
request.settings(source);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets repository-specific restore settings in JSON or YAML format
|
||||
* <p>
|
||||
|
@ -263,19 +248,6 @@ public class RestoreSnapshotRequestBuilder extends MasterNodeOperationRequestBui
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets index settings that should be added or replaced during restore
|
||||
*
|
||||
* @param source index settings
|
||||
* @return this builder
|
||||
* @deprecated use {@link #setIndexSettings(String, XContentType)} to avoid content type detection
|
||||
*/
|
||||
@Deprecated
|
||||
public RestoreSnapshotRequestBuilder setIndexSettings(String source) {
|
||||
request.indexSettings(source);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets index settings that should be added or replaced during restore
|
||||
*
|
||||
|
|
|
@ -45,11 +45,6 @@ public class PutStoredScriptRequest extends AcknowledgedRequest<PutStoredScriptR
|
|||
super();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public PutStoredScriptRequest(String id, String lang, BytesReference content) {
|
||||
this(id, lang, content, XContentFactory.xContentType(content));
|
||||
}
|
||||
|
||||
public PutStoredScriptRequest(String id, String lang, BytesReference content, XContentType xContentType) {
|
||||
super();
|
||||
this.id = id;
|
||||
|
@ -107,15 +102,6 @@ public class PutStoredScriptRequest extends AcknowledgedRequest<PutStoredScriptR
|
|||
return xContentType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the script source using bytes.
|
||||
* @deprecated this method is deprecated as it relies on content type detection. Use {@link #content(BytesReference, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public PutStoredScriptRequest content(BytesReference content) {
|
||||
return content(content, XContentFactory.xContentType(content));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the script source and the content type of the bytes.
|
||||
*/
|
||||
|
|
|
@ -36,16 +36,6 @@ public class PutStoredScriptRequestBuilder extends AcknowledgedRequestBuilder<Pu
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the source of the script.
|
||||
* @deprecated this method requires content type detection. Use {@link #setContent(BytesReference, XContentType)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public PutStoredScriptRequestBuilder setContent(BytesReference content) {
|
||||
request.content(content);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the source of the script along with the content type of the source
|
||||
*/
|
||||
|
|
|
@ -170,16 +170,6 @@ public class CreateIndexRequest extends AcknowledgedRequest<CreateIndexRequest>
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The settings to create the index with (either json or yaml format)
|
||||
* @deprecated use {@link #source(String, XContentType)} instead to avoid content type detection
|
||||
*/
|
||||
@Deprecated
|
||||
public CreateIndexRequest settings(String source) {
|
||||
this.settings = Settings.builder().loadFromSource(source).build();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The settings to create the index with (either json or yaml format)
|
||||
*/
|
||||
|
@ -215,18 +205,6 @@ public class CreateIndexRequest extends AcknowledgedRequest<CreateIndexRequest>
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds mapping that will be added when the index gets created.
|
||||
*
|
||||
* @param type The mapping type
|
||||
* @param source The mapping source
|
||||
* @deprecated use {@link #mapping(String, String, XContentType)} to avoid content type detection
|
||||
*/
|
||||
@Deprecated
|
||||
public CreateIndexRequest mapping(String type, String source) {
|
||||
return mapping(type, new BytesArray(source), XContentFactory.xContentType(source));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds mapping that will be added when the index gets created.
|
||||
*
|
||||
|
@ -362,15 +340,6 @@ public class CreateIndexRequest extends AcknowledgedRequest<CreateIndexRequest>
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the settings and mappings as a single source.
|
||||
* @deprecated use {@link #source(String, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public CreateIndexRequest source(String source) {
|
||||
return source(new BytesArray(source));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the settings and mappings as a single source.
|
||||
*/
|
||||
|
@ -382,16 +351,7 @@ public class CreateIndexRequest extends AcknowledgedRequest<CreateIndexRequest>
|
|||
* Sets the settings and mappings as a single source.
|
||||
*/
|
||||
public CreateIndexRequest source(XContentBuilder source) {
|
||||
return source(source.bytes());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the settings and mappings as a single source.
|
||||
* @deprecated use {@link #source(byte[], XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public CreateIndexRequest source(byte[] source) {
|
||||
return source(source, 0, source.length);
|
||||
return source(source.bytes(), source.contentType());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -401,15 +361,6 @@ public class CreateIndexRequest extends AcknowledgedRequest<CreateIndexRequest>
|
|||
return source(source, 0, source.length, xContentType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the settings and mappings as a single source.
|
||||
* @deprecated use {@link #source(byte[], int, int, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public CreateIndexRequest source(byte[] source, int offset, int length) {
|
||||
return source(new BytesArray(source, offset, length));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the settings and mappings as a single source.
|
||||
*/
|
||||
|
@ -417,17 +368,6 @@ public class CreateIndexRequest extends AcknowledgedRequest<CreateIndexRequest>
|
|||
return source(new BytesArray(source, offset, length), xContentType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the settings and mappings as a single source.
|
||||
* @deprecated use {@link #source(BytesReference, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public CreateIndexRequest source(BytesReference source) {
|
||||
XContentType xContentType = XContentFactory.xContentType(source);
|
||||
source(source, xContentType);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the settings and mappings as a single source.
|
||||
*/
|
||||
|
|
|
@ -110,19 +110,6 @@ public class CreateIndexRequestBuilder extends AcknowledgedRequestBuilder<Create
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds mapping that will be added when the index gets created.
|
||||
*
|
||||
* @param type The mapping type
|
||||
* @param source The mapping source
|
||||
* @deprecated use {@link #addMapping(String, String, XContentType)} to avoid content type auto-detection
|
||||
*/
|
||||
@Deprecated
|
||||
public CreateIndexRequestBuilder addMapping(String type, String source) {
|
||||
request.mapping(type, source);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds mapping that will be added when the index gets created.
|
||||
*
|
||||
|
@ -214,16 +201,6 @@ public class CreateIndexRequestBuilder extends AcknowledgedRequestBuilder<Create
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the settings and mappings as a single source.
|
||||
* @deprecated use {@link #setSource(String, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public CreateIndexRequestBuilder setSource(String source) {
|
||||
request.source(source);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the settings and mappings as a single source.
|
||||
*/
|
||||
|
@ -232,16 +209,6 @@ public class CreateIndexRequestBuilder extends AcknowledgedRequestBuilder<Create
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the settings and mappings as a single source.
|
||||
* @deprecated use {@link #setSource(BytesReference, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public CreateIndexRequestBuilder setSource(BytesReference source) {
|
||||
request.source(source);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the settings and mappings as a single source.
|
||||
*/
|
||||
|
@ -250,16 +217,6 @@ public class CreateIndexRequestBuilder extends AcknowledgedRequestBuilder<Create
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the settings and mappings as a single source.
|
||||
* @deprecated use {@link #setSource(byte[], XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public CreateIndexRequestBuilder setSource(byte[] source) {
|
||||
request.source(source);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the settings and mappings as a single source.
|
||||
*/
|
||||
|
@ -268,16 +225,6 @@ public class CreateIndexRequestBuilder extends AcknowledgedRequestBuilder<Create
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the settings and mappings as a single source.
|
||||
* @deprecated use {@link #setSource(byte[], int, int, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public CreateIndexRequestBuilder setSource(byte[] source, int offset, int length) {
|
||||
request.source(source, offset, length);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the settings and mappings as a single source.
|
||||
*/
|
||||
|
|
|
@ -270,15 +270,6 @@ public class PutMappingRequest extends AcknowledgedRequest<PutMappingRequest> im
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The mapping source definition.
|
||||
* @deprecated use {@link #source(String, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public PutMappingRequest source(String mappingSource) {
|
||||
return source(mappingSource, XContentFactory.xContentType(mappingSource));
|
||||
}
|
||||
|
||||
/**
|
||||
* The mapping source definition.
|
||||
*/
|
||||
|
|
|
@ -81,16 +81,6 @@ public class PutMappingRequestBuilder extends AcknowledgedRequestBuilder<PutMapp
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The mapping source definition.
|
||||
* @deprecated use {@link #setSource(String, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public PutMappingRequestBuilder setSource(String mappingSource) {
|
||||
request.source(mappingSource);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The mapping source definition.
|
||||
*/
|
||||
|
|
|
@ -120,16 +120,6 @@ public class UpdateSettingsRequest extends AcknowledgedRequest<UpdateSettingsReq
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the settings to be updated (either json or yaml format)
|
||||
* @deprecated use {@link #settings(String, XContentType)} to avoid content type detection
|
||||
*/
|
||||
@Deprecated
|
||||
public UpdateSettingsRequest settings(String source) {
|
||||
this.settings = Settings.builder().loadFromSource(source).build();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the settings to be updated (either json or yaml format)
|
||||
*/
|
||||
|
|
|
@ -70,16 +70,6 @@ public class UpdateSettingsRequestBuilder extends AcknowledgedRequestBuilder<Upd
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the settings to be updated (either json or yaml format)
|
||||
* @deprecated use {@link #setSettings(String, XContentType)} to avoid content type detection
|
||||
*/
|
||||
@Deprecated
|
||||
public UpdateSettingsRequestBuilder setSettings(String source) {
|
||||
request.settings(source);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the settings to be updated (either json or yaml format)
|
||||
*/
|
||||
|
|
|
@ -180,16 +180,6 @@ public class PutIndexTemplateRequest extends MasterNodeRequest<PutIndexTemplateR
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The settings to create the index template with (either json/yaml format).
|
||||
* @deprecated use {@link #settings(String, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public PutIndexTemplateRequest settings(String source) {
|
||||
this.settings = Settings.builder().loadFromSource(source).build();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The settings to create the index template with (either json/yaml format).
|
||||
*/
|
||||
|
@ -216,19 +206,6 @@ public class PutIndexTemplateRequest extends MasterNodeRequest<PutIndexTemplateR
|
|||
return this.settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds mapping that will be added when the index gets created.
|
||||
*
|
||||
* @param type The mapping type
|
||||
* @param source The mapping source
|
||||
* @deprecated use {@link #mapping(String, String, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public PutIndexTemplateRequest mapping(String type, String source) {
|
||||
XContentType xContentType = XContentFactory.xContentType(source);
|
||||
return mapping(type, source, xContentType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds mapping that will be added when the index gets created.
|
||||
*
|
||||
|
@ -385,15 +362,6 @@ public class PutIndexTemplateRequest extends MasterNodeRequest<PutIndexTemplateR
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The template source definition.
|
||||
* @deprecated use {@link #source(String, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public PutIndexTemplateRequest source(String templateSource) {
|
||||
return source(XContentHelper.convertToMap(XContentFactory.xContent(templateSource), templateSource, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* The template source definition.
|
||||
*/
|
||||
|
@ -401,15 +369,6 @@ public class PutIndexTemplateRequest extends MasterNodeRequest<PutIndexTemplateR
|
|||
return source(XContentHelper.convertToMap(xContentType.xContent(), templateSource, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* The template source definition.
|
||||
* @deprecated use {@link #source(byte[], XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public PutIndexTemplateRequest source(byte[] source) {
|
||||
return source(source, 0, source.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* The template source definition.
|
||||
*/
|
||||
|
@ -417,15 +376,6 @@ public class PutIndexTemplateRequest extends MasterNodeRequest<PutIndexTemplateR
|
|||
return source(source, 0, source.length, xContentType);
|
||||
}
|
||||
|
||||
/**
|
||||
* The template source definition.
|
||||
* @deprecated use {@link #source(byte[], int, int, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public PutIndexTemplateRequest source(byte[] source, int offset, int length) {
|
||||
return source(new BytesArray(source, offset, length));
|
||||
}
|
||||
|
||||
/**
|
||||
* The template source definition.
|
||||
*/
|
||||
|
@ -433,15 +383,6 @@ public class PutIndexTemplateRequest extends MasterNodeRequest<PutIndexTemplateR
|
|||
return source(new BytesArray(source, offset, length), xContentType);
|
||||
}
|
||||
|
||||
/**
|
||||
* The template source definition.
|
||||
* @deprecated use {@link #source(BytesReference, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public PutIndexTemplateRequest source(BytesReference source) {
|
||||
return source(XContentHelper.convertToMap(source, true).v2());
|
||||
}
|
||||
|
||||
/**
|
||||
* The template source definition.
|
||||
*/
|
||||
|
|
|
@ -100,16 +100,6 @@ public class PutIndexTemplateRequestBuilder
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The settings to crete the index template with (either json or yaml format)
|
||||
* @deprecated use {@link #setSettings(String, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public PutIndexTemplateRequestBuilder setSettings(String source) {
|
||||
request.settings(source);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The settings to crete the index template with (either json or yaml format)
|
||||
*/
|
||||
|
@ -126,19 +116,6 @@ public class PutIndexTemplateRequestBuilder
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds mapping that will be added when the index template gets created.
|
||||
*
|
||||
* @param type The mapping type
|
||||
* @param source The mapping source
|
||||
* @deprecated use {@link #addMapping(String, String, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public PutIndexTemplateRequestBuilder addMapping(String type, String source) {
|
||||
request.mapping(type, source);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds mapping that will be added when the index template gets created.
|
||||
*
|
||||
|
@ -249,16 +226,6 @@ public class PutIndexTemplateRequestBuilder
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The template source definition.
|
||||
* @deprecated use {@link #setSource(BytesReference, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public PutIndexTemplateRequestBuilder setSource(String templateSource) {
|
||||
request.source(templateSource);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The template source definition.
|
||||
*/
|
||||
|
@ -267,26 +234,6 @@ public class PutIndexTemplateRequestBuilder
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The template source definition.
|
||||
* @deprecated use {@link #setSource(BytesReference, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public PutIndexTemplateRequestBuilder setSource(BytesReference templateSource) {
|
||||
request.source(templateSource);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The template source definition.
|
||||
* @deprecated use {@link #setSource(byte[], XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public PutIndexTemplateRequestBuilder setSource(byte[] templateSource) {
|
||||
request.source(templateSource);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The template source definition.
|
||||
*/
|
||||
|
@ -295,16 +242,6 @@ public class PutIndexTemplateRequestBuilder
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The template source definition.
|
||||
* @deprecated use {@link #setSource(byte[], int, int, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public PutIndexTemplateRequestBuilder setSource(byte[] templateSource, int offset, int length) {
|
||||
request.source(templateSource, offset, length);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The template source definition.
|
||||
*/
|
||||
|
|
|
@ -289,15 +289,6 @@ public class BulkProcessor implements Closeable {
|
|||
executeIfNeeded();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the data from the bytes to be processed by the bulk processor
|
||||
* @deprecated use {@link #add(BytesReference, String, String, XContentType)} instead to avoid content type auto-detection
|
||||
*/
|
||||
@Deprecated
|
||||
public BulkProcessor add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType) throws Exception {
|
||||
return add(data, defaultIndex, defaultType, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the data from the bytes to be processed by the bulk processor
|
||||
*/
|
||||
|
@ -306,19 +297,6 @@ public class BulkProcessor implements Closeable {
|
|||
return add(data, defaultIndex, defaultType, null, null, xContentType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the data from the bytes to be processed by the bulk processor
|
||||
* @deprecated use {@link #add(BytesReference, String, String, String, Object, XContentType)} instead to avoid content type
|
||||
* auto-detection
|
||||
*/
|
||||
@Deprecated
|
||||
public synchronized BulkProcessor add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType,
|
||||
@Nullable String defaultPipeline, @Nullable Object payload) throws Exception {
|
||||
bulkRequest.add(data, defaultIndex, defaultType, null, null, null, defaultPipeline, payload, true);
|
||||
executeIfNeeded();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the data from the bytes to be processed by the bulk processor
|
||||
*/
|
||||
|
|
|
@ -243,15 +243,6 @@ public class BulkRequest extends ActionRequest implements CompositeIndicesReques
|
|||
return sizeInBytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a framed data in binary format
|
||||
* @deprecated use {@link #add(byte[], int, int, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public BulkRequest add(byte[] data, int from, int length) throws IOException {
|
||||
return add(data, from, length, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a framed data in binary format
|
||||
*/
|
||||
|
@ -259,15 +250,6 @@ public class BulkRequest extends ActionRequest implements CompositeIndicesReques
|
|||
return add(data, from, length, null, null, xContentType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a framed data in binary format
|
||||
* @deprecated use {@link #add(byte[], int, int, String, String, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public BulkRequest add(byte[] data, int from, int length, @Nullable String defaultIndex, @Nullable String defaultType) throws IOException {
|
||||
return add(new BytesArray(data, from, length), defaultIndex, defaultType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a framed data in binary format
|
||||
*/
|
||||
|
@ -276,16 +258,6 @@ public class BulkRequest extends ActionRequest implements CompositeIndicesReques
|
|||
return add(new BytesArray(data, from, length), defaultIndex, defaultType, xContentType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a framed data in binary format
|
||||
*
|
||||
* @deprecated use {@link #add(BytesReference, String, String, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType) throws IOException {
|
||||
return add(data, defaultIndex, defaultType, null, null, null, null, null, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a framed data in binary format
|
||||
*/
|
||||
|
@ -294,16 +266,6 @@ public class BulkRequest extends ActionRequest implements CompositeIndicesReques
|
|||
return add(data, defaultIndex, defaultType, null, null, null, null, null, true, xContentType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a framed data in binary format
|
||||
*
|
||||
* @deprecated use {@link #add(BytesReference, String, String, boolean, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType, boolean allowExplicitIndex) throws IOException {
|
||||
return add(data, defaultIndex, defaultType, null, null, null, null, null, allowExplicitIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a framed data in binary format
|
||||
*/
|
||||
|
@ -312,13 +274,6 @@ public class BulkRequest extends ActionRequest implements CompositeIndicesReques
|
|||
return add(data, defaultIndex, defaultType, null, null, null, null, null, allowExplicitIndex, xContentType);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType, @Nullable String defaultRouting, @Nullable String[] defaultFields, @Nullable FetchSourceContext defaultFetchSourceContext, @Nullable String defaultPipeline, @Nullable Object payload, boolean allowExplicitIndex) throws IOException {
|
||||
XContentType xContentType = XContentFactory.xContentType(data);
|
||||
return add(data, defaultIndex, defaultType, defaultRouting, defaultFields, defaultFetchSourceContext, defaultPipeline, payload,
|
||||
allowExplicitIndex, xContentType);
|
||||
}
|
||||
|
||||
public BulkRequest add(BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType, @Nullable String
|
||||
defaultRouting, @Nullable String[] defaultFields, @Nullable FetchSourceContext defaultFetchSourceContext, @Nullable String
|
||||
defaultPipeline, @Nullable Object payload, boolean allowExplicitIndex, XContentType xContentType) throws IOException {
|
||||
|
|
|
@ -96,16 +96,6 @@ public class BulkRequestBuilder extends ActionRequestBuilder<BulkRequest, BulkRe
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a framed data in binary format
|
||||
* @deprecated use {@link #add(byte[], int, int, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public BulkRequestBuilder add(byte[] data, int from, int length) throws Exception {
|
||||
request.add(data, from, length, null, null);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a framed data in binary format
|
||||
*/
|
||||
|
@ -114,16 +104,6 @@ public class BulkRequestBuilder extends ActionRequestBuilder<BulkRequest, BulkRe
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a framed data in binary format
|
||||
* @deprecated use {@link #add(byte[], int, int, String, String, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public BulkRequestBuilder add(byte[] data, int from, int length, @Nullable String defaultIndex, @Nullable String defaultType) throws Exception {
|
||||
request.add(data, from, length, defaultIndex, defaultType);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a framed data in binary format
|
||||
*/
|
||||
|
|
|
@ -121,7 +121,7 @@ public class IndexRequest extends ReplicatedWriteRequest<IndexRequest> implement
|
|||
|
||||
/**
|
||||
* Constructs a new index request against the specific index and type. The
|
||||
* {@link #source(byte[])} must be set.
|
||||
* {@link #source(byte[], XContentType)} must be set.
|
||||
*/
|
||||
public IndexRequest(String index, String type) {
|
||||
this.index = index;
|
||||
|
@ -316,16 +316,6 @@ public class IndexRequest extends ReplicatedWriteRequest<IndexRequest> implement
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the document source to index.
|
||||
*
|
||||
* @deprecated use {@link #source(String, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public IndexRequest source(String source) {
|
||||
return source(new BytesArray(source), XContentFactory.xContentType(source));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the document source to index.
|
||||
*
|
||||
|
@ -383,16 +373,6 @@ public class IndexRequest extends ReplicatedWriteRequest<IndexRequest> implement
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the document to index in bytes form.
|
||||
* @deprecated use {@link #source(BytesReference, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public IndexRequest source(BytesReference source) {
|
||||
return source(source, XContentFactory.xContentType(source));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the document to index in bytes form.
|
||||
*/
|
||||
|
@ -402,15 +382,6 @@ public class IndexRequest extends ReplicatedWriteRequest<IndexRequest> implement
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the document to index in bytes form.
|
||||
* @deprecated use {@link #source(byte[], XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public IndexRequest source(byte[] source) {
|
||||
return source(source, 0, source.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the document to index in bytes form.
|
||||
*/
|
||||
|
@ -418,20 +389,6 @@ public class IndexRequest extends ReplicatedWriteRequest<IndexRequest> implement
|
|||
return source(source, 0, source.length, xContentType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the document to index in bytes form (assumed to be safe to be used from different
|
||||
* threads).
|
||||
*
|
||||
* @param source The source to index
|
||||
* @param offset The offset in the byte array
|
||||
* @param length The length of the data
|
||||
* @deprecated use {@link #source(byte[], int, int, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public IndexRequest source(byte[] source, int offset, int length) {
|
||||
return source(new BytesArray(source, offset, length), XContentFactory.xContentType(source));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the document to index in bytes form (assumed to be safe to be used from different
|
||||
* threads).
|
||||
|
|
|
@ -80,16 +80,6 @@ public class IndexRequestBuilder extends ReplicationRequestBuilder<IndexRequest,
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the source.
|
||||
* @deprecated use {@link #setSource(BytesReference, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public IndexRequestBuilder setSource(BytesReference source) {
|
||||
request.source(source);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the source.
|
||||
*/
|
||||
|
@ -118,19 +108,6 @@ public class IndexRequestBuilder extends ReplicationRequestBuilder<IndexRequest,
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the document source to index.
|
||||
* <p>
|
||||
* Note, its preferable to either set it using {@link #setSource(org.elasticsearch.common.xcontent.XContentBuilder)}
|
||||
* or using the {@link #setSource(byte[], XContentType)}.
|
||||
* @deprecated use {@link #setSource(String, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public IndexRequestBuilder setSource(String source) {
|
||||
request.source(source);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the document source to index.
|
||||
* <p>
|
||||
|
@ -150,16 +127,6 @@ public class IndexRequestBuilder extends ReplicationRequestBuilder<IndexRequest,
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the document to index in bytes form.
|
||||
* @deprecated use {@link #setSource(byte[], XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public IndexRequestBuilder setSource(byte[] source) {
|
||||
request.source(source);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the document to index in bytes form.
|
||||
*/
|
||||
|
@ -168,21 +135,6 @@ public class IndexRequestBuilder extends ReplicationRequestBuilder<IndexRequest,
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the document to index in bytes form (assumed to be safe to be used from different
|
||||
* threads).
|
||||
*
|
||||
* @param source The source to index
|
||||
* @param offset The offset in the byte array
|
||||
* @param length The length of the data
|
||||
* @deprecated use {@link #setSource(byte[], int, int, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public IndexRequestBuilder setSource(byte[] source, int offset, int length) {
|
||||
request.source(source, offset, length);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the document to index in bytes form (assumed to be safe to be used from different
|
||||
* threads).
|
||||
|
|
|
@ -553,16 +553,6 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the doc to use for updates when a script is not specified.
|
||||
* @deprecated use {@link #doc(String, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public UpdateRequest doc(String source) {
|
||||
safeDoc().source(source);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the doc to use for updates when a script is not specified.
|
||||
*/
|
||||
|
@ -571,16 +561,6 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the doc to use for updates when a script is not specified.
|
||||
* @deprecated use {@link #doc(byte[], XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public UpdateRequest doc(byte[] source) {
|
||||
safeDoc().source(source);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the doc to use for updates when a script is not specified.
|
||||
*/
|
||||
|
@ -589,16 +569,6 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the doc to use for updates when a script is not specified.
|
||||
* @deprecated use {@link #doc(byte[], int, int, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public UpdateRequest doc(byte[] source, int offset, int length) {
|
||||
safeDoc().source(source, offset, length);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the doc to use for updates when a script is not specified.
|
||||
*/
|
||||
|
@ -669,16 +639,6 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the doc source of the update request to be used when the document does not exists.
|
||||
* @deprecated use {@link #upsert(String, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public UpdateRequest upsert(String source) {
|
||||
safeUpsertRequest().source(source);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the doc source of the update request to be used when the document does not exists.
|
||||
*/
|
||||
|
@ -687,16 +647,6 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the doc source of the update request to be used when the document does not exists.
|
||||
* @deprecated use {@link #upsert(byte[], XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public UpdateRequest upsert(byte[] source) {
|
||||
safeUpsertRequest().source(source);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the doc source of the update request to be used when the document does not exists.
|
||||
*/
|
||||
|
@ -705,16 +655,6 @@ public class UpdateRequest extends InstanceShardOperationRequest<UpdateRequest>
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the doc source of the update request to be used when the document does not exists.
|
||||
* @deprecated use {@link #upsert(byte[], int, int, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public UpdateRequest upsert(byte[] source, int offset, int length) {
|
||||
safeUpsertRequest().source(source, offset, length);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the doc source of the update request to be used when the document does not exists.
|
||||
*/
|
||||
|
|
|
@ -221,16 +221,6 @@ public class UpdateRequestBuilder extends InstanceShardOperationRequestBuilder<U
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the doc to use for updates when a script is not specified.
|
||||
* @deprecated use {@link #setDoc(String, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public UpdateRequestBuilder setDoc(String source) {
|
||||
request.doc(source);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the doc to use for updates when a script is not specified.
|
||||
*/
|
||||
|
@ -239,16 +229,6 @@ public class UpdateRequestBuilder extends InstanceShardOperationRequestBuilder<U
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the doc to use for updates when a script is not specified.
|
||||
* @deprecated use {@link #setDoc(byte[], XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public UpdateRequestBuilder setDoc(byte[] source) {
|
||||
request.doc(source);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the doc to use for updates when a script is not specified.
|
||||
*/
|
||||
|
@ -257,16 +237,6 @@ public class UpdateRequestBuilder extends InstanceShardOperationRequestBuilder<U
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the doc to use for updates when a script is not specified.
|
||||
* @deprecated use {@link #setDoc(byte[], int, int, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public UpdateRequestBuilder setDoc(byte[] source, int offset, int length) {
|
||||
request.doc(source, offset, length);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the doc to use for updates when a script is not specified.
|
||||
*/
|
||||
|
@ -326,16 +296,6 @@ public class UpdateRequestBuilder extends InstanceShardOperationRequestBuilder<U
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the doc source of the update request to be used when the document does not exists.
|
||||
* @deprecated use {@link #setUpsert(String, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public UpdateRequestBuilder setUpsert(String source) {
|
||||
request.upsert(source);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the doc source of the update request to be used when the document does not exists.
|
||||
*/
|
||||
|
@ -344,16 +304,6 @@ public class UpdateRequestBuilder extends InstanceShardOperationRequestBuilder<U
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the doc source of the update request to be used when the document does not exists.
|
||||
* @deprecated use {@link #setDoc(byte[], XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public UpdateRequestBuilder setUpsert(byte[] source) {
|
||||
request.upsert(source);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the doc source of the update request to be used when the document does not exists.
|
||||
*/
|
||||
|
@ -362,16 +312,6 @@ public class UpdateRequestBuilder extends InstanceShardOperationRequestBuilder<U
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the doc source of the update request to be used when the document does not exists.
|
||||
* @deprecated use {@link #setUpsert(byte[], int, int, XContentType)}
|
||||
*/
|
||||
@Deprecated
|
||||
public UpdateRequestBuilder setUpsert(byte[] source, int offset, int length) {
|
||||
request.upsert(source, offset, length);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the doc source of the update request to be used when the document does not exists.
|
||||
*/
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.elasticsearch.common.settings.Setting;
|
|||
import org.elasticsearch.common.settings.Setting.Property;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
import org.elasticsearch.index.mapper.Mapping;
|
||||
|
@ -68,7 +69,7 @@ public class MappingUpdatedAction extends AbstractComponent {
|
|||
if (type.equals(MapperService.DEFAULT_MAPPING)) {
|
||||
throw new IllegalArgumentException("_default_ mapping should not be updated");
|
||||
}
|
||||
return client.preparePutMapping().setConcreteIndex(index).setType(type).setSource(mappingUpdate.toString())
|
||||
return client.preparePutMapping().setConcreteIndex(index).setType(type).setSource(mappingUpdate.toString(), XContentType.JSON)
|
||||
.setMasterNodeTimeout(timeout).setTimeout(timeout);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
package org.elasticsearch.http;
|
||||
|
||||
import org.elasticsearch.common.Booleans;
|
||||
import org.elasticsearch.common.settings.Setting;
|
||||
import org.elasticsearch.common.settings.Setting.Property;
|
||||
import org.elasticsearch.common.transport.PortsRange;
|
||||
|
@ -69,7 +70,14 @@ public final class HttpTransportSettings {
|
|||
public static final Setting<Boolean> SETTING_HTTP_DETAILED_ERRORS_ENABLED =
|
||||
Setting.boolSetting("http.detailed_errors.enabled", true, Property.NodeScope);
|
||||
public static final Setting<Boolean> SETTING_HTTP_CONTENT_TYPE_REQUIRED =
|
||||
Setting.boolSetting("http.content_type.required", false, Property.NodeScope);
|
||||
new Setting<>("http.content_type.required", (s) -> Boolean.toString(true), (s) -> {
|
||||
final boolean value = Booleans.parseBoolean(s);
|
||||
if (value == false) {
|
||||
throw new IllegalArgumentException("http.content_type.required cannot be set to false. It exists only to make a rolling" +
|
||||
" upgrade easier");
|
||||
}
|
||||
return true;
|
||||
}, Property.NodeScope, Property.Deprecated);
|
||||
public static final Setting<ByteSizeValue> SETTING_HTTP_MAX_CONTENT_LENGTH =
|
||||
Setting.byteSizeSetting("http.max_content_length", new ByteSizeValue(100, ByteSizeUnit.MB), Property.NodeScope);
|
||||
public static final Setting<ByteSizeValue> SETTING_HTTP_MAX_CHUNK_SIZE =
|
||||
|
|
|
@ -69,6 +69,7 @@ import org.elasticsearch.common.util.iterable.Iterables;
|
|||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.env.NodeEnvironment;
|
||||
import org.elasticsearch.env.ShardLock;
|
||||
import org.elasticsearch.env.ShardLockObtainFailedException;
|
||||
|
@ -509,7 +510,7 @@ public class IndicesService extends AbstractLifecycleComponent
|
|||
client.admin().indices().preparePutMapping()
|
||||
.setConcreteIndex(shardRouting.index()) // concrete index - no name clash, it uses uuid
|
||||
.setType(type)
|
||||
.setSource(mapping.source().string())
|
||||
.setSource(mapping.source().string(), XContentType.JSON)
|
||||
.get();
|
||||
} catch (IOException ex) {
|
||||
throw new ElasticsearchException("failed to stringify mapping source", ex);
|
||||
|
|
|
@ -34,10 +34,8 @@ import org.elasticsearch.common.path.PathTrie;
|
|||
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.http.HttpServerTransport;
|
||||
import org.elasticsearch.http.HttpTransportSettings;
|
||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
@ -75,10 +73,6 @@ public class RestController extends AbstractComponent implements HttpServerTrans
|
|||
/** Rest headers that are copied to internal requests made during a rest request. */
|
||||
private final Set<String> headersToCopy;
|
||||
|
||||
private final boolean isContentTypeRequired;
|
||||
|
||||
private final DeprecationLogger deprecationLogger;
|
||||
|
||||
public RestController(Settings settings, Set<String> headersToCopy, UnaryOperator<RestHandler> handlerWrapper,
|
||||
NodeClient client, CircuitBreakerService circuitBreakerService) {
|
||||
super(settings);
|
||||
|
@ -89,8 +83,6 @@ public class RestController extends AbstractComponent implements HttpServerTrans
|
|||
this.handlerWrapper = handlerWrapper;
|
||||
this.client = client;
|
||||
this.circuitBreakerService = circuitBreakerService;
|
||||
this.isContentTypeRequired = HttpTransportSettings.SETTING_HTTP_CONTENT_TYPE_REQUIRED.get(settings);
|
||||
this.deprecationLogger = new DeprecationLogger(logger);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -182,7 +174,7 @@ public class RestController extends AbstractComponent implements HttpServerTrans
|
|||
assert contentLength >= 0 : "content length was negative, how is that possible?";
|
||||
final RestHandler handler = getHandler(request);
|
||||
|
||||
if (contentLength > 0 && hasContentTypeOrCanAutoDetect(request, handler) == false) {
|
||||
if (contentLength > 0 && hasContentType(request, handler) == false) {
|
||||
sendContentTypeErrorMessage(request, responseChannel);
|
||||
} else if (contentLength > 0 && handler != null && handler.supportsContentStream() &&
|
||||
request.getXContentType() != XContentType.JSON && request.getXContentType() != XContentType.SMILE) {
|
||||
|
@ -266,43 +258,19 @@ public class RestController extends AbstractComponent implements HttpServerTrans
|
|||
|
||||
/**
|
||||
* If a request contains content, this method will return {@code true} if the {@code Content-Type} header is present, matches an
|
||||
* {@link XContentType} or the request is plain text, and content type is required. If content type is not required then this method
|
||||
* returns true unless a content type could not be inferred from the body and the rest handler does not support plain text
|
||||
* {@link XContentType} or the handler supports a content stream and the content type header is for newline delimited JSON,
|
||||
*/
|
||||
private boolean hasContentTypeOrCanAutoDetect(final RestRequest restRequest, final RestHandler restHandler) {
|
||||
private boolean hasContentType(final RestRequest restRequest, final RestHandler restHandler) {
|
||||
if (restRequest.getXContentType() == null) {
|
||||
if (restHandler != null && restHandler.supportsPlainText()) {
|
||||
// content type of null with a handler that supports plain text gets through for now. Once we remove plain text this can
|
||||
// be removed!
|
||||
deprecationLogger.deprecated("Plain text request bodies are deprecated. Use request parameters or body " +
|
||||
"in a supported format.");
|
||||
} else if (restHandler != null && restHandler.supportsContentStream() && restRequest.header("Content-Type") != null) {
|
||||
if (restHandler != null && restHandler.supportsContentStream() && restRequest.header("Content-Type") != null) {
|
||||
final String lowercaseMediaType = restRequest.header("Content-Type").toLowerCase(Locale.ROOT);
|
||||
// we also support newline delimited JSON: http://specs.okfnlabs.org/ndjson/
|
||||
if (lowercaseMediaType.equals("application/x-ndjson")) {
|
||||
restRequest.setXContentType(XContentType.JSON);
|
||||
} else if (isContentTypeRequired) {
|
||||
return false;
|
||||
} else {
|
||||
return autoDetectXContentType(restRequest);
|
||||
return true;
|
||||
}
|
||||
} else if (isContentTypeRequired) {
|
||||
return false;
|
||||
} else {
|
||||
return autoDetectXContentType(restRequest);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean autoDetectXContentType(RestRequest restRequest) {
|
||||
deprecationLogger.deprecated("Content type detection for rest requests is deprecated. Specify the content type using " +
|
||||
"the [Content-Type] header.");
|
||||
XContentType xContentType = XContentFactory.xContentType(restRequest.content());
|
||||
if (xContentType == null) {
|
||||
return false;
|
||||
} else {
|
||||
restRequest.setXContentType(xContentType);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -39,15 +39,6 @@ public interface RestHandler {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if a RestHandler supports plain text bodies
|
||||
* @deprecated use request parameters or bodies that can be parsed with XContent!
|
||||
*/
|
||||
@Deprecated
|
||||
default boolean supportsPlainText() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the RestHandler supports content as a stream. A stream would be multiple objects delineated by
|
||||
* {@link XContent#streamSeparator()}. If a handler returns true this will affect the types of content that can be sent to
|
||||
|
|
|
@ -28,13 +28,10 @@ import org.elasticsearch.common.Strings;
|
|||
import org.elasticsearch.common.bytes.BytesArray;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.collect.Tuple;
|
||||
import org.elasticsearch.common.logging.DeprecationLogger;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
|
||||
|
@ -54,7 +51,6 @@ import static org.elasticsearch.common.unit.TimeValue.parseTimeValue;
|
|||
|
||||
public abstract class RestRequest implements ToXContent.Params {
|
||||
|
||||
private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(Loggers.getLogger(RestRequest.class));
|
||||
// tchar pattern as defined by RFC7230 section 3.2.6
|
||||
private static final Pattern TCHAR_PATTERN = Pattern.compile("[a-zA-z0-9!#$%&'*+\\-.\\^_`|~]+");
|
||||
|
||||
|
@ -407,66 +403,17 @@ public abstract class RestRequest implements ToXContent.Params {
|
|||
|
||||
String source = param("source");
|
||||
String typeParam = param("source_content_type");
|
||||
if (source != null) {
|
||||
if (source != null && typeParam != null) {
|
||||
BytesArray bytes = new BytesArray(source);
|
||||
final XContentType xContentType;
|
||||
if (typeParam != null) {
|
||||
xContentType = parseContentType(Collections.singletonList(typeParam));
|
||||
} else {
|
||||
DEPRECATION_LOGGER.deprecated("Deprecated use of the [source] parameter without the [source_content_type] parameter. Use " +
|
||||
"the [source_content_type] parameter to specify the content type of the source such as [application/json]");
|
||||
xContentType = XContentFactory.xContentType(bytes);
|
||||
}
|
||||
|
||||
final XContentType xContentType = parseContentType(Collections.singletonList(typeParam));
|
||||
if (xContentType == null) {
|
||||
throw new IllegalStateException("could not determine source content type");
|
||||
throw new IllegalStateException("Unknown value for source_content_type [" + typeParam + "]");
|
||||
}
|
||||
return new Tuple<>(xContentType, bytes);
|
||||
}
|
||||
return new Tuple<>(XContentType.JSON, BytesArray.EMPTY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call a consumer with the parser for the contents of this request if it has contents, otherwise with a parser for the {@code source}
|
||||
* parameter if there is one, otherwise with {@code null}. Use {@link #contentOrSourceParamParser()} if you should throw an exception
|
||||
* back to the user when there isn't request content. This version allows for plain text content
|
||||
*/
|
||||
@Deprecated
|
||||
public final void withContentOrSourceParamParserOrNullLenient(CheckedConsumer<XContentParser, IOException> withParser)
|
||||
throws IOException {
|
||||
if (hasContent() && xContentType.get() == null) {
|
||||
withParser.accept(null);
|
||||
}
|
||||
|
||||
Tuple<XContentType, BytesReference> tuple = contentOrSourceParam();
|
||||
BytesReference content = tuple.v2();
|
||||
XContentType xContentType = tuple.v1();
|
||||
if (content.length() > 0) {
|
||||
try (XContentParser parser = xContentType.xContent().createParser(xContentRegistry, content)) {
|
||||
withParser.accept(parser);
|
||||
}
|
||||
} else {
|
||||
withParser.accept(null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the content of the request or the contents of the {@code source} param without the xcontent type. This is useful the request can
|
||||
* accept non xcontent values.
|
||||
* @deprecated we should only take xcontent
|
||||
*/
|
||||
@Deprecated
|
||||
public final BytesReference getContentOrSourceParamOnly() {
|
||||
if (hasContent()) {
|
||||
return content();
|
||||
}
|
||||
String source = param("source");
|
||||
if (source != null) {
|
||||
return new BytesArray(source);
|
||||
}
|
||||
return BytesArray.EMPTY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the given content type string for the media type. This method currently ignores parameters.
|
||||
*/
|
||||
|
|
|
@ -22,7 +22,6 @@ package org.elasticsearch.rest.action.search;
|
|||
import org.elasticsearch.action.search.ClearScrollRequest;
|
||||
import org.elasticsearch.client.node.NodeClient;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.rest.BaseRestHandler;
|
||||
|
@ -48,15 +47,8 @@ public class RestClearScrollAction extends BaseRestHandler {
|
|||
String scrollIds = request.param("scroll_id");
|
||||
ClearScrollRequest clearRequest = new ClearScrollRequest();
|
||||
clearRequest.setScrollIds(Arrays.asList(splitScrollIds(scrollIds)));
|
||||
request.withContentOrSourceParamParserOrNullLenient((xContentParser -> {
|
||||
if (xContentParser == null) {
|
||||
if (request.hasContent()) {
|
||||
// TODO: why do we accept this plain text value? maybe we can just use the scroll params?
|
||||
BytesReference body = request.content();
|
||||
String bodyScrollIds = body.utf8ToString();
|
||||
clearRequest.setScrollIds(Arrays.asList(splitScrollIds(bodyScrollIds)));
|
||||
}
|
||||
} else {
|
||||
request.withContentOrSourceParamParserOrNull((xContentParser -> {
|
||||
if (xContentParser != null) {
|
||||
// NOTE: if rest request with xcontent body has request parameters, these parameters does not override xcontent value
|
||||
clearRequest.setScrollIds(null);
|
||||
try {
|
||||
|
@ -70,11 +62,6 @@ public class RestClearScrollAction extends BaseRestHandler {
|
|||
return channel -> client.clearScroll(clearRequest, new RestStatusToXContentListener<>(channel));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsPlainText() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static String[] splitScrollIds(String scrollIds) {
|
||||
if (scrollIds == null) {
|
||||
return Strings.EMPTY_ARRAY;
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.elasticsearch.rest.action.search;
|
|||
|
||||
import org.elasticsearch.action.search.SearchScrollRequest;
|
||||
import org.elasticsearch.client.node.NodeClient;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
@ -58,32 +57,17 @@ public class RestSearchScrollAction extends BaseRestHandler {
|
|||
}
|
||||
|
||||
request.withContentOrSourceParamParserOrNull(xContentParser -> {
|
||||
if (xContentParser == null) {
|
||||
if (request.hasContent()) {
|
||||
// TODO: why do we accept this plain text value? maybe we can just use the scroll params?
|
||||
BytesReference body = request.getContentOrSourceParamOnly();
|
||||
if (scrollId == null) {
|
||||
String bodyScrollId = body.utf8ToString();
|
||||
searchScrollRequest.scrollId(bodyScrollId);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (xContentParser != null) {
|
||||
// NOTE: if rest request with xcontent body has request parameters, these parameters override xcontent values
|
||||
try {
|
||||
buildFromContent(xContentParser, searchScrollRequest);
|
||||
} catch (IOException e) {
|
||||
throw new IllegalArgumentException("Failed to parse request body", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}});
|
||||
return channel -> client.searchScroll(searchScrollRequest, new RestStatusToXContentListener<>(channel));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsPlainText() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void buildFromContent(XContentParser parser, SearchScrollRequest searchScrollRequest) throws IOException {
|
||||
if (parser.nextToken() != XContentParser.Token.START_OBJECT) {
|
||||
throw new IllegalArgumentException("Malformed content, must start with an object");
|
||||
|
|
|
@ -43,6 +43,7 @@ import org.elasticsearch.common.xcontent.ToXContent;
|
|||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.ResourceAlreadyExistsException;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -82,7 +83,7 @@ public class TaskResultsService extends AbstractComponent {
|
|||
CreateIndexRequest createIndexRequest = new CreateIndexRequest();
|
||||
createIndexRequest.settings(taskResultIndexSettings());
|
||||
createIndexRequest.index(TASK_INDEX);
|
||||
createIndexRequest.mapping(TASK_TYPE, taskResultIndexMapping());
|
||||
createIndexRequest.mapping(TASK_TYPE, taskResultIndexMapping(), XContentType.JSON);
|
||||
createIndexRequest.cause("auto(task api)");
|
||||
|
||||
createIndexAction.execute(null, createIndexRequest, new ActionListener<CreateIndexResponse>() {
|
||||
|
@ -110,7 +111,8 @@ public class TaskResultsService extends AbstractComponent {
|
|||
IndexMetaData metaData = state.getMetaData().index(TASK_INDEX);
|
||||
if (metaData.getMappings().containsKey(TASK_TYPE) == false) {
|
||||
// The index already exists but doesn't have our mapping
|
||||
client.admin().indices().preparePutMapping(TASK_INDEX).setType(TASK_TYPE).setSource(taskResultIndexMapping())
|
||||
client.admin().indices().preparePutMapping(TASK_INDEX).setType(TASK_TYPE)
|
||||
.setSource(taskResultIndexMapping(), XContentType.JSON)
|
||||
.execute(new ActionListener<PutMappingResponse>() {
|
||||
@Override
|
||||
public void onResponse(PutMappingResponse putMappingResponse) {
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.elasticsearch.cluster.metadata.AliasMetaData;
|
|||
import org.elasticsearch.cluster.metadata.MappingMetaData;
|
||||
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.IndexNotFoundException;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
|
||||
|
@ -48,7 +49,7 @@ import static org.hamcrest.Matchers.notNullValue;
|
|||
public class GetIndexIT extends ESIntegTestCase {
|
||||
@Override
|
||||
protected void setupSuiteScopeCluster() throws Exception {
|
||||
assertAcked(prepareCreate("idx").addAlias(new Alias("alias_idx")).addMapping("type1", "{\"type1\":{}}")
|
||||
assertAcked(prepareCreate("idx").addAlias(new Alias("alias_idx")).addMapping("type1", "{\"type1\":{}}", XContentType.JSON)
|
||||
.setSettings(Settings.builder().put("number_of_shards", 1)).get());
|
||||
ensureSearchable("idx");
|
||||
createIndex("empty_idx");
|
||||
|
|
|
@ -243,7 +243,7 @@ public class BulkRequestTests extends ESTestCase {
|
|||
}
|
||||
|
||||
BulkRequest bulkRequest = new BulkRequest();
|
||||
bulkRequest.add(data, null, null);
|
||||
bulkRequest.add(data, null, null, xContentType);
|
||||
assertEquals(1, bulkRequest.requests().size());
|
||||
DocWriteRequest docWriteRequest = bulkRequest.requests().get(0);
|
||||
assertEquals(DocWriteRequest.OpType.INDEX, docWriteRequest.opType());
|
||||
|
|
|
@ -455,8 +455,8 @@ public class BulkWithUpdatesIT extends ESIntegTestCase {
|
|||
*/
|
||||
public void testBulkUpdateDocAsUpsertWithParent() throws Exception {
|
||||
client().admin().indices().prepareCreate("test")
|
||||
.addMapping("parent", "{\"parent\":{}}")
|
||||
.addMapping("child", "{\"child\": {\"_parent\": {\"type\": \"parent\"}}}")
|
||||
.addMapping("parent", "{\"parent\":{}}", XContentType.JSON)
|
||||
.addMapping("child", "{\"child\": {\"_parent\": {\"type\": \"parent\"}}}", XContentType.JSON)
|
||||
.execute().actionGet();
|
||||
ensureGreen();
|
||||
|
||||
|
@ -519,8 +519,8 @@ public class BulkWithUpdatesIT extends ESIntegTestCase {
|
|||
*/
|
||||
public void testBulkUpdateUpsertWithParent() throws Exception {
|
||||
assertAcked(prepareCreate("test")
|
||||
.addMapping("parent", "{\"parent\":{}}")
|
||||
.addMapping("child", "{\"child\": {\"_parent\": {\"type\": \"parent\"}}}"));
|
||||
.addMapping("parent", "{\"parent\":{}}", XContentType.JSON)
|
||||
.addMapping("child", "{\"child\": {\"_parent\": {\"type\": \"parent\"}}}", XContentType.JSON));
|
||||
ensureGreen();
|
||||
|
||||
BulkRequestBuilder builder = client().prepareBulk();
|
||||
|
@ -603,8 +603,8 @@ public class BulkWithUpdatesIT extends ESIntegTestCase {
|
|||
* Test for https://github.com/elastic/elasticsearch/issues/8365
|
||||
*/
|
||||
public void testBulkUpdateChildMissingParentRouting() throws Exception {
|
||||
assertAcked(prepareCreate("test").addMapping("parent", "{\"parent\":{}}").addMapping("child",
|
||||
"{\"child\": {\"_parent\": {\"type\": \"parent\"}}}"));
|
||||
assertAcked(prepareCreate("test").addMapping("parent", "{\"parent\":{}}", XContentType.JSON)
|
||||
.addMapping("child", "{\"child\": {\"_parent\": {\"type\": \"parent\"}}}", XContentType.JSON));
|
||||
ensureGreen();
|
||||
|
||||
BulkRequestBuilder builder = client().prepareBulk();
|
||||
|
|
|
@ -209,11 +209,11 @@ public class IndexRequestTests extends ESTestCase {
|
|||
IndexRequest request = new IndexRequest("index", "type");
|
||||
|
||||
String source = "{\"name\":\"value\"}";
|
||||
request.source(source);
|
||||
request.source(source, XContentType.JSON);
|
||||
assertEquals("index {[index][type][null], source[" + source + "]}", request.toString());
|
||||
|
||||
source = "{\"name\":\"" + randomUnicodeOfLength(IndexRequest.MAX_SOURCE_LENGTH_IN_TOSTRING) + "\"}";
|
||||
request.source(source);
|
||||
request.source(source, XContentType.JSON);
|
||||
int actualBytes = source.getBytes("UTF-8").length;
|
||||
assertEquals("index {[index][type][null], source[n/a, actual length: [" + new ByteSizeValue(actualBytes).toString() +
|
||||
"], max length: " + new ByteSizeValue(IndexRequest.MAX_SOURCE_LENGTH_IN_TOSTRING).toString() + "]}", request.toString());
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.cluster;
|
|||
import org.apache.lucene.search.join.ScoreMode;
|
||||
import org.elasticsearch.cluster.metadata.MappingMetaData;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.discovery.MasterNotDiscoveredException;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.node.Node;
|
||||
|
@ -129,7 +130,8 @@ public class SpecificMasterNodesIT extends ESIntegTestCase {
|
|||
logger.info("--> start data node / non master node");
|
||||
internalCluster().startNode(Settings.builder().put(Node.NODE_DATA_SETTING.getKey(), true).put(Node.NODE_MASTER_SETTING.getKey(), false));
|
||||
|
||||
assertAcked(prepareCreate("test").addMapping("type1", "{\"type1\" : {\"properties\" : {\"table_a\" : { \"type\" : \"nested\", \"properties\" : {\"field_a\" : { \"type\" : \"keyword\" },\"field_b\" :{ \"type\" : \"keyword\" }}}}}}"));
|
||||
assertAcked(prepareCreate("test").addMapping("type1", "{\"type1\" : {\"properties\" : {\"table_a\" : { \"type\" : \"nested\", " +
|
||||
"\"properties\" : {\"field_a\" : { \"type\" : \"keyword\" },\"field_b\" :{ \"type\" : \"keyword\" }}}}}}", XContentType.JSON));
|
||||
client().admin().indices().prepareAliases().addAlias("test", "a_test", QueryBuilders.nestedQuery("table_a", QueryBuilders.termQuery("table_a.field_b", "y"), ScoreMode.Avg)).get();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.elasticsearch.cluster.ClusterState;
|
|||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.compress.CompressedXContent;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.IndexService;
|
||||
import org.elasticsearch.index.mapper.DocumentMapper;
|
||||
import org.elasticsearch.index.mapper.MapperParsingException;
|
||||
|
@ -73,8 +74,8 @@ public class MetaDataMappingServiceTests extends ESSingleNodeTestCase {
|
|||
public void testParentIsAString() throws Exception {
|
||||
// Shouldn't be able the add the _parent field pointing to an already existing type, which isn't a parent type
|
||||
Exception e = expectThrows(MapperParsingException.class, () -> client().admin().indices().prepareCreate("test")
|
||||
.addMapping("parent", "{\"properties\":{}}")
|
||||
.addMapping("child", "{\"_parent\": \"parent\",\"properties\":{}}")
|
||||
.addMapping("parent", "{\"properties\":{}}", XContentType.JSON)
|
||||
.addMapping("child", "{\"_parent\": \"parent\",\"properties\":{}}", XContentType.JSON)
|
||||
.get());
|
||||
assertEquals("Failed to parse mapping [child]: [_parent] must be an object containing [type]", e.getMessage());
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.elasticsearch.common.logging.Loggers;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.discovery.zen.ElectMasterService;
|
||||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.env.NodeEnvironment;
|
||||
|
@ -459,7 +460,7 @@ public class GatewayIndexStateIT extends ESIntegTestCase {
|
|||
" }\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" }}").get();
|
||||
" }}", XContentType.JSON).get();
|
||||
logger.info("--> indexing a simple document");
|
||||
client().prepareIndex("test", "type1", "1").setSource("field1", "value one").setRefreshPolicy(IMMEDIATE).get();
|
||||
logger.info("--> waiting for green status");
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.elasticsearch.cluster.node.DiscoveryNode;
|
|||
import org.elasticsearch.cluster.service.ClusterService;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.env.NodeEnvironment;
|
||||
import org.elasticsearch.index.Index;
|
||||
|
@ -86,7 +87,7 @@ public class RecoveryFromGatewayIT extends ESIntegTestCase {
|
|||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
|
||||
.startObject("properties").startObject("appAccountIds").field("type", "text").endObject().endObject()
|
||||
.endObject().endObject().string();
|
||||
assertAcked(prepareCreate("test").addMapping("type1", mapping));
|
||||
assertAcked(prepareCreate("test").addMapping("type1", mapping, XContentType.JSON));
|
||||
|
||||
client().prepareIndex("test", "type1", "10990239").setSource(jsonBuilder().startObject()
|
||||
.startArray("appAccountIds").value(14).value(179).endArray().endObject()).execute().actionGet();
|
||||
|
@ -160,7 +161,7 @@ public class RecoveryFromGatewayIT extends ESIntegTestCase {
|
|||
assertAcked(prepareCreate("test").setSettings(
|
||||
SETTING_NUMBER_OF_SHARDS, numberOfShards(),
|
||||
SETTING_NUMBER_OF_REPLICAS, randomIntBetween(0, 1)
|
||||
).addMapping("type1", mapping));
|
||||
).addMapping("type1", mapping, XContentType.JSON));
|
||||
|
||||
int value1Docs;
|
||||
int value2Docs;
|
||||
|
|
|
@ -253,8 +253,8 @@ public class GetActionIT extends ESIntegTestCase {
|
|||
.endObject()
|
||||
.endObject().endObject().string();
|
||||
assertAcked(prepareCreate("test")
|
||||
.addMapping("type1", mapping1)
|
||||
.addMapping("type2", mapping2)
|
||||
.addMapping("type1", mapping1, XContentType.JSON)
|
||||
.addMapping("type2", mapping2, XContentType.JSON)
|
||||
.setSettings(Settings.builder().put("index.refresh_interval", -1)));
|
||||
ensureGreen();
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package org.elasticsearch.index.mapper;
|
||||
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.IndexService;
|
||||
import org.elasticsearch.index.mapper.DocumentMapper;
|
||||
import org.elasticsearch.index.mapper.ParsedDocument;
|
||||
|
@ -31,7 +32,7 @@ public class CamelCaseFieldNameTests extends ESSingleNodeTestCase {
|
|||
.endObject().endObject().string();
|
||||
|
||||
IndexService index = createIndex("test");
|
||||
client().admin().indices().preparePutMapping("test").setType("type").setSource(mapping).get();
|
||||
client().admin().indices().preparePutMapping("test").setType("type").setSource(mapping, XContentType.JSON).get();
|
||||
DocumentMapper documentMapper = index.mapperService().documentMapper("type");
|
||||
|
||||
ParsedDocument doc = documentMapper.parse("test", "type", "1", XContentFactory.jsonBuilder().startObject()
|
||||
|
@ -39,7 +40,8 @@ public class CamelCaseFieldNameTests extends ESSingleNodeTestCase {
|
|||
.endObject().bytes());
|
||||
|
||||
assertNotNull(doc.dynamicMappingsUpdate());
|
||||
client().admin().indices().preparePutMapping("test").setType("type").setSource(doc.dynamicMappingsUpdate().toString()).get();
|
||||
client().admin().indices().preparePutMapping("test").setType("type")
|
||||
.setSource(doc.dynamicMappingsUpdate().toString(), XContentType.JSON).get();
|
||||
|
||||
documentMapper = index.mapperService().documentMapper("type");
|
||||
assertNotNull(documentMapper.mappers().getMapper("thisIsCamelCase"));
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.index.mapper;
|
|||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.search.aggregations.AggregationBuilders;
|
||||
import org.elasticsearch.search.aggregations.Aggregator.SubAggCollectionMode;
|
||||
|
@ -76,7 +77,7 @@ public class CopyToMapperIntegrationIT extends ESIntegTestCase {
|
|||
.endObject().endObject().endObject().string();
|
||||
assertAcked(
|
||||
client().admin().indices().prepareCreate("test-idx")
|
||||
.addMapping("doc", mapping)
|
||||
.addMapping("doc", mapping, XContentType.JSON)
|
||||
);
|
||||
client().prepareIndex("test-idx", "doc", "1")
|
||||
.setSource("foo", "bar")
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.elasticsearch.common.xcontent.ToXContent;
|
|||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.index.IndexService;
|
||||
import org.elasticsearch.index.mapper.ParseContext.Document;
|
||||
|
@ -66,7 +67,7 @@ public class CopyToMapperTests extends ESSingleNodeTestCase {
|
|||
.endObject().endObject().endObject().string();
|
||||
|
||||
IndexService index = createIndex("test");
|
||||
client().admin().indices().preparePutMapping("test").setType("type1").setSource(mapping).get();
|
||||
client().admin().indices().preparePutMapping("test").setType("type1").setSource(mapping, XContentType.JSON).get();
|
||||
DocumentMapper docMapper = index.mapperService().documentMapper("type1");
|
||||
FieldMapper fieldMapper = docMapper.mappers().getMapper("copy_test");
|
||||
|
||||
|
@ -114,7 +115,8 @@ public class CopyToMapperTests extends ESSingleNodeTestCase {
|
|||
assertThat(doc.getFields("new_field")[0].numericValue().intValue(), equalTo(42));
|
||||
|
||||
assertNotNull(parsedDoc.dynamicMappingsUpdate());
|
||||
client().admin().indices().preparePutMapping("test").setType("type1").setSource(parsedDoc.dynamicMappingsUpdate().toString()).get();
|
||||
client().admin().indices().preparePutMapping("test").setType("type1")
|
||||
.setSource(parsedDoc.dynamicMappingsUpdate().toString(), XContentType.JSON).get();
|
||||
|
||||
docMapper = index.mapperService().documentMapper("type1");
|
||||
fieldMapper = docMapper.mappers().getMapper("new_field");
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.elasticsearch.common.compress.CompressedXContent;
|
|||
import org.elasticsearch.common.lucene.all.AllField;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.IndexService;
|
||||
import org.elasticsearch.index.mapper.ParseContext.Document;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
|
@ -1273,7 +1274,7 @@ public class DocumentParserTests extends ESSingleNodeTestCase {
|
|||
.endObject().endArray()
|
||||
.endObject().bytes();
|
||||
|
||||
client().prepareIndex("idx", "type").setSource(bytes).get();
|
||||
client().prepareIndex("idx", "type").setSource(bytes, XContentType.JSON).get();
|
||||
|
||||
bytes = XContentFactory.jsonBuilder().startObject().startArray("top.")
|
||||
.startObject().startArray("foo.")
|
||||
|
@ -1288,7 +1289,7 @@ public class DocumentParserTests extends ESSingleNodeTestCase {
|
|||
.endObject().bytes();
|
||||
|
||||
try {
|
||||
client().prepareIndex("idx", "type").setSource(bytes).get();
|
||||
client().prepareIndex("idx", "type").setSource(bytes, XContentType.JSON).get();
|
||||
fail("should have failed to dynamically introduce a double-dot field");
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertThat(e.getMessage(),
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.apache.lucene.search.TopDocs;
|
|||
import org.apache.lucene.store.Directory;
|
||||
import org.elasticsearch.common.lucene.Lucene;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.IndexService;
|
||||
import org.elasticsearch.index.mapper.DocumentMapper;
|
||||
import org.elasticsearch.index.mapper.ParsedDocument;
|
||||
|
@ -43,7 +44,7 @@ public class DoubleIndexingDocTests extends ESSingleNodeTestCase {
|
|||
.startObject("properties").endObject()
|
||||
.endObject().endObject().string();
|
||||
IndexService index = createIndex("test");
|
||||
client().admin().indices().preparePutMapping("test").setType("type").setSource(mapping).get();
|
||||
client().admin().indices().preparePutMapping("test").setType("type").setSource(mapping, XContentType.JSON).get();
|
||||
DocumentMapper mapper = index.mapperService().documentMapper("type");
|
||||
QueryShardContext context = index.newQueryShardContext(0, null, () -> 0L);
|
||||
|
||||
|
@ -57,7 +58,8 @@ public class DoubleIndexingDocTests extends ESSingleNodeTestCase {
|
|||
.endObject()
|
||||
.bytes());
|
||||
assertNotNull(doc.dynamicMappingsUpdate());
|
||||
client().admin().indices().preparePutMapping("test").setType("type").setSource(doc.dynamicMappingsUpdate().toString()).get();
|
||||
client().admin().indices().preparePutMapping("test").setType("type")
|
||||
.setSource(doc.dynamicMappingsUpdate().toString(), XContentType.JSON).get();
|
||||
mapper = index.mapperService().documentMapper("type");
|
||||
|
||||
writer.addDocument(doc.rootDoc());
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.elasticsearch.common.xcontent.ToXContent;
|
|||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.index.IndexService;
|
||||
import org.elasticsearch.index.mapper.BooleanFieldMapper.BooleanFieldType;
|
||||
|
@ -599,7 +600,7 @@ public class DynamicMappingTests extends ESSingleNodeTestCase {
|
|||
.endObject().endObject().string();
|
||||
|
||||
IndexService index = createIndex("test");
|
||||
client().admin().indices().preparePutMapping("test").setType("type").setSource(mapping).get();
|
||||
client().admin().indices().preparePutMapping("test").setType("type").setSource(mapping, XContentType.JSON).get();
|
||||
DocumentMapper defaultMapper = index.mapperService().documentMapper("type");
|
||||
|
||||
ParsedDocument doc = defaultMapper.parse("test", "type", "1", XContentFactory.jsonBuilder()
|
||||
|
@ -609,7 +610,8 @@ public class DynamicMappingTests extends ESSingleNodeTestCase {
|
|||
.endObject()
|
||||
.bytes());
|
||||
assertNotNull(doc.dynamicMappingsUpdate());
|
||||
client().admin().indices().preparePutMapping("test").setType("type").setSource(doc.dynamicMappingsUpdate().toString()).get();
|
||||
client().admin().indices().preparePutMapping("test").setType("type")
|
||||
.setSource(doc.dynamicMappingsUpdate().toString(), XContentType.JSON).get();
|
||||
|
||||
defaultMapper = index.mapperService().documentMapper("type");
|
||||
FieldMapper mapper = defaultMapper.mappers().smartNameFieldMapper("s_long");
|
||||
|
@ -624,7 +626,7 @@ public class DynamicMappingTests extends ESSingleNodeTestCase {
|
|||
.endObject().endObject().string();
|
||||
|
||||
IndexService index = createIndex("test");
|
||||
client().admin().indices().preparePutMapping("test").setType("type").setSource(mapping).get();
|
||||
client().admin().indices().preparePutMapping("test").setType("type").setSource(mapping, XContentType.JSON).get();
|
||||
DocumentMapper defaultMapper = index.mapperService().documentMapper("type");
|
||||
|
||||
ParsedDocument doc = defaultMapper.parse("test", "type", "1", XContentFactory.jsonBuilder()
|
||||
|
@ -634,7 +636,8 @@ public class DynamicMappingTests extends ESSingleNodeTestCase {
|
|||
.endObject()
|
||||
.bytes());
|
||||
assertNotNull(doc.dynamicMappingsUpdate());
|
||||
assertAcked(client().admin().indices().preparePutMapping("test").setType("type").setSource(doc.dynamicMappingsUpdate().toString()).get());
|
||||
assertAcked(client().admin().indices().preparePutMapping("test").setType("type")
|
||||
.setSource(doc.dynamicMappingsUpdate().toString(), XContentType.JSON).get());
|
||||
|
||||
defaultMapper = index.mapperService().documentMapper("type");
|
||||
FieldMapper mapper = defaultMapper.mappers().smartNameFieldMapper("s_long");
|
||||
|
@ -671,7 +674,7 @@ public class DynamicMappingTests extends ESSingleNodeTestCase {
|
|||
.endObject().endObject().string();
|
||||
|
||||
IndexService index = createIndex("test");
|
||||
client().admin().indices().preparePutMapping("test").setType("type").setSource(mapping).get();
|
||||
client().admin().indices().preparePutMapping("test").setType("type").setSource(mapping, XContentType.JSON).get();
|
||||
DocumentMapper defaultMapper = index.mapperService().documentMapper("type");
|
||||
|
||||
ParsedDocument doc = defaultMapper.parse("test", "type", "1", XContentFactory.jsonBuilder()
|
||||
|
@ -682,7 +685,8 @@ public class DynamicMappingTests extends ESSingleNodeTestCase {
|
|||
.endObject()
|
||||
.bytes());
|
||||
assertNotNull(doc.dynamicMappingsUpdate());
|
||||
assertAcked(client().admin().indices().preparePutMapping("test").setType("type").setSource(doc.dynamicMappingsUpdate().toString()).get());
|
||||
assertAcked(client().admin().indices().preparePutMapping("test").setType("type")
|
||||
.setSource(doc.dynamicMappingsUpdate().toString(), XContentType.JSON).get());
|
||||
|
||||
defaultMapper = index.mapperService().documentMapper("type");
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.apache.lucene.index.IndexableField;
|
|||
import org.apache.lucene.util.BytesRef;
|
||||
import org.elasticsearch.common.bytes.BytesArray;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.index.IndexService;
|
||||
import org.elasticsearch.index.mapper.DocumentFieldMappers;
|
||||
|
@ -46,12 +47,13 @@ public class DynamicTemplatesTests extends ESSingleNodeTestCase {
|
|||
.startObject("mapping").field("index", false).endObject()
|
||||
.endObject().endObject().endArray().endObject().endObject();
|
||||
IndexService index = createIndex("test");
|
||||
client().admin().indices().preparePutMapping("test").setType("person").setSource(builder.string()).get();
|
||||
client().admin().indices().preparePutMapping("test").setType("person").setSource(builder).get();
|
||||
DocumentMapper docMapper = index.mapperService().documentMapper("person");
|
||||
builder = JsonXContent.contentBuilder();
|
||||
builder.startObject().field("s", "hello").field("l", 1).endObject();
|
||||
ParsedDocument parsedDoc = docMapper.parse("test", "person", "1", builder.bytes());
|
||||
client().admin().indices().preparePutMapping("test").setType("person").setSource(parsedDoc.dynamicMappingsUpdate().toString()).get();
|
||||
client().admin().indices().preparePutMapping("test").setType("person")
|
||||
.setSource(parsedDoc.dynamicMappingsUpdate().toString(), XContentType.JSON).get();
|
||||
|
||||
docMapper = index.mapperService().documentMapper("person");
|
||||
DocumentFieldMappers mappers = docMapper.mappers();
|
||||
|
@ -68,11 +70,12 @@ public class DynamicTemplatesTests extends ESSingleNodeTestCase {
|
|||
public void testSimple() throws Exception {
|
||||
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/dynamictemplate/simple/test-mapping.json");
|
||||
IndexService index = createIndex("test");
|
||||
client().admin().indices().preparePutMapping("test").setType("person").setSource(mapping).get();
|
||||
client().admin().indices().preparePutMapping("test").setType("person").setSource(mapping, XContentType.JSON).get();
|
||||
DocumentMapper docMapper = index.mapperService().documentMapper("person");
|
||||
byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/dynamictemplate/simple/test-data.json");
|
||||
ParsedDocument parsedDoc = docMapper.parse("test", "person", "1", new BytesArray(json));
|
||||
client().admin().indices().preparePutMapping("test").setType("person").setSource(parsedDoc.dynamicMappingsUpdate().toString()).get();
|
||||
client().admin().indices().preparePutMapping("test").setType("person")
|
||||
.setSource(parsedDoc.dynamicMappingsUpdate().toString(), XContentType.JSON).get();
|
||||
docMapper = index.mapperService().documentMapper("person");
|
||||
Document doc = parsedDoc.rootDoc();
|
||||
|
||||
|
@ -125,11 +128,12 @@ public class DynamicTemplatesTests extends ESSingleNodeTestCase {
|
|||
public void testSimpleWithXContentTraverse() throws Exception {
|
||||
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/dynamictemplate/simple/test-mapping.json");
|
||||
IndexService index = createIndex("test");
|
||||
client().admin().indices().preparePutMapping("test").setType("person").setSource(mapping).get();
|
||||
client().admin().indices().preparePutMapping("test").setType("person").setSource(mapping, XContentType.JSON).get();
|
||||
DocumentMapper docMapper = index.mapperService().documentMapper("person");
|
||||
byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/dynamictemplate/simple/test-data.json");
|
||||
ParsedDocument parsedDoc = docMapper.parse("test", "person", "1", new BytesArray(json));
|
||||
client().admin().indices().preparePutMapping("test").setType("person").setSource(parsedDoc.dynamicMappingsUpdate().toString()).get();
|
||||
client().admin().indices().preparePutMapping("test").setType("person")
|
||||
.setSource(parsedDoc.dynamicMappingsUpdate().toString(), XContentType.JSON).get();
|
||||
docMapper = index.mapperService().documentMapper("person");
|
||||
Document doc = parsedDoc.rootDoc();
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.elasticsearch.index.mapper;
|
|||
|
||||
import org.apache.lucene.index.IndexableField;
|
||||
import org.elasticsearch.common.bytes.BytesArray;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.IndexService;
|
||||
import org.elasticsearch.index.mapper.DocumentMapper;
|
||||
import org.elasticsearch.index.mapper.FieldMapper;
|
||||
|
@ -36,11 +37,12 @@ public class GenericStoreDynamicTemplateTests extends ESSingleNodeTestCase {
|
|||
public void testSimple() throws Exception {
|
||||
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/dynamictemplate/genericstore/test-mapping.json");
|
||||
IndexService index = createIndex("test");
|
||||
client().admin().indices().preparePutMapping("test").setType("person").setSource(mapping).get();
|
||||
client().admin().indices().preparePutMapping("test").setType("person").setSource(mapping, XContentType.JSON).get();
|
||||
DocumentMapper docMapper = index.mapperService().documentMapper("person");
|
||||
byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/dynamictemplate/genericstore/test-data.json");
|
||||
ParsedDocument parsedDoc = docMapper.parse("test", "person", "1", new BytesArray(json));
|
||||
client().admin().indices().preparePutMapping("test").setType("person").setSource(parsedDoc.dynamicMappingsUpdate().toString()).get();
|
||||
client().admin().indices().preparePutMapping("test").setType("person")
|
||||
.setSource(parsedDoc.dynamicMappingsUpdate().toString(), XContentType.JSON).get();
|
||||
docMapper = index.mapperService().documentMapper("person");
|
||||
Document doc = parsedDoc.rootDoc();
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.elasticsearch.common.compress.CompressedXContent;
|
|||
import org.elasticsearch.common.geo.GeoPoint;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.test.ESSingleNodeTestCase;
|
||||
import org.elasticsearch.test.InternalSettingsPlugin;
|
||||
|
@ -227,7 +228,7 @@ public class GeoPointFieldMapperTests extends ESSingleNodeTestCase {
|
|||
.endObject()
|
||||
.endObject().endObject().endObject().endObject().string();
|
||||
CreateIndexRequestBuilder mappingRequest = client().admin().indices().prepareCreate("test")
|
||||
.addMapping("pin", mapping);
|
||||
.addMapping("pin", mapping, XContentType.JSON);
|
||||
mappingRequest.execute().actionGet();
|
||||
|
||||
// create index and add random test points
|
||||
|
|
|
@ -241,7 +241,7 @@ public class MapperServiceTests extends ESSingleNodeTestCase {
|
|||
// partitioned index must have routing
|
||||
IllegalArgumentException noRoutingException = expectThrows(IllegalArgumentException.class, () -> {
|
||||
client().admin().indices().prepareCreate("test-index")
|
||||
.addMapping("type", "{\"type\":{}}")
|
||||
.addMapping("type", "{\"type\":{}}", XContentType.JSON)
|
||||
.setSettings(Settings.builder()
|
||||
.put("index.number_of_shards", 4)
|
||||
.put("index.routing_partition_size", 2))
|
||||
|
@ -252,8 +252,9 @@ public class MapperServiceTests extends ESSingleNodeTestCase {
|
|||
// partitioned index cannot have parent/child relationships
|
||||
IllegalArgumentException parentException = expectThrows(IllegalArgumentException.class, () -> {
|
||||
client().admin().indices().prepareCreate("test-index")
|
||||
.addMapping("parent", "{\"parent\":{\"_routing\":{\"required\":true}}}")
|
||||
.addMapping("child", "{\"child\": {\"_routing\":{\"required\":true}, \"_parent\": {\"type\": \"parent\"}}}")
|
||||
.addMapping("parent", "{\"parent\":{\"_routing\":{\"required\":true}}}", XContentType.JSON)
|
||||
.addMapping("child", "{\"child\": {\"_routing\":{\"required\":true}, \"_parent\": {\"type\": \"parent\"}}}",
|
||||
XContentType.JSON)
|
||||
.setSettings(Settings.builder()
|
||||
.put("index.number_of_shards", 4)
|
||||
.put("index.routing_partition_size", 2))
|
||||
|
@ -263,7 +264,7 @@ public class MapperServiceTests extends ESSingleNodeTestCase {
|
|||
|
||||
// valid partitioned index
|
||||
assertTrue(client().admin().indices().prepareCreate("test-index")
|
||||
.addMapping("type", "{\"type\":{\"_routing\":{\"required\":true}}}")
|
||||
.addMapping("type", "{\"type\":{\"_routing\":{\"required\":true}}}", XContentType.JSON)
|
||||
.setSettings(Settings.builder()
|
||||
.put("index.number_of_shards", 4)
|
||||
.put("index.routing_partition_size", 2))
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.elasticsearch.index.mapper;
|
|||
|
||||
import org.apache.lucene.index.IndexableField;
|
||||
import org.elasticsearch.common.bytes.BytesArray;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.IndexService;
|
||||
import org.elasticsearch.index.mapper.DocumentMapper;
|
||||
import org.elasticsearch.index.mapper.FieldMapper;
|
||||
|
@ -36,11 +37,12 @@ public class PathMatchDynamicTemplateTests extends ESSingleNodeTestCase {
|
|||
public void testSimple() throws Exception {
|
||||
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/dynamictemplate/pathmatch/test-mapping.json");
|
||||
IndexService index = createIndex("test");
|
||||
client().admin().indices().preparePutMapping("test").setType("person").setSource(mapping).get();
|
||||
client().admin().indices().preparePutMapping("test").setType("person").setSource(mapping, XContentType.JSON).get();
|
||||
DocumentMapper docMapper = index.mapperService().documentMapper("person");
|
||||
byte[] json = copyToBytesFromClasspath("/org/elasticsearch/index/mapper/dynamictemplate/pathmatch/test-data.json");
|
||||
ParsedDocument parsedDoc = docMapper.parse("test", "person", "1", new BytesArray(json));
|
||||
client().admin().indices().preparePutMapping("test").setType("person").setSource(parsedDoc.dynamicMappingsUpdate().toString()).get();
|
||||
client().admin().indices().preparePutMapping("test").setType("person")
|
||||
.setSource(parsedDoc.dynamicMappingsUpdate().toString(), XContentType.JSON).get();
|
||||
docMapper = index.mapperService().documentMapper("person");
|
||||
Document doc = parsedDoc.rootDoc();
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.elasticsearch.Version;
|
|||
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse;
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.elasticsearch.test.InternalSettingsPlugin;
|
||||
|
@ -45,11 +46,11 @@ public class UpdateMappingOnClusterIT extends ESIntegTestCase {
|
|||
}
|
||||
|
||||
protected void testConflict(String mapping, String mappingUpdate, Version idxVersion, String... errorMessages) throws InterruptedException {
|
||||
assertAcked(prepareCreate(INDEX).setSource(mapping).setSettings("index.version.created", idxVersion.id));
|
||||
assertAcked(prepareCreate(INDEX).setSource(mapping, XContentType.JSON).setSettings("index.version.created", idxVersion.id));
|
||||
ensureGreen(INDEX);
|
||||
GetMappingsResponse mappingsBeforeUpdateResponse = client().admin().indices().prepareGetMappings(INDEX).addTypes(TYPE).get();
|
||||
try {
|
||||
client().admin().indices().preparePutMapping(INDEX).setType(TYPE).setSource(mappingUpdate).get();
|
||||
client().admin().indices().preparePutMapping(INDEX).setType(TYPE).setSource(mappingUpdate, XContentType.JSON).get();
|
||||
fail();
|
||||
} catch (IllegalArgumentException e) {
|
||||
for (String errorMessage : errorMessages) {
|
||||
|
|
|
@ -32,6 +32,7 @@ import org.elasticsearch.index.engine.Engine;
|
|||
import org.elasticsearch.index.engine.EngineConfig;
|
||||
import org.elasticsearch.index.engine.EngineFactory;
|
||||
import org.elasticsearch.index.engine.InternalEngineTests;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.shard.IndexShard;
|
||||
import org.elasticsearch.index.store.Store;
|
||||
import org.elasticsearch.index.translog.Translog;
|
||||
|
@ -164,7 +165,8 @@ public class RecoveryDuringReplicationTests extends ESIndexLevelReplicationTestC
|
|||
final int rollbackDocs = randomIntBetween(1, 5);
|
||||
logger.info("--> indexing {} rollback docs", rollbackDocs);
|
||||
for (int i = 0; i < rollbackDocs; i++) {
|
||||
final IndexRequest indexRequest = new IndexRequest(index.getName(), "type", "rollback_" + i).source("{}");
|
||||
final IndexRequest indexRequest = new IndexRequest(index.getName(), "type", "rollback_" + i)
|
||||
.source("{}", XContentType.JSON);
|
||||
indexOnPrimary(indexRequest, oldPrimary);
|
||||
indexOnReplica(indexRequest, replica);
|
||||
}
|
||||
|
@ -266,7 +268,7 @@ public class RecoveryDuringReplicationTests extends ESIndexLevelReplicationTestC
|
|||
final String id = "pending_" + i;
|
||||
threadPool.generic().submit(() -> {
|
||||
try {
|
||||
shards.index(new IndexRequest(index.getName(), "type", id).source("{}"));
|
||||
shards.index(new IndexRequest(index.getName(), "type", id).source("{}", XContentType.JSON));
|
||||
} catch (Exception e) {
|
||||
throw new AssertionError(e);
|
||||
} finally {
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.indices.mapping;
|
|||
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.action.index.IndexResponse;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
|
||||
|
@ -53,7 +54,7 @@ public class ConcurrentDynamicTemplateIT extends ESIntegTestCase {
|
|||
for (int i = 0; i < iters; i++) {
|
||||
cluster().wipeIndices("test");
|
||||
assertAcked(prepareCreate("test")
|
||||
.addMapping(mappingType, mapping));
|
||||
.addMapping(mappingType, mapping, XContentType.JSON));
|
||||
int numDocs = scaledRandomIntBetween(10, 100);
|
||||
final CountDownLatch latch = new CountDownLatch(numDocs);
|
||||
final List<Throwable> throwable = new CopyOnWriteArrayList<>();
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.elasticsearch.cluster.metadata.MappingMetaData;
|
|||
import org.elasticsearch.common.Priority;
|
||||
import org.elasticsearch.common.collect.ImmutableOpenMap;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.index.mapper.MapperParsingException;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
|
@ -102,12 +103,12 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase {
|
|||
Settings.builder()
|
||||
.put("index.number_of_shards", 1)
|
||||
.put("index.number_of_replicas", 0)
|
||||
).addMapping("doc", "{\"doc\":{\"properties\":{\"body\":{\"type\":\"text\"}}}}")
|
||||
).addMapping("doc", "{\"doc\":{\"properties\":{\"body\":{\"type\":\"text\"}}}}", XContentType.JSON)
|
||||
.execute().actionGet();
|
||||
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
|
||||
|
||||
PutMappingResponse putMappingResponse = client().admin().indices().preparePutMapping("test").setType("doc")
|
||||
.setSource("{\"properties\":{\"date\":{\"type\":\"integer\"}}}")
|
||||
.setSource("{\"properties\":{\"date\":{\"type\":\"integer\"}}}", XContentType.JSON)
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(putMappingResponse.isAcknowledged(), equalTo(true));
|
||||
|
@ -127,7 +128,7 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase {
|
|||
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
|
||||
|
||||
PutMappingResponse putMappingResponse = client().admin().indices().preparePutMapping("test").setType("doc")
|
||||
.setSource("{\"properties\":{\"date\":{\"type\":\"integer\"}}}")
|
||||
.setSource("{\"properties\":{\"date\":{\"type\":\"integer\"}}}", XContentType.JSON)
|
||||
.execute().actionGet();
|
||||
|
||||
assertThat(putMappingResponse.isAcknowledged(), equalTo(true));
|
||||
|
@ -143,13 +144,13 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase {
|
|||
Settings.builder()
|
||||
.put("index.number_of_shards", 2)
|
||||
.put("index.number_of_replicas", 0)
|
||||
).addMapping("type", "{\"type\":{\"properties\":{\"body\":{\"type\":\"text\"}}}}")
|
||||
).addMapping("type", "{\"type\":{\"properties\":{\"body\":{\"type\":\"text\"}}}}", XContentType.JSON)
|
||||
.execute().actionGet();
|
||||
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
|
||||
|
||||
try {
|
||||
client().admin().indices().preparePutMapping("test").setType("type")
|
||||
.setSource("{\"type\":{\"properties\":{\"body\":{\"type\":\"integer\"}}}}").execute().actionGet();
|
||||
.setSource("{\"type\":{\"properties\":{\"body\":{\"type\":\"integer\"}}}}", XContentType.JSON).execute().actionGet();
|
||||
fail("Expected MergeMappingException");
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertThat(e.getMessage(), containsString("mapper [body] of different type, current_type [text], merged_type [integer]"));
|
||||
|
@ -158,11 +159,11 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase {
|
|||
|
||||
public void testUpdateMappingWithNormsConflicts() throws Exception {
|
||||
client().admin().indices().prepareCreate("test")
|
||||
.addMapping("type", "{\"type\":{\"properties\":{\"body\":{\"type\":\"text\", \"norms\": false }}}}")
|
||||
.addMapping("type", "{\"type\":{\"properties\":{\"body\":{\"type\":\"text\", \"norms\": false }}}}", XContentType.JSON)
|
||||
.execute().actionGet();
|
||||
try {
|
||||
client().admin().indices().preparePutMapping("test").setType("type")
|
||||
.setSource("{\"type\":{\"properties\":{\"body\":{\"type\":\"text\", \"norms\": true }}}}").execute()
|
||||
.setSource("{\"type\":{\"properties\":{\"body\":{\"type\":\"text\", \"norms\": true }}}}", XContentType.JSON).execute()
|
||||
.actionGet();
|
||||
fail("Expected MergeMappingException");
|
||||
} catch (IllegalArgumentException e) {
|
||||
|
@ -179,12 +180,12 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase {
|
|||
Settings.builder()
|
||||
.put("index.number_of_shards", 2)
|
||||
.put("index.number_of_replicas", 0)
|
||||
).addMapping("type", "{\"type\":{\"properties\":{\"body\":{\"type\":\"text\"}}}}")
|
||||
).addMapping("type", "{\"type\":{\"properties\":{\"body\":{\"type\":\"text\"}}}}", XContentType.JSON)
|
||||
.execute().actionGet();
|
||||
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
|
||||
|
||||
PutMappingResponse putMappingResponse = client().admin().indices().preparePutMapping("test").setType("type")
|
||||
.setSource("{\"type\":{\"properties\":{\"body\":{\"type\":\"text\"}}}}")
|
||||
.setSource("{\"type\":{\"properties\":{\"body\":{\"type\":\"text\"}}}}", XContentType.JSON)
|
||||
.execute().actionGet();
|
||||
|
||||
//no changes, we return
|
||||
|
@ -321,7 +322,8 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase {
|
|||
for (String block : Arrays.asList(SETTING_BLOCKS_READ, SETTING_BLOCKS_WRITE)) {
|
||||
try {
|
||||
enableIndexBlock("test", block);
|
||||
assertAcked(client().admin().indices().preparePutMapping("test").setType("doc").setSource("{\"properties\":{\"date\":{\"type\":\"integer\"}}}"));
|
||||
assertAcked(client().admin().indices().preparePutMapping("test").setType("doc")
|
||||
.setSource("{\"properties\":{\"date\":{\"type\":\"integer\"}}}", XContentType.JSON));
|
||||
} finally {
|
||||
disableIndexBlock("test", block);
|
||||
}
|
||||
|
@ -330,7 +332,8 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase {
|
|||
for (String block : Arrays.asList(SETTING_READ_ONLY, SETTING_BLOCKS_METADATA)) {
|
||||
try {
|
||||
enableIndexBlock("test", block);
|
||||
assertBlocked(client().admin().indices().preparePutMapping("test").setType("doc").setSource("{\"properties\":{\"date\":{\"type\":\"integer\"}}}"));
|
||||
assertBlocked(client().admin().indices().preparePutMapping("test").setType("doc")
|
||||
.setSource("{\"properties\":{\"date\":{\"type\":\"integer\"}}}", XContentType.JSON));
|
||||
} finally {
|
||||
disableIndexBlock("test", block);
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.elasticsearch.common.settings.Setting.Property;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.MockEngineFactoryPlugin;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.indices.IndicesService;
|
||||
|
@ -126,7 +127,7 @@ public class RandomExceptionCircuitBreakerIT extends ESIntegTestCase {
|
|||
logger.info("creating index: [test] using settings: [{}]", settings.build().getAsMap());
|
||||
CreateIndexResponse response = client().admin().indices().prepareCreate("test")
|
||||
.setSettings(settings)
|
||||
.addMapping("type", mapping).execute().actionGet();
|
||||
.addMapping("type", mapping, XContentType.JSON).execute().actionGet();
|
||||
final int numDocs;
|
||||
if (response.isShardsAcked() == false) {
|
||||
/* some seeds just won't let you create the index at all and we enter a ping-pong mode
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.elasticsearch.action.support.IndicesOptions;
|
|||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.IndexNotFoundException;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
|
@ -315,7 +316,7 @@ public class OpenCloseIndexIT extends ESIntegTestCase {
|
|||
.endObject().string();
|
||||
|
||||
assertAcked(client().admin().indices().prepareCreate("test")
|
||||
.addMapping("type", mapping));
|
||||
.addMapping("type", mapping, XContentType.JSON));
|
||||
ensureGreen();
|
||||
int docs = between(10, 100);
|
||||
IndexRequestBuilder[] builder = new IndexRequestBuilder[docs];
|
||||
|
|
|
@ -784,7 +784,7 @@ public class IndexStatsIT extends ESIntegTestCase {
|
|||
assertAcked(prepareCreate("test1")
|
||||
.addMapping(
|
||||
"bar",
|
||||
"{ \"properties\": { \"bar\": { \"type\": \"text\", \"fields\": { \"completion\": { \"type\": \"completion\" }}},\"baz\": { \"type\": \"text\", \"fields\": { \"completion\": { \"type\": \"completion\" }}}}}"));
|
||||
"{ \"properties\": { \"bar\": { \"type\": \"text\", \"fields\": { \"completion\": { \"type\": \"completion\" }}},\"baz\": { \"type\": \"text\", \"fields\": { \"completion\": { \"type\": \"completion\" }}}}}", XContentType.JSON));
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex("test1", "bar", Integer.toString(1)).setSource("{\"bar\":\"bar\",\"baz\":\"baz\"}", XContentType.JSON).get();
|
||||
|
|
|
@ -807,7 +807,7 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase {
|
|||
IllegalArgumentException eBadMapping = expectThrows(IllegalArgumentException.class,
|
||||
() -> client().admin().indices().preparePutTemplate("template_2")
|
||||
.setPatterns(Collections.singletonList("te*"))
|
||||
.addMapping("type", "{\"type\":{\"_routing\":{\"required\":false}}}")
|
||||
.addMapping("type", "{\"type\":{\"_routing\":{\"required\":false}}}", XContentType.JSON)
|
||||
.setSettings(Settings.builder()
|
||||
.put("index.number_of_shards", "6")
|
||||
.put("index.routing_partition_size", "3"))
|
||||
|
|
|
@ -277,40 +277,33 @@ public class RestControllerTests extends ESTestCase {
|
|||
assertTrue(channel.getSendResponseCalled());
|
||||
}
|
||||
|
||||
public void testDispatchWorksWithPlainText() {
|
||||
public void testDispatchFailsWithPlainText() {
|
||||
String content = randomAsciiOfLengthBetween(1, BREAKER_LIMIT.bytesAsInt());
|
||||
FakeRestRequest fakeRestRequest = new FakeRestRequest.Builder(NamedXContentRegistry.EMPTY)
|
||||
.withContent(new BytesArray(content), null).withPath("/foo")
|
||||
.withHeaders(Collections.singletonMap("Content-Type", Collections.singletonList("text/plain"))).build();
|
||||
AssertingChannel channel = new AssertingChannel(fakeRestRequest, true, RestStatus.OK);
|
||||
AssertingChannel channel = new AssertingChannel(fakeRestRequest, true, RestStatus.NOT_ACCEPTABLE);
|
||||
restController.registerHandler(RestRequest.Method.GET, "/foo", new RestHandler() {
|
||||
@Override
|
||||
public void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws Exception {
|
||||
channel.sendResponse(new BytesRestResponse(RestStatus.OK, BytesRestResponse.TEXT_CONTENT_TYPE, BytesArray.EMPTY));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsPlainText() {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
assertFalse(channel.getSendResponseCalled());
|
||||
restController.dispatchRequest(fakeRestRequest, channel, new ThreadContext(Settings.EMPTY));
|
||||
assertTrue(channel.getSendResponseCalled());
|
||||
assertWarnings("Plain text request bodies are deprecated. Use request parameters or body in a supported format.");
|
||||
}
|
||||
|
||||
public void testDispatchWorksWithAutoDetection() {
|
||||
public void testDispatchUnsupportedContentType() {
|
||||
FakeRestRequest fakeRestRequest = new FakeRestRequest.Builder(NamedXContentRegistry.EMPTY)
|
||||
.withContent(new BytesArray("{}"), null).withPath("/")
|
||||
.withHeaders(Collections.singletonMap("Content-Type", Collections.singletonList("application/x-www-form-urlencoded"))).build();
|
||||
AssertingChannel channel = new AssertingChannel(fakeRestRequest, true, RestStatus.OK);
|
||||
AssertingChannel channel = new AssertingChannel(fakeRestRequest, true, RestStatus.NOT_ACCEPTABLE);
|
||||
|
||||
assertFalse(channel.getSendResponseCalled());
|
||||
restController.dispatchRequest(fakeRestRequest, channel, new ThreadContext(Settings.EMPTY));
|
||||
assertTrue(channel.getSendResponseCalled());
|
||||
assertWarnings("Content type detection for rest requests is deprecated. Specify the content type using the [Content-Type] header.");
|
||||
}
|
||||
|
||||
public void testDispatchWorksWithNewlineDelimitedJson() {
|
||||
|
@ -361,32 +354,9 @@ public class RestControllerTests extends ESTestCase {
|
|||
assertTrue(channel.getSendResponseCalled());
|
||||
}
|
||||
|
||||
public void testDispatchWithContentStreamAutoDetect() {
|
||||
public void testDispatchWithContentStreamNoContentType() {
|
||||
FakeRestRequest fakeRestRequest = new FakeRestRequest.Builder(NamedXContentRegistry.EMPTY)
|
||||
.withContent(new BytesArray("{}"), null).withPath("/foo").build();
|
||||
AssertingChannel channel = new AssertingChannel(fakeRestRequest, true, RestStatus.OK);
|
||||
restController.registerHandler(RestRequest.Method.GET, "/foo", new RestHandler() {
|
||||
@Override
|
||||
public void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws Exception {
|
||||
channel.sendResponse(new BytesRestResponse(RestStatus.OK, BytesRestResponse.TEXT_CONTENT_TYPE, BytesArray.EMPTY));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsContentStream() {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
assertFalse(channel.getSendResponseCalled());
|
||||
restController.dispatchRequest(fakeRestRequest, channel, new ThreadContext(Settings.EMPTY));
|
||||
assertTrue(channel.getSendResponseCalled());
|
||||
assertWarnings("Content type detection for rest requests is deprecated. Specify the content type using the [Content-Type] header.");
|
||||
}
|
||||
|
||||
public void testNonStreamingXContentCausesErrorResponse() throws IOException {
|
||||
// auto detect
|
||||
FakeRestRequest fakeRestRequest = new FakeRestRequest.Builder(NamedXContentRegistry.EMPTY)
|
||||
.withContent(YamlXContent.contentBuilder().startObject().endObject().bytes(), null).withPath("/foo").build();
|
||||
AssertingChannel channel = new AssertingChannel(fakeRestRequest, true, RestStatus.NOT_ACCEPTABLE);
|
||||
restController.registerHandler(RestRequest.Method.GET, "/foo", new RestHandler() {
|
||||
@Override
|
||||
|
@ -403,25 +373,11 @@ public class RestControllerTests extends ESTestCase {
|
|||
assertFalse(channel.getSendResponseCalled());
|
||||
restController.dispatchRequest(fakeRestRequest, channel, new ThreadContext(Settings.EMPTY));
|
||||
assertTrue(channel.getSendResponseCalled());
|
||||
|
||||
assertWarnings("Content type detection for rest requests is deprecated. Specify the content type using the [Content-Type] header.");
|
||||
|
||||
// specified
|
||||
fakeRestRequest = new FakeRestRequest.Builder(NamedXContentRegistry.EMPTY)
|
||||
.withContent(YamlXContent.contentBuilder().startObject().endObject().bytes(), XContentType.YAML).withPath("/foo").build();
|
||||
channel = new AssertingChannel(fakeRestRequest, true, RestStatus.NOT_ACCEPTABLE);
|
||||
assertFalse(channel.getSendResponseCalled());
|
||||
restController.dispatchRequest(fakeRestRequest, channel, new ThreadContext(Settings.EMPTY));
|
||||
assertTrue(channel.getSendResponseCalled());
|
||||
}
|
||||
|
||||
public void testStrictModeContentStream() {
|
||||
restController = new RestController(
|
||||
Settings.builder().put(HttpTransportSettings.SETTING_HTTP_CONTENT_TYPE_REQUIRED.getKey(), true).build(),
|
||||
Collections.emptySet(), null, null, circuitBreakerService);
|
||||
public void testNonStreamingXContentCausesErrorResponse() throws IOException {
|
||||
FakeRestRequest fakeRestRequest = new FakeRestRequest.Builder(NamedXContentRegistry.EMPTY)
|
||||
.withContent(new BytesArray("{}"), null).withPath("/foo")
|
||||
.build();
|
||||
.withContent(YamlXContent.contentBuilder().startObject().endObject().bytes(), XContentType.YAML).withPath("/foo").build();
|
||||
AssertingChannel channel = new AssertingChannel(fakeRestRequest, true, RestStatus.NOT_ACCEPTABLE);
|
||||
restController.registerHandler(RestRequest.Method.GET, "/foo", new RestHandler() {
|
||||
@Override
|
||||
|
@ -459,7 +415,6 @@ public class RestControllerTests extends ESTestCase {
|
|||
assertFalse(channel.getSendResponseCalled());
|
||||
restController.dispatchRequest(fakeRestRequest, channel, new ThreadContext(Settings.EMPTY));
|
||||
assertTrue(channel.getSendResponseCalled());
|
||||
assertWarnings("Content type detection for rest requests is deprecated. Specify the content type using the [Content-Type] header.");
|
||||
}
|
||||
|
||||
public void testDispatchBadRequest() {
|
||||
|
@ -519,7 +474,7 @@ public class RestControllerTests extends ESTestCase {
|
|||
}
|
||||
|
||||
private static final class AssertingChannel extends AbstractRestChannel {
|
||||
|
||||
|
||||
private final RestStatus expectedStatus;
|
||||
private final AtomicReference<RestResponse> responseReference = new AtomicReference<>();
|
||||
|
||||
|
@ -533,15 +488,15 @@ public class RestControllerTests extends ESTestCase {
|
|||
assertEquals(expectedStatus, response.status());
|
||||
responseReference.set(response);
|
||||
}
|
||||
|
||||
|
||||
RestResponse getRestResponse() {
|
||||
return responseReference.get();
|
||||
}
|
||||
|
||||
|
||||
boolean getSendResponseCalled() {
|
||||
return getRestResponse() != null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static final class ExceptionThrowingChannel extends AbstractRestChannel {
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.elasticsearch.ElasticsearchParseException;
|
|||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.bytes.BytesArray;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.collect.MapBuilder;
|
||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
|
@ -61,10 +62,12 @@ public class RestRequestTests extends ESTestCase {
|
|||
assertEquals(BytesArray.EMPTY, new ContentRestRequest("", emptyMap()).contentOrSourceParam().v2());
|
||||
assertEquals(new BytesArray("stuff"), new ContentRestRequest("stuff", emptyMap()).contentOrSourceParam().v2());
|
||||
assertEquals(new BytesArray("stuff"),
|
||||
new ContentRestRequest("stuff", singletonMap("source", "stuff2")).contentOrSourceParam().v2());
|
||||
new ContentRestRequest("stuff", MapBuilder.<String, String>newMapBuilder()
|
||||
.put("source", "stuff2").put("source_content_type", "application/json").immutableMap()).contentOrSourceParam().v2());
|
||||
assertEquals(new BytesArray("{\"foo\": \"stuff\"}"),
|
||||
new ContentRestRequest("", singletonMap("source", "{\"foo\": \"stuff\"}")).contentOrSourceParam().v2());
|
||||
assertWarnings("Deprecated use of the [source] parameter without the [source_content_type] parameter.");
|
||||
new ContentRestRequest("", MapBuilder.<String, String>newMapBuilder()
|
||||
.put("source", "{\"foo\": \"stuff\"}").put("source_content_type", "application/json").immutableMap())
|
||||
.contentOrSourceParam().v2());
|
||||
}
|
||||
|
||||
public void testHasContentOrSourceParam() throws IOException {
|
||||
|
@ -80,8 +83,8 @@ public class RestRequestTests extends ESTestCase {
|
|||
assertEquals("Body required", e.getMessage());
|
||||
assertEquals(emptyMap(), new ContentRestRequest("{}", emptyMap()).contentOrSourceParamParser().map());
|
||||
assertEquals(emptyMap(), new ContentRestRequest("{}", singletonMap("source", "stuff2")).contentOrSourceParamParser().map());
|
||||
assertEquals(emptyMap(), new ContentRestRequest("", singletonMap("source", "{}")).contentOrSourceParamParser().map());
|
||||
assertWarnings("Deprecated use of the [source] parameter without the [source_content_type] parameter.");
|
||||
assertEquals(emptyMap(), new ContentRestRequest("", MapBuilder.<String, String>newMapBuilder()
|
||||
.put("source", "{}").put("source_content_type", "application/json").immutableMap()).contentOrSourceParamParser().map());
|
||||
}
|
||||
|
||||
public void testWithContentOrSourceParamParserOrNull() throws IOException {
|
||||
|
@ -89,9 +92,10 @@ public class RestRequestTests extends ESTestCase {
|
|||
new ContentRestRequest("{}", emptyMap()).withContentOrSourceParamParserOrNull(parser -> assertEquals(emptyMap(), parser.map()));
|
||||
new ContentRestRequest("{}", singletonMap("source", "stuff2")).withContentOrSourceParamParserOrNull(parser ->
|
||||
assertEquals(emptyMap(), parser.map()));
|
||||
new ContentRestRequest("", singletonMap("source", "{}")).withContentOrSourceParamParserOrNull(parser ->
|
||||
new ContentRestRequest("", MapBuilder.<String, String>newMapBuilder().put("source_content_type", "application/json")
|
||||
.put("source", "{}").immutableMap())
|
||||
.withContentOrSourceParamParserOrNull(parser ->
|
||||
assertEquals(emptyMap(), parser.map()));
|
||||
assertWarnings("Deprecated use of the [source] parameter without the [source_content_type] parameter.");
|
||||
}
|
||||
|
||||
public void testContentTypeParsing() {
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.elasticsearch.routing;
|
|||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.cluster.node.DiscoveryNode;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.mockito.internal.util.collections.Sets;
|
||||
|
@ -42,7 +43,7 @@ public class PartitionedRoutingIT extends ESIntegTestCase {
|
|||
.setSettings(Settings.builder()
|
||||
.put("index.number_of_shards", shards)
|
||||
.put("index.routing_partition_size", partitionSize))
|
||||
.addMapping("type", "{\"type\":{\"_routing\":{\"required\":true}}}")
|
||||
.addMapping("type", "{\"type\":{\"_routing\":{\"required\":true}}}", XContentType.JSON)
|
||||
.execute().actionGet();
|
||||
ensureGreen();
|
||||
|
||||
|
@ -67,7 +68,7 @@ public class PartitionedRoutingIT extends ESIntegTestCase {
|
|||
.setSettings(Settings.builder()
|
||||
.put("index.number_of_shards", currentShards)
|
||||
.put("index.routing_partition_size", partitionSize))
|
||||
.addMapping("type", "{\"type\":{\"_routing\":{\"required\":true}}}")
|
||||
.addMapping("type", "{\"type\":{\"_routing\":{\"required\":true}}}", XContentType.JSON)
|
||||
.execute().actionGet();
|
||||
ensureGreen();
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.elasticsearch.action.search.SearchResponse;
|
|||
import org.elasticsearch.common.joda.DateMathParser;
|
||||
import org.elasticsearch.common.joda.Joda;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.mapper.DateFieldMapper;
|
||||
import org.elasticsearch.index.query.MatchNoneQueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
|
@ -1051,7 +1052,7 @@ public class DateHistogramIT extends ESIntegTestCase {
|
|||
|
||||
public void testSingleValueWithMultipleDateFormatsFromMapping() throws Exception {
|
||||
String mappingJson = jsonBuilder().startObject().startObject("type").startObject("properties").startObject("date").field("type", "date").field("format", "dateOptionalTime||dd-MM-yyyy").endObject().endObject().endObject().endObject().string();
|
||||
prepareCreate("idx2").addMapping("type", mappingJson).execute().actionGet();
|
||||
prepareCreate("idx2").addMapping("type", mappingJson, XContentType.JSON).execute().actionGet();
|
||||
IndexRequestBuilder[] reqs = new IndexRequestBuilder[5];
|
||||
for (int i = 0; i < reqs.length; i++) {
|
||||
reqs[i] = client().prepareIndex("idx2", "type", "" + i).setSource(jsonBuilder().startObject().field("date", "10-03-2014").endObject());
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.elasticsearch.action.index.IndexRequestBuilder;
|
|||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.search.aggregations.Aggregator.SubAggCollectionMode;
|
||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms.Bucket;
|
||||
|
@ -85,7 +86,8 @@ public class TermsDocCountErrorIT extends ESIntegTestCase {
|
|||
.endObject()));
|
||||
}
|
||||
numRoutingValues = between(1,40);
|
||||
assertAcked(prepareCreate("idx_with_routing").addMapping("type", "{ \"type\" : { \"_routing\" : { \"required\" : true } } }"));
|
||||
assertAcked(prepareCreate("idx_with_routing")
|
||||
.addMapping("type", "{ \"type\" : { \"_routing\" : { \"required\" : true } } }", XContentType.JSON));
|
||||
for (int i = 0; i < numDocs; i++) {
|
||||
builders.add(client().prepareIndex("idx_single_shard", "type", "" + i)
|
||||
.setRouting(String.valueOf(randomInt(numRoutingValues)))
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.settings.Settings.Builder;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.MockEngineFactoryPlugin;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
|
@ -109,7 +110,7 @@ public class SearchWithRandomExceptionsIT extends ESIntegTestCase {
|
|||
logger.info("creating index: [test] using settings: [{}]", settings.build().getAsMap());
|
||||
assertAcked(prepareCreate("test")
|
||||
.setSettings(settings)
|
||||
.addMapping("type", mapping));
|
||||
.addMapping("type", mapping, XContentType.JSON));
|
||||
ensureSearchable();
|
||||
final int numDocs = between(10, 100);
|
||||
int numCreated = 0;
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.elasticsearch.client.Requests;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.search.sort.SortOrder;
|
||||
|
@ -92,7 +93,7 @@ public class SearchWithRandomIOExceptionsIT extends ESIntegTestCase {
|
|||
logger.info("creating index: [test] using settings: [{}]", settings.build().getAsMap());
|
||||
client().admin().indices().prepareCreate("test")
|
||||
.setSettings(settings)
|
||||
.addMapping("type", mapping).execute().actionGet();
|
||||
.addMapping("type", mapping, XContentType.JSON).execute().actionGet();
|
||||
numInitialDocs = between(10, 100);
|
||||
ensureGreen();
|
||||
for (int i = 0; i < numInitialDocs; i++) {
|
||||
|
@ -114,7 +115,7 @@ public class SearchWithRandomIOExceptionsIT extends ESIntegTestCase {
|
|||
logger.info("creating index: [test] using settings: [{}]", settings.build().getAsMap());
|
||||
client().admin().indices().prepareCreate("test")
|
||||
.setSettings(settings)
|
||||
.addMapping("type", mapping).execute().actionGet();
|
||||
.addMapping("type", mapping, XContentType.JSON).execute().actionGet();
|
||||
}
|
||||
ClusterHealthResponse clusterHealthResponse = client().admin().cluster()
|
||||
.health(Requests.clusterHealthRequest().waitForYellowStatus().timeout(TimeValue.timeValueSeconds(5))).get(); // it's OK to timeout here
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.elasticsearch.common.settings.Settings;
|
|||
import org.elasticsearch.common.settings.Settings.Builder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.query.AbstractQueryBuilder;
|
||||
import org.elasticsearch.index.query.IdsQueryBuilder;
|
||||
import org.elasticsearch.index.query.MatchQueryBuilder;
|
||||
|
@ -2902,7 +2903,7 @@ public class HighlighterSearchIT extends ESIntegTestCase {
|
|||
.field("store", true)
|
||||
.endObject()
|
||||
.endObject().endObject().endObject().string();
|
||||
prepareCreate("test").addMapping("type", mapping).get();
|
||||
prepareCreate("test").addMapping("type", mapping, XContentType.JSON).get();
|
||||
|
||||
client().prepareIndex("test", "type", "1").setSource(jsonBuilder().startObject().startArray("foo")
|
||||
.startObject().field("text", "brown").endObject()
|
||||
|
|
|
@ -165,7 +165,7 @@ public class SearchFieldsIT extends ESIntegTestCase {
|
|||
.startObject("field3").field("type", "text").field("store", true).endObject()
|
||||
.endObject().endObject().endObject().string();
|
||||
|
||||
client().admin().indices().preparePutMapping().setType("type1").setSource(mapping).execute().actionGet();
|
||||
client().admin().indices().preparePutMapping().setType("type1").setSource(mapping, XContentType.JSON).execute().actionGet();
|
||||
|
||||
client().prepareIndex("test", "type1", "1").setSource(jsonBuilder().startObject()
|
||||
.field("field1", "value1")
|
||||
|
@ -255,7 +255,7 @@ public class SearchFieldsIT extends ESIntegTestCase {
|
|||
.startObject("num1").field("type", "double").field("store", true).endObject()
|
||||
.endObject().endObject().endObject().string();
|
||||
|
||||
client().admin().indices().preparePutMapping().setType("type1").setSource(mapping).execute().actionGet();
|
||||
client().admin().indices().preparePutMapping().setType("type1").setSource(mapping, XContentType.JSON).execute().actionGet();
|
||||
|
||||
client().prepareIndex("test", "type1", "1")
|
||||
.setSource(jsonBuilder().startObject()
|
||||
|
@ -560,7 +560,7 @@ public class SearchFieldsIT extends ESIntegTestCase {
|
|||
.endObject()
|
||||
.string();
|
||||
|
||||
client().admin().indices().preparePutMapping().setType("type1").setSource(mapping).execute().actionGet();
|
||||
client().admin().indices().preparePutMapping().setType("type1").setSource(mapping, XContentType.JSON).execute().actionGet();
|
||||
|
||||
client().prepareIndex("test", "type1", "1").setSource(jsonBuilder().startObject()
|
||||
.field("byte_field", (byte) 1)
|
||||
|
@ -776,7 +776,7 @@ public class SearchFieldsIT extends ESIntegTestCase {
|
|||
.endObject()
|
||||
.string();
|
||||
|
||||
client().admin().indices().preparePutMapping().setType("type1").setSource(mapping).execute().actionGet();
|
||||
client().admin().indices().preparePutMapping().setType("type1").setSource(mapping, XContentType.JSON).execute().actionGet();
|
||||
|
||||
ReadableDateTime date = new DateTime(2012, 3, 22, 0, 0, DateTimeZone.UTC);
|
||||
client().prepareIndex("test", "type1", "1").setSource(jsonBuilder().startObject()
|
||||
|
|
|
@ -613,7 +613,7 @@ public class DecayFunctionScoreIT extends ESIntegTestCase {
|
|||
.field("doc_values", true).endObject().startObject("geo").field("type", "geo_point")
|
||||
.field("ignore_malformed", true);
|
||||
xContentBuilder.endObject().endObject().endObject().endObject();
|
||||
assertAcked(prepareCreate("test").setSettings(settings).addMapping("type", xContentBuilder.string()));
|
||||
assertAcked(prepareCreate("test").setSettings(settings).addMapping("type", xContentBuilder));
|
||||
int numDocs = 200;
|
||||
List<IndexRequestBuilder> indexBuilders = new ArrayList<>();
|
||||
|
||||
|
|
|
@ -215,7 +215,8 @@ public class GeoFilterIT extends ESIntegTestCase {
|
|||
.endObject()
|
||||
.endObject().string();
|
||||
|
||||
CreateIndexRequestBuilder mappingRequest = client().admin().indices().prepareCreate("shapes").addMapping("polygon", mapping);
|
||||
CreateIndexRequestBuilder mappingRequest = client().admin().indices().prepareCreate("shapes")
|
||||
.addMapping("polygon", mapping, XContentType.JSON);
|
||||
mappingRequest.execute().actionGet();
|
||||
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
|
||||
|
||||
|
@ -384,7 +385,7 @@ public class GeoFilterIT extends ESIntegTestCase {
|
|||
.endObject();
|
||||
|
||||
client().admin().indices().prepareCreate("countries").setSettings(settings)
|
||||
.addMapping("country", xContentBuilder.string()).execute().actionGet();
|
||||
.addMapping("country", xContentBuilder).execute().actionGet();
|
||||
BulkResponse bulk = client().prepareBulk().add(bulkAction, 0, bulkAction.length, null, null, xContentBuilder.contentType()).get();
|
||||
|
||||
for (BulkItemResponse item : bulk.getItems()) {
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.elasticsearch.cluster.ClusterState;
|
|||
import org.elasticsearch.cluster.routing.IndexShardRoutingTable;
|
||||
import org.elasticsearch.common.geo.builders.ShapeBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.IndexService;
|
||||
import org.elasticsearch.index.mapper.GeoShapeFieldMapper;
|
||||
import org.elasticsearch.index.mapper.MappedFieldType;
|
||||
|
@ -47,7 +48,7 @@ public class GeoShapeIntegrationIT extends ESIntegTestCase {
|
|||
.endObject().endObject().string();
|
||||
|
||||
// create index
|
||||
assertAcked(prepareCreate(idxName).addMapping("shape", mapping));
|
||||
assertAcked(prepareCreate(idxName).addMapping("shape", mapping, XContentType.JSON));
|
||||
|
||||
mapping = XContentFactory.jsonBuilder().startObject().startObject("shape")
|
||||
.startObject("properties").startObject("location")
|
||||
|
@ -56,7 +57,7 @@ public class GeoShapeIntegrationIT extends ESIntegTestCase {
|
|||
.endObject().endObject()
|
||||
.endObject().endObject().string();
|
||||
|
||||
assertAcked(prepareCreate(idxName+"2").addMapping("shape", mapping));
|
||||
assertAcked(prepareCreate(idxName+"2").addMapping("shape", mapping, XContentType.JSON));
|
||||
ensureGreen(idxName, idxName+"2");
|
||||
|
||||
internalCluster().fullRestart();
|
||||
|
|
|
@ -67,7 +67,7 @@ public class GeoShapeQueryTests extends ESSingleNodeTestCase {
|
|||
.field("type", "geo_shape")
|
||||
.endObject().endObject()
|
||||
.endObject().endObject().string();
|
||||
client().admin().indices().prepareCreate("test").addMapping("type1", mapping).execute().actionGet();
|
||||
client().admin().indices().prepareCreate("test").addMapping("type1", mapping, XContentType.JSON).execute().actionGet();
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex("test", "type1", "aNullshape").setSource("{\"location\": null}", XContentType.JSON)
|
||||
|
@ -83,7 +83,7 @@ public class GeoShapeQueryTests extends ESSingleNodeTestCase {
|
|||
.field("tree", "quadtree")
|
||||
.endObject().endObject()
|
||||
.endObject().endObject().string();
|
||||
client().admin().indices().prepareCreate("test").addMapping("type1", mapping).execute().actionGet();
|
||||
client().admin().indices().prepareCreate("test").addMapping("type1", mapping, XContentType.JSON).execute().actionGet();
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex("test", "type1", "1").setSource(jsonBuilder().startObject()
|
||||
|
@ -130,7 +130,7 @@ public class GeoShapeQueryTests extends ESSingleNodeTestCase {
|
|||
.field("tree", "quadtree")
|
||||
.endObject().endObject()
|
||||
.endObject().endObject().string();
|
||||
client().admin().indices().prepareCreate("test").addMapping("type1", mapping).execute().actionGet();
|
||||
client().admin().indices().prepareCreate("test").addMapping("type1", mapping, XContentType.JSON).execute().actionGet();
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex("test", "type1", "blakely").setSource(jsonBuilder().startObject()
|
||||
|
@ -167,7 +167,7 @@ public class GeoShapeQueryTests extends ESSingleNodeTestCase {
|
|||
.field("tree", "quadtree")
|
||||
.endObject().endObject()
|
||||
.endObject().endObject().string();
|
||||
client().admin().indices().prepareCreate("test").addMapping("type1", mapping).execute().actionGet();
|
||||
client().admin().indices().prepareCreate("test").addMapping("type1", mapping, XContentType.JSON).execute().actionGet();
|
||||
createIndex("shapes");
|
||||
ensureGreen();
|
||||
|
||||
|
@ -449,7 +449,7 @@ public class GeoShapeQueryTests extends ESSingleNodeTestCase {
|
|||
.endObject().endObject()
|
||||
.endObject().endObject().string();
|
||||
|
||||
client().admin().indices().prepareCreate("geo_points_only").addMapping("type1", mapping).execute().actionGet();
|
||||
client().admin().indices().prepareCreate("geo_points_only").addMapping("type1", mapping, XContentType.JSON).execute().actionGet();
|
||||
ensureGreen();
|
||||
|
||||
ShapeBuilder shape = RandomShapeGenerator.createShape(random());
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.cluster.health.ClusterHealthStatus;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.query.MoreLikeThisQueryBuilder;
|
||||
import org.elasticsearch.index.query.MoreLikeThisQueryBuilder.Item;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
|
@ -152,7 +153,7 @@ public class MoreLikeThisIT extends ESIntegTestCase {
|
|||
.startObject("properties")
|
||||
.endObject()
|
||||
.endObject().endObject().string();
|
||||
client().admin().indices().prepareCreate(indexName).addMapping(typeName, mapping).get();
|
||||
client().admin().indices().prepareCreate(indexName).addMapping(typeName, mapping, XContentType.JSON).get();
|
||||
client().admin().indices().prepareAliases().addAlias(indexName, aliasName).get();
|
||||
|
||||
assertThat(ensureGreen(), equalTo(ClusterHealthStatus.GREEN));
|
||||
|
@ -174,7 +175,7 @@ public class MoreLikeThisIT extends ESIntegTestCase {
|
|||
.startObject("properties")
|
||||
.endObject()
|
||||
.endObject().endObject().string();
|
||||
client().admin().indices().prepareCreate("foo").addMapping("bar", mapping).execute().actionGet();
|
||||
client().admin().indices().prepareCreate("foo").addMapping("bar", mapping, XContentType.JSON).execute().actionGet();
|
||||
client().prepareIndex("foo", "bar", "1")
|
||||
.setSource(jsonBuilder().startObject().startObject("foo").field("bar", "boz").endObject().endObject())
|
||||
.execute().actionGet();
|
||||
|
@ -197,7 +198,7 @@ public class MoreLikeThisIT extends ESIntegTestCase {
|
|||
.startObject("properties")
|
||||
.endObject()
|
||||
.endObject().endObject().string();
|
||||
client().admin().indices().prepareCreate("foo").addMapping("bar", mapping).execute().actionGet();
|
||||
client().admin().indices().prepareCreate("foo").addMapping("bar", mapping, XContentType.JSON).execute().actionGet();
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex("foo", "bar", "1")
|
||||
|
@ -220,7 +221,7 @@ public class MoreLikeThisIT extends ESIntegTestCase {
|
|||
.endObject().endObject().string();
|
||||
assertAcked(prepareCreate("foo", 2,
|
||||
Settings.builder().put(SETTING_NUMBER_OF_SHARDS, 2).put(SETTING_NUMBER_OF_REPLICAS, 0))
|
||||
.addMapping("bar", mapping));
|
||||
.addMapping("bar", mapping, XContentType.JSON));
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex("foo", "bar", "1")
|
||||
|
|
|
@ -313,7 +313,8 @@ public class SimpleQueryStringIT extends ESIntegTestCase {
|
|||
.endObject()
|
||||
.endObject().string();
|
||||
|
||||
CreateIndexRequestBuilder mappingRequest = client().admin().indices().prepareCreate("test1").addMapping("type1", mapping);
|
||||
CreateIndexRequestBuilder mappingRequest = client().admin().indices().prepareCreate("test1")
|
||||
.addMapping("type1", mapping, XContentType.JSON);
|
||||
mappingRequest.execute().actionGet();
|
||||
indexRandom(true, client().prepareIndex("test1", "type1", "1").setSource("location", "Köln"));
|
||||
refresh();
|
||||
|
@ -364,7 +365,7 @@ public class SimpleQueryStringIT extends ESIntegTestCase {
|
|||
|
||||
CreateIndexRequestBuilder mappingRequest = client().admin().indices()
|
||||
.prepareCreate("test1")
|
||||
.addMapping("type1", mapping);
|
||||
.addMapping("type1", mapping, XContentType.JSON);
|
||||
mappingRequest.execute().actionGet();
|
||||
indexRandom(true, client().prepareIndex("test1", "type1", "1").setSource("body", "Some Text"));
|
||||
refresh();
|
||||
|
@ -377,7 +378,7 @@ public class SimpleQueryStringIT extends ESIntegTestCase {
|
|||
|
||||
public void testBasicAllQuery() throws Exception {
|
||||
String indexBody = copyToStringFromClasspath("/org/elasticsearch/search/query/all-query-index.json");
|
||||
prepareCreate("test").setSource(indexBody).get();
|
||||
prepareCreate("test").setSource(indexBody, XContentType.JSON).get();
|
||||
ensureGreen("test");
|
||||
|
||||
List<IndexRequestBuilder> reqs = new ArrayList<>();
|
||||
|
@ -405,7 +406,7 @@ public class SimpleQueryStringIT extends ESIntegTestCase {
|
|||
|
||||
public void testWithDate() throws Exception {
|
||||
String indexBody = copyToStringFromClasspath("/org/elasticsearch/search/query/all-query-index.json");
|
||||
prepareCreate("test").setSource(indexBody).get();
|
||||
prepareCreate("test").setSource(indexBody, XContentType.JSON).get();
|
||||
ensureGreen("test");
|
||||
|
||||
List<IndexRequestBuilder> reqs = new ArrayList<>();
|
||||
|
@ -432,7 +433,7 @@ public class SimpleQueryStringIT extends ESIntegTestCase {
|
|||
|
||||
public void testWithLotsOfTypes() throws Exception {
|
||||
String indexBody = copyToStringFromClasspath("/org/elasticsearch/search/query/all-query-index.json");
|
||||
prepareCreate("test").setSource(indexBody).get();
|
||||
prepareCreate("test").setSource(indexBody, XContentType.JSON).get();
|
||||
ensureGreen("test");
|
||||
|
||||
List<IndexRequestBuilder> reqs = new ArrayList<>();
|
||||
|
@ -465,7 +466,7 @@ public class SimpleQueryStringIT extends ESIntegTestCase {
|
|||
|
||||
public void testDocWithAllTypes() throws Exception {
|
||||
String indexBody = copyToStringFromClasspath("/org/elasticsearch/search/query/all-query-index.json");
|
||||
prepareCreate("test").setSource(indexBody).get();
|
||||
prepareCreate("test").setSource(indexBody, XContentType.JSON).get();
|
||||
ensureGreen("test");
|
||||
|
||||
List<IndexRequestBuilder> reqs = new ArrayList<>();
|
||||
|
@ -515,7 +516,7 @@ public class SimpleQueryStringIT extends ESIntegTestCase {
|
|||
|
||||
public void testKeywordWithWhitespace() throws Exception {
|
||||
String indexBody = copyToStringFromClasspath("/org/elasticsearch/search/query/all-query-index.json");
|
||||
prepareCreate("test").setSource(indexBody).get();
|
||||
prepareCreate("test").setSource(indexBody, XContentType.JSON).get();
|
||||
ensureGreen("test");
|
||||
|
||||
List<IndexRequestBuilder> reqs = new ArrayList<>();
|
||||
|
@ -536,7 +537,7 @@ public class SimpleQueryStringIT extends ESIntegTestCase {
|
|||
public void testExplicitAllFieldsRequested() throws Exception {
|
||||
String indexBody = copyToStringFromClasspath("/org/elasticsearch/search/query/all-query-index-with-all.json");
|
||||
prepareCreate("test")
|
||||
.setSource(indexBody)
|
||||
.setSource(indexBody, XContentType.JSON)
|
||||
// .setSettings(Settings.builder().put("index.version.created", Version.V_5_0_0.id)).get();
|
||||
.get();
|
||||
ensureGreen("test");
|
||||
|
@ -564,7 +565,7 @@ public class SimpleQueryStringIT extends ESIntegTestCase {
|
|||
@LuceneTestCase.AwaitsFix(bugUrl="currently can't perform phrase queries on fields that don't support positions")
|
||||
public void testPhraseQueryOnFieldWithNoPositions() throws Exception {
|
||||
String indexBody = copyToStringFromClasspath("/org/elasticsearch/search/query/all-query-index.json");
|
||||
prepareCreate("test").setSource(indexBody).get();
|
||||
prepareCreate("test").setSource(indexBody, XContentType.JSON).get();
|
||||
ensureGreen("test");
|
||||
|
||||
List<IndexRequestBuilder> reqs = new ArrayList<>();
|
||||
|
@ -579,7 +580,7 @@ public class SimpleQueryStringIT extends ESIntegTestCase {
|
|||
|
||||
public void testAllFieldsWithSpecifiedLeniency() throws IOException {
|
||||
String indexBody = copyToStringFromClasspath("/org/elasticsearch/search/query/all-query-index.json");
|
||||
prepareCreate("test").setSource(indexBody).get();
|
||||
prepareCreate("test").setSource(indexBody, XContentType.JSON).get();
|
||||
ensureGreen("test");
|
||||
|
||||
Exception e = expectThrows(Exception.class, () ->
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.elasticsearch.action.search.SearchResponse;
|
|||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.search.Scroll;
|
||||
import org.elasticsearch.search.SearchContextException;
|
||||
import org.elasticsearch.search.SearchHit;
|
||||
|
@ -71,7 +72,7 @@ public class SearchSliceIT extends ESIntegTestCase {
|
|||
assertAcked(client().admin().indices().prepareCreate("test")
|
||||
.setSettings("number_of_shards", numberOfShards,
|
||||
"index.max_slices_per_scroll", 10000)
|
||||
.addMapping("type", mapping));
|
||||
.addMapping("type", mapping, XContentType.JSON));
|
||||
ensureGreen();
|
||||
|
||||
if (withDocs == false) {
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.elasticsearch.action.search.SearchResponse;
|
|||
import org.elasticsearch.action.search.ShardSearchFailure;
|
||||
import org.elasticsearch.common.geo.GeoPoint;
|
||||
import org.elasticsearch.common.geo.GeoUtils;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.fielddata.ScriptDocValues;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.script.MockScriptPlugin;
|
||||
|
@ -243,7 +244,7 @@ public class SimpleSortIT extends ESIntegTestCase {
|
|||
.endObject()
|
||||
.endObject().string();
|
||||
|
||||
assertAcked(prepareCreate("test").addMapping("type1", mapping));
|
||||
assertAcked(prepareCreate("test").addMapping("type1", mapping, XContentType.JSON));
|
||||
ensureGreen();
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
|
@ -355,7 +356,7 @@ public class SimpleSortIT extends ESIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.endObject().string();
|
||||
assertAcked(prepareCreate("test").addMapping("type1", mapping));
|
||||
assertAcked(prepareCreate("test").addMapping("type1", mapping, XContentType.JSON));
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex("test", "type1")
|
||||
|
|
|
@ -35,6 +35,7 @@ import org.elasticsearch.common.FieldMemoryStats;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.Fuzziness;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.mapper.MapperParsingException;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.search.aggregations.AggregationBuilders;
|
||||
|
@ -1064,7 +1065,7 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
|
|||
.endObject()
|
||||
.string();
|
||||
|
||||
assertAcked(client().admin().indices().prepareCreate(INDEX).addMapping(TYPE, mapping).get());
|
||||
assertAcked(client().admin().indices().prepareCreate(INDEX).addMapping(TYPE, mapping, XContentType.JSON).get());
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex(INDEX, TYPE, "1").setSource(FIELD, "strings make me happy", FIELD + "_1", "nulls make me sad")
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package org.elasticsearch.test.rest;
|
||||
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.elasticsearch.action.ActionFuture;
|
||||
|
@ -50,7 +51,8 @@ public class WaitForRefreshAndCloseTests extends ESRestTestCase {
|
|||
// If we get an error, it should be because the index doesn't exist
|
||||
assertEquals(404, e.getResponse().getStatusLine().getStatusCode());
|
||||
}
|
||||
client().performRequest("PUT", indexName(), emptyMap(), new StringEntity("{\"settings\":{\"refresh_interval\":-1}}"));
|
||||
client().performRequest("PUT", indexName(), emptyMap(),
|
||||
new StringEntity("{\"settings\":{\"refresh_interval\":-1}}", ContentType.APPLICATION_JSON));
|
||||
}
|
||||
|
||||
@After
|
||||
|
@ -67,16 +69,17 @@ public class WaitForRefreshAndCloseTests extends ESRestTestCase {
|
|||
}
|
||||
|
||||
public void testIndexAndThenClose() throws Exception {
|
||||
closeWhileListenerEngaged(start("PUT", "", new StringEntity("{\"test\":\"test\"}")));
|
||||
closeWhileListenerEngaged(start("PUT", "", new StringEntity("{\"test\":\"test\"}", ContentType.APPLICATION_JSON)));
|
||||
}
|
||||
|
||||
public void testUpdateAndThenClose() throws Exception {
|
||||
client().performRequest("PUT", docPath(), emptyMap(), new StringEntity("{\"test\":\"test\"}"));
|
||||
closeWhileListenerEngaged(start("POST", "/_update", new StringEntity("{\"doc\":{\"name\":\"test\"}}")));
|
||||
client().performRequest("PUT", docPath(), emptyMap(), new StringEntity("{\"test\":\"test\"}", ContentType.APPLICATION_JSON));
|
||||
closeWhileListenerEngaged(start("POST", "/_update",
|
||||
new StringEntity("{\"doc\":{\"name\":\"test\"}}", ContentType.APPLICATION_JSON)));
|
||||
}
|
||||
|
||||
public void testDeleteAndThenClose() throws Exception {
|
||||
client().performRequest("PUT", docPath(), emptyMap(), new StringEntity("{\"test\":\"test\"}"));
|
||||
client().performRequest("PUT", docPath(), emptyMap(), new StringEntity("{\"test\":\"test\"}", ContentType.APPLICATION_JSON));
|
||||
closeWhileListenerEngaged(start("DELETE", "", null));
|
||||
}
|
||||
|
||||
|
|
|
@ -675,22 +675,17 @@ should also be passed with a media type value that indicates the format
|
|||
of the source, such as `application/json`.
|
||||
|
||||
[float]
|
||||
=== Content-Type auto-detection
|
||||
=== Content-Type Requirements
|
||||
|
||||
deprecated[5.3.0, Provide the proper Content-Type header]
|
||||
The type of the content sent in a request body must be specified using
|
||||
the `Content-Type` header. The value of this header must map to one of
|
||||
the supported formats that the API supports. Most APIs support JSON,
|
||||
YAML, CBOR, and SMILE. The bulk and multi-search APIs support NDJSON,
|
||||
JSON and SMILE; other types will result in an error response.
|
||||
|
||||
The content sent in a request body or using the `source` query string
|
||||
parameter is inspected to automatically determine the content type
|
||||
(JSON, YAML, SMILE, or CBOR).
|
||||
|
||||
A strict mode can be enabled which disables auto-detection and requires
|
||||
that all requests with a body have a Content-Type header that maps to
|
||||
a supported format. To enabled this strict mode, add the following
|
||||
setting to the `elasticsearch.yml` file:
|
||||
|
||||
http.content_type.required: true
|
||||
|
||||
The default value is `false`.
|
||||
Additionally, when using the `source` query string parameter the
|
||||
content type must be specified using the `source_content_type` query
|
||||
string parameter.
|
||||
|
||||
[[url-access-control]]
|
||||
== URL-based access control
|
||||
|
|
|
@ -37,6 +37,7 @@ way to reindex old indices is to use the `reindex` API.
|
|||
* <<breaking_60_scripting_changes>>
|
||||
* <<breaking_60_ingest_changes>>
|
||||
* <<breaking_60_percolator_changes>>
|
||||
* <<breaking_60_java_changes>>
|
||||
|
||||
include::migrate_6_0/cat.asciidoc[]
|
||||
|
||||
|
@ -63,3 +64,5 @@ include::migrate_6_0/scripting.asciidoc[]
|
|||
include::migrate_6_0/ingest.asciidoc[]
|
||||
|
||||
include::migrate_6_0/percolator.asciidoc[]
|
||||
|
||||
include::migrate_6_0/java.asciidoc[]
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
[[breaking_60_java_changes]]
|
||||
=== Java API changes
|
||||
|
||||
==== `setSource` methods require XContentType
|
||||
|
||||
Previously the `setSource` methods and other methods that accepted byte/string representations of
|
||||
an object source did not require the XContentType to be specified. The auto-detection of the content
|
||||
type is no longer used, so these methods now require the XContentType as an additional argument when
|
||||
providing the source in bytes or as a string.
|
|
@ -19,6 +19,9 @@ In previous versions of Elasticsearch, having a proper Content-Type for the data
|
|||
Elasticsearch 6.0.0 enforces that all requests with a body must have a supported Content-Type and this type will
|
||||
be used when parsing the data.
|
||||
|
||||
When using the `source` query string parameter, the `source_content_type` parameter must also be specified with
|
||||
the media type of the source.
|
||||
|
||||
==== Boolean API parameters
|
||||
|
||||
All REST APIs parameters (both request parameters and JSON body) support providing boolean "false" as the
|
||||
|
|
|
@ -100,9 +100,6 @@ simple message will be returned. Defaults to `true`
|
|||
|
||||
|`http.pipelining.max_events` |The maximum number of events to be queued up in memory before a HTTP connection is closed, defaults to `10000`.
|
||||
|
||||
|`http.content_type.required`|Enables or disables strict checking and usage of
|
||||
the `Content-Type` header for all requests with content, defaults to `false`.
|
||||
|
||||
|=======================================================================
|
||||
|
||||
It also uses the common
|
||||
|
|
|
@ -120,7 +120,7 @@ public class TransportUpdateByQueryAction extends HandledTransportAction<UpdateB
|
|||
index.index(doc.getIndex());
|
||||
index.type(doc.getType());
|
||||
index.id(doc.getId());
|
||||
index.source(doc.getSource());
|
||||
index.source(doc.getSource(), doc.getXContentType());
|
||||
index.versionType(VersionType.INTERNAL);
|
||||
index.version(doc.getVersion());
|
||||
index.setPipeline(mainRequest.getPipeline());
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package org.elasticsearch.index.reindex;
|
||||
|
||||
import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
|
||||
import static org.elasticsearch.index.query.QueryBuilders.hasParentQuery;
|
||||
|
@ -89,8 +90,8 @@ public class ReindexParentChildTests extends ReindexTestCase {
|
|||
*/
|
||||
private void createParentChildIndex(String indexName) throws Exception {
|
||||
CreateIndexRequestBuilder create = client().admin().indices().prepareCreate(indexName);
|
||||
create.addMapping("city", "{\"_parent\": {\"type\": \"country\"}}");
|
||||
create.addMapping("neighborhood", "{\"_parent\": {\"type\": \"city\"}}");
|
||||
create.addMapping("city", "{\"_parent\": {\"type\": \"country\"}}", XContentType.JSON);
|
||||
create.addMapping("neighborhood", "{\"_parent\": {\"type\": \"city\"}}", XContentType.JSON);
|
||||
assertAcked(create);
|
||||
ensureGreen();
|
||||
}
|
||||
|
|
|
@ -389,7 +389,7 @@ public class RemoteScrollableHitSourceTests extends ESTestCase {
|
|||
assertEquals("No error body.", wrapped.getMessage());
|
||||
|
||||
// Successfully get the status without a body
|
||||
HttpEntity okEntity = new StringEntity("test body", StandardCharsets.UTF_8);
|
||||
HttpEntity okEntity = new StringEntity("test body", ContentType.TEXT_PLAIN);
|
||||
wrapped = RemoteScrollableHitSource.wrapExceptionToPreserveStatus(status.getStatus(), okEntity, cause);
|
||||
assertEquals(status, wrapped.status());
|
||||
assertEquals(cause, wrapped.getCause());
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
package org.elasticsearch.rest;
|
||||
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.elasticsearch.client.Response;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
@ -55,7 +56,8 @@ public class Netty4HeadBodyIsEmptyIT extends ESRestTestCase {
|
|||
builder.field("test", "test");
|
||||
}
|
||||
builder.endObject();
|
||||
client().performRequest("PUT", "/" + indexName + "/" + typeName + "/" + "1", emptyMap(), new StringEntity(builder.string()));
|
||||
client().performRequest("PUT", "/" + indexName + "/" + typeName + "/" + "1", emptyMap(),
|
||||
new StringEntity(builder.string(), ContentType.APPLICATION_JSON));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,7 +102,7 @@ public class Netty4HeadBodyIsEmptyIT extends ESRestTestCase {
|
|||
}
|
||||
builder.endObject();
|
||||
|
||||
client().performRequest("POST", "_aliases", emptyMap(), new StringEntity(builder.string()));
|
||||
client().performRequest("POST", "_aliases", emptyMap(), new StringEntity(builder.string(), ContentType.APPLICATION_JSON));
|
||||
headTestCase("/_alias/test_alias", emptyMap(), greaterThan(0));
|
||||
headTestCase("/test/_alias/test_alias", emptyMap(), greaterThan(0));
|
||||
}
|
||||
|
@ -119,7 +121,8 @@ public class Netty4HeadBodyIsEmptyIT extends ESRestTestCase {
|
|||
}
|
||||
builder.endObject();
|
||||
|
||||
client().performRequest("PUT", "/_template/template", emptyMap(), new StringEntity(builder.string()));
|
||||
client().performRequest("PUT", "/_template/template", emptyMap(),
|
||||
new StringEntity(builder.string(), ContentType.APPLICATION_JSON));
|
||||
headTestCase("/_template/template", emptyMap(), greaterThan(0));
|
||||
}
|
||||
}
|
||||
|
@ -147,7 +150,7 @@ public class Netty4HeadBodyIsEmptyIT extends ESRestTestCase {
|
|||
builder.endObject();
|
||||
}
|
||||
builder.endObject();
|
||||
client().performRequest("PUT", "/test-no-source", emptyMap(), new StringEntity(builder.string()));
|
||||
client().performRequest("PUT", "/test-no-source", emptyMap(), new StringEntity(builder.string(), ContentType.APPLICATION_JSON));
|
||||
createTestDoc("test-no-source", "test-no-source");
|
||||
headTestCase("/test-no-source/test-no-source/1/_source", emptyMap(), NOT_FOUND.getStatus(), equalTo(0));
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue