Merge pull request #15710 from jpountz/remove/multi_field
Remove support for the `multi_field` type.
This commit is contained in:
commit
4c99559df6
|
@ -36,7 +36,6 @@ import org.elasticsearch.index.mapper.Mapper;
|
|||
import org.elasticsearch.index.mapper.MapperParsingException;
|
||||
import org.elasticsearch.index.mapper.object.ObjectMapper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
@ -55,88 +54,6 @@ import static org.elasticsearch.common.xcontent.support.XContentMapValues.nodeSt
|
|||
*/
|
||||
public class TypeParsers {
|
||||
|
||||
public static final String MULTI_FIELD_CONTENT_TYPE = "multi_field";
|
||||
public static final Mapper.TypeParser multiFieldConverterTypeParser = new Mapper.TypeParser() {
|
||||
|
||||
@Override
|
||||
public Mapper.Builder<?, ?> parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
|
||||
FieldMapper.Builder mainFieldBuilder = null;
|
||||
List<FieldMapper.Builder> fields = null;
|
||||
String firstType = null;
|
||||
|
||||
for (Iterator<Map.Entry<String, Object>> iterator = node.entrySet().iterator(); iterator.hasNext();) {
|
||||
Map.Entry<String, Object> entry = iterator.next();
|
||||
String fieldName = Strings.toUnderscoreCase(entry.getKey());
|
||||
Object fieldNode = entry.getValue();
|
||||
if (fieldName.equals("fields")) {
|
||||
Map<String, Object> fieldsNode = (Map<String, Object>) fieldNode;
|
||||
for (Iterator<Map.Entry<String, Object>> fieldsIterator = fieldsNode.entrySet().iterator(); fieldsIterator.hasNext();) {
|
||||
Map.Entry<String, Object> entry1 = fieldsIterator.next();
|
||||
String propName = entry1.getKey();
|
||||
Map<String, Object> propNode = (Map<String, Object>) entry1.getValue();
|
||||
|
||||
String type;
|
||||
Object typeNode = propNode.get("type");
|
||||
if (typeNode != null) {
|
||||
type = typeNode.toString();
|
||||
if (firstType == null) {
|
||||
firstType = type;
|
||||
}
|
||||
} else {
|
||||
throw new MapperParsingException("no type specified for property [" + propName + "]");
|
||||
}
|
||||
|
||||
Mapper.TypeParser typeParser = parserContext.typeParser(type);
|
||||
if (typeParser == null) {
|
||||
throw new MapperParsingException("no handler for type [" + type + "] declared on field [" + fieldName + "]");
|
||||
}
|
||||
if (propName.equals(name)) {
|
||||
mainFieldBuilder = (FieldMapper.Builder) typeParser.parse(propName, propNode, parserContext);
|
||||
fieldsIterator.remove();
|
||||
} else {
|
||||
if (fields == null) {
|
||||
fields = new ArrayList<>(2);
|
||||
}
|
||||
fields.add((FieldMapper.Builder) typeParser.parse(propName, propNode, parserContext));
|
||||
fieldsIterator.remove();
|
||||
}
|
||||
}
|
||||
fieldsNode.remove("type");
|
||||
DocumentMapperParser.checkNoRemainingFields(fieldName, fieldsNode, parserContext.indexVersionCreated());
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
if (mainFieldBuilder == null) {
|
||||
if (fields == null) {
|
||||
// No fields at all were specified in multi_field, so lets return a non indexed string field.
|
||||
return new StringFieldMapper.Builder(name).index(false);
|
||||
}
|
||||
Mapper.TypeParser typeParser = parserContext.typeParser(firstType);
|
||||
if (typeParser == null) {
|
||||
// The first multi field's type is unknown
|
||||
mainFieldBuilder = new StringFieldMapper.Builder(name).index(false);
|
||||
} else {
|
||||
Mapper.Builder substitute = typeParser.parse(name, Collections.<String, Object>emptyMap(), parserContext);
|
||||
if (substitute instanceof FieldMapper.Builder) {
|
||||
mainFieldBuilder = ((FieldMapper.Builder) substitute).index(false);
|
||||
} else {
|
||||
// The first multi isn't a core field type
|
||||
mainFieldBuilder = new StringFieldMapper.Builder(name).index(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fields != null) {
|
||||
for (Mapper.Builder field : fields) {
|
||||
mainFieldBuilder.addMultiField(field);
|
||||
}
|
||||
}
|
||||
return mainFieldBuilder;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public static final String DOC_VALUES = "doc_values";
|
||||
public static final String INDEX_OPTIONS_DOCS = "docs";
|
||||
public static final String INDEX_OPTIONS_FREQS = "freqs";
|
||||
|
|
|
@ -40,7 +40,6 @@ import org.elasticsearch.index.mapper.core.LongFieldMapper;
|
|||
import org.elasticsearch.index.mapper.core.ShortFieldMapper;
|
||||
import org.elasticsearch.index.mapper.core.StringFieldMapper;
|
||||
import org.elasticsearch.index.mapper.core.TokenCountFieldMapper;
|
||||
import org.elasticsearch.index.mapper.core.TypeParsers;
|
||||
import org.elasticsearch.index.mapper.geo.GeoPointFieldMapper;
|
||||
import org.elasticsearch.index.mapper.geo.GeoShapeFieldMapper;
|
||||
import org.elasticsearch.index.mapper.internal.AllFieldMapper;
|
||||
|
@ -210,7 +209,6 @@ public class IndicesModule extends AbstractModule {
|
|||
registerMapper(TokenCountFieldMapper.CONTENT_TYPE, new TokenCountFieldMapper.TypeParser());
|
||||
registerMapper(ObjectMapper.CONTENT_TYPE, new ObjectMapper.TypeParser());
|
||||
registerMapper(ObjectMapper.NESTED_CONTENT_TYPE, new ObjectMapper.TypeParser());
|
||||
registerMapper(TypeParsers.MULTI_FIELD_CONTENT_TYPE, TypeParsers.multiFieldConverterTypeParser);
|
||||
registerMapper(CompletionFieldMapper.CONTENT_TYPE, new CompletionFieldMapper.TypeParser());
|
||||
registerMapper(GeoPointFieldMapper.CONTENT_TYPE, new GeoPointFieldMapper.TypeParser());
|
||||
|
||||
|
|
|
@ -112,13 +112,10 @@ public class TokenCountFieldMapperIntegrationIT extends ESIntegTestCase {
|
|||
.startObject("test")
|
||||
.startObject("properties")
|
||||
.startObject("foo")
|
||||
.field("type", "multi_field")
|
||||
.field("type", "string")
|
||||
.field("store", storeCountedFields)
|
||||
.field("analyzer", "simple")
|
||||
.startObject("fields")
|
||||
.startObject("foo")
|
||||
.field("type", "string")
|
||||
.field("store", storeCountedFields)
|
||||
.field("analyzer", "simple")
|
||||
.endObject()
|
||||
.startObject("token_count")
|
||||
.field("type", "token_count")
|
||||
.field("analyzer", "standard")
|
||||
|
|
|
@ -67,10 +67,6 @@ import static org.hamcrest.Matchers.notNullValue;
|
|||
*
|
||||
*/
|
||||
public class MultiFieldTests extends ESSingleNodeTestCase {
|
||||
public void testMultiFieldMultiFieldType() throws Exception {
|
||||
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multifield/test-multi-field-type.json");
|
||||
testMultiField(mapping);
|
||||
}
|
||||
|
||||
public void testMultiFieldMultiFields() throws Exception {
|
||||
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multifield/test-multi-fields.json");
|
||||
|
@ -186,224 +182,6 @@ public class MultiFieldTests extends ESSingleNodeTestCase {
|
|||
assertEquals(IndexOptions.NONE, f.fieldType().indexOptions());
|
||||
}
|
||||
|
||||
public void testConvertMultiFieldNoDefaultField() throws Exception {
|
||||
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multifield/test-multi-field-type-no-default-field.json");
|
||||
DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("person", new CompressedXContent(mapping));
|
||||
BytesReference json = new BytesArray(copyToBytesFromClasspath("/org/elasticsearch/index/mapper/multifield/test-data.json"));
|
||||
Document doc = docMapper.parse("test", "person", "1", json).rootDoc();
|
||||
|
||||
assertNull(doc.getField("name"));
|
||||
IndexableField f = doc.getField("name.indexed");
|
||||
assertThat(f.name(), equalTo("name.indexed"));
|
||||
assertThat(f.stringValue(), equalTo("some name"));
|
||||
assertThat(f.fieldType().stored(), equalTo(false));
|
||||
assertNotSame(IndexOptions.NONE, f.fieldType().indexOptions());
|
||||
|
||||
f = doc.getField("name.not_indexed");
|
||||
assertThat(f.name(), equalTo("name.not_indexed"));
|
||||
assertThat(f.stringValue(), equalTo("some name"));
|
||||
assertThat(f.fieldType().stored(), equalTo(true));
|
||||
assertEquals(IndexOptions.NONE, f.fieldType().indexOptions());
|
||||
|
||||
assertThat(docMapper.mappers().getMapper("name"), notNullValue());
|
||||
assertThat(docMapper.mappers().getMapper("name"), instanceOf(StringFieldMapper.class));
|
||||
assertEquals(IndexOptions.NONE, docMapper.mappers().getMapper("name").fieldType().indexOptions());
|
||||
assertThat(docMapper.mappers().getMapper("name").fieldType().stored(), equalTo(false));
|
||||
assertThat(docMapper.mappers().getMapper("name").fieldType().tokenized(), equalTo(true));
|
||||
|
||||
assertThat(docMapper.mappers().getMapper("name.indexed"), notNullValue());
|
||||
assertThat(docMapper.mappers().getMapper("name.indexed"), instanceOf(StringFieldMapper.class));
|
||||
assertNotNull(docMapper.mappers().getMapper("name.indexed").fieldType().indexOptions());
|
||||
assertThat(docMapper.mappers().getMapper("name.indexed").fieldType().stored(), equalTo(false));
|
||||
assertThat(docMapper.mappers().getMapper("name.indexed").fieldType().tokenized(), equalTo(true));
|
||||
|
||||
assertThat(docMapper.mappers().getMapper("name.not_indexed"), notNullValue());
|
||||
assertThat(docMapper.mappers().getMapper("name.not_indexed"), instanceOf(StringFieldMapper.class));
|
||||
assertEquals(IndexOptions.NONE, docMapper.mappers().getMapper("name.not_indexed").fieldType().indexOptions());
|
||||
assertThat(docMapper.mappers().getMapper("name.not_indexed").fieldType().stored(), equalTo(true));
|
||||
assertThat(docMapper.mappers().getMapper("name.not_indexed").fieldType().tokenized(), equalTo(true));
|
||||
|
||||
assertNull(doc.getField("age"));
|
||||
f = doc.getField("age.not_stored");
|
||||
assertThat(f.name(), equalTo("age.not_stored"));
|
||||
assertThat(f.numericValue(), equalTo((Number) 28L));
|
||||
assertThat(f.fieldType().stored(), equalTo(false));
|
||||
assertNotSame(IndexOptions.NONE, f.fieldType().indexOptions());
|
||||
|
||||
f = doc.getField("age.stored");
|
||||
assertThat(f.name(), equalTo("age.stored"));
|
||||
assertThat(f.numericValue(), equalTo((Number) 28L));
|
||||
assertThat(f.fieldType().stored(), equalTo(true));
|
||||
assertNotSame(IndexOptions.NONE, f.fieldType().indexOptions());
|
||||
|
||||
assertThat(docMapper.mappers().getMapper("age"), notNullValue());
|
||||
assertThat(docMapper.mappers().getMapper("age"), instanceOf(LongFieldMapper.class));
|
||||
assertEquals(IndexOptions.NONE, docMapper.mappers().getMapper("age").fieldType().indexOptions());
|
||||
assertThat(docMapper.mappers().getMapper("age").fieldType().stored(), equalTo(false));
|
||||
assertThat(docMapper.mappers().getMapper("age").fieldType().tokenized(), equalTo(false));
|
||||
|
||||
assertThat(docMapper.mappers().getMapper("age.not_stored"), notNullValue());
|
||||
assertThat(docMapper.mappers().getMapper("age.not_stored"), instanceOf(LongFieldMapper.class));
|
||||
assertNotSame(IndexOptions.NONE, docMapper.mappers().getMapper("age.not_stored").fieldType().indexOptions());
|
||||
assertThat(docMapper.mappers().getMapper("age.not_stored").fieldType().stored(), equalTo(false));
|
||||
assertThat(docMapper.mappers().getMapper("age.not_stored").fieldType().tokenized(), equalTo(false));
|
||||
|
||||
assertThat(docMapper.mappers().getMapper("age.stored"), notNullValue());
|
||||
assertThat(docMapper.mappers().getMapper("age.stored"), instanceOf(LongFieldMapper.class));
|
||||
assertNotSame(IndexOptions.NONE, docMapper.mappers().getMapper("age.stored").fieldType().indexOptions());
|
||||
assertThat(docMapper.mappers().getMapper("age.stored").fieldType().stored(), equalTo(true));
|
||||
assertThat(docMapper.mappers().getMapper("age.stored").fieldType().tokenized(), equalTo(false));
|
||||
}
|
||||
|
||||
public void testConvertMultiFieldGeoPoint() throws Exception {
|
||||
Version version = VersionUtils.randomVersionBetween(random(), Version.V_1_0_0, Version.CURRENT);
|
||||
Settings settings = Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, version).build();
|
||||
boolean indexCreatedBefore22 = version.before(Version.V_2_2_0);
|
||||
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multifield/test-multi-field-type-geo_point.json");
|
||||
DocumentMapper docMapper = createIndex("test", settings).mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
|
||||
|
||||
assertThat(docMapper.mappers().getMapper("a"), notNullValue());
|
||||
assertThat(docMapper.mappers().getMapper("a"), instanceOf(StringFieldMapper.class));
|
||||
assertNotSame(IndexOptions.NONE, docMapper.mappers().getMapper("a").fieldType().indexOptions());
|
||||
assertThat(docMapper.mappers().getMapper("a").fieldType().stored(), equalTo(false));
|
||||
assertThat(docMapper.mappers().getMapper("a").fieldType().tokenized(), equalTo(false));
|
||||
|
||||
assertThat(docMapper.mappers().getMapper("a.b"), notNullValue());
|
||||
assertThat(docMapper.mappers().getMapper("a.b"), instanceOf(BaseGeoPointFieldMapper.class));
|
||||
assertNotSame(IndexOptions.NONE, docMapper.mappers().getMapper("a.b").fieldType().indexOptions());
|
||||
final boolean stored = indexCreatedBefore22 == false;
|
||||
assertThat(docMapper.mappers().getMapper("a.b").fieldType().stored(), equalTo(stored));
|
||||
assertThat(docMapper.mappers().getMapper("a.b").fieldType().tokenized(), equalTo(false));
|
||||
final boolean hasDocValues = indexCreatedBefore22 == false;
|
||||
assertThat(docMapper.mappers().getMapper("a.b").fieldType().hasDocValues(), equalTo(hasDocValues));
|
||||
|
||||
BytesReference json = jsonBuilder().startObject()
|
||||
.field("a", "-1,-1")
|
||||
.endObject().bytes();
|
||||
Document doc = docMapper.parse("test", "type", "1", json).rootDoc();
|
||||
|
||||
IndexableField f = doc.getField("a");
|
||||
assertThat(f, notNullValue());
|
||||
assertThat(f.name(), equalTo("a"));
|
||||
assertThat(f.stringValue(), equalTo("-1,-1"));
|
||||
assertThat(f.fieldType().stored(), equalTo(false));
|
||||
assertNotSame(IndexOptions.NONE, f.fieldType().indexOptions());
|
||||
|
||||
f = doc.getField("a.b");
|
||||
assertThat(f, notNullValue());
|
||||
assertThat(f.name(), equalTo("a.b"));
|
||||
if (indexCreatedBefore22 == true) {
|
||||
assertThat(f.stringValue(), equalTo("-1.0,-1.0"));
|
||||
} else {
|
||||
assertThat(Long.parseLong(f.stringValue()), equalTo(GeoUtils.mortonHash(-1.0, -1.0)));
|
||||
}
|
||||
assertThat(f.fieldType().stored(), equalTo(stored));
|
||||
assertNotSame(IndexOptions.NONE, f.fieldType().indexOptions());
|
||||
|
||||
assertThat(docMapper.mappers().getMapper("b"), notNullValue());
|
||||
assertThat(docMapper.mappers().getMapper("b"), instanceOf(BaseGeoPointFieldMapper.class));
|
||||
assertNotSame(IndexOptions.NONE, docMapper.mappers().getMapper("b").fieldType().indexOptions());
|
||||
assertThat(docMapper.mappers().getMapper("b").fieldType().stored(), equalTo(stored));
|
||||
assertThat(docMapper.mappers().getMapper("b").fieldType().tokenized(), equalTo(false));
|
||||
assertThat(docMapper.mappers().getMapper("b").fieldType().hasDocValues(), equalTo(hasDocValues));
|
||||
|
||||
assertThat(docMapper.mappers().getMapper("b.a"), notNullValue());
|
||||
assertThat(docMapper.mappers().getMapper("b.a"), instanceOf(StringFieldMapper.class));
|
||||
assertNotSame(IndexOptions.NONE, docMapper.mappers().getMapper("b.a").fieldType().indexOptions());
|
||||
assertThat(docMapper.mappers().getMapper("b.a").fieldType().stored(), equalTo(false));
|
||||
assertThat(docMapper.mappers().getMapper("b.a").fieldType().tokenized(), equalTo(false));
|
||||
|
||||
json = jsonBuilder().startObject()
|
||||
.field("b", "-1,-1")
|
||||
.endObject().bytes();
|
||||
doc = docMapper.parse("test", "type", "1", json).rootDoc();
|
||||
|
||||
f = doc.getField("b");
|
||||
assertThat(f, notNullValue());
|
||||
assertThat(f.name(), equalTo("b"));
|
||||
if (indexCreatedBefore22 == true) {
|
||||
assertThat(f.stringValue(), equalTo("-1.0,-1.0"));
|
||||
} else {
|
||||
assertThat(Long.parseLong(f.stringValue()), equalTo(GeoUtils.mortonHash(-1.0, -1.0)));
|
||||
}
|
||||
assertThat(f.fieldType().stored(), equalTo(stored));
|
||||
assertNotSame(IndexOptions.NONE, f.fieldType().indexOptions());
|
||||
|
||||
f = doc.getField("b.a");
|
||||
assertThat(f, notNullValue());
|
||||
assertThat(f.name(), equalTo("b.a"));
|
||||
assertThat(f.stringValue(), equalTo("-1,-1"));
|
||||
assertThat(f.fieldType().stored(), equalTo(false));
|
||||
assertNotSame(IndexOptions.NONE, f.fieldType().indexOptions());
|
||||
}
|
||||
|
||||
public void testConvertMultiFieldCompletion() throws Exception {
|
||||
String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/multifield/test-multi-field-type-completion.json");
|
||||
DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse("type", new CompressedXContent(mapping));
|
||||
|
||||
assertThat(docMapper.mappers().getMapper("a"), notNullValue());
|
||||
assertThat(docMapper.mappers().getMapper("a"), instanceOf(StringFieldMapper.class));
|
||||
assertNotSame(IndexOptions.NONE, docMapper.mappers().getMapper("a").fieldType().indexOptions());
|
||||
assertThat(docMapper.mappers().getMapper("a").fieldType().stored(), equalTo(false));
|
||||
assertThat(docMapper.mappers().getMapper("a").fieldType().tokenized(), equalTo(false));
|
||||
|
||||
assertThat(docMapper.mappers().getMapper("a.b"), notNullValue());
|
||||
assertThat(docMapper.mappers().getMapper("a.b"), instanceOf(CompletionFieldMapper.class));
|
||||
assertNotSame(IndexOptions.NONE, docMapper.mappers().getMapper("a.b").fieldType().indexOptions());
|
||||
assertThat(docMapper.mappers().getMapper("a.b").fieldType().stored(), equalTo(false));
|
||||
assertThat(docMapper.mappers().getMapper("a.b").fieldType().tokenized(), equalTo(true));
|
||||
|
||||
BytesReference json = jsonBuilder().startObject()
|
||||
.field("a", "complete me")
|
||||
.endObject().bytes();
|
||||
Document doc = docMapper.parse("test", "type", "1", json).rootDoc();
|
||||
|
||||
IndexableField f = doc.getField("a");
|
||||
assertThat(f, notNullValue());
|
||||
assertThat(f.name(), equalTo("a"));
|
||||
assertThat(f.stringValue(), equalTo("complete me"));
|
||||
assertThat(f.fieldType().stored(), equalTo(false));
|
||||
assertNotSame(IndexOptions.NONE, f.fieldType().indexOptions());
|
||||
|
||||
f = doc.getField("a.b");
|
||||
assertThat(f, notNullValue());
|
||||
assertThat(f.name(), equalTo("a.b"));
|
||||
assertThat(f.stringValue(), equalTo("complete me"));
|
||||
assertThat(f.fieldType().stored(), equalTo(false));
|
||||
assertNotSame(IndexOptions.NONE, f.fieldType().indexOptions());
|
||||
|
||||
assertThat(docMapper.mappers().getMapper("b"), notNullValue());
|
||||
assertThat(docMapper.mappers().getMapper("b"), instanceOf(CompletionFieldMapper.class));
|
||||
assertNotSame(IndexOptions.NONE, docMapper.mappers().getMapper("b").fieldType().indexOptions());
|
||||
assertThat(docMapper.mappers().getMapper("b").fieldType().stored(), equalTo(false));
|
||||
assertThat(docMapper.mappers().getMapper("b").fieldType().tokenized(), equalTo(true));
|
||||
|
||||
assertThat(docMapper.mappers().getMapper("b.a"), notNullValue());
|
||||
assertThat(docMapper.mappers().getMapper("b.a"), instanceOf(StringFieldMapper.class));
|
||||
assertNotSame(IndexOptions.NONE, docMapper.mappers().getMapper("b.a").fieldType().indexOptions());
|
||||
assertThat(docMapper.mappers().getMapper("b.a").fieldType().stored(), equalTo(false));
|
||||
assertThat(docMapper.mappers().getMapper("b.a").fieldType().tokenized(), equalTo(false));
|
||||
|
||||
json = jsonBuilder().startObject()
|
||||
.field("b", "complete me")
|
||||
.endObject().bytes();
|
||||
doc = docMapper.parse("test", "type", "1", json).rootDoc();
|
||||
|
||||
f = doc.getField("b");
|
||||
assertThat(f, notNullValue());
|
||||
assertThat(f.name(), equalTo("b"));
|
||||
assertThat(f.stringValue(), equalTo("complete me"));
|
||||
assertThat(f.fieldType().stored(), equalTo(false));
|
||||
assertNotSame(IndexOptions.NONE, f.fieldType().indexOptions());
|
||||
|
||||
f = doc.getField("b.a");
|
||||
assertThat(f, notNullValue());
|
||||
assertThat(f.name(), equalTo("b.a"));
|
||||
assertThat(f.stringValue(), equalTo("complete me"));
|
||||
assertThat(f.fieldType().stored(), equalTo(false));
|
||||
assertNotSame(IndexOptions.NONE, f.fieldType().indexOptions());
|
||||
}
|
||||
|
||||
// The underlying order of the fields in multi fields in the mapping source should always be consistent, if not this
|
||||
// can to unnecessary re-syncing of the mappings between the local instance and cluster state
|
||||
public void testMultiFieldsInConsistentOrder() throws Exception {
|
||||
|
|
|
@ -233,13 +233,10 @@ public class HighlighterSearchIT extends ESIntegTestCase {
|
|||
.field("search_analyzer", "search_autocomplete")
|
||||
.field("term_vector", "with_positions_offsets")
|
||||
.endObject()
|
||||
.startObject("name")
|
||||
.endObject()
|
||||
.field("type", "string")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.field("type", "multi_field")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject())
|
||||
.setSettings(settingsBuilder()
|
||||
.put(indexSettings())
|
||||
|
@ -900,14 +897,11 @@ public class HighlighterSearchIT extends ESIntegTestCase {
|
|||
.addMapping("type1", XContentFactory.jsonBuilder().startObject().startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("foo")
|
||||
.field("type", "multi_field")
|
||||
.field("type", "string")
|
||||
.field("termVector", "with_positions_offsets")
|
||||
.field("store", "yes")
|
||||
.field("analyzer", "english")
|
||||
.startObject("fields")
|
||||
.startObject("foo")
|
||||
.field("type", "string")
|
||||
.field("termVector", "with_positions_offsets")
|
||||
.field("store", "yes")
|
||||
.field("analyzer", "english")
|
||||
.endObject()
|
||||
.startObject("plain")
|
||||
.field("type", "string")
|
||||
.field("termVector", "with_positions_offsets")
|
||||
|
@ -916,14 +910,11 @@ public class HighlighterSearchIT extends ESIntegTestCase {
|
|||
.endObject()
|
||||
.endObject()
|
||||
.startObject("bar")
|
||||
.field("type", "multi_field")
|
||||
.field("type", "string")
|
||||
.field("termVector", "with_positions_offsets")
|
||||
.field("store", "yes")
|
||||
.field("analyzer", "english")
|
||||
.startObject("fields")
|
||||
.startObject("bar")
|
||||
.field("type", "string")
|
||||
.field("termVector", "with_positions_offsets")
|
||||
.field("store", "yes")
|
||||
.field("analyzer", "english")
|
||||
.endObject()
|
||||
.startObject("plain")
|
||||
.field("type", "string")
|
||||
.field("termVector", "with_positions_offsets")
|
||||
|
@ -1194,8 +1185,8 @@ public class HighlighterSearchIT extends ESIntegTestCase {
|
|||
public void testMultiMapperVectorWithStore() throws Exception {
|
||||
assertAcked(prepareCreate("test")
|
||||
.addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties")
|
||||
.startObject("title").field("type", "multi_field").startObject("fields")
|
||||
.startObject("title").field("type", "string").field("store", "yes").field("term_vector", "with_positions_offsets").field("analyzer", "classic").endObject()
|
||||
.startObject("title").field("type", "string").field("store", "yes").field("term_vector", "with_positions_offsets").field("analyzer", "classic")
|
||||
.startObject("fields")
|
||||
.startObject("key").field("type", "string").field("store", "yes").field("term_vector", "with_positions_offsets").field("analyzer", "whitespace").endObject()
|
||||
.endObject().endObject()
|
||||
.endObject().endObject().endObject()));
|
||||
|
@ -1222,8 +1213,8 @@ public class HighlighterSearchIT extends ESIntegTestCase {
|
|||
public void testMultiMapperVectorFromSource() throws Exception {
|
||||
assertAcked(prepareCreate("test")
|
||||
.addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties")
|
||||
.startObject("title").field("type", "multi_field").startObject("fields")
|
||||
.startObject("title").field("type", "string").field("store", "no").field("term_vector", "with_positions_offsets").field("analyzer", "classic").endObject()
|
||||
.startObject("title").field("type", "string").field("store", "no").field("term_vector", "with_positions_offsets").field("analyzer", "classic")
|
||||
.startObject("fields")
|
||||
.startObject("key").field("type", "string").field("store", "no").field("term_vector", "with_positions_offsets").field("analyzer", "whitespace").endObject()
|
||||
.endObject().endObject()
|
||||
.endObject().endObject().endObject()));
|
||||
|
@ -1252,8 +1243,8 @@ public class HighlighterSearchIT extends ESIntegTestCase {
|
|||
public void testMultiMapperNoVectorWithStore() throws Exception {
|
||||
assertAcked(prepareCreate("test")
|
||||
.addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties")
|
||||
.startObject("title").field("type", "multi_field").startObject("fields")
|
||||
.startObject("title").field("type", "string").field("store", "yes").field("term_vector", "no").field("analyzer", "classic").endObject()
|
||||
.startObject("title").field("type", "string").field("store", "yes").field("term_vector", "no").field("analyzer", "classic")
|
||||
.startObject("fields")
|
||||
.startObject("key").field("type", "string").field("store", "yes").field("term_vector", "no").field("analyzer", "whitespace").endObject()
|
||||
.endObject().endObject()
|
||||
.endObject().endObject().endObject()));
|
||||
|
@ -1282,8 +1273,8 @@ public class HighlighterSearchIT extends ESIntegTestCase {
|
|||
public void testMultiMapperNoVectorFromSource() throws Exception {
|
||||
assertAcked(prepareCreate("test")
|
||||
.addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties")
|
||||
.startObject("title").field("type", "multi_field").startObject("fields")
|
||||
.startObject("title").field("type", "string").field("store", "no").field("term_vector", "no").field("analyzer", "classic").endObject()
|
||||
.startObject("title").field("type", "string").field("store", "no").field("term_vector", "no").field("analyzer", "classic")
|
||||
.startObject("fields")
|
||||
.startObject("key").field("type", "string").field("store", "no").field("term_vector", "no").field("analyzer", "whitespace").endObject()
|
||||
.endObject().endObject()
|
||||
.endObject().endObject().endObject()));
|
||||
|
@ -2219,8 +2210,8 @@ public class HighlighterSearchIT extends ESIntegTestCase {
|
|||
assertAcked(prepareCreate("test")
|
||||
.addMapping("type1", jsonBuilder().startObject().startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("title").field("type", "multi_field").startObject("fields")
|
||||
.startObject("title").field("type", "string").field("store", "yes").field("index_options", "offsets").field("analyzer", "classic").endObject()
|
||||
.startObject("title").field("type", "string").field("store", "yes").field("index_options", "offsets").field("analyzer", "classic")
|
||||
.startObject("fields")
|
||||
.startObject("key").field("type", "string").field("store", "yes").field("index_options", "offsets").field("analyzer", "whitespace").endObject()
|
||||
.endObject().endObject()
|
||||
.endObject().endObject().endObject()));
|
||||
|
@ -2251,8 +2242,8 @@ public class HighlighterSearchIT extends ESIntegTestCase {
|
|||
public void testPostingsHighlighterMultiMapperFromSource() throws Exception {
|
||||
assertAcked(prepareCreate("test")
|
||||
.addMapping("type1", jsonBuilder().startObject().startObject("type1").startObject("properties")
|
||||
.startObject("title").field("type", "multi_field").startObject("fields")
|
||||
.startObject("title").field("type", "string").field("store", "no").field("index_options", "offsets").field("analyzer", "classic").endObject()
|
||||
.startObject("title").field("type", "string").field("store", "no").field("index_options", "offsets").field("analyzer", "classic")
|
||||
.startObject("fields")
|
||||
.startObject("key").field("type", "string").field("store", "no").field("index_options", "offsets").field("analyzer", "whitespace").endObject()
|
||||
.endObject().endObject()
|
||||
.endObject().endObject().endObject()));
|
||||
|
|
|
@ -601,49 +601,6 @@ public class CompletionSuggestSearchIT extends ESIntegTestCase {
|
|||
assertSuggestions("r", "Foo Fighters");
|
||||
}
|
||||
|
||||
public void testThatUpgradeToMultiFieldTypeWorks() throws Exception {
|
||||
final XContentBuilder mapping = jsonBuilder()
|
||||
.startObject()
|
||||
.startObject(TYPE)
|
||||
.startObject("properties")
|
||||
.startObject(FIELD)
|
||||
.field("type", "string")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject();
|
||||
assertAcked(prepareCreate(INDEX).addMapping(TYPE, mapping));
|
||||
client().prepareIndex(INDEX, TYPE, "1").setRefresh(true).setSource(jsonBuilder().startObject().field(FIELD, "Foo Fighters").endObject()).get();
|
||||
ensureGreen(INDEX);
|
||||
|
||||
PutMappingResponse putMappingResponse = client().admin().indices().preparePutMapping(INDEX).setType(TYPE).setSource(jsonBuilder().startObject()
|
||||
.startObject(TYPE).startObject("properties")
|
||||
.startObject(FIELD)
|
||||
.field("type", "multi_field")
|
||||
.startObject("fields")
|
||||
.startObject(FIELD).field("type", "string").endObject()
|
||||
.startObject("suggest").field("type", "completion").field("analyzer", "simple").endObject()
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject().endObject()
|
||||
.endObject())
|
||||
.get();
|
||||
assertThat(putMappingResponse.isAcknowledged(), is(true));
|
||||
|
||||
SuggestResponse suggestResponse = client().prepareSuggest(INDEX).addSuggestion(
|
||||
new CompletionSuggestionBuilder("suggs").field(FIELD + ".suggest").text("f").size(10)
|
||||
).execute().actionGet();
|
||||
assertSuggestions(suggestResponse, "suggs");
|
||||
|
||||
client().prepareIndex(INDEX, TYPE, "1").setRefresh(true).setSource(jsonBuilder().startObject().field(FIELD, "Foo Fighters").endObject()).get();
|
||||
ensureGreen(INDEX);
|
||||
|
||||
SuggestResponse afterReindexingResponse = client().prepareSuggest(INDEX).addSuggestion(
|
||||
SuggestBuilders.completionSuggestion("suggs").field(FIELD + ".suggest").text("f").size(10)
|
||||
).execute().actionGet();
|
||||
assertSuggestions(afterReindexingResponse, "suggs", "Foo Fighters");
|
||||
}
|
||||
|
||||
public void testThatUpgradeToMultiFieldsWorks() throws Exception {
|
||||
final XContentBuilder mapping = jsonBuilder()
|
||||
.startObject()
|
||||
|
|
|
@ -2,13 +2,10 @@
|
|||
person:{
|
||||
properties:{
|
||||
"name":{
|
||||
type:"multi_field",
|
||||
type:"string",
|
||||
index:"analyzed",
|
||||
store:"yes",
|
||||
"fields":{
|
||||
"name":{
|
||||
type:"string",
|
||||
index:"analyzed",
|
||||
store:"yes"
|
||||
},
|
||||
"indexed":{
|
||||
type:"string",
|
||||
index:"analyzed"
|
||||
|
@ -22,4 +19,4 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,13 +2,10 @@
|
|||
person:{
|
||||
properties:{
|
||||
"name":{
|
||||
type:"multi_field",
|
||||
type:"string",
|
||||
index:"analyzed",
|
||||
store:"yes",
|
||||
"fields":{
|
||||
"name":{
|
||||
type:"string",
|
||||
index:"analyzed",
|
||||
store:"yes"
|
||||
},
|
||||
"indexed":{
|
||||
type:"string",
|
||||
index:"analyzed"
|
||||
|
@ -27,4 +24,4 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
person:{
|
||||
properties:{
|
||||
"name":{
|
||||
type:"multi_field",
|
||||
type:"string",
|
||||
index:"no",
|
||||
"fields":{
|
||||
"not_indexed3":{
|
||||
type:"string",
|
||||
|
@ -13,4 +14,4 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
{
|
||||
"person":{
|
||||
"properties":{
|
||||
"name":{
|
||||
"type":"multi_field",
|
||||
"fields":{
|
||||
"name":{
|
||||
"type":"string",
|
||||
"index":"analyzed",
|
||||
"store":"yes"
|
||||
},
|
||||
"indexed":{
|
||||
"type":"string",
|
||||
"index":"analyzed"
|
||||
},
|
||||
"not_indexed":{
|
||||
"type":"string",
|
||||
"index":"no",
|
||||
"store":"yes"
|
||||
},
|
||||
"test1" : {
|
||||
"type":"string",
|
||||
"index":"analyzed",
|
||||
"store" : "yes",
|
||||
"fielddata" : {
|
||||
"loading" : "eager"
|
||||
}
|
||||
},
|
||||
"test2" : {
|
||||
"type" : "token_count",
|
||||
"store" : "yes",
|
||||
"index" : "not_analyzed",
|
||||
"analyzer" : "simple"
|
||||
}
|
||||
}
|
||||
},
|
||||
"object1":{
|
||||
"properties":{
|
||||
"multi1":{
|
||||
"type":"multi_field",
|
||||
"fields":{
|
||||
"multi1":{
|
||||
"type":"date"
|
||||
},
|
||||
"string":{
|
||||
"type":"string",
|
||||
"index":"not_analyzed"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -193,11 +193,8 @@ public class SuggestSearchTests extends ESIntegTestCase {
|
|||
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("name")
|
||||
.field("type", "multi_field")
|
||||
.field("type", "string")
|
||||
.startObject("fields")
|
||||
.startObject("name")
|
||||
.field("type", "string")
|
||||
.endObject()
|
||||
.startObject("shingled")
|
||||
.field("type", "string")
|
||||
.field("analyzer", "biword")
|
||||
|
@ -267,11 +264,8 @@ public class SuggestSearchTests extends ESIntegTestCase {
|
|||
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
|
||||
.startObject("properties")
|
||||
.startObject("name")
|
||||
.field("type", "multi_field")
|
||||
.field("type", "string")
|
||||
.startObject("fields")
|
||||
.startObject("name")
|
||||
.field("type", "string")
|
||||
.endObject()
|
||||
.startObject("shingled")
|
||||
.field("type", "string")
|
||||
.field("analyzer", "biword")
|
||||
|
@ -808,13 +802,8 @@ public class SuggestSearchTests extends ESIntegTestCase {
|
|||
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type2")
|
||||
.startObject("properties")
|
||||
.startObject("name")
|
||||
.field("type", "multi_field")
|
||||
.startObject("fields")
|
||||
.startObject("name")
|
||||
.field("type", "string")
|
||||
.field("analyzer", "suggest")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.field("type", "string")
|
||||
.field("analyzer", "suggest")
|
||||
.endObject()
|
||||
.endObject()
|
||||
.endObject().endObject();
|
||||
|
@ -855,13 +844,8 @@ public class SuggestSearchTests extends ESIntegTestCase {
|
|||
startObject("type1").
|
||||
startObject("properties").
|
||||
startObject("name").
|
||||
field("type", "multi_field").
|
||||
startObject("fields").
|
||||
startObject("name").
|
||||
field("type", "string").
|
||||
field("analyzer", "suggest").
|
||||
endObject().
|
||||
endObject().
|
||||
field("type", "string").
|
||||
field("analyzer", "suggest").
|
||||
endObject().
|
||||
endObject().
|
||||
endObject().
|
||||
|
|
|
@ -35,15 +35,6 @@
|
|||
test_type:
|
||||
properties:
|
||||
text1:
|
||||
type: multi_field
|
||||
fields:
|
||||
text1:
|
||||
type: string
|
||||
analyzer: whitespace
|
||||
text_raw:
|
||||
type: string
|
||||
index: not_analyzed
|
||||
text2:
|
||||
type: string
|
||||
analyzer: whitespace
|
||||
fields:
|
||||
|
@ -58,5 +49,3 @@
|
|||
|
||||
- match: {test_index.mappings.test_type.properties.text1.type: string}
|
||||
- match: {test_index.mappings.test_type.properties.text1.fields.text_raw.index: not_analyzed}
|
||||
- match: {test_index.mappings.test_type.properties.text2.type: string}
|
||||
- match: {test_index.mappings.test_type.properties.text2.fields.text_raw.index: not_analyzed}
|
||||
|
|
Loading…
Reference in New Issue