Disable XContent auto closing of object and arrays
This commit is contained in:
parent
de6b4f35b1
commit
bdee8c2632
|
@ -192,6 +192,7 @@ public class ListTasksResponse extends BaseTasksResponse implements ToXContent {
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
}
|
}
|
||||||
|
builder.endObject();
|
||||||
} else if ("parents".equals(groupBy)) {
|
} else if ("parents".equals(groupBy)) {
|
||||||
builder.startObject("tasks");
|
builder.startObject("tasks");
|
||||||
for (TaskGroup group : getTaskGroups()) {
|
for (TaskGroup group : getTaskGroups()) {
|
||||||
|
|
|
@ -781,7 +781,7 @@ public final class XContentBuilder implements BytesStream, Releasable {
|
||||||
try {
|
try {
|
||||||
generator.close();
|
generator.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// ignore
|
throw new IllegalStateException("failed to close the XContentBuilder", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
package org.elasticsearch.common.xcontent.cbor;
|
package org.elasticsearch.common.xcontent.cbor;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonEncoding;
|
import com.fasterxml.jackson.core.JsonEncoding;
|
||||||
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
import com.fasterxml.jackson.dataformat.cbor.CBORFactory;
|
import com.fasterxml.jackson.dataformat.cbor.CBORFactory;
|
||||||
import org.elasticsearch.ElasticsearchParseException;
|
import org.elasticsearch.ElasticsearchParseException;
|
||||||
import org.elasticsearch.common.bytes.BytesReference;
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
|
@ -50,6 +51,8 @@ public class CborXContent implements XContent {
|
||||||
static {
|
static {
|
||||||
cborFactory = new CBORFactory();
|
cborFactory = new CBORFactory();
|
||||||
cborFactory.configure(CBORFactory.Feature.FAIL_ON_SYMBOL_HASH_OVERFLOW, false); // this trips on many mappings now...
|
cborFactory.configure(CBORFactory.Feature.FAIL_ON_SYMBOL_HASH_OVERFLOW, false); // this trips on many mappings now...
|
||||||
|
// Do not automatically close unclosed objects/arrays in com.fasterxml.jackson.dataformat.cbor.CBORGenerator#close() method
|
||||||
|
cborFactory.configure(JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT, false);
|
||||||
cborXContent = new CborXContent();
|
cborXContent = new CborXContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,8 @@ public class JsonXContent implements XContent {
|
||||||
jsonFactory.configure(JsonGenerator.Feature.QUOTE_FIELD_NAMES, true);
|
jsonFactory.configure(JsonGenerator.Feature.QUOTE_FIELD_NAMES, true);
|
||||||
jsonFactory.configure(JsonParser.Feature.ALLOW_COMMENTS, true);
|
jsonFactory.configure(JsonParser.Feature.ALLOW_COMMENTS, true);
|
||||||
jsonFactory.configure(JsonFactory.Feature.FAIL_ON_SYMBOL_HASH_OVERFLOW, false); // this trips on many mappings now...
|
jsonFactory.configure(JsonFactory.Feature.FAIL_ON_SYMBOL_HASH_OVERFLOW, false); // this trips on many mappings now...
|
||||||
|
// Do not automatically close unclosed objects/arrays in com.fasterxml.jackson.core.json.UTF8JsonGenerator#close() method
|
||||||
|
jsonFactory.configure(JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT, false);
|
||||||
jsonXContent = new JsonXContent();
|
jsonXContent = new JsonXContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -389,6 +389,10 @@ public class JsonXContentGenerator implements XContentGenerator {
|
||||||
if (generator.isClosed()) {
|
if (generator.isClosed()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
JsonStreamContext context = generator.getOutputContext();
|
||||||
|
if ((context != null) && (context.inRoot() == false)) {
|
||||||
|
throw new IOException("unclosed object or array found");
|
||||||
|
}
|
||||||
if (writeLineFeedAtEnd) {
|
if (writeLineFeedAtEnd) {
|
||||||
flush();
|
flush();
|
||||||
generator.writeRaw(LF);
|
generator.writeRaw(LF);
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
package org.elasticsearch.common.xcontent.smile;
|
package org.elasticsearch.common.xcontent.smile;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonEncoding;
|
import com.fasterxml.jackson.core.JsonEncoding;
|
||||||
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
import com.fasterxml.jackson.dataformat.smile.SmileFactory;
|
import com.fasterxml.jackson.dataformat.smile.SmileFactory;
|
||||||
import com.fasterxml.jackson.dataformat.smile.SmileGenerator;
|
import com.fasterxml.jackson.dataformat.smile.SmileGenerator;
|
||||||
import org.elasticsearch.common.bytes.BytesReference;
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
|
@ -51,6 +52,8 @@ public class SmileXContent implements XContent {
|
||||||
smileFactory = new SmileFactory();
|
smileFactory = new SmileFactory();
|
||||||
smileFactory.configure(SmileGenerator.Feature.ENCODE_BINARY_AS_7BIT, false); // for now, this is an overhead, might make sense for web sockets
|
smileFactory.configure(SmileGenerator.Feature.ENCODE_BINARY_AS_7BIT, false); // for now, this is an overhead, might make sense for web sockets
|
||||||
smileFactory.configure(SmileFactory.Feature.FAIL_ON_SYMBOL_HASH_OVERFLOW, false); // this trips on many mappings now...
|
smileFactory.configure(SmileFactory.Feature.FAIL_ON_SYMBOL_HASH_OVERFLOW, false); // this trips on many mappings now...
|
||||||
|
// Do not automatically close unclosed objects/arrays in com.fasterxml.jackson.dataformat.smile.SmileGenerator#close() method
|
||||||
|
smileFactory.configure(JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT, false);
|
||||||
smileXContent = new SmileXContent();
|
smileXContent = new SmileXContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,9 @@ public class RestFieldStatsAction extends BaseRestHandler {
|
||||||
for (Map.Entry<String, String> entry : response.getConflicts().entrySet()) {
|
for (Map.Entry<String, String> entry : response.getConflicts().entrySet()) {
|
||||||
builder.field(entry.getKey(), entry.getValue());
|
builder.field(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
|
builder.endObject();
|
||||||
}
|
}
|
||||||
|
builder.endObject();
|
||||||
return new BytesRestResponse(RestStatus.OK, builder);
|
return new BytesRestResponse(RestStatus.OK, builder);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -94,6 +94,7 @@ public final class ScriptMetaData implements MetaData.Custom {
|
||||||
// because the parsers current location is already beyond the beginning we need to add a START_OBJECT:
|
// because the parsers current location is already beyond the beginning we need to add a START_OBJECT:
|
||||||
builder.startObject();
|
builder.startObject();
|
||||||
builder.copyCurrentStructure(parser);
|
builder.copyCurrentStructure(parser);
|
||||||
|
builder.endObject();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return builder.string();
|
return builder.string();
|
||||||
|
|
|
@ -27,6 +27,8 @@ import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
|
||||||
public abstract class BaseXContentTestCase extends ESTestCase {
|
public abstract class BaseXContentTestCase extends ESTestCase {
|
||||||
|
|
||||||
public abstract XContentType xcontentType();
|
public abstract XContentType xcontentType();
|
||||||
|
@ -41,6 +43,29 @@ public abstract class BaseXContentTestCase extends ESTestCase {
|
||||||
assertEquals(xcontentType(), XContentFactory.xContentType(data));
|
assertEquals(xcontentType(), XContentFactory.xContentType(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testMissingEndObject() throws IOException {
|
||||||
|
IOException e = expectThrows(IOException.class, () -> {
|
||||||
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||||
|
try (XContentGenerator generator = xcontentType().xContent().createGenerator(os)) {
|
||||||
|
generator.writeStartObject();
|
||||||
|
generator.writeFieldName("foo");
|
||||||
|
generator.writeNumber(2L);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
assertEquals(e.getMessage(), "unclosed object or array found");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testMissingEndArray() throws IOException {
|
||||||
|
IOException e = expectThrows(IOException.class, () -> {
|
||||||
|
ByteArrayOutputStream os = new ByteArrayOutputStream();
|
||||||
|
try (XContentGenerator generator = xcontentType().xContent().createGenerator(os)) {
|
||||||
|
generator.writeStartArray();
|
||||||
|
generator.writeNumber(2L);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
assertEquals(e.getMessage(), "unclosed object or array found");
|
||||||
|
}
|
||||||
|
|
||||||
public void testRawField() throws Exception {
|
public void testRawField() throws Exception {
|
||||||
for (boolean useStream : new boolean[] {false, true}) {
|
for (boolean useStream : new boolean[] {false, true}) {
|
||||||
for (XContentType xcontentType : XContentType.values()) {
|
for (XContentType xcontentType : XContentType.values()) {
|
||||||
|
|
|
@ -363,4 +363,28 @@ public class XContentBuilderTests extends ESTestCase {
|
||||||
assertThat(e.getMessage(), equalTo("field name cannot be null"));
|
assertThat(e.getMessage(), equalTo("field name cannot be null"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testMissingEndObject() throws IOException {
|
||||||
|
IllegalStateException e = expectThrows(IllegalStateException.class, () -> {
|
||||||
|
try (XContentBuilder builder = XContentFactory.contentBuilder(randomFrom(XContentType.values()))) {
|
||||||
|
builder.startObject();
|
||||||
|
builder.field("foo", true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
assertThat(e.getMessage(), equalTo("failed to close the XContentBuilder"));
|
||||||
|
assertThat(e.getCause().getMessage(), equalTo("unclosed object or array found"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testMissingEndArray() throws IOException {
|
||||||
|
IllegalStateException e = expectThrows(IllegalStateException.class, () -> {
|
||||||
|
try (XContentBuilder builder = XContentFactory.contentBuilder(randomFrom(XContentType.values()))) {
|
||||||
|
builder.startObject();
|
||||||
|
builder.startArray("foo");
|
||||||
|
builder.value(0);
|
||||||
|
builder.value(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
assertThat(e.getMessage(), equalTo("failed to close the XContentBuilder"));
|
||||||
|
assertThat(e.getCause().getMessage(), equalTo("unclosed object or array found"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -627,7 +627,7 @@ public class GetActionIT extends ESIntegTestCase {
|
||||||
.startObject("field4").field("type", "text").field("store", true)
|
.startObject("field4").field("type", "text").field("store", true)
|
||||||
.endObject().endObject()
|
.endObject().endObject()
|
||||||
.endObject().endObject()
|
.endObject().endObject()
|
||||||
.endObject().endObject()
|
.endObject().endObject().endObject()
|
||||||
.endObject().endObject().endObject()));
|
.endObject().endObject().endObject()));
|
||||||
|
|
||||||
BytesReference source = jsonBuilder().startObject()
|
BytesReference source = jsonBuilder().startObject()
|
||||||
|
|
|
@ -109,7 +109,7 @@ public class DocumentParserTests extends ESSingleNodeTestCase {
|
||||||
.field("type", "object")
|
.field("type", "object")
|
||||||
.field("dynamic", true)
|
.field("dynamic", true)
|
||||||
.startObject("properties")
|
.startObject("properties")
|
||||||
.endObject().endObject().endObject().endObject().string();
|
.endObject().endObject().endObject().endObject().endObject().string();
|
||||||
DocumentMapper mapper = mapperParser.parse("type", new CompressedXContent(mapping));
|
DocumentMapper mapper = mapperParser.parse("type", new CompressedXContent(mapping));
|
||||||
BytesReference bytes = XContentFactory.jsonBuilder()
|
BytesReference bytes = XContentFactory.jsonBuilder()
|
||||||
.startObject().startObject("foo")
|
.startObject().startObject("foo")
|
||||||
|
@ -129,7 +129,7 @@ public class DocumentParserTests extends ESSingleNodeTestCase {
|
||||||
.field("type", "object")
|
.field("type", "object")
|
||||||
.field("dynamic", true)
|
.field("dynamic", true)
|
||||||
.startObject("properties")
|
.startObject("properties")
|
||||||
.endObject().endObject().endObject().endObject().string();
|
.endObject().endObject().endObject().endObject().endObject().string();
|
||||||
DocumentMapper mapper = mapperParser.parse("type", new CompressedXContent(mapping));
|
DocumentMapper mapper = mapperParser.parse("type", new CompressedXContent(mapping));
|
||||||
BytesReference bytes = XContentFactory.jsonBuilder()
|
BytesReference bytes = XContentFactory.jsonBuilder()
|
||||||
.startObject().startObject("foo").startObject("bar")
|
.startObject().startObject("foo").startObject("bar")
|
||||||
|
@ -148,7 +148,7 @@ public class DocumentParserTests extends ESSingleNodeTestCase {
|
||||||
.startObject("foo")
|
.startObject("foo")
|
||||||
.field("type", "object")
|
.field("type", "object")
|
||||||
.startObject("properties")
|
.startObject("properties")
|
||||||
.endObject().endObject().endObject().endObject().string();
|
.endObject().endObject().endObject().endObject().endObject().string();
|
||||||
DocumentMapper mapper = mapperParser.parse("type", new CompressedXContent(mapping));
|
DocumentMapper mapper = mapperParser.parse("type", new CompressedXContent(mapping));
|
||||||
BytesReference bytes = XContentFactory.jsonBuilder()
|
BytesReference bytes = XContentFactory.jsonBuilder()
|
||||||
.startObject().startObject("foo")
|
.startObject().startObject("foo")
|
||||||
|
|
|
@ -65,6 +65,7 @@ public class DynamicMappingTests extends ESSingleNodeTestCase {
|
||||||
.startObject()
|
.startObject()
|
||||||
.field("field1", "value1")
|
.field("field1", "value1")
|
||||||
.field("field2", "value2")
|
.field("field2", "value2")
|
||||||
|
.endObject()
|
||||||
.bytes());
|
.bytes());
|
||||||
|
|
||||||
assertThat(doc.rootDoc().get("field1"), equalTo("value1"));
|
assertThat(doc.rootDoc().get("field1"), equalTo("value1"));
|
||||||
|
@ -85,6 +86,7 @@ public class DynamicMappingTests extends ESSingleNodeTestCase {
|
||||||
.startObject()
|
.startObject()
|
||||||
.field("field1", "value1")
|
.field("field1", "value1")
|
||||||
.field("field2", "value2")
|
.field("field2", "value2")
|
||||||
|
.endObject()
|
||||||
.bytes());
|
.bytes());
|
||||||
|
|
||||||
assertThat(doc.rootDoc().get("field1"), equalTo("value1"));
|
assertThat(doc.rootDoc().get("field1"), equalTo("value1"));
|
||||||
|
@ -102,27 +104,21 @@ public class DynamicMappingTests extends ESSingleNodeTestCase {
|
||||||
|
|
||||||
DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
|
DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
|
||||||
|
|
||||||
try {
|
StrictDynamicMappingException e = expectThrows(StrictDynamicMappingException.class, () -> defaultMapper.parse("test", "type", "1", jsonBuilder()
|
||||||
defaultMapper.parse("test", "type", "1", jsonBuilder()
|
|
||||||
.startObject()
|
.startObject()
|
||||||
.field("field1", "value1")
|
.field("field1", "value1")
|
||||||
.field("field2", "value2")
|
.field("field2", "value2")
|
||||||
.bytes());
|
.endObject()
|
||||||
fail();
|
.bytes()));
|
||||||
} catch (StrictDynamicMappingException e) {
|
assertThat(e.getMessage(), equalTo("mapping set to strict, dynamic introduction of [field2] within [type] is not allowed"));
|
||||||
// all is well
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
e = expectThrows(StrictDynamicMappingException.class, () -> defaultMapper.parse("test", "type", "1", XContentFactory.jsonBuilder()
|
||||||
defaultMapper.parse("test", "type", "1", XContentFactory.jsonBuilder()
|
|
||||||
.startObject()
|
.startObject()
|
||||||
.field("field1", "value1")
|
.field("field1", "value1")
|
||||||
.field("field2", (String) null)
|
.field("field2", (String) null)
|
||||||
.bytes());
|
.endObject()
|
||||||
fail();
|
.bytes()));
|
||||||
} catch (StrictDynamicMappingException e) {
|
assertThat(e.getMessage(), equalTo("mapping set to strict, dynamic introduction of [field2] within [type] is not allowed"));
|
||||||
// all is well
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDynamicFalseWithInnerObjectButDynamicSetOnRoot() throws IOException {
|
public void testDynamicFalseWithInnerObjectButDynamicSetOnRoot() throws IOException {
|
||||||
|
@ -142,6 +138,7 @@ public class DynamicMappingTests extends ESSingleNodeTestCase {
|
||||||
.field("field1", "value1")
|
.field("field1", "value1")
|
||||||
.field("field2", "value2")
|
.field("field2", "value2")
|
||||||
.endObject()
|
.endObject()
|
||||||
|
.endObject()
|
||||||
.bytes());
|
.bytes());
|
||||||
|
|
||||||
assertThat(doc.rootDoc().get("obj1.field1"), equalTo("value1"));
|
assertThat(doc.rootDoc().get("obj1.field1"), equalTo("value1"));
|
||||||
|
@ -160,17 +157,15 @@ public class DynamicMappingTests extends ESSingleNodeTestCase {
|
||||||
|
|
||||||
DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
|
DocumentMapper defaultMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
|
||||||
|
|
||||||
try {
|
StrictDynamicMappingException e = expectThrows(StrictDynamicMappingException.class, () ->
|
||||||
defaultMapper.parse("test", "type", "1", jsonBuilder()
|
defaultMapper.parse("test", "type", "1", jsonBuilder()
|
||||||
.startObject().startObject("obj1")
|
.startObject().startObject("obj1")
|
||||||
.field("field1", "value1")
|
.field("field1", "value1")
|
||||||
.field("field2", "value2")
|
.field("field2", "value2")
|
||||||
.endObject()
|
.endObject()
|
||||||
.bytes());
|
.endObject()
|
||||||
fail();
|
.bytes()));
|
||||||
} catch (StrictDynamicMappingException e) {
|
assertThat(e.getMessage(), equalTo("mapping set to strict, dynamic introduction of [field2] within [obj1] is not allowed"));
|
||||||
// all is well
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDynamicMappingOnEmptyString() throws Exception {
|
public void testDynamicMappingOnEmptyString() throws Exception {
|
||||||
|
@ -220,7 +215,7 @@ public class DynamicMappingTests extends ESSingleNodeTestCase {
|
||||||
DocumentMapperParser parser = indexService.mapperService().documentMapperParser();
|
DocumentMapperParser parser = indexService.mapperService().documentMapperParser();
|
||||||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
|
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
|
||||||
.startObject("properties").startObject("foo").field("type", "text").endObject().endObject()
|
.startObject("properties").startObject("foo").field("type", "text").endObject().endObject()
|
||||||
.endObject().string();
|
.endObject().endObject().string();
|
||||||
|
|
||||||
DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));
|
DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));
|
||||||
Mapper update = parse(mapper, parser, XContentFactory.jsonBuilder().startObject().field("foo", "bar").endObject());
|
Mapper update = parse(mapper, parser, XContentFactory.jsonBuilder().startObject().field("foo", "bar").endObject());
|
||||||
|
@ -263,7 +258,7 @@ public class DynamicMappingTests extends ESSingleNodeTestCase {
|
||||||
// every new field introduction runs in linear time with the total number of fields
|
// every new field introduction runs in linear time with the total number of fields
|
||||||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
|
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
|
||||||
.startObject("properties").startObject("foo").field("type", "text").endObject().endObject()
|
.startObject("properties").startObject("foo").field("type", "text").endObject().endObject()
|
||||||
.endObject().string();
|
.endObject().endObject().string();
|
||||||
|
|
||||||
DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));
|
DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));
|
||||||
assertEquals(mapping, serialize(mapper));
|
assertEquals(mapping, serialize(mapper));
|
||||||
|
@ -283,7 +278,7 @@ public class DynamicMappingTests extends ESSingleNodeTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject().endObject().string(), serialize(update));
|
.endObject().endObject().endObject().string(), serialize(update));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIntroduceTwoFields() throws Exception {
|
public void testIntroduceTwoFields() throws Exception {
|
||||||
|
@ -318,7 +313,7 @@ public class DynamicMappingTests extends ESSingleNodeTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject().endObject().string(), serialize(update));
|
.endObject().endObject().endObject().string(), serialize(update));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testObject() throws Exception {
|
public void testObject() throws Exception {
|
||||||
|
|
|
@ -37,6 +37,7 @@ import java.util.Collection;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.closeTo;
|
import static org.hamcrest.Matchers.closeTo;
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
import static org.hamcrest.Matchers.instanceOf;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
|
@ -59,6 +60,7 @@ public class FieldLevelBoostTests extends ESSingleNodeTestCase {
|
||||||
.startObject("float_field").field("type", "float").startObject("norms").field("enabled", true).endObject().endObject()
|
.startObject("float_field").field("type", "float").startObject("norms").field("enabled", true).endObject().endObject()
|
||||||
.startObject("long_field").field("type", "long").startObject("norms").field("enabled", true).endObject().endObject()
|
.startObject("long_field").field("type", "long").startObject("norms").field("enabled", true).endObject().endObject()
|
||||||
.startObject("short_field").field("type", "short").startObject("norms").field("enabled", true).endObject().endObject()
|
.startObject("short_field").field("type", "short").startObject("norms").field("enabled", true).endObject().endObject()
|
||||||
|
.endObject().endObject().endObject()
|
||||||
.string();
|
.string();
|
||||||
|
|
||||||
DocumentMapper docMapper = createIndex("test", BW_SETTINGS).mapperService().documentMapperParser().parse("person", new CompressedXContent(mapping));
|
DocumentMapper docMapper = createIndex("test", BW_SETTINGS).mapperService().documentMapperParser().parse("person", new CompressedXContent(mapping));
|
||||||
|
@ -71,6 +73,7 @@ public class FieldLevelBoostTests extends ESSingleNodeTestCase {
|
||||||
.startObject("float_field").field("boost", 7.0).field("value", 40.0).endObject()
|
.startObject("float_field").field("boost", 7.0).field("value", 40.0).endObject()
|
||||||
.startObject("long_field").field("boost", 8.0).field("value", 50).endObject()
|
.startObject("long_field").field("boost", 8.0).field("value", 50).endObject()
|
||||||
.startObject("short_field").field("boost", 9.0).field("value", 60).endObject()
|
.startObject("short_field").field("boost", 9.0).field("value", 60).endObject()
|
||||||
|
.endObject()
|
||||||
.bytes();
|
.bytes();
|
||||||
Document doc = docMapper.parse("test", "person", "1", json).rootDoc();
|
Document doc = docMapper.parse("test", "person", "1", json).rootDoc();
|
||||||
|
|
||||||
|
@ -109,6 +112,7 @@ public class FieldLevelBoostTests extends ESSingleNodeTestCase {
|
||||||
.startObject("float_field").field("type", "float").field("boost", "7.0").endObject()
|
.startObject("float_field").field("type", "float").field("boost", "7.0").endObject()
|
||||||
.startObject("long_field").field("type", "long").field("boost", "8.0").endObject()
|
.startObject("long_field").field("type", "long").field("boost", "8.0").endObject()
|
||||||
.startObject("short_field").field("type", "short").field("boost", "9.0").endObject()
|
.startObject("short_field").field("type", "short").field("boost", "9.0").endObject()
|
||||||
|
.endObject().endObject().endObject()
|
||||||
.string();
|
.string();
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -122,6 +126,7 @@ public class FieldLevelBoostTests extends ESSingleNodeTestCase {
|
||||||
.field("float_field", 40.0)
|
.field("float_field", 40.0)
|
||||||
.field("long_field", 50)
|
.field("long_field", 50)
|
||||||
.field("short_field", 60)
|
.field("short_field", 60)
|
||||||
|
.endObject()
|
||||||
.bytes();
|
.bytes();
|
||||||
Document doc = docMapper.parse("test", "person", "1", json).rootDoc();
|
Document doc = docMapper.parse("test", "person", "1", json).rootDoc();
|
||||||
|
|
||||||
|
@ -161,6 +166,7 @@ public class FieldLevelBoostTests extends ESSingleNodeTestCase {
|
||||||
.field("float_field", 40.0)
|
.field("float_field", 40.0)
|
||||||
.field("long_field", 50)
|
.field("long_field", 50)
|
||||||
.field("short_field", 60)
|
.field("short_field", 60)
|
||||||
|
.endObject()
|
||||||
.bytes();
|
.bytes();
|
||||||
Document doc = docMapper.parse("test", "person", "1", json).rootDoc();
|
Document doc = docMapper.parse("test", "person", "1", json).rootDoc();
|
||||||
|
|
||||||
|
@ -200,79 +206,80 @@ public class FieldLevelBoostTests extends ESSingleNodeTestCase {
|
||||||
.startObject("float_field").field("type", "float").startObject("norms").field("enabled", true).endObject().endObject()
|
.startObject("float_field").field("type", "float").startObject("norms").field("enabled", true).endObject().endObject()
|
||||||
.startObject("long_field").field("type", "long").startObject("norms").field("enabled", true).endObject().endObject()
|
.startObject("long_field").field("type", "long").startObject("norms").field("enabled", true).endObject().endObject()
|
||||||
.startObject("short_field").field("type", "short").startObject("norms").field("enabled", true).endObject().endObject()
|
.startObject("short_field").field("type", "short").startObject("norms").field("enabled", true).endObject().endObject()
|
||||||
|
.endObject().endObject().endObject()
|
||||||
.string();
|
.string();
|
||||||
|
|
||||||
DocumentMapper docMapper = createIndex("test", BW_SETTINGS).mapperService().documentMapperParser().parse("person", new CompressedXContent(mapping));
|
DocumentMapper docMapper = createIndex("test", BW_SETTINGS).mapperService().documentMapperParser().parse("person", new CompressedXContent(mapping));
|
||||||
try {
|
try {
|
||||||
docMapper.parse("test", "person", "1", XContentFactory.jsonBuilder().startObject()
|
docMapper.parse("test", "person", "1", XContentFactory.jsonBuilder().startObject()
|
||||||
.startObject("str_field").field("foo", "bar")
|
.startObject("str_field").field("foo", "bar")
|
||||||
.endObject().bytes()).rootDoc();
|
.endObject().endObject().bytes()).rootDoc();
|
||||||
fail();
|
fail();
|
||||||
} catch (MapperParsingException ex) {
|
} catch (Exception ex) {
|
||||||
// Expected
|
assertThat(ex, instanceOf(MapperParsingException.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
docMapper.parse("test", "person", "1", XContentFactory.jsonBuilder().startObject()
|
docMapper.parse("test", "person", "1", XContentFactory.jsonBuilder().startObject()
|
||||||
.startObject("int_field").field("foo", "bar")
|
.startObject("int_field").field("foo", "bar")
|
||||||
.endObject().bytes()).rootDoc();
|
.endObject().endObject().bytes()).rootDoc();
|
||||||
fail();
|
fail();
|
||||||
} catch (MapperParsingException ex) {
|
} catch (Exception ex) {
|
||||||
// Expected
|
assertThat(ex, instanceOf(MapperParsingException.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
docMapper.parse("test", "person", "1", XContentFactory.jsonBuilder().startObject()
|
docMapper.parse("test", "person", "1", XContentFactory.jsonBuilder().startObject()
|
||||||
.startObject("byte_field").field("foo", "bar")
|
.startObject("byte_field").field("foo", "bar")
|
||||||
.endObject().bytes()).rootDoc();
|
.endObject().endObject().bytes()).rootDoc();
|
||||||
fail();
|
fail();
|
||||||
} catch (MapperParsingException ex) {
|
} catch (Exception ex) {
|
||||||
// Expected
|
assertThat(ex, instanceOf(MapperParsingException.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
docMapper.parse("test", "person", "1", XContentFactory.jsonBuilder().startObject()
|
docMapper.parse("test", "person", "1", XContentFactory.jsonBuilder().startObject()
|
||||||
.startObject("date_field").field("foo", "bar")
|
.startObject("date_field").field("foo", "bar")
|
||||||
.endObject().bytes()).rootDoc();
|
.endObject().endObject().bytes()).rootDoc();
|
||||||
fail();
|
fail();
|
||||||
} catch (MapperParsingException ex) {
|
} catch (Exception ex) {
|
||||||
// Expected
|
assertThat(ex, instanceOf(MapperParsingException.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
docMapper.parse("test", "person", "1", XContentFactory.jsonBuilder().startObject()
|
docMapper.parse("test", "person", "1", XContentFactory.jsonBuilder().startObject()
|
||||||
.startObject("double_field").field("foo", "bar")
|
.startObject("double_field").field("foo", "bar")
|
||||||
.endObject().bytes()).rootDoc();
|
.endObject().endObject().bytes()).rootDoc();
|
||||||
fail();
|
fail();
|
||||||
} catch (MapperParsingException ex) {
|
} catch (Exception ex) {
|
||||||
// Expected
|
assertThat(ex, instanceOf(MapperParsingException.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
docMapper.parse("test", "person", "1", XContentFactory.jsonBuilder().startObject()
|
docMapper.parse("test", "person", "1", XContentFactory.jsonBuilder().startObject()
|
||||||
.startObject("float_field").field("foo", "bar")
|
.startObject("float_field").field("foo", "bar")
|
||||||
.endObject().bytes()).rootDoc();
|
.endObject().endObject().bytes()).rootDoc();
|
||||||
fail();
|
fail();
|
||||||
} catch (MapperParsingException ex) {
|
} catch (Exception ex) {
|
||||||
// Expected
|
assertThat(ex, instanceOf(MapperParsingException.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
docMapper.parse("test", "person", "1", XContentFactory.jsonBuilder().startObject()
|
docMapper.parse("test", "person", "1", XContentFactory.jsonBuilder().startObject()
|
||||||
.startObject("long_field").field("foo", "bar")
|
.startObject("long_field").field("foo", "bar")
|
||||||
.endObject().bytes()).rootDoc();
|
.endObject().endObject().bytes()).rootDoc();
|
||||||
fail();
|
fail();
|
||||||
} catch (MapperParsingException ex) {
|
} catch (Exception ex) {
|
||||||
// Expected
|
assertThat(ex, instanceOf(MapperParsingException.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
docMapper.parse("test", "person", "1", XContentFactory.jsonBuilder().startObject()
|
docMapper.parse("test", "person", "1", XContentFactory.jsonBuilder().startObject()
|
||||||
.startObject("short_field").field("foo", "bar")
|
.startObject("short_field").field("foo", "bar")
|
||||||
.endObject().bytes()).rootDoc();
|
.endObject().endObject().bytes()).rootDoc();
|
||||||
fail();
|
fail();
|
||||||
} catch (MapperParsingException ex) {
|
} catch (Exception ex) {
|
||||||
// Expected
|
assertThat(ex, instanceOf(MapperParsingException.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,7 @@ public class CompoundTypesTests extends ESSingleNodeTestCase {
|
||||||
.startObject()
|
.startObject()
|
||||||
.field("field1", "value1")
|
.field("field1", "value1")
|
||||||
.field("field2", "value2")
|
.field("field2", "value2")
|
||||||
|
.endObject()
|
||||||
.bytes());
|
.bytes());
|
||||||
|
|
||||||
assertThat(doc.rootDoc().get("field1"), equalTo("value1"));
|
assertThat(doc.rootDoc().get("field1"), equalTo("value1"));
|
||||||
|
@ -67,6 +68,7 @@ public class CompoundTypesTests extends ESSingleNodeTestCase {
|
||||||
.startObject()
|
.startObject()
|
||||||
.startObject("field1").field("value", "value1").field("boost", 2.0f).endObject()
|
.startObject("field1").field("value", "value1").field("boost", 2.0f).endObject()
|
||||||
.field("field2", "value2")
|
.field("field2", "value2")
|
||||||
|
.endObject()
|
||||||
.bytes());
|
.bytes());
|
||||||
|
|
||||||
assertThat(doc.rootDoc().get("field1"), equalTo("value1"));
|
assertThat(doc.rootDoc().get("field1"), equalTo("value1"));
|
||||||
|
@ -77,6 +79,7 @@ public class CompoundTypesTests extends ESSingleNodeTestCase {
|
||||||
.startObject()
|
.startObject()
|
||||||
.field("field1", "value1")
|
.field("field1", "value1")
|
||||||
.field("field2", "value2")
|
.field("field2", "value2")
|
||||||
|
.endObject()
|
||||||
.bytes());
|
.bytes());
|
||||||
|
|
||||||
assertThat(doc.rootDoc().get("field1"), equalTo("value1"));
|
assertThat(doc.rootDoc().get("field1"), equalTo("value1"));
|
||||||
|
|
|
@ -106,7 +106,8 @@ public class CopyToMapperIntegrationIT extends ESIntegTestCase {
|
||||||
.field("copy_to", "{name}_raw").endObject()
|
.field("copy_to", "{name}_raw").endObject()
|
||||||
.endObject().endObject()
|
.endObject().endObject()
|
||||||
|
|
||||||
.endArray();
|
.endArray()
|
||||||
|
.endObject().endObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,6 +241,7 @@ public class MultiFieldTests extends ESSingleNodeTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
|
|
||||||
MapperService mapperService = createIndex("test").mapperService();
|
MapperService mapperService = createIndex("test").mapperService();
|
||||||
|
|
|
@ -117,7 +117,7 @@ public class NestedMappingTests extends ESSingleNodeTestCase {
|
||||||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
|
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
|
||||||
.startObject("nested1").field("type", "nested").startObject("properties")
|
.startObject("nested1").field("type", "nested").startObject("properties")
|
||||||
.startObject("nested2").field("type", "nested")
|
.startObject("nested2").field("type", "nested")
|
||||||
.endObject().endObject()
|
.endObject().endObject().endObject()
|
||||||
.endObject().endObject().endObject().string();
|
.endObject().endObject().endObject().string();
|
||||||
|
|
||||||
DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
|
DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
|
||||||
|
@ -168,7 +168,7 @@ public class NestedMappingTests extends ESSingleNodeTestCase {
|
||||||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
|
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
|
||||||
.startObject("nested1").field("type", "nested").startObject("properties")
|
.startObject("nested1").field("type", "nested").startObject("properties")
|
||||||
.startObject("nested2").field("type", "nested").field("include_in_parent", true)
|
.startObject("nested2").field("type", "nested").field("include_in_parent", true)
|
||||||
.endObject().endObject()
|
.endObject().endObject().endObject()
|
||||||
.endObject().endObject().endObject().string();
|
.endObject().endObject().endObject().string();
|
||||||
|
|
||||||
DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
|
DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
|
||||||
|
@ -219,7 +219,7 @@ public class NestedMappingTests extends ESSingleNodeTestCase {
|
||||||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
|
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
|
||||||
.startObject("nested1").field("type", "nested").field("include_in_parent", true).startObject("properties")
|
.startObject("nested1").field("type", "nested").field("include_in_parent", true).startObject("properties")
|
||||||
.startObject("nested2").field("type", "nested").field("include_in_parent", true)
|
.startObject("nested2").field("type", "nested").field("include_in_parent", true)
|
||||||
.endObject().endObject()
|
.endObject().endObject().endObject()
|
||||||
.endObject().endObject().endObject().string();
|
.endObject().endObject().endObject().string();
|
||||||
|
|
||||||
DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
|
DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
|
||||||
|
@ -270,7 +270,7 @@ public class NestedMappingTests extends ESSingleNodeTestCase {
|
||||||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
|
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
|
||||||
.startObject("nested1").field("type", "nested").startObject("properties")
|
.startObject("nested1").field("type", "nested").startObject("properties")
|
||||||
.startObject("nested2").field("type", "nested").field("include_in_root", true)
|
.startObject("nested2").field("type", "nested").field("include_in_root", true)
|
||||||
.endObject().endObject()
|
.endObject().endObject().endObject()
|
||||||
.endObject().endObject().endObject().string();
|
.endObject().endObject().endObject().string();
|
||||||
|
|
||||||
DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
|
DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
|
||||||
|
@ -321,7 +321,7 @@ public class NestedMappingTests extends ESSingleNodeTestCase {
|
||||||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
|
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
|
||||||
.startObject("nested1").field("type", "nested").field("dynamic", "strict").startObject("properties")
|
.startObject("nested1").field("type", "nested").field("dynamic", "strict").startObject("properties")
|
||||||
.startObject("field1").field("type", "text")
|
.startObject("field1").field("type", "text")
|
||||||
.endObject().endObject()
|
.endObject().endObject().endObject()
|
||||||
.endObject().endObject().endObject().string();
|
.endObject().endObject().endObject().string();
|
||||||
|
|
||||||
DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
|
DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
|
||||||
|
@ -355,7 +355,7 @@ public class NestedMappingTests extends ESSingleNodeTestCase {
|
||||||
return XContentFactory.jsonBuilder().startObject().startObject(type).startObject("properties")
|
return XContentFactory.jsonBuilder().startObject().startObject(type).startObject("properties")
|
||||||
.startObject("nested1").field("type", "nested").startObject("properties")
|
.startObject("nested1").field("type", "nested").startObject("properties")
|
||||||
.startObject("nested2").field("type", "nested")
|
.startObject("nested2").field("type", "nested")
|
||||||
.endObject().endObject()
|
.endObject().endObject().endObject()
|
||||||
.endObject().endObject().endObject().string();
|
.endObject().endObject().endObject().string();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new UncheckedIOException(e);
|
throw new UncheckedIOException(e);
|
||||||
|
@ -390,7 +390,7 @@ public class NestedMappingTests extends ESSingleNodeTestCase {
|
||||||
mapperService.merge("type2", new CompressedXContent(mapping.apply("type2")), MergeReason.MAPPING_UPDATE, false);
|
mapperService.merge("type2", new CompressedXContent(mapping.apply("type2")), MergeReason.MAPPING_UPDATE, false);
|
||||||
// adding new fields from different type is not ok
|
// adding new fields from different type is not ok
|
||||||
String mapping2 = XContentFactory.jsonBuilder().startObject().startObject("type3").startObject("properties").startObject("nested3")
|
String mapping2 = XContentFactory.jsonBuilder().startObject().startObject("type3").startObject("properties").startObject("nested3")
|
||||||
.field("type", "nested").startObject("properties").endObject().endObject().endObject().endObject().string();
|
.field("type", "nested").startObject("properties").endObject().endObject().endObject().endObject().endObject().string();
|
||||||
try {
|
try {
|
||||||
mapperService.merge("type3", new CompressedXContent(mapping2), MergeReason.MAPPING_UPDATE, false);
|
mapperService.merge("type3", new CompressedXContent(mapping2), MergeReason.MAPPING_UPDATE, false);
|
||||||
fail("Expected IllegalArgumentException");
|
fail("Expected IllegalArgumentException");
|
||||||
|
|
|
@ -125,7 +125,7 @@ public class SimpleMapperTests extends ESSingleNodeTestCase {
|
||||||
DocumentMapperParser mapperParser = indexService.mapperService().documentMapperParser();
|
DocumentMapperParser mapperParser = indexService.mapperService().documentMapperParser();
|
||||||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
|
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
|
||||||
.startObject("foo.bar").field("type", "text").endObject()
|
.startObject("foo.bar").field("type", "text").endObject()
|
||||||
.endObject().endObject().string();
|
.endObject().endObject().endObject().string();
|
||||||
try {
|
try {
|
||||||
mapperParser.parse("type", new CompressedXContent(mapping));
|
mapperParser.parse("type", new CompressedXContent(mapping));
|
||||||
fail("Mapping parse should have failed");
|
fail("Mapping parse should have failed");
|
||||||
|
|
|
@ -136,6 +136,7 @@ public class StringFieldMapperPositionIncrementGapTests extends ESSingleNodeTest
|
||||||
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("properties").startObject("string");
|
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("properties").startObject("string");
|
||||||
mapping.field("type", "string");
|
mapping.field("type", "string");
|
||||||
mapping.field("position_increment_gap", positionIncrementGap);
|
mapping.field("position_increment_gap", positionIncrementGap);
|
||||||
|
mapping.endObject().endObject().endObject();
|
||||||
client().admin().indices().prepareCreate("test")
|
client().admin().indices().prepareCreate("test")
|
||||||
.setSettings(Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_2_3_0).build())
|
.setSettings(Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_2_3_0).build())
|
||||||
.addMapping("test", mapping)
|
.addMapping("test", mapping)
|
||||||
|
@ -151,6 +152,7 @@ public class StringFieldMapperPositionIncrementGapTests extends ESSingleNodeTest
|
||||||
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("properties").startObject("string");
|
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("properties").startObject("string");
|
||||||
mapping.field("type", "string");
|
mapping.field("type", "string");
|
||||||
mapping.field("analyzer", analyzer);
|
mapping.field("analyzer", analyzer);
|
||||||
|
mapping.endObject().endObject().endObject();
|
||||||
client().admin().indices().prepareCreate("test")
|
client().admin().indices().prepareCreate("test")
|
||||||
.addMapping("test", mapping)
|
.addMapping("test", mapping)
|
||||||
.setSettings(settings)
|
.setSettings(settings)
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class TimestampMappingTests extends ESSingleNodeTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSimpleDisabled() throws Exception {
|
public void testSimpleDisabled() throws Exception {
|
||||||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().string();
|
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string();
|
||||||
DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
|
DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
|
||||||
BytesReference source = XContentFactory.jsonBuilder()
|
BytesReference source = XContentFactory.jsonBuilder()
|
||||||
.startObject()
|
.startObject()
|
||||||
|
@ -104,8 +104,8 @@ public class TimestampMappingTests extends ESSingleNodeTestCase {
|
||||||
version = randomVersion(random());
|
version = randomVersion(random());
|
||||||
} while (version.before(Version.V_2_0_0_beta1));
|
} while (version.before(Version.V_2_0_0_beta1));
|
||||||
for (String mapping : Arrays.asList(
|
for (String mapping : Arrays.asList(
|
||||||
XContentFactory.jsonBuilder().startObject().startObject("type").endObject().string(),
|
XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string(),
|
||||||
XContentFactory.jsonBuilder().startObject().startObject("type").startObject("_timestamp").endObject().endObject().string())) {
|
XContentFactory.jsonBuilder().startObject().startObject("type").startObject("_timestamp").endObject().endObject().endObject().string())) {
|
||||||
DocumentMapper docMapper = createIndex("test", Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version).build()).mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
|
DocumentMapper docMapper = createIndex("test", Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, version).build()).mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
|
||||||
assertThat(docMapper.timestampFieldMapper().enabled(), equalTo(TimestampFieldMapper.Defaults.ENABLED.enabled));
|
assertThat(docMapper.timestampFieldMapper().enabled(), equalTo(TimestampFieldMapper.Defaults.ENABLED.enabled));
|
||||||
assertThat(docMapper.timestampFieldMapper().fieldType().stored(), equalTo(version.onOrAfter(Version.V_2_0_0_beta1)));
|
assertThat(docMapper.timestampFieldMapper().fieldType().stored(), equalTo(version.onOrAfter(Version.V_2_0_0_beta1)));
|
||||||
|
|
|
@ -44,7 +44,7 @@ import static org.hamcrest.Matchers.notNullValue;
|
||||||
|
|
||||||
public class TTLMappingTests extends ESSingleNodeTestCase {
|
public class TTLMappingTests extends ESSingleNodeTestCase {
|
||||||
public void testSimpleDisabled() throws Exception {
|
public void testSimpleDisabled() throws Exception {
|
||||||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().string();
|
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string();
|
||||||
DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
|
DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
|
||||||
BytesReference source = XContentFactory.jsonBuilder()
|
BytesReference source = XContentFactory.jsonBuilder()
|
||||||
.startObject()
|
.startObject()
|
||||||
|
@ -74,7 +74,7 @@ public class TTLMappingTests extends ESSingleNodeTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDefaultValues() throws Exception {
|
public void testDefaultValues() throws Exception {
|
||||||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().string();
|
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string();
|
||||||
DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
|
DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
|
||||||
assertThat(docMapper.TTLFieldMapper().enabled(), equalTo(TTLFieldMapper.Defaults.ENABLED_STATE.enabled));
|
assertThat(docMapper.TTLFieldMapper().enabled(), equalTo(TTLFieldMapper.Defaults.ENABLED_STATE.enabled));
|
||||||
assertThat(docMapper.TTLFieldMapper().fieldType().stored(), equalTo(TTLFieldMapper.Defaults.TTL_FIELD_TYPE.stored()));
|
assertThat(docMapper.TTLFieldMapper().fieldType().stored(), equalTo(TTLFieldMapper.Defaults.TTL_FIELD_TYPE.stored()));
|
||||||
|
|
|
@ -125,7 +125,7 @@ public class UpdateMappingOnClusterIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDocValuesInvalidMappingOnUpdate() throws Exception {
|
public void testDocValuesInvalidMappingOnUpdate() throws Exception {
|
||||||
String mapping = jsonBuilder().startObject().startObject(TYPE).startObject("properties").startObject("text").field("type", "text").endObject().endObject().endObject().string();
|
String mapping = jsonBuilder().startObject().startObject(TYPE).startObject("properties").startObject("text").field("type", "text").endObject().endObject().endObject().endObject().string();
|
||||||
prepareCreate(INDEX).addMapping(TYPE, mapping).get();
|
prepareCreate(INDEX).addMapping(TYPE, mapping).get();
|
||||||
String mappingUpdate = jsonBuilder().startObject().startObject(TYPE).startObject("_all").startObject("fielddata").field("format", "doc_values").endObject().endObject().endObject().endObject().string();
|
String mappingUpdate = jsonBuilder().startObject().startObject(TYPE).startObject("_all").startObject("fielddata").field("format", "doc_values").endObject().endObject().endObject().endObject().string();
|
||||||
GetMappingsResponse mappingsBeforeUpdateResponse = client().admin().indices().prepareGetMappings(INDEX).addTypes(TYPE).get();
|
GetMappingsResponse mappingsBeforeUpdateResponse = client().admin().indices().prepareGetMappings(INDEX).addTypes(TYPE).get();
|
||||||
|
|
|
@ -121,6 +121,7 @@ public class MoreLikeThisQueryBuilderTests extends AbstractQueryTestCase<MoreLik
|
||||||
for (String field : randomFields) {
|
for (String field : randomFields) {
|
||||||
doc.field(field, randomAsciiOfLength(10));
|
doc.field(field, randomAsciiOfLength(10));
|
||||||
}
|
}
|
||||||
|
doc.endObject();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new ElasticsearchException("Unable to generate random artificial doc!");
|
throw new ElasticsearchException("Unable to generate random artificial doc!");
|
||||||
}
|
}
|
||||||
|
|
|
@ -240,6 +240,7 @@ public class SimilarityTests extends ESSingleNodeTestCase {
|
||||||
.field("type", "text")
|
.field("type", "text")
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
|
.endObject()
|
||||||
.endObject().string();
|
.endObject().string();
|
||||||
Settings settings = Settings.builder()
|
Settings settings = Settings.builder()
|
||||||
.put(IndexMetaData.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.V_2_2_0))
|
.put(IndexMetaData.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.V_2_2_0))
|
||||||
|
|
|
@ -244,6 +244,7 @@ public class AggregatorParsingTests extends ESTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
|
.endObject()
|
||||||
.endObject().string();
|
.endObject().string();
|
||||||
try {
|
try {
|
||||||
XContentParser parser = XContentFactory.xContent(source).createParser(source);
|
XContentParser parser = XContentFactory.xContent(source).createParser(source);
|
||||||
|
@ -282,6 +283,7 @@ public class AggregatorParsingTests extends ESTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
|
.endObject()
|
||||||
.endObject().string();
|
.endObject().string();
|
||||||
try {
|
try {
|
||||||
XContentParser parser = XContentFactory.xContent(source).createParser(source);
|
XContentParser parser = XContentFactory.xContent(source).createParser(source);
|
||||||
|
@ -336,6 +338,7 @@ public class AggregatorParsingTests extends ESTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
//.endObject()
|
//.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
|
.endObject()
|
||||||
.endObject().string();
|
.endObject().string();
|
||||||
try {
|
try {
|
||||||
XContentParser parser = XContentFactory.xContent(source).createParser(source);
|
XContentParser parser = XContentFactory.xContent(source).createParser(source);
|
||||||
|
@ -364,6 +367,7 @@ public class AggregatorParsingTests extends ESTestCase {
|
||||||
//.endObject()
|
//.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
|
.endObject()
|
||||||
.endObject().string();
|
.endObject().string();
|
||||||
try {
|
try {
|
||||||
XContentParser parser = XContentFactory.xContent(source).createParser(source);
|
XContentParser parser = XContentFactory.xContent(source).createParser(source);
|
||||||
|
|
|
@ -40,6 +40,7 @@ public class ParentIdAggIT extends ESIntegTestCase {
|
||||||
.startObject("_parent")
|
.startObject("_parent")
|
||||||
.field("type", "parenttype")
|
.field("type", "parenttype")
|
||||||
.endObject()
|
.endObject()
|
||||||
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
assertAcked(prepareCreate("testidx").addMapping("childtype", mapping));
|
assertAcked(prepareCreate("testidx").addMapping("childtype", mapping));
|
||||||
client().prepareIndex("testidx", "childtype").setSource(jsonBuilder().startObject().field("num", 1).endObject()).setParent("p1").get();
|
client().prepareIndex("testidx", "childtype").setSource(jsonBuilder().startObject().field("num", 1).endObject()).setParent("p1").get();
|
||||||
|
|
|
@ -199,6 +199,7 @@ public class HighlighterSearchIT extends ESIntegTestCase {
|
||||||
.field("type", "text")
|
.field("type", "text")
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
|
.endObject()
|
||||||
.endObject())
|
.endObject())
|
||||||
.setSettings(Settings.builder()
|
.setSettings(Settings.builder()
|
||||||
.put(indexSettings())
|
.put(indexSettings())
|
||||||
|
@ -828,7 +829,7 @@ public class HighlighterSearchIT extends ESIntegTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()));
|
.endObject().endObject().endObject()));
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
|
|
||||||
index("test", "type1", "1",
|
index("test", "type1", "1",
|
||||||
|
|
|
@ -179,7 +179,7 @@ public class MoreLikeThisIT extends ESIntegTestCase {
|
||||||
.endObject().endObject().string();
|
.endObject().endObject().string();
|
||||||
client().admin().indices().prepareCreate("foo").addMapping("bar", mapping).execute().actionGet();
|
client().admin().indices().prepareCreate("foo").addMapping("bar", mapping).execute().actionGet();
|
||||||
client().prepareIndex("foo", "bar", "1")
|
client().prepareIndex("foo", "bar", "1")
|
||||||
.setSource(jsonBuilder().startObject().startObject("foo").field("bar", "boz").endObject())
|
.setSource(jsonBuilder().startObject().startObject("foo").field("bar", "boz").endObject().endObject())
|
||||||
.execute().actionGet();
|
.execute().actionGet();
|
||||||
client().admin().indices().prepareRefresh("foo").execute().actionGet();
|
client().admin().indices().prepareRefresh("foo").execute().actionGet();
|
||||||
assertThat(ensureGreen(), equalTo(ClusterHealthStatus.GREEN));
|
assertThat(ensureGreen(), equalTo(ClusterHealthStatus.GREEN));
|
||||||
|
@ -204,7 +204,7 @@ public class MoreLikeThisIT extends ESIntegTestCase {
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
|
|
||||||
client().prepareIndex("foo", "bar", "1")
|
client().prepareIndex("foo", "bar", "1")
|
||||||
.setSource(jsonBuilder().startObject().startObject("foo").field("bar", "boz").endObject())
|
.setSource(jsonBuilder().startObject().startObject("foo").field("bar", "boz").endObject().endObject())
|
||||||
.setRouting("2")
|
.setRouting("2")
|
||||||
.execute().actionGet();
|
.execute().actionGet();
|
||||||
client().admin().indices().prepareRefresh("foo").execute().actionGet();
|
client().admin().indices().prepareRefresh("foo").execute().actionGet();
|
||||||
|
@ -227,7 +227,7 @@ public class MoreLikeThisIT extends ESIntegTestCase {
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
|
|
||||||
client().prepareIndex("foo", "bar", "1")
|
client().prepareIndex("foo", "bar", "1")
|
||||||
.setSource(jsonBuilder().startObject().startObject("foo").field("bar", "boz").endObject())
|
.setSource(jsonBuilder().startObject().startObject("foo").field("bar", "boz").endObject().endObject())
|
||||||
.setRouting("4000")
|
.setRouting("4000")
|
||||||
.execute().actionGet();
|
.execute().actionGet();
|
||||||
client().admin().indices().prepareRefresh("foo").execute().actionGet();
|
client().admin().indices().prepareRefresh("foo").execute().actionGet();
|
||||||
|
@ -522,17 +522,6 @@ public class MoreLikeThisIT extends ESIntegTestCase {
|
||||||
assertSearchResponse(response);
|
assertSearchResponse(response);
|
||||||
assertHitCount(response, 0);
|
assertHitCount(response, 0);
|
||||||
|
|
||||||
logger.info("Checking when document is malformed ...");
|
|
||||||
XContentBuilder malformedDoc = jsonBuilder().startObject();
|
|
||||||
mltQuery = moreLikeThisQuery(null, new Item[] {new Item("test", "type1", malformedDoc)})
|
|
||||||
.minTermFreq(0)
|
|
||||||
.minDocFreq(0)
|
|
||||||
.minimumShouldMatch("0%");
|
|
||||||
response = client().prepareSearch("test").setTypes("type1")
|
|
||||||
.setQuery(mltQuery).get();
|
|
||||||
assertSearchResponse(response);
|
|
||||||
assertHitCount(response, 0);
|
|
||||||
|
|
||||||
logger.info("Checking the document matches otherwise ...");
|
logger.info("Checking the document matches otherwise ...");
|
||||||
XContentBuilder normalDoc = jsonBuilder()
|
XContentBuilder normalDoc = jsonBuilder()
|
||||||
.startObject()
|
.startObject()
|
||||||
|
|
|
@ -1711,7 +1711,8 @@ public class SearchQueryIT extends ESIntegTestCase {
|
||||||
public void testAllDisabledButQueried() throws Exception {
|
public void testAllDisabledButQueried() throws Exception {
|
||||||
createIndex("myindex");
|
createIndex("myindex");
|
||||||
assertAcked(client().admin().indices().preparePutMapping("myindex").setType("mytype").setSource(
|
assertAcked(client().admin().indices().preparePutMapping("myindex").setType("mytype").setSource(
|
||||||
jsonBuilder().startObject().startObject("mytype").startObject("_all").field("enabled", false)));
|
jsonBuilder().startObject().startObject("mytype").startObject("_all").field("enabled", false)
|
||||||
|
.endObject().endObject().endObject()));
|
||||||
client().prepareIndex("myindex", "mytype").setId("1").setSource("bar", "foo").setRefresh(true).get();
|
client().prepareIndex("myindex", "mytype").setId("1").setSource("bar", "foo").setRefresh(true).get();
|
||||||
SearchResponse response = client().prepareSearch("myindex").setQuery(matchQuery("_all", "foo")).get();
|
SearchResponse response = client().prepareSearch("myindex").setQuery(matchQuery("_all", "foo")).get();
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
|
|
|
@ -193,6 +193,7 @@ public class ContextSuggestSearch2xIT extends ESIntegTestCase {
|
||||||
.field("type", "geo")
|
.field("type", "geo")
|
||||||
.field("precision", precision)
|
.field("precision", precision)
|
||||||
.endObject()
|
.endObject()
|
||||||
|
.endObject()
|
||||||
.endObject().endObject()
|
.endObject().endObject()
|
||||||
.endObject().endObject();
|
.endObject().endObject();
|
||||||
|
|
||||||
|
@ -212,6 +213,7 @@ public class ContextSuggestSearch2xIT extends ESIntegTestCase {
|
||||||
.field("type", "geo")
|
.field("type", "geo")
|
||||||
.field("precision", precision)
|
.field("precision", precision)
|
||||||
.endObject()
|
.endObject()
|
||||||
|
.endObject()
|
||||||
.endObject().endObject()
|
.endObject().endObject()
|
||||||
.endObject().endObject();
|
.endObject().endObject();
|
||||||
assertAcked(client().admin().indices().preparePutMapping(INDEX).setType(TYPE).setSource(mapping.string()).get());
|
assertAcked(client().admin().indices().preparePutMapping(INDEX).setType(TYPE).setSource(mapping.string()).get());
|
||||||
|
|
|
@ -158,6 +158,7 @@ public class GeoContextMappingTests extends ESSingleNodeTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.field("weight", 5)
|
.field("weight", 5)
|
||||||
.endObject()
|
.endObject()
|
||||||
|
.endObject()
|
||||||
.bytes());
|
.bytes());
|
||||||
IndexableField[] fields = parsedDocument.rootDoc().getFields(completionFieldType.name());
|
IndexableField[] fields = parsedDocument.rootDoc().getFields(completionFieldType.name());
|
||||||
assertContextSuggestFields(fields, 3);
|
assertContextSuggestFields(fields, 3);
|
||||||
|
|
|
@ -49,6 +49,7 @@ public class SimilarityIT extends ESIntegTestCase {
|
||||||
.field("type", "text")
|
.field("type", "text")
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
|
.endObject()
|
||||||
.endObject())
|
.endObject())
|
||||||
.setSettings(Settings.builder()
|
.setSettings(Settings.builder()
|
||||||
.put("index.number_of_shards", 1)
|
.put("index.number_of_shards", 1)
|
||||||
|
|
|
@ -102,7 +102,7 @@ public class SimpleTimestampIT extends ESIntegTestCase {
|
||||||
assertTimestampMappingEnabled(index, type, true);
|
assertTimestampMappingEnabled(index, type, true);
|
||||||
|
|
||||||
// update some field in the mapping
|
// update some field in the mapping
|
||||||
XContentBuilder updateMappingBuilder = jsonBuilder().startObject().startObject("properties").startObject("otherField").field("type", "text").endObject().endObject();
|
XContentBuilder updateMappingBuilder = jsonBuilder().startObject().startObject("properties").startObject("otherField").field("type", "text").endObject().endObject().endObject();
|
||||||
PutMappingResponse putMappingResponse = client().admin().indices().preparePutMapping(index).setType(type).setSource(updateMappingBuilder).get();
|
PutMappingResponse putMappingResponse = client().admin().indices().preparePutMapping(index).setType(type).setSource(updateMappingBuilder).get();
|
||||||
assertAcked(putMappingResponse);
|
assertAcked(putMappingResponse);
|
||||||
|
|
||||||
|
|
|
@ -214,7 +214,7 @@ public class SimpleTTLIT extends ESIntegTestCase {
|
||||||
assertTTLMappingEnabled(index, type);
|
assertTTLMappingEnabled(index, type);
|
||||||
|
|
||||||
// update some field in the mapping
|
// update some field in the mapping
|
||||||
XContentBuilder updateMappingBuilder = jsonBuilder().startObject().startObject("properties").startObject("otherField").field("type", "text").endObject().endObject();
|
XContentBuilder updateMappingBuilder = jsonBuilder().startObject().startObject("properties").startObject("otherField").field("type", "text").endObject().endObject().endObject();
|
||||||
PutMappingResponse putMappingResponse = client().admin().indices().preparePutMapping(index).setType(type).setSource(updateMappingBuilder).get();
|
PutMappingResponse putMappingResponse = client().admin().indices().preparePutMapping(index).setType(type).setSource(updateMappingBuilder).get();
|
||||||
assertAcked(putMappingResponse);
|
assertAcked(putMappingResponse);
|
||||||
|
|
||||||
|
|
|
@ -184,7 +184,8 @@ public class EquivalenceTests extends ESIntegTestCase {
|
||||||
final IntHashSet valuesSet = new IntHashSet();
|
final IntHashSet valuesSet = new IntHashSet();
|
||||||
cluster().wipeIndices("idx");
|
cluster().wipeIndices("idx");
|
||||||
prepareCreate("idx")
|
prepareCreate("idx")
|
||||||
.addMapping("type", jsonBuilder().startObject()
|
.addMapping("type", jsonBuilder()
|
||||||
|
.startObject()
|
||||||
.startObject("type")
|
.startObject("type")
|
||||||
.startObject("properties")
|
.startObject("properties")
|
||||||
.startObject("string_values")
|
.startObject("string_values")
|
||||||
|
@ -203,6 +204,7 @@ public class EquivalenceTests extends ESIntegTestCase {
|
||||||
.field("type", "double")
|
.field("type", "double")
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
|
.endObject()
|
||||||
.endObject()).execute().actionGet();
|
.endObject()).execute().actionGet();
|
||||||
|
|
||||||
List<IndexRequestBuilder> indexingRequests = new ArrayList<>();
|
List<IndexRequestBuilder> indexingRequests = new ArrayList<>();
|
||||||
|
|
|
@ -484,15 +484,32 @@ public class SearchFieldsTests extends ESIntegTestCase {
|
||||||
public void testGetFieldsComplexField() throws Exception {
|
public void testGetFieldsComplexField() throws Exception {
|
||||||
client().admin().indices().prepareCreate("my-index")
|
client().admin().indices().prepareCreate("my-index")
|
||||||
.setSettings(Settings.builder().put("index.refresh_interval", -1))
|
.setSettings(Settings.builder().put("index.refresh_interval", -1))
|
||||||
.addMapping("my-type2", jsonBuilder().startObject().startObject("my-type2").startObject("properties")
|
.addMapping("my-type2", jsonBuilder()
|
||||||
.startObject("field1").field("type", "object").startObject("properties")
|
.startObject()
|
||||||
.startObject("field2").field("type", "object").startObject("properties")
|
.startObject("my-type2")
|
||||||
.startObject("field3").field("type", "object").startObject("properties")
|
.startObject("properties")
|
||||||
.startObject("field4").field("type", "text").field("store", true)
|
.startObject("field1")
|
||||||
.endObject().endObject()
|
.field("type", "object")
|
||||||
.endObject().endObject()
|
.startObject("properties")
|
||||||
.endObject().endObject()
|
.startObject("field2")
|
||||||
.endObject().endObject().endObject())
|
.field("type", "object")
|
||||||
|
.startObject("properties")
|
||||||
|
.startObject("field3")
|
||||||
|
.field("type", "object")
|
||||||
|
.startObject("properties")
|
||||||
|
.startObject("field4")
|
||||||
|
.field("type", "text")
|
||||||
|
.field("store", true)
|
||||||
|
.endObject()
|
||||||
|
.endObject()
|
||||||
|
.endObject()
|
||||||
|
.endObject()
|
||||||
|
.endObject()
|
||||||
|
.endObject()
|
||||||
|
.endObject()
|
||||||
|
.endObject()
|
||||||
|
.endObject()
|
||||||
|
.endObject())
|
||||||
.get();
|
.get();
|
||||||
|
|
||||||
BytesReference source = jsonBuilder().startObject()
|
BytesReference source = jsonBuilder().startObject()
|
||||||
|
|
|
@ -235,7 +235,7 @@ public class MultiPercolatorIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
client().prepareIndex(INDEX_NAME, "type", "1")
|
client().prepareIndex(INDEX_NAME, "type", "1")
|
||||||
.setSource(jsonBuilder().startObject().field("field", "a"))
|
.setSource(jsonBuilder().startObject().field("field", "a").endObject())
|
||||||
.execute().actionGet();
|
.execute().actionGet();
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
|
|
|
@ -1489,6 +1489,7 @@ public class PercolatorIT extends ESIntegTestCase {
|
||||||
XContentBuilder doc = jsonBuilder();
|
XContentBuilder doc = jsonBuilder();
|
||||||
doc.startObject();
|
doc.startObject();
|
||||||
doc.field("some_unnested_field", "value");
|
doc.field("some_unnested_field", "value");
|
||||||
|
doc.endObject();
|
||||||
PercolateResponse response = preparePercolate(client()).setPercolateDoc(new PercolateSourceBuilder.DocBuilder().setDoc(doc)).setIndices(INDEX_NAME).setDocumentType("company").get();
|
PercolateResponse response = preparePercolate(client()).setPercolateDoc(new PercolateSourceBuilder.DocBuilder().setDoc(doc)).setIndices(INDEX_NAME).setDocumentType("company").get();
|
||||||
assertNoFailures(response);
|
assertNoFailures(response);
|
||||||
}
|
}
|
||||||
|
|
|
@ -314,6 +314,7 @@ public class PercolatorQuerySearchIT extends ESSingleNodeTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
|
.endObject()
|
||||||
.endObject().endObject())
|
.endObject().endObject())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -334,6 +335,7 @@ public class PercolatorQuerySearchIT extends ESSingleNodeTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
|
.endObject()
|
||||||
.endObject().endObject())
|
.endObject().endObject())
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -113,6 +113,7 @@ public class SimpleAttachmentMapperTests extends AttachmentUnitTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
|
.endObject()
|
||||||
.endObject();
|
.endObject();
|
||||||
|
|
||||||
byte[] mapping = mappingBuilder.bytes().toBytes();
|
byte[] mapping = mappingBuilder.bytes().toBytes();
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class SizeMappingIT extends ESIntegTestCase {
|
||||||
assertSizeMappingEnabled(index, type, true);
|
assertSizeMappingEnabled(index, type, true);
|
||||||
|
|
||||||
// update some field in the mapping
|
// update some field in the mapping
|
||||||
XContentBuilder updateMappingBuilder = jsonBuilder().startObject().startObject("properties").startObject("otherField").field("type", "text").endObject().endObject();
|
XContentBuilder updateMappingBuilder = jsonBuilder().startObject().startObject("properties").startObject("otherField").field("type", "text").endObject().endObject().endObject();
|
||||||
PutMappingResponse putMappingResponse = client().admin().indices().preparePutMapping(index).setType(type).setSource(updateMappingBuilder).get();
|
PutMappingResponse putMappingResponse = client().admin().indices().preparePutMapping(index).setType(type).setSource(updateMappingBuilder).get();
|
||||||
assertAcked(putMappingResponse);
|
assertAcked(putMappingResponse);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue