|
@@ -20,7 +20,6 @@
|
|
|
package org.elasticsearch.index.mapper;
|
|
|
|
|
|
import org.apache.lucene.index.IndexableField;
|
|
|
-import org.apache.lucene.util.BytesRef;
|
|
|
import org.elasticsearch.Version;
|
|
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
|
|
import org.elasticsearch.common.Strings;
|
|
@@ -132,12 +131,6 @@ public class ExternalFieldMapperTests extends ESSingleNodeTestCase {
|
|
|
.startObject("field")
|
|
|
.field("type", "text")
|
|
|
.field("store", true)
|
|
|
- .startObject("fields")
|
|
|
- .startObject("raw")
|
|
|
- .field("type", "keyword")
|
|
|
- .field("store", true)
|
|
|
- .endObject()
|
|
|
- .endObject()
|
|
|
.endObject()
|
|
|
.endObject()
|
|
|
.endObject()
|
|
@@ -164,87 +157,5 @@ public class ExternalFieldMapperTests extends ESSingleNodeTestCase {
|
|
|
IndexableField field = doc.rootDoc().getField("field.field");
|
|
|
assertThat(field, notNullValue());
|
|
|
assertThat(field.stringValue(), is("foo"));
|
|
|
-
|
|
|
- IndexableField raw = doc.rootDoc().getField("field.field.raw");
|
|
|
-
|
|
|
- assertThat(raw, notNullValue());
|
|
|
- assertThat(raw.binaryValue(), is(new BytesRef("foo")));
|
|
|
-
|
|
|
- assertWarnings("At least one multi-field, [field], was " +
|
|
|
- "encountered that itself contains a multi-field. Defining multi-fields within a multi-field is deprecated and will " +
|
|
|
- "no longer be supported in 8.0. To resolve the issue, all instances of [fields] that occur within a [fields] block " +
|
|
|
- "should be removed from the mappings, either by flattening the chained [fields] blocks into a single level, or " +
|
|
|
- "switching to [copy_to] if appropriate.");
|
|
|
- }
|
|
|
-
|
|
|
- public void testExternalValuesWithMultifieldTwoLevels() throws Exception {
|
|
|
- IndexService indexService = createIndex("test");
|
|
|
- Map<String, Mapper.TypeParser> mapperParsers = new HashMap<>();
|
|
|
- mapperParsers.put(ExternalMapperPlugin.EXTERNAL, new ExternalMapper.TypeParser(ExternalMapperPlugin.EXTERNAL, "foo"));
|
|
|
- mapperParsers.put(ExternalMapperPlugin.EXTERNAL_BIS, new ExternalMapper.TypeParser(ExternalMapperPlugin.EXTERNAL, "bar"));
|
|
|
- mapperParsers.put(TextFieldMapper.CONTENT_TYPE, new TextFieldMapper.TypeParser());
|
|
|
- MapperRegistry mapperRegistry = new MapperRegistry(mapperParsers, Collections.emptyMap(), MapperPlugin.NOOP_FIELD_FILTER);
|
|
|
-
|
|
|
- Supplier<QueryShardContext> queryShardContext = () -> {
|
|
|
- return indexService.newQueryShardContext(0, null, () -> { throw new UnsupportedOperationException(); }, null);
|
|
|
- };
|
|
|
- DocumentMapperParser parser = new DocumentMapperParser(indexService.getIndexSettings(), indexService.mapperService(),
|
|
|
- indexService.xContentRegistry(), indexService.similarityService(), mapperRegistry, queryShardContext);
|
|
|
-
|
|
|
- DocumentMapper documentMapper = parser.parse("type", new CompressedXContent(
|
|
|
- Strings
|
|
|
- .toString(XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
|
|
|
- .startObject("field")
|
|
|
- .field("type", ExternalMapperPlugin.EXTERNAL)
|
|
|
- .startObject("fields")
|
|
|
- .startObject("field")
|
|
|
- .field("type", "text")
|
|
|
- .startObject("fields")
|
|
|
- .startObject("generated")
|
|
|
- .field("type", ExternalMapperPlugin.EXTERNAL_BIS)
|
|
|
- .endObject()
|
|
|
- .startObject("raw")
|
|
|
- .field("type", "text")
|
|
|
- .endObject()
|
|
|
- .endObject()
|
|
|
- .endObject()
|
|
|
- .startObject("raw")
|
|
|
- .field("type", "text")
|
|
|
- .endObject()
|
|
|
- .endObject()
|
|
|
- .endObject()
|
|
|
- .endObject().endObject().endObject())));
|
|
|
-
|
|
|
- ParsedDocument doc = documentMapper.parse(new SourceToParse("test", "type", "1", BytesReference
|
|
|
- .bytes(XContentFactory.jsonBuilder()
|
|
|
- .startObject()
|
|
|
- .field("field", "1234")
|
|
|
- .endObject()),
|
|
|
- XContentType.JSON));
|
|
|
-
|
|
|
- assertThat(doc.rootDoc().getField("field.bool"), notNullValue());
|
|
|
- assertThat(doc.rootDoc().getField("field.bool").stringValue(), is("T"));
|
|
|
-
|
|
|
- assertThat(doc.rootDoc().getField("field.point"), notNullValue());
|
|
|
-
|
|
|
- assertThat(doc.rootDoc().getField("field.shape"), notNullValue());
|
|
|
-
|
|
|
- assertThat(doc.rootDoc().getField("field.field"), notNullValue());
|
|
|
- assertThat(doc.rootDoc().getField("field.field").stringValue(), is("foo"));
|
|
|
-
|
|
|
- assertThat(doc.rootDoc().getField("field.field.generated.generated"), notNullValue());
|
|
|
- assertThat(doc.rootDoc().getField("field.field.generated.generated").stringValue(), is("bar"));
|
|
|
-
|
|
|
- assertThat(doc.rootDoc().getField("field.field.raw"), notNullValue());
|
|
|
- assertThat(doc.rootDoc().getField("field.field.raw").stringValue(), is("foo"));
|
|
|
-
|
|
|
- assertThat(doc.rootDoc().getField("field.raw"), notNullValue());
|
|
|
- assertThat(doc.rootDoc().getField("field.raw").stringValue(), is("foo"));
|
|
|
-
|
|
|
- assertWarnings("At least one multi-field, [field], was " +
|
|
|
- "encountered that itself contains a multi-field. Defining multi-fields within a multi-field is deprecated and will " +
|
|
|
- "no longer be supported in 8.0. To resolve the issue, all instances of [fields] that occur within a [fields] block " +
|
|
|
- "should be removed from the mappings, either by flattening the chained [fields] blocks into a single level, or " +
|
|
|
- "switching to [copy_to] if appropriate.");
|
|
|
}
|
|
|
}
|