Deprecate string in favor of text/keyword. #16877
This commit removes the ability to use string fields on indices created on or after 5.0. Dynamic mappings now generate text fields by default for strings but there are plans to also add a sub keyword field (in a future PR). Most of the changes in this commit are just about replacing string with keyword or text. Some tests have been removed because they existed because of corner cases of string mappings like setting ignore-above on a text field or enabling term vectors on a keyword field which are now impossible. The plan is to remove strings entirely in 6.0.
This commit is contained in:
parent
f70e5aca50
commit
eef19be072
|
@ -510,17 +510,17 @@ class DocumentParser implements Closeable {
|
||||||
private static Mapper.Builder<?,?> createBuilderFromFieldType(final ParseContext context, MappedFieldType fieldType, String currentFieldName) {
|
private static Mapper.Builder<?,?> createBuilderFromFieldType(final ParseContext context, MappedFieldType fieldType, String currentFieldName) {
|
||||||
Mapper.Builder builder = null;
|
Mapper.Builder builder = null;
|
||||||
if (fieldType instanceof StringFieldType) {
|
if (fieldType instanceof StringFieldType) {
|
||||||
builder = context.root().findTemplateBuilder(context, currentFieldName, "string");
|
builder = context.root().findTemplateBuilder(context, currentFieldName, "string", "string");
|
||||||
if (builder == null) {
|
if (builder == null) {
|
||||||
builder = new StringFieldMapper.Builder(currentFieldName);
|
builder = new StringFieldMapper.Builder(currentFieldName);
|
||||||
}
|
}
|
||||||
} else if (fieldType instanceof TextFieldType) {
|
} else if (fieldType instanceof TextFieldType) {
|
||||||
builder = context.root().findTemplateBuilder(context, currentFieldName, "string");
|
builder = context.root().findTemplateBuilder(context, currentFieldName, "text", "string");
|
||||||
if (builder == null) {
|
if (builder == null) {
|
||||||
builder = new TextFieldMapper.Builder(currentFieldName);
|
builder = new TextFieldMapper.Builder(currentFieldName);
|
||||||
}
|
}
|
||||||
} else if (fieldType instanceof KeywordFieldType) {
|
} else if (fieldType instanceof KeywordFieldType) {
|
||||||
builder = context.root().findTemplateBuilder(context, currentFieldName, "string");
|
builder = context.root().findTemplateBuilder(context, currentFieldName, "keyword", "string");
|
||||||
if (builder == null) {
|
if (builder == null) {
|
||||||
builder = new KeywordFieldMapper.Builder(currentFieldName);
|
builder = new KeywordFieldMapper.Builder(currentFieldName);
|
||||||
}
|
}
|
||||||
|
@ -568,7 +568,7 @@ class DocumentParser implements Closeable {
|
||||||
// we need to do it here so we can handle things like attachment templates, where calling
|
// we need to do it here so we can handle things like attachment templates, where calling
|
||||||
// text (to see if its a date) causes the binary value to be cleared
|
// text (to see if its a date) causes the binary value to be cleared
|
||||||
{
|
{
|
||||||
Mapper.Builder builder = context.root().findTemplateBuilder(context, currentFieldName, "string", null);
|
Mapper.Builder builder = context.root().findTemplateBuilder(context, currentFieldName, "text", null);
|
||||||
if (builder != null) {
|
if (builder != null) {
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
@ -617,7 +617,7 @@ class DocumentParser implements Closeable {
|
||||||
}
|
}
|
||||||
Mapper.Builder builder = context.root().findTemplateBuilder(context, currentFieldName, "string");
|
Mapper.Builder builder = context.root().findTemplateBuilder(context, currentFieldName, "string");
|
||||||
if (builder == null) {
|
if (builder == null) {
|
||||||
builder = new StringFieldMapper.Builder(currentFieldName);
|
builder = new TextFieldMapper.Builder(currentFieldName);
|
||||||
}
|
}
|
||||||
return builder;
|
return builder;
|
||||||
} else if (token == XContentParser.Token.VALUE_NUMBER) {
|
} else if (token == XContentParser.Token.VALUE_NUMBER) {
|
||||||
|
|
|
@ -132,6 +132,10 @@ public class StringFieldMapper extends FieldMapper implements AllFieldMapper.Inc
|
||||||
public static class TypeParser implements Mapper.TypeParser {
|
public static class TypeParser implements Mapper.TypeParser {
|
||||||
@Override
|
@Override
|
||||||
public Mapper.Builder parse(String fieldName, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
|
public Mapper.Builder parse(String fieldName, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
|
||||||
|
if (parserContext.indexVersionCreated().onOrAfter(Version.V_5_0_0)) {
|
||||||
|
throw new IllegalArgumentException("The [string] type is removed in 5.0. You should now use either a [text] "
|
||||||
|
+ "or [keyword] field instead for field [" + fieldName + "]");
|
||||||
|
}
|
||||||
StringFieldMapper.Builder builder = new StringFieldMapper.Builder(fieldName);
|
StringFieldMapper.Builder builder = new StringFieldMapper.Builder(fieldName);
|
||||||
// hack for the fact that string can't just accept true/false for
|
// hack for the fact that string can't just accept true/false for
|
||||||
// the index property and still accepts no/not_analyzed/analyzed
|
// the index property and still accepts no/not_analyzed/analyzed
|
||||||
|
@ -236,6 +240,10 @@ public class StringFieldMapper extends FieldMapper implements AllFieldMapper.Inc
|
||||||
int positionIncrementGap, int ignoreAbove,
|
int positionIncrementGap, int ignoreAbove,
|
||||||
Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
|
Settings indexSettings, MultiFields multiFields, CopyTo copyTo) {
|
||||||
super(simpleName, fieldType, defaultFieldType, indexSettings, multiFields, copyTo);
|
super(simpleName, fieldType, defaultFieldType, indexSettings, multiFields, copyTo);
|
||||||
|
if (Version.indexCreated(indexSettings).onOrAfter(Version.V_5_0_0)) {
|
||||||
|
throw new IllegalArgumentException("The [string] type is removed in 5.0. You should now use either a [text] "
|
||||||
|
+ "or [keyword] field instead for field [" + fieldType.name() + "]");
|
||||||
|
}
|
||||||
if (fieldType.tokenized() && fieldType.indexOptions() != NONE && fieldType().hasDocValues()) {
|
if (fieldType.tokenized() && fieldType.indexOptions() != NONE && fieldType().hasDocValues()) {
|
||||||
throw new MapperParsingException("Field [" + fieldType.name() + "] cannot be analyzed and have doc values");
|
throw new MapperParsingException("Field [" + fieldType.name() + "] cannot be analyzed and have doc values");
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,6 @@
|
||||||
package org.elasticsearch.index.mapper.geo;
|
package org.elasticsearch.index.mapper.geo;
|
||||||
|
|
||||||
import org.apache.lucene.document.Field;
|
import org.apache.lucene.document.Field;
|
||||||
import org.apache.lucene.index.IndexOptions;
|
|
||||||
import org.apache.lucene.spatial.geopoint.document.GeoPointField;
|
|
||||||
import org.apache.lucene.spatial.util.GeoHashUtils;
|
import org.apache.lucene.spatial.util.GeoHashUtils;
|
||||||
import org.apache.lucene.util.NumericUtils;
|
import org.apache.lucene.util.NumericUtils;
|
||||||
import org.elasticsearch.Version;
|
import org.elasticsearch.Version;
|
||||||
|
@ -40,9 +38,8 @@ import org.elasticsearch.index.mapper.Mapper;
|
||||||
import org.elasticsearch.index.mapper.MapperParsingException;
|
import org.elasticsearch.index.mapper.MapperParsingException;
|
||||||
import org.elasticsearch.index.mapper.ParseContext;
|
import org.elasticsearch.index.mapper.ParseContext;
|
||||||
import org.elasticsearch.index.mapper.core.DoubleFieldMapper;
|
import org.elasticsearch.index.mapper.core.DoubleFieldMapper;
|
||||||
|
import org.elasticsearch.index.mapper.core.KeywordFieldMapper;
|
||||||
import org.elasticsearch.index.mapper.core.NumberFieldMapper;
|
import org.elasticsearch.index.mapper.core.NumberFieldMapper;
|
||||||
import org.elasticsearch.index.mapper.core.StringFieldMapper;
|
|
||||||
import org.elasticsearch.index.mapper.core.TokenCountFieldMapper;
|
|
||||||
import org.elasticsearch.index.mapper.object.ArrayValueMapperParser;
|
import org.elasticsearch.index.mapper.object.ArrayValueMapperParser;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -148,7 +145,7 @@ public abstract class BaseGeoPointFieldMapper extends FieldMapper implements Arr
|
||||||
|
|
||||||
public abstract Y build(BuilderContext context, String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType,
|
public abstract Y build(BuilderContext context, String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType,
|
||||||
Settings indexSettings, DoubleFieldMapper latMapper, DoubleFieldMapper lonMapper,
|
Settings indexSettings, DoubleFieldMapper latMapper, DoubleFieldMapper lonMapper,
|
||||||
StringFieldMapper geoHashMapper, MultiFields multiFields, Explicit<Boolean> ignoreMalformed, CopyTo copyTo);
|
KeywordFieldMapper geoHashMapper, MultiFields multiFields, Explicit<Boolean> ignoreMalformed, CopyTo copyTo);
|
||||||
|
|
||||||
public Y build(Mapper.BuilderContext context) {
|
public Y build(Mapper.BuilderContext context) {
|
||||||
GeoPointFieldType geoPointFieldType = (GeoPointFieldType)fieldType;
|
GeoPointFieldType geoPointFieldType = (GeoPointFieldType)fieldType;
|
||||||
|
@ -168,11 +165,10 @@ public abstract class BaseGeoPointFieldMapper extends FieldMapper implements Arr
|
||||||
lonMapper = (DoubleFieldMapper) lonMapperBuilder.includeInAll(false).store(fieldType.stored()).docValues(false).build(context);
|
lonMapper = (DoubleFieldMapper) lonMapperBuilder.includeInAll(false).store(fieldType.stored()).docValues(false).build(context);
|
||||||
geoPointFieldType.setLatLonEnabled(latMapper.fieldType(), lonMapper.fieldType());
|
geoPointFieldType.setLatLonEnabled(latMapper.fieldType(), lonMapper.fieldType());
|
||||||
}
|
}
|
||||||
StringFieldMapper geoHashMapper = null;
|
KeywordFieldMapper geoHashMapper = null;
|
||||||
if (enableGeoHash || enableGeoHashPrefix) {
|
if (enableGeoHash || enableGeoHashPrefix) {
|
||||||
// TODO: possible also implicitly enable geohash if geohash precision is set
|
// TODO: possible also implicitly enable geohash if geohash precision is set
|
||||||
geoHashMapper = new StringFieldMapper.Builder(Names.GEOHASH).index(true).tokenized(false).includeInAll(false).store(fieldType.stored())
|
geoHashMapper = new KeywordFieldMapper.Builder(Names.GEOHASH).index(true).includeInAll(false).store(fieldType.stored()).build(context);
|
||||||
.omitNorms(true).indexOptions(IndexOptions.DOCS).build(context);
|
|
||||||
geoPointFieldType.setGeoHashEnabled(geoHashMapper.fieldType(), geoHashPrecision, enableGeoHashPrefix);
|
geoPointFieldType.setGeoHashEnabled(geoHashMapper.fieldType(), geoHashPrecision, enableGeoHashPrefix);
|
||||||
}
|
}
|
||||||
context.path().remove();
|
context.path().remove();
|
||||||
|
@ -349,12 +345,12 @@ public abstract class BaseGeoPointFieldMapper extends FieldMapper implements Arr
|
||||||
|
|
||||||
protected DoubleFieldMapper lonMapper;
|
protected DoubleFieldMapper lonMapper;
|
||||||
|
|
||||||
protected StringFieldMapper geoHashMapper;
|
protected KeywordFieldMapper geoHashMapper;
|
||||||
|
|
||||||
protected Explicit<Boolean> ignoreMalformed;
|
protected Explicit<Boolean> ignoreMalformed;
|
||||||
|
|
||||||
protected BaseGeoPointFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType, Settings indexSettings,
|
protected BaseGeoPointFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType, Settings indexSettings,
|
||||||
DoubleFieldMapper latMapper, DoubleFieldMapper lonMapper, StringFieldMapper geoHashMapper,
|
DoubleFieldMapper latMapper, DoubleFieldMapper lonMapper, KeywordFieldMapper geoHashMapper,
|
||||||
MultiFields multiFields, Explicit<Boolean> ignoreMalformed, CopyTo copyTo) {
|
MultiFields multiFields, Explicit<Boolean> ignoreMalformed, CopyTo copyTo) {
|
||||||
super(simpleName, fieldType, defaultFieldType, indexSettings, multiFields, copyTo);
|
super(simpleName, fieldType, defaultFieldType, indexSettings, multiFields, copyTo);
|
||||||
this.latMapper = latMapper;
|
this.latMapper = latMapper;
|
||||||
|
@ -507,7 +503,7 @@ public abstract class BaseGeoPointFieldMapper extends FieldMapper implements Arr
|
||||||
@Override
|
@Override
|
||||||
public FieldMapper updateFieldType(Map<String, MappedFieldType> fullNameToFieldType) {
|
public FieldMapper updateFieldType(Map<String, MappedFieldType> fullNameToFieldType) {
|
||||||
BaseGeoPointFieldMapper updated = (BaseGeoPointFieldMapper) super.updateFieldType(fullNameToFieldType);
|
BaseGeoPointFieldMapper updated = (BaseGeoPointFieldMapper) super.updateFieldType(fullNameToFieldType);
|
||||||
StringFieldMapper geoUpdated = geoHashMapper == null ? null : (StringFieldMapper) geoHashMapper.updateFieldType(fullNameToFieldType);
|
KeywordFieldMapper geoUpdated = geoHashMapper == null ? null : (KeywordFieldMapper) geoHashMapper.updateFieldType(fullNameToFieldType);
|
||||||
DoubleFieldMapper latUpdated = latMapper == null ? null : (DoubleFieldMapper) latMapper.updateFieldType(fullNameToFieldType);
|
DoubleFieldMapper latUpdated = latMapper == null ? null : (DoubleFieldMapper) latMapper.updateFieldType(fullNameToFieldType);
|
||||||
DoubleFieldMapper lonUpdated = lonMapper == null ? null : (DoubleFieldMapper) lonMapper.updateFieldType(fullNameToFieldType);
|
DoubleFieldMapper lonUpdated = lonMapper == null ? null : (DoubleFieldMapper) lonMapper.updateFieldType(fullNameToFieldType);
|
||||||
if (updated == this
|
if (updated == this
|
||||||
|
|
|
@ -33,7 +33,7 @@ import org.elasticsearch.index.mapper.Mapper;
|
||||||
import org.elasticsearch.index.mapper.MapperParsingException;
|
import org.elasticsearch.index.mapper.MapperParsingException;
|
||||||
import org.elasticsearch.index.mapper.ParseContext;
|
import org.elasticsearch.index.mapper.ParseContext;
|
||||||
import org.elasticsearch.index.mapper.core.DoubleFieldMapper;
|
import org.elasticsearch.index.mapper.core.DoubleFieldMapper;
|
||||||
import org.elasticsearch.index.mapper.core.StringFieldMapper;
|
import org.elasticsearch.index.mapper.core.KeywordFieldMapper;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -79,7 +79,7 @@ public class GeoPointFieldMapper extends BaseGeoPointFieldMapper {
|
||||||
@Override
|
@Override
|
||||||
public GeoPointFieldMapper build(BuilderContext context, String simpleName, MappedFieldType fieldType,
|
public GeoPointFieldMapper build(BuilderContext context, String simpleName, MappedFieldType fieldType,
|
||||||
MappedFieldType defaultFieldType, Settings indexSettings, DoubleFieldMapper latMapper,
|
MappedFieldType defaultFieldType, Settings indexSettings, DoubleFieldMapper latMapper,
|
||||||
DoubleFieldMapper lonMapper, StringFieldMapper geoHashMapper, MultiFields multiFields, Explicit<Boolean> ignoreMalformed,
|
DoubleFieldMapper lonMapper, KeywordFieldMapper geoHashMapper, MultiFields multiFields, Explicit<Boolean> ignoreMalformed,
|
||||||
CopyTo copyTo) {
|
CopyTo copyTo) {
|
||||||
fieldType.setTokenized(false);
|
fieldType.setTokenized(false);
|
||||||
if (context.indexCreatedVersion().before(Version.V_2_3_0)) {
|
if (context.indexCreatedVersion().before(Version.V_2_3_0)) {
|
||||||
|
@ -110,7 +110,7 @@ public class GeoPointFieldMapper extends BaseGeoPointFieldMapper {
|
||||||
|
|
||||||
public GeoPointFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType, Settings indexSettings,
|
public GeoPointFieldMapper(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType, Settings indexSettings,
|
||||||
DoubleFieldMapper latMapper, DoubleFieldMapper lonMapper,
|
DoubleFieldMapper latMapper, DoubleFieldMapper lonMapper,
|
||||||
StringFieldMapper geoHashMapper, MultiFields multiFields, Explicit<Boolean> ignoreMalformed, CopyTo copyTo) {
|
KeywordFieldMapper geoHashMapper, MultiFields multiFields, Explicit<Boolean> ignoreMalformed, CopyTo copyTo) {
|
||||||
super(simpleName, fieldType, defaultFieldType, indexSettings, latMapper, lonMapper, geoHashMapper, multiFields,
|
super(simpleName, fieldType, defaultFieldType, indexSettings, latMapper, lonMapper, geoHashMapper, multiFields,
|
||||||
ignoreMalformed, copyTo);
|
ignoreMalformed, copyTo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ import com.carrotsearch.hppc.cursors.ObjectCursor;
|
||||||
import org.apache.lucene.document.Field;
|
import org.apache.lucene.document.Field;
|
||||||
import org.apache.lucene.index.IndexOptions;
|
import org.apache.lucene.index.IndexOptions;
|
||||||
import org.apache.lucene.util.BytesRef;
|
import org.apache.lucene.util.BytesRef;
|
||||||
import org.elasticsearch.Version;
|
|
||||||
import org.elasticsearch.common.Explicit;
|
import org.elasticsearch.common.Explicit;
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.geo.GeoDistance;
|
import org.elasticsearch.common.geo.GeoDistance;
|
||||||
|
@ -40,8 +39,8 @@ import org.elasticsearch.index.mapper.Mapper;
|
||||||
import org.elasticsearch.index.mapper.MapperParsingException;
|
import org.elasticsearch.index.mapper.MapperParsingException;
|
||||||
import org.elasticsearch.index.mapper.ParseContext;
|
import org.elasticsearch.index.mapper.ParseContext;
|
||||||
import org.elasticsearch.index.mapper.core.DoubleFieldMapper;
|
import org.elasticsearch.index.mapper.core.DoubleFieldMapper;
|
||||||
|
import org.elasticsearch.index.mapper.core.KeywordFieldMapper;
|
||||||
import org.elasticsearch.index.mapper.core.NumberFieldMapper.CustomNumericDocValuesField;
|
import org.elasticsearch.index.mapper.core.NumberFieldMapper.CustomNumericDocValuesField;
|
||||||
import org.elasticsearch.index.mapper.core.StringFieldMapper;
|
|
||||||
import org.elasticsearch.index.mapper.object.ArrayValueMapperParser;
|
import org.elasticsearch.index.mapper.object.ArrayValueMapperParser;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -110,7 +109,7 @@ public class GeoPointFieldMapperLegacy extends BaseGeoPointFieldMapper implement
|
||||||
@Override
|
@Override
|
||||||
public GeoPointFieldMapperLegacy build(BuilderContext context, String simpleName, MappedFieldType fieldType,
|
public GeoPointFieldMapperLegacy build(BuilderContext context, String simpleName, MappedFieldType fieldType,
|
||||||
MappedFieldType defaultFieldType, Settings indexSettings, DoubleFieldMapper latMapper,
|
MappedFieldType defaultFieldType, Settings indexSettings, DoubleFieldMapper latMapper,
|
||||||
DoubleFieldMapper lonMapper, StringFieldMapper geoHashMapper, MultiFields multiFields, Explicit<Boolean> ignoreMalformed,
|
DoubleFieldMapper lonMapper, KeywordFieldMapper geoHashMapper, MultiFields multiFields, Explicit<Boolean> ignoreMalformed,
|
||||||
CopyTo copyTo) {
|
CopyTo copyTo) {
|
||||||
fieldType.setTokenized(false);
|
fieldType.setTokenized(false);
|
||||||
setupFieldType(context);
|
setupFieldType(context);
|
||||||
|
@ -268,7 +267,7 @@ public class GeoPointFieldMapperLegacy extends BaseGeoPointFieldMapper implement
|
||||||
|
|
||||||
public GeoPointFieldMapperLegacy(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType, Settings indexSettings,
|
public GeoPointFieldMapperLegacy(String simpleName, MappedFieldType fieldType, MappedFieldType defaultFieldType, Settings indexSettings,
|
||||||
DoubleFieldMapper latMapper, DoubleFieldMapper lonMapper,
|
DoubleFieldMapper latMapper, DoubleFieldMapper lonMapper,
|
||||||
StringFieldMapper geoHashMapper, MultiFields multiFields, Explicit<Boolean> ignoreMalformed,
|
KeywordFieldMapper geoHashMapper, MultiFields multiFields, Explicit<Boolean> ignoreMalformed,
|
||||||
Explicit<Boolean> coerce, CopyTo copyTo) {
|
Explicit<Boolean> coerce, CopyTo copyTo) {
|
||||||
super(simpleName, fieldType, defaultFieldType, indexSettings, latMapper, lonMapper, geoHashMapper, multiFields,
|
super(simpleName, fieldType, defaultFieldType, indexSettings, latMapper, lonMapper, geoHashMapper, multiFields,
|
||||||
ignoreMalformed, copyTo);
|
ignoreMalformed, copyTo);
|
||||||
|
|
|
@ -235,10 +235,30 @@ public class RootObjectMapper extends ObjectMapper {
|
||||||
return dynamicDateTimeFormatters;
|
return dynamicDateTimeFormatters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Mapper.Builder findTemplateBuilder(ParseContext context, String name, String dynamicType) {
|
public Mapper.Builder findTemplateBuilder(ParseContext context, String name, String matchType) {
|
||||||
return findTemplateBuilder(context, name, dynamicType, dynamicType);
|
final String dynamicType;
|
||||||
|
switch (matchType) {
|
||||||
|
case "string":
|
||||||
|
// string is a corner case since a json string can either map to a
|
||||||
|
// text or keyword field in elasticsearch. For now we use text when
|
||||||
|
// unspecified. For other types, the mapping type matches the json
|
||||||
|
// type so we are fine
|
||||||
|
dynamicType = "text";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
dynamicType = matchType;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return findTemplateBuilder(context, name, dynamicType, matchType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find a template. Returns {@code null} if no template could be found.
|
||||||
|
* @param name the field name
|
||||||
|
* @param dynamicType the field type to give the field if the template does not define one
|
||||||
|
* @param matchType the type of the field in the json document or null if unknown
|
||||||
|
* @return a mapper builder, or null if there is no template for such a field
|
||||||
|
*/
|
||||||
public Mapper.Builder findTemplateBuilder(ParseContext context, String name, String dynamicType, String matchType) {
|
public Mapper.Builder findTemplateBuilder(ParseContext context, String name, String dynamicType, String matchType) {
|
||||||
DynamicTemplate dynamicTemplate = findTemplate(context.path(), name, matchType);
|
DynamicTemplate dynamicTemplate = findTemplate(context.path(), name, matchType);
|
||||||
if (dynamicTemplate == null) {
|
if (dynamicTemplate == null) {
|
||||||
|
|
|
@ -82,7 +82,7 @@ public abstract class AbstractTermVectorsTestCase extends ESIntegTestCase {
|
||||||
|
|
||||||
public void addToMappings(XContentBuilder mappingsBuilder) throws IOException {
|
public void addToMappings(XContentBuilder mappingsBuilder) throws IOException {
|
||||||
mappingsBuilder.startObject(name);
|
mappingsBuilder.startObject(name);
|
||||||
mappingsBuilder.field("type", "string");
|
mappingsBuilder.field("type", "text");
|
||||||
String tv_settings;
|
String tv_settings;
|
||||||
if (storedPositions && storedOffset && storedPayloads) {
|
if (storedPositions && storedOffset && storedPayloads) {
|
||||||
tv_settings = "with_positions_offsets_payloads";
|
tv_settings = "with_positions_offsets_payloads";
|
||||||
|
|
|
@ -129,7 +129,7 @@ public class SpecificMasterNodesIT extends ESIntegTestCase {
|
||||||
logger.info("--> start data node / non master node");
|
logger.info("--> start data node / non master node");
|
||||||
internalCluster().startNode(settingsBuilder().put(Node.NODE_DATA_SETTING.getKey(), true).put(Node.NODE_MASTER_SETTING.getKey(), false));
|
internalCluster().startNode(settingsBuilder().put(Node.NODE_DATA_SETTING.getKey(), true).put(Node.NODE_MASTER_SETTING.getKey(), false));
|
||||||
|
|
||||||
assertAcked(prepareCreate("test").addMapping("type1", "{\"type1\" : {\"properties\" : {\"table_a\" : { \"type\" : \"nested\", \"properties\" : {\"field_a\" : { \"type\" : \"string\" },\"field_b\" :{ \"type\" : \"string\" }}}}}}"));
|
assertAcked(prepareCreate("test").addMapping("type1", "{\"type1\" : {\"properties\" : {\"table_a\" : { \"type\" : \"nested\", \"properties\" : {\"field_a\" : { \"type\" : \"keyword\" },\"field_b\" :{ \"type\" : \"keyword\" }}}}}}"));
|
||||||
client().admin().indices().prepareAliases().addAlias("test", "a_test", QueryBuilders.nestedQuery("table_a", QueryBuilders.termQuery("table_a.field_b", "y"))).get();
|
client().admin().indices().prepareAliases().addAlias("test", "a_test", QueryBuilders.nestedQuery("table_a", QueryBuilders.termQuery("table_a.field_b", "y"))).get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class CodecTests extends ESSingleNodeTestCase {
|
||||||
|
|
||||||
public void testAcceptPostingsFormat() throws IOException {
|
public void testAcceptPostingsFormat() throws IOException {
|
||||||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
|
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
|
||||||
.startObject("properties").startObject("field").field("type", "string").field("postings_format", Codec.getDefault().postingsFormat().getName()).endObject().endObject()
|
.startObject("properties").startObject("field").field("type", "keyword").field("postings_format", Codec.getDefault().postingsFormat().getName()).endObject().endObject()
|
||||||
.endObject().endObject().string();
|
.endObject().endObject().string();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Version v : VersionUtils.allVersions()) {
|
for (Version v : VersionUtils.allVersions()) {
|
||||||
|
@ -75,7 +75,7 @@ public class CodecTests extends ESSingleNodeTestCase {
|
||||||
|
|
||||||
public void testAcceptDocValuesFormat() throws IOException {
|
public void testAcceptDocValuesFormat() throws IOException {
|
||||||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
|
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
|
||||||
.startObject("properties").startObject("field").field("type", "string").field("doc_values_format", Codec.getDefault().docValuesFormat().getName()).endObject().endObject()
|
.startObject("properties").startObject("field").field("type", "keyword").field("doc_values_format", Codec.getDefault().docValuesFormat().getName()).endObject().endObject()
|
||||||
.endObject().endObject().string();
|
.endObject().endObject().string();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Version v : VersionUtils.allVersions()) {
|
for (Version v : VersionUtils.allVersions()) {
|
||||||
|
|
|
@ -751,7 +751,7 @@ public class GetActionIT extends ESIntegTestCase {
|
||||||
.startObject("field1").field("type", "object").startObject("properties")
|
.startObject("field1").field("type", "object").startObject("properties")
|
||||||
.startObject("field2").field("type", "object").startObject("properties")
|
.startObject("field2").field("type", "object").startObject("properties")
|
||||||
.startObject("field3").field("type", "object").startObject("properties")
|
.startObject("field3").field("type", "object").startObject("properties")
|
||||||
.startObject("field4").field("type", "string").field("store", true)
|
.startObject("field4").field("type", "text").field("store", true)
|
||||||
.endObject().endObject()
|
.endObject().endObject()
|
||||||
.endObject().endObject()
|
.endObject().endObject()
|
||||||
.endObject().endObject()
|
.endObject().endObject()
|
||||||
|
|
|
@ -135,7 +135,7 @@ public abstract class AbstractFieldDataTestCase extends ESSingleNodeTestCase {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() throws Exception {
|
public void setup() throws Exception {
|
||||||
Version version = VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.CURRENT);
|
Version version = VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.V_2_3_0); // we need 2.x so that fielddata is allowed on string fields
|
||||||
Settings settings = Settings.builder().put("index.fielddata.cache", "none")
|
Settings settings = Settings.builder().put("index.fielddata.cache", "none")
|
||||||
.put(IndexMetaData.SETTING_VERSION_CREATED, version).build();
|
.put(IndexMetaData.SETTING_VERSION_CREATED, version).build();
|
||||||
indexService = createIndex("test", settings);
|
indexService = createIndex("test", settings);
|
||||||
|
|
|
@ -27,15 +27,12 @@ import org.apache.lucene.index.DirectoryReader;
|
||||||
import org.apache.lucene.index.IndexReader;
|
import org.apache.lucene.index.IndexReader;
|
||||||
import org.apache.lucene.index.IndexWriter;
|
import org.apache.lucene.index.IndexWriter;
|
||||||
import org.apache.lucene.index.IndexWriterConfig;
|
import org.apache.lucene.index.IndexWriterConfig;
|
||||||
import org.apache.lucene.index.LeafReader;
|
|
||||||
import org.apache.lucene.index.LeafReaderContext;
|
import org.apache.lucene.index.LeafReaderContext;
|
||||||
import org.apache.lucene.store.RAMDirectory;
|
import org.apache.lucene.store.RAMDirectory;
|
||||||
import org.apache.lucene.util.Accountable;
|
import org.apache.lucene.util.Accountable;
|
||||||
import org.elasticsearch.common.lucene.index.ElasticsearchDirectoryReader;
|
import org.elasticsearch.common.lucene.index.ElasticsearchDirectoryReader;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.index.IndexService;
|
import org.elasticsearch.index.IndexService;
|
||||||
import org.elasticsearch.index.fielddata.plain.PagedBytesAtomicFieldData;
|
|
||||||
import org.elasticsearch.index.fielddata.plain.PagedBytesIndexFieldData;
|
|
||||||
import org.elasticsearch.index.fielddata.plain.SortedNumericDVIndexFieldData;
|
import org.elasticsearch.index.fielddata.plain.SortedNumericDVIndexFieldData;
|
||||||
import org.elasticsearch.index.fielddata.plain.SortedSetDVOrdinalsIndexFieldData;
|
import org.elasticsearch.index.fielddata.plain.SortedSetDVOrdinalsIndexFieldData;
|
||||||
import org.elasticsearch.index.mapper.ContentPath;
|
import org.elasticsearch.index.mapper.ContentPath;
|
||||||
|
@ -46,33 +43,38 @@ import org.elasticsearch.index.mapper.core.ByteFieldMapper;
|
||||||
import org.elasticsearch.index.mapper.core.DoubleFieldMapper;
|
import org.elasticsearch.index.mapper.core.DoubleFieldMapper;
|
||||||
import org.elasticsearch.index.mapper.core.FloatFieldMapper;
|
import org.elasticsearch.index.mapper.core.FloatFieldMapper;
|
||||||
import org.elasticsearch.index.mapper.core.IntegerFieldMapper;
|
import org.elasticsearch.index.mapper.core.IntegerFieldMapper;
|
||||||
|
import org.elasticsearch.index.mapper.core.KeywordFieldMapper;
|
||||||
import org.elasticsearch.index.mapper.core.LongFieldMapper;
|
import org.elasticsearch.index.mapper.core.LongFieldMapper;
|
||||||
import org.elasticsearch.index.mapper.core.ShortFieldMapper;
|
import org.elasticsearch.index.mapper.core.ShortFieldMapper;
|
||||||
import org.elasticsearch.index.mapper.core.StringFieldMapper;
|
import org.elasticsearch.index.mapper.core.StringFieldMapper;
|
||||||
|
import org.elasticsearch.index.mapper.core.TextFieldMapper;
|
||||||
import org.elasticsearch.index.shard.ShardId;
|
import org.elasticsearch.index.shard.ShardId;
|
||||||
import org.elasticsearch.indices.IndicesService;
|
import org.elasticsearch.indices.IndicesService;
|
||||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
|
||||||
import org.elasticsearch.indices.fielddata.cache.IndicesFieldDataCache;
|
import org.elasticsearch.indices.fielddata.cache.IndicesFieldDataCache;
|
||||||
|
import org.elasticsearch.plugins.Plugin;
|
||||||
import org.elasticsearch.test.ESSingleNodeTestCase;
|
import org.elasticsearch.test.ESSingleNodeTestCase;
|
||||||
import org.elasticsearch.test.IndexSettingsModule;
|
import org.elasticsearch.test.IndexSettingsModule;
|
||||||
|
import org.elasticsearch.test.InternalSettingsPlugin;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collection;
|
||||||
import java.util.IdentityHashMap;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.containsString;
|
import static org.hamcrest.Matchers.containsString;
|
||||||
import static org.hamcrest.Matchers.instanceOf;
|
|
||||||
|
|
||||||
public class IndexFieldDataServiceTests extends ESSingleNodeTestCase {
|
public class IndexFieldDataServiceTests extends ESSingleNodeTestCase {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Collection<Class<? extends Plugin>> getPlugins() {
|
||||||
|
return pluginList(InternalSettingsPlugin.class);
|
||||||
|
}
|
||||||
|
|
||||||
public void testGetForFieldDefaults() {
|
public void testGetForFieldDefaults() {
|
||||||
final IndexService indexService = createIndex("test");
|
final IndexService indexService = createIndex("test");
|
||||||
final IndexFieldDataService ifdService = indexService.fieldData();
|
final IndexFieldDataService ifdService = indexService.fieldData();
|
||||||
final BuilderContext ctx = new BuilderContext(indexService.getIndexSettings().getSettings(), new ContentPath(1));
|
final BuilderContext ctx = new BuilderContext(indexService.getIndexSettings().getSettings(), new ContentPath(1));
|
||||||
final MappedFieldType stringMapper = new StringFieldMapper.Builder("string").tokenized(false).build(ctx).fieldType();
|
final MappedFieldType stringMapper = new KeywordFieldMapper.Builder("string").build(ctx).fieldType();
|
||||||
ifdService.clear();
|
ifdService.clear();
|
||||||
IndexFieldData<?> fd = ifdService.getForField(stringMapper);
|
IndexFieldData<?> fd = ifdService.getForField(stringMapper);
|
||||||
assertTrue(fd instanceof SortedSetDVOrdinalsIndexFieldData);
|
assertTrue(fd instanceof SortedSetDVOrdinalsIndexFieldData);
|
||||||
|
@ -99,36 +101,6 @@ public class IndexFieldDataServiceTests extends ESSingleNodeTestCase {
|
||||||
assertTrue(fd instanceof SortedNumericDVIndexFieldData);
|
assertTrue(fd instanceof SortedNumericDVIndexFieldData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testChangeFieldDataFormat() throws Exception {
|
|
||||||
final IndexService indexService = createIndex("test");
|
|
||||||
final IndexFieldDataService ifdService = indexService.fieldData();
|
|
||||||
final BuilderContext ctx = new BuilderContext(indexService.getIndexSettings().getSettings(), new ContentPath(1));
|
|
||||||
final MappedFieldType mapper1 = new StringFieldMapper.Builder("s").tokenized(false).docValues(true).fieldDataSettings(Settings.builder().put(FieldDataType.FORMAT_KEY, "paged_bytes").build()).build(ctx).fieldType();
|
|
||||||
final IndexWriter writer = new IndexWriter(new RAMDirectory(), new IndexWriterConfig(new KeywordAnalyzer()));
|
|
||||||
Document doc = new Document();
|
|
||||||
doc.add(new StringField("s", "thisisastring", Store.NO));
|
|
||||||
writer.addDocument(doc);
|
|
||||||
final IndexReader reader1 = DirectoryReader.open(writer, true);
|
|
||||||
IndexFieldData<?> ifd = ifdService.getForField(mapper1);
|
|
||||||
assertThat(ifd, instanceOf(PagedBytesIndexFieldData.class));
|
|
||||||
Set<LeafReader> oldSegments = Collections.newSetFromMap(new IdentityHashMap<LeafReader, Boolean>());
|
|
||||||
for (LeafReaderContext arc : reader1.leaves()) {
|
|
||||||
oldSegments.add(arc.reader());
|
|
||||||
AtomicFieldData afd = ifd.load(arc);
|
|
||||||
assertThat(afd, instanceOf(PagedBytesAtomicFieldData.class));
|
|
||||||
}
|
|
||||||
// write new segment
|
|
||||||
writer.addDocument(doc);
|
|
||||||
final IndexReader reader2 = DirectoryReader.open(writer, true);
|
|
||||||
final MappedFieldType mapper2 = new StringFieldMapper.Builder("s").tokenized(false).docValues(true).fieldDataSettings(Settings.builder().put(FieldDataType.FORMAT_KEY, "doc_values").build()).build(ctx).fieldType();
|
|
||||||
ifd = ifdService.getForField(mapper2);
|
|
||||||
assertThat(ifd, instanceOf(SortedSetDVOrdinalsIndexFieldData.class));
|
|
||||||
reader1.close();
|
|
||||||
reader2.close();
|
|
||||||
writer.close();
|
|
||||||
writer.getDirectory().close();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testFieldDataCacheListener() throws Exception {
|
public void testFieldDataCacheListener() throws Exception {
|
||||||
final IndexService indexService = createIndex("test");
|
final IndexService indexService = createIndex("test");
|
||||||
final IndicesService indicesService = getInstanceFromNode(IndicesService.class);
|
final IndicesService indicesService = getInstanceFromNode(IndicesService.class);
|
||||||
|
@ -137,7 +109,7 @@ public class IndexFieldDataServiceTests extends ESSingleNodeTestCase {
|
||||||
indicesService.getIndicesFieldDataCache(), indicesService.getCircuitBreakerService(), indexService.mapperService());
|
indicesService.getIndicesFieldDataCache(), indicesService.getCircuitBreakerService(), indexService.mapperService());
|
||||||
|
|
||||||
final BuilderContext ctx = new BuilderContext(indexService.getIndexSettings().getSettings(), new ContentPath(1));
|
final BuilderContext ctx = new BuilderContext(indexService.getIndexSettings().getSettings(), new ContentPath(1));
|
||||||
final MappedFieldType mapper1 = new StringFieldMapper.Builder("s").tokenized(false).docValues(true).fieldDataSettings(Settings.builder().put(FieldDataType.FORMAT_KEY, "paged_bytes").build()).build(ctx).fieldType();
|
final MappedFieldType mapper1 = new TextFieldMapper.Builder("s").build(ctx).fieldType();
|
||||||
final IndexWriter writer = new IndexWriter(new RAMDirectory(), new IndexWriterConfig(new KeywordAnalyzer()));
|
final IndexWriter writer = new IndexWriter(new RAMDirectory(), new IndexWriterConfig(new KeywordAnalyzer()));
|
||||||
Document doc = new Document();
|
Document doc = new Document();
|
||||||
doc.add(new StringField("s", "thisisastring", Store.NO));
|
doc.add(new StringField("s", "thisisastring", Store.NO));
|
||||||
|
|
|
@ -242,7 +242,7 @@ public class DynamicMappingTests extends ESSingleNodeTestCase {
|
||||||
// original mapping not modified
|
// original mapping not modified
|
||||||
assertEquals(mapping, serialize(mapper));
|
assertEquals(mapping, serialize(mapper));
|
||||||
// but we have an update
|
// but we have an update
|
||||||
assertEquals("{\"type\":{\"properties\":{\"foo\":{\"type\":\"string\"}}}}", serialize(update));
|
assertEquals("{\"type\":{\"properties\":{\"foo\":{\"type\":\"text\"}}}}", serialize(update));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIncremental() throws Exception {
|
public void testIncremental() throws Exception {
|
||||||
|
@ -264,7 +264,7 @@ public class DynamicMappingTests extends ESSingleNodeTestCase {
|
||||||
// but we have an update
|
// but we have an update
|
||||||
assertEquals(XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
|
assertEquals(XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
|
||||||
// foo is NOT in the update
|
// foo is NOT in the update
|
||||||
.startObject("bar").field("type", "string").endObject()
|
.startObject("bar").field("type", "text").endObject()
|
||||||
.endObject().endObject().string(), serialize(update));
|
.endObject().endObject().string(), serialize(update));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,8 +284,8 @@ public class DynamicMappingTests extends ESSingleNodeTestCase {
|
||||||
assertEquals(mapping, serialize(mapper));
|
assertEquals(mapping, serialize(mapper));
|
||||||
// but we have an update
|
// but we have an update
|
||||||
assertEquals(XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
|
assertEquals(XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
|
||||||
.startObject("bar").field("type", "string").endObject()
|
.startObject("bar").field("type", "text").endObject()
|
||||||
.startObject("foo").field("type", "string").endObject()
|
.startObject("foo").field("type", "text").endObject()
|
||||||
.endObject().endObject().string(), serialize(update));
|
.endObject().endObject().string(), serialize(update));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -305,7 +305,7 @@ public class DynamicMappingTests extends ESSingleNodeTestCase {
|
||||||
assertEquals(mapping, serialize(mapper));
|
assertEquals(mapping, serialize(mapper));
|
||||||
// but we have an update
|
// but we have an update
|
||||||
assertEquals(XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
|
assertEquals(XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
|
||||||
.startObject("foo").startObject("properties").startObject("bar").startObject("properties").startObject("baz").field("type", "string").endObject().endObject().endObject().endObject().endObject()
|
.startObject("foo").startObject("properties").startObject("bar").startObject("properties").startObject("baz").field("type", "text").endObject().endObject().endObject().endObject().endObject()
|
||||||
.endObject().endObject().endObject().string(), serialize(update));
|
.endObject().endObject().endObject().string(), serialize(update));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,7 +325,7 @@ public class DynamicMappingTests extends ESSingleNodeTestCase {
|
||||||
assertEquals(mapping, serialize(mapper));
|
assertEquals(mapping, serialize(mapper));
|
||||||
// but we have an update
|
// but we have an update
|
||||||
assertEquals(XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
|
assertEquals(XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
|
||||||
.startObject("foo").field("type", "string").endObject()
|
.startObject("foo").field("type", "text").endObject()
|
||||||
.endObject().endObject().endObject().string(), serialize(update));
|
.endObject().endObject().endObject().string(), serialize(update));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,7 +345,7 @@ public class DynamicMappingTests extends ESSingleNodeTestCase {
|
||||||
assertEquals(mapping, serialize(mapper));
|
assertEquals(mapping, serialize(mapper));
|
||||||
// but we have an update
|
// but we have an update
|
||||||
assertEquals(XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
|
assertEquals(XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
|
||||||
.startObject("foo").startObject("properties").startObject("bar").startObject("properties").startObject("baz").field("type", "string").endObject().endObject().endObject().endObject().endObject()
|
.startObject("foo").startObject("properties").startObject("bar").startObject("properties").startObject("baz").field("type", "text").endObject().endObject().endObject().endObject().endObject()
|
||||||
.endObject().endObject().endObject().string(), serialize(update));
|
.endObject().endObject().endObject().string(), serialize(update));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,7 +366,7 @@ public class DynamicMappingTests extends ESSingleNodeTestCase {
|
||||||
assertEquals(mapping, serialize(mapper));
|
assertEquals(mapping, serialize(mapper));
|
||||||
assertEquals(XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
|
assertEquals(XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties")
|
||||||
.startObject("foo").startObject("properties")
|
.startObject("foo").startObject("properties")
|
||||||
.startObject("bar").field("type", "string").endObject()
|
.startObject("bar").field("type", "text").endObject()
|
||||||
.startObject("baz").field("type", "long").endObject()
|
.startObject("baz").field("type", "long").endObject()
|
||||||
.endObject().endObject()
|
.endObject().endObject()
|
||||||
.endObject().endObject().endObject().string(), serialize(update));
|
.endObject().endObject().endObject().string(), serialize(update));
|
||||||
|
|
|
@ -112,7 +112,7 @@ public class TokenCountFieldMapperIntegrationIT extends ESIntegTestCase {
|
||||||
.startObject("test")
|
.startObject("test")
|
||||||
.startObject("properties")
|
.startObject("properties")
|
||||||
.startObject("foo")
|
.startObject("foo")
|
||||||
.field("type", "string")
|
.field("type", "text")
|
||||||
.field("store", storeCountedFields)
|
.field("store", storeCountedFields)
|
||||||
.field("analyzer", "simple")
|
.field("analyzer", "simple")
|
||||||
.startObject("fields")
|
.startObject("fields")
|
||||||
|
|
|
@ -27,7 +27,6 @@ import org.apache.lucene.search.NumericRangeQuery;
|
||||||
import org.apache.lucene.util.Constants;
|
import org.apache.lucene.util.Constants;
|
||||||
import org.elasticsearch.Version;
|
import org.elasticsearch.Version;
|
||||||
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse;
|
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse;
|
||||||
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
|
|
||||||
import org.elasticsearch.action.index.IndexResponse;
|
import org.elasticsearch.action.index.IndexResponse;
|
||||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||||
import org.elasticsearch.common.compress.CompressedXContent;
|
import org.elasticsearch.common.compress.CompressedXContent;
|
||||||
|
@ -48,11 +47,10 @@ import org.elasticsearch.index.mapper.ParseContext.Document;
|
||||||
import org.elasticsearch.index.mapper.ParsedDocument;
|
import org.elasticsearch.index.mapper.ParsedDocument;
|
||||||
import org.elasticsearch.index.mapper.core.DateFieldMapper;
|
import org.elasticsearch.index.mapper.core.DateFieldMapper;
|
||||||
import org.elasticsearch.index.mapper.core.LongFieldMapper;
|
import org.elasticsearch.index.mapper.core.LongFieldMapper;
|
||||||
import org.elasticsearch.index.mapper.core.StringFieldMapper;
|
import org.elasticsearch.index.mapper.core.TextFieldMapper;
|
||||||
import org.elasticsearch.search.internal.SearchContext;
|
import org.elasticsearch.search.internal.SearchContext;
|
||||||
import org.elasticsearch.test.ESSingleNodeTestCase;
|
import org.elasticsearch.test.ESSingleNodeTestCase;
|
||||||
import org.elasticsearch.test.TestSearchContext;
|
import org.elasticsearch.test.TestSearchContext;
|
||||||
import org.elasticsearch.test.VersionUtils;
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
import org.joda.time.DateTimeZone;
|
import org.joda.time.DateTimeZone;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
@ -106,11 +104,11 @@ public class SimpleDateMappingTests extends ESSingleNodeTestCase {
|
||||||
assertThat(fieldMapper, instanceOf(DateFieldMapper.class));
|
assertThat(fieldMapper, instanceOf(DateFieldMapper.class));
|
||||||
|
|
||||||
fieldMapper = defaultMapper.mappers().smartNameFieldMapper("wrong_date1");
|
fieldMapper = defaultMapper.mappers().smartNameFieldMapper("wrong_date1");
|
||||||
assertThat(fieldMapper, instanceOf(StringFieldMapper.class));
|
assertThat(fieldMapper, instanceOf(TextFieldMapper.class));
|
||||||
fieldMapper = defaultMapper.mappers().smartNameFieldMapper("wrong_date2");
|
fieldMapper = defaultMapper.mappers().smartNameFieldMapper("wrong_date2");
|
||||||
assertThat(fieldMapper, instanceOf(StringFieldMapper.class));
|
assertThat(fieldMapper, instanceOf(TextFieldMapper.class));
|
||||||
fieldMapper = defaultMapper.mappers().smartNameFieldMapper("wrong_date3");
|
fieldMapper = defaultMapper.mappers().smartNameFieldMapper("wrong_date3");
|
||||||
assertThat(fieldMapper, instanceOf(StringFieldMapper.class));
|
assertThat(fieldMapper, instanceOf(TextFieldMapper.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testParseLocal() {
|
public void testParseLocal() {
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class SimpleDynamicTemplatesTests extends ESSingleNodeTestCase {
|
||||||
XContentBuilder builder = JsonXContent.contentBuilder();
|
XContentBuilder builder = JsonXContent.contentBuilder();
|
||||||
builder.startObject().startObject("person").startArray("dynamic_templates").startObject().startObject("test")
|
builder.startObject().startObject("person").startArray("dynamic_templates").startObject().startObject("test")
|
||||||
.field("match_mapping_type", "string")
|
.field("match_mapping_type", "string")
|
||||||
.startObject("mapping").field("index", "no").endObject()
|
.startObject("mapping").field("index", false).endObject()
|
||||||
.endObject().endObject().endArray().endObject().endObject();
|
.endObject().endObject().endArray().endObject().endObject();
|
||||||
IndexService index = createIndex("test");
|
IndexService index = createIndex("test");
|
||||||
client().admin().indices().preparePutMapping("test").setType("person").setSource(builder.string()).get();
|
client().admin().indices().preparePutMapping("test").setType("person").setSource(builder.string()).get();
|
||||||
|
|
|
@ -140,7 +140,7 @@ public class MultiFieldTests extends ESSingleNodeTestCase {
|
||||||
IndexService indexService = createIndex("test");
|
IndexService indexService = createIndex("test");
|
||||||
|
|
||||||
DocumentMapper builderDocMapper = new DocumentMapper.Builder(new RootObjectMapper.Builder("person").add(
|
DocumentMapper builderDocMapper = new DocumentMapper.Builder(new RootObjectMapper.Builder("person").add(
|
||||||
new StringFieldMapper.Builder("name").store(true)
|
new TextFieldMapper.Builder("name").store(true)
|
||||||
.addMultiField(new TextFieldMapper.Builder("indexed").index(true).tokenized(true))
|
.addMultiField(new TextFieldMapper.Builder("indexed").index(true).tokenized(true))
|
||||||
.addMultiField(new TextFieldMapper.Builder("not_indexed").index(false).store(true))
|
.addMultiField(new TextFieldMapper.Builder("not_indexed").index(false).store(true))
|
||||||
), indexService.mapperService()).build(indexService.mapperService());
|
), indexService.mapperService()).build(indexService.mapperService());
|
||||||
|
|
|
@ -35,7 +35,7 @@ import static org.hamcrest.Matchers.equalTo;
|
||||||
public class NullValueTests extends ESSingleNodeTestCase {
|
public class NullValueTests extends ESSingleNodeTestCase {
|
||||||
public void testNullNullValue() throws Exception {
|
public void testNullNullValue() throws Exception {
|
||||||
IndexService indexService = createIndex("test", Settings.settingsBuilder().build());
|
IndexService indexService = createIndex("test", Settings.settingsBuilder().build());
|
||||||
String[] typesToTest = {"integer", "long", "double", "float", "short", "date", "ip", "string", "boolean", "byte"};
|
String[] typesToTest = {"integer", "long", "double", "float", "short", "date", "ip", "keyword", "boolean", "byte"};
|
||||||
|
|
||||||
for (String type : typesToTest) {
|
for (String type : typesToTest) {
|
||||||
String mapping = XContentFactory.jsonBuilder()
|
String mapping = XContentFactory.jsonBuilder()
|
||||||
|
|
|
@ -40,7 +40,7 @@ import org.elasticsearch.index.mapper.ParsedDocument;
|
||||||
import org.elasticsearch.index.mapper.core.DoubleFieldMapper;
|
import org.elasticsearch.index.mapper.core.DoubleFieldMapper;
|
||||||
import org.elasticsearch.index.mapper.core.LongFieldMapper;
|
import org.elasticsearch.index.mapper.core.LongFieldMapper;
|
||||||
import org.elasticsearch.index.mapper.core.NumberFieldMapper;
|
import org.elasticsearch.index.mapper.core.NumberFieldMapper;
|
||||||
import org.elasticsearch.index.mapper.core.StringFieldMapper;
|
import org.elasticsearch.index.mapper.core.TextFieldMapper;
|
||||||
import org.elasticsearch.index.mapper.string.SimpleStringMappingTests;
|
import org.elasticsearch.index.mapper.string.SimpleStringMappingTests;
|
||||||
import org.elasticsearch.plugins.Plugin;
|
import org.elasticsearch.plugins.Plugin;
|
||||||
import org.elasticsearch.test.ESSingleNodeTestCase;
|
import org.elasticsearch.test.ESSingleNodeTestCase;
|
||||||
|
@ -111,10 +111,10 @@ public class SimpleNumericTests extends ESSingleNodeTestCase {
|
||||||
|
|
||||||
defaultMapper = index.mapperService().documentMapper("type");
|
defaultMapper = index.mapperService().documentMapper("type");
|
||||||
FieldMapper mapper = defaultMapper.mappers().smartNameFieldMapper("s_long");
|
FieldMapper mapper = defaultMapper.mappers().smartNameFieldMapper("s_long");
|
||||||
assertThat(mapper, instanceOf(StringFieldMapper.class));
|
assertThat(mapper, instanceOf(TextFieldMapper.class));
|
||||||
|
|
||||||
mapper = defaultMapper.mappers().smartNameFieldMapper("s_double");
|
mapper = defaultMapper.mappers().smartNameFieldMapper("s_double");
|
||||||
assertThat(mapper, instanceOf(StringFieldMapper.class));
|
assertThat(mapper, instanceOf(TextFieldMapper.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIgnoreMalformedOption() throws Exception {
|
public void testIgnoreMalformedOption() throws Exception {
|
||||||
|
|
|
@ -47,7 +47,6 @@ import org.elasticsearch.index.mapper.core.StringFieldMapper.Builder;
|
||||||
import org.elasticsearch.plugins.Plugin;
|
import org.elasticsearch.plugins.Plugin;
|
||||||
import org.elasticsearch.test.ESSingleNodeTestCase;
|
import org.elasticsearch.test.ESSingleNodeTestCase;
|
||||||
import org.elasticsearch.test.InternalSettingsPlugin;
|
import org.elasticsearch.test.InternalSettingsPlugin;
|
||||||
import org.elasticsearch.test.VersionUtils;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -75,7 +74,9 @@ public class SimpleStringMappingTests extends ESSingleNodeTestCase {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void before() {
|
public void before() {
|
||||||
indexService = createIndex("test");
|
indexService = createIndex("test",
|
||||||
|
// we need 2.x since string is deprecated in 5.0
|
||||||
|
Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_2_3_0).build());
|
||||||
parser = indexService.mapperService().documentMapperParser();
|
parser = indexService.mapperService().documentMapperParser();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,14 +20,20 @@
|
||||||
package org.elasticsearch.index.mapper.string;
|
package org.elasticsearch.index.mapper.string;
|
||||||
|
|
||||||
import org.elasticsearch.ExceptionsHelper;
|
import org.elasticsearch.ExceptionsHelper;
|
||||||
|
import org.elasticsearch.Version;
|
||||||
import org.elasticsearch.client.Client;
|
import org.elasticsearch.client.Client;
|
||||||
|
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||||
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||||
import org.elasticsearch.index.mapper.MapperParsingException;
|
import org.elasticsearch.index.mapper.MapperParsingException;
|
||||||
|
import org.elasticsearch.plugins.Plugin;
|
||||||
import org.elasticsearch.test.ESSingleNodeTestCase;
|
import org.elasticsearch.test.ESSingleNodeTestCase;
|
||||||
|
import org.elasticsearch.test.InternalSettingsPlugin;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
import static org.elasticsearch.index.query.QueryBuilders.matchPhraseQuery;
|
import static org.elasticsearch.index.query.QueryBuilders.matchPhraseQuery;
|
||||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
|
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
|
||||||
|
@ -38,6 +44,12 @@ import static org.hamcrest.Matchers.containsString;
|
||||||
* expected in queries.
|
* expected in queries.
|
||||||
*/
|
*/
|
||||||
public class StringFieldMapperPositionIncrementGapTests extends ESSingleNodeTestCase {
|
public class StringFieldMapperPositionIncrementGapTests extends ESSingleNodeTestCase {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Collection<Class<? extends Plugin>> getPlugins() {
|
||||||
|
return pluginList(InternalSettingsPlugin.class);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default position_increment_gap should be large enough that most
|
* The default position_increment_gap should be large enough that most
|
||||||
* "sensible" queries phrase slops won't match across values.
|
* "sensible" queries phrase slops won't match across values.
|
||||||
|
@ -106,11 +118,12 @@ public class StringFieldMapperPositionIncrementGapTests extends ESSingleNodeTest
|
||||||
* strange but not worth breaking some thought.
|
* strange but not worth breaking some thought.
|
||||||
*/
|
*/
|
||||||
public void testDefaultDefaultsToAnalyzer() throws IOException {
|
public void testDefaultDefaultsToAnalyzer() throws IOException {
|
||||||
XContentBuilder settings = XContentFactory.jsonBuilder().startObject().startObject("analysis").startObject("analyzer")
|
Settings settings = Settings.builder()
|
||||||
.startObject("gappy");
|
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_2_3_0)
|
||||||
settings.field("type", "custom");
|
.put("analysis.analyzer.gappy.type", "custom")
|
||||||
settings.field("tokenizer", "standard");
|
.put("analysis.analyzer.gappy.tokenizer", "standard")
|
||||||
settings.field("position_increment_gap", 2);
|
.put("analysis.analyzer.gappy.position_increment_gap", "2")
|
||||||
|
.build();
|
||||||
setupAnalyzer(settings, "gappy");
|
setupAnalyzer(settings, "gappy");
|
||||||
testGap(client(), "test", "test", 2);
|
testGap(client(), "test", "test", 2);
|
||||||
}
|
}
|
||||||
|
@ -123,7 +136,10 @@ 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);
|
||||||
client().admin().indices().prepareCreate("test").addMapping("test", mapping).get();
|
client().admin().indices().prepareCreate("test")
|
||||||
|
.setSettings(Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_2_3_0).build())
|
||||||
|
.addMapping("test", mapping)
|
||||||
|
.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -131,11 +147,14 @@ public class StringFieldMapperPositionIncrementGapTests extends ESSingleNodeTest
|
||||||
* named "string" that uses the specified analyzer and default
|
* named "string" that uses the specified analyzer and default
|
||||||
* position_increment_gap.
|
* position_increment_gap.
|
||||||
*/
|
*/
|
||||||
private void setupAnalyzer(XContentBuilder settings, String analyzer) throws IOException {
|
private void setupAnalyzer(Settings settings, String analyzer) throws IOException {
|
||||||
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);
|
||||||
client().admin().indices().prepareCreate("test").addMapping("test", mapping).setSettings(settings).get();
|
client().admin().indices().prepareCreate("test")
|
||||||
|
.addMapping("test", mapping)
|
||||||
|
.setSettings(settings)
|
||||||
|
.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void testGap(Client client, String indexName, String type, int positionIncrementGap) throws IOException {
|
private static void testGap(Client client, String indexName, String type, int positionIncrementGap) throws IOException {
|
||||||
|
|
|
@ -54,10 +54,10 @@ public class MultiMatchQueryTests extends ESSingleNodeTestCase {
|
||||||
" \"name\":{\n" +
|
" \"name\":{\n" +
|
||||||
" \"properties\":{\n" +
|
" \"properties\":{\n" +
|
||||||
" \"first\": {\n" +
|
" \"first\": {\n" +
|
||||||
" \"type\":\"string\"\n" +
|
" \"type\":\"text\"\n" +
|
||||||
" }," +
|
" }," +
|
||||||
" \"last\": {\n" +
|
" \"last\": {\n" +
|
||||||
" \"type\":\"string\"\n" +
|
" \"type\":\"text\"\n" +
|
||||||
" }" +
|
" }" +
|
||||||
" }" +
|
" }" +
|
||||||
" }\n" +
|
" }\n" +
|
||||||
|
|
|
@ -44,8 +44,8 @@ public class ConcurrentDynamicTemplateIT extends ESIntegTestCase {
|
||||||
final String fieldName = "field";
|
final String fieldName = "field";
|
||||||
final String mapping = "{ \"" + mappingType + "\": {" +
|
final String mapping = "{ \"" + mappingType + "\": {" +
|
||||||
"\"dynamic_templates\": ["
|
"\"dynamic_templates\": ["
|
||||||
+ "{ \"" + fieldName + "\": {" + "\"path_match\": \"*\"," + "\"mapping\": {" + "\"type\": \"string\"," + "\"store\": true,"
|
+ "{ \"" + fieldName + "\": {" + "\"path_match\": \"*\"," + "\"mapping\": {" + "\"type\": \"text\"," + "\"store\": true,"
|
||||||
+ "\"index\": \"analyzed\", \"analyzer\": \"whitespace\" } } } ] } }";
|
+ "\"analyzer\": \"whitespace\" } } } ] } }";
|
||||||
// The 'fieldNames' array is used to help with retrieval of index terms
|
// The 'fieldNames' array is used to help with retrieval of index terms
|
||||||
// after testing
|
// after testing
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase {
|
||||||
settingsBuilder()
|
settingsBuilder()
|
||||||
.put("index.number_of_shards", 1)
|
.put("index.number_of_shards", 1)
|
||||||
.put("index.number_of_replicas", 0)
|
.put("index.number_of_replicas", 0)
|
||||||
).addMapping("doc", "{\"doc\":{\"properties\":{\"body\":{\"type\":\"string\"}}}}")
|
).addMapping("doc", "{\"doc\":{\"properties\":{\"body\":{\"type\":\"text\"}}}}")
|
||||||
.execute().actionGet();
|
.execute().actionGet();
|
||||||
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
|
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase {
|
||||||
|
|
||||||
GetMappingsResponse getMappingsResponse = client().admin().indices().prepareGetMappings("test").execute().actionGet();
|
GetMappingsResponse getMappingsResponse = client().admin().indices().prepareGetMappings("test").execute().actionGet();
|
||||||
assertThat(getMappingsResponse.mappings().get("test").get("doc").source().toString(),
|
assertThat(getMappingsResponse.mappings().get("test").get("doc").source().toString(),
|
||||||
equalTo("{\"doc\":{\"properties\":{\"body\":{\"type\":\"string\"},\"date\":{\"type\":\"integer\"}}}}"));
|
equalTo("{\"doc\":{\"properties\":{\"body\":{\"type\":\"text\"},\"date\":{\"type\":\"integer\"}}}}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testUpdateMappingWithoutTypeMultiObjects() throws Exception {
|
public void testUpdateMappingWithoutTypeMultiObjects() throws Exception {
|
||||||
|
@ -141,7 +141,7 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase {
|
||||||
settingsBuilder()
|
settingsBuilder()
|
||||||
.put("index.number_of_shards", 2)
|
.put("index.number_of_shards", 2)
|
||||||
.put("index.number_of_replicas", 0)
|
.put("index.number_of_replicas", 0)
|
||||||
).addMapping("type", "{\"type\":{\"properties\":{\"body\":{\"type\":\"string\"}}}}")
|
).addMapping("type", "{\"type\":{\"properties\":{\"body\":{\"type\":\"text\"}}}}")
|
||||||
.execute().actionGet();
|
.execute().actionGet();
|
||||||
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
|
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
|
||||||
|
|
||||||
|
@ -150,17 +150,17 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase {
|
||||||
.setSource("{\"type\":{\"properties\":{\"body\":{\"type\":\"integer\"}}}}").execute().actionGet();
|
.setSource("{\"type\":{\"properties\":{\"body\":{\"type\":\"integer\"}}}}").execute().actionGet();
|
||||||
fail("Expected MergeMappingException");
|
fail("Expected MergeMappingException");
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
assertThat(e.getMessage(), containsString("mapper [body] of different type, current_type [string], merged_type [integer]"));
|
assertThat(e.getMessage(), containsString("mapper [body] of different type, current_type [text], merged_type [integer]"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testUpdateMappingWithNormsConflicts() throws Exception {
|
public void testUpdateMappingWithNormsConflicts() throws Exception {
|
||||||
client().admin().indices().prepareCreate("test")
|
client().admin().indices().prepareCreate("test")
|
||||||
.addMapping("type", "{\"type\":{\"properties\":{\"body\":{\"type\":\"string\", \"norms\": { \"enabled\": false }}}}}")
|
.addMapping("type", "{\"type\":{\"properties\":{\"body\":{\"type\":\"text\", \"norms\": { \"enabled\": false }}}}}")
|
||||||
.execute().actionGet();
|
.execute().actionGet();
|
||||||
try {
|
try {
|
||||||
client().admin().indices().preparePutMapping("test").setType("type")
|
client().admin().indices().preparePutMapping("test").setType("type")
|
||||||
.setSource("{\"type\":{\"properties\":{\"body\":{\"type\":\"string\", \"norms\": { \"enabled\": true }}}}}").execute()
|
.setSource("{\"type\":{\"properties\":{\"body\":{\"type\":\"text\", \"norms\": { \"enabled\": true }}}}}").execute()
|
||||||
.actionGet();
|
.actionGet();
|
||||||
fail("Expected MergeMappingException");
|
fail("Expected MergeMappingException");
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
|
@ -177,12 +177,12 @@ public class UpdateMappingIntegrationIT extends ESIntegTestCase {
|
||||||
settingsBuilder()
|
settingsBuilder()
|
||||||
.put("index.number_of_shards", 2)
|
.put("index.number_of_shards", 2)
|
||||||
.put("index.number_of_replicas", 0)
|
.put("index.number_of_replicas", 0)
|
||||||
).addMapping("type", "{\"type\":{\"properties\":{\"body\":{\"type\":\"string\"}}}}")
|
).addMapping("type", "{\"type\":{\"properties\":{\"body\":{\"type\":\"text\"}}}}")
|
||||||
.execute().actionGet();
|
.execute().actionGet();
|
||||||
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
|
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
|
||||||
|
|
||||||
PutMappingResponse putMappingResponse = client().admin().indices().preparePutMapping("test").setType("type")
|
PutMappingResponse putMappingResponse = client().admin().indices().preparePutMapping("test").setType("type")
|
||||||
.setSource("{\"type\":{\"properties\":{\"body\":{\"type\":\"string\"}}}}")
|
.setSource("{\"type\":{\"properties\":{\"body\":{\"type\":\"text\"}}}}")
|
||||||
.execute().actionGet();
|
.execute().actionGet();
|
||||||
|
|
||||||
//no changes, we return
|
//no changes, we return
|
||||||
|
|
|
@ -148,7 +148,7 @@ public class CircuitBreakerServiceIT extends ESIntegTestCase {
|
||||||
|
|
||||||
// Create an index where the mappings have a field data filter
|
// Create an index where the mappings have a field data filter
|
||||||
assertAcked(prepareCreate("ramtest").setSource("{\"mappings\": {\"type\": {\"properties\": {\"test\": " +
|
assertAcked(prepareCreate("ramtest").setSource("{\"mappings\": {\"type\": {\"properties\": {\"test\": " +
|
||||||
"{\"type\": \"string\",\"fielddata\": {\"filter\": {\"regex\": {\"pattern\": \"^value.*\"}}}}}}}}"));
|
"{\"type\": \"text\",\"fielddata\": {\"filter\": {\"regex\": {\"pattern\": \"^value.*\"}}}}}}}}"));
|
||||||
|
|
||||||
ensureGreen("ramtest");
|
ensureGreen("ramtest");
|
||||||
|
|
||||||
|
|
|
@ -749,7 +749,7 @@ public class IndexStatsIT extends ESIntegTestCase {
|
||||||
assertAcked(prepareCreate("test1")
|
assertAcked(prepareCreate("test1")
|
||||||
.addMapping(
|
.addMapping(
|
||||||
"bar",
|
"bar",
|
||||||
"{ \"properties\": { \"bar\": { \"type\": \"string\", \"fields\": { \"completion\": { \"type\": \"completion\" }}},\"baz\": { \"type\": \"string\", \"fields\": { \"completion\": { \"type\": \"completion\" }}}}}"));
|
"{ \"properties\": { \"bar\": { \"type\": \"text\", \"fields\": { \"completion\": { \"type\": \"completion\" }}},\"baz\": { \"type\": \"text\", \"fields\": { \"completion\": { \"type\": \"completion\" }}}}}"));
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
|
|
||||||
client().prepareIndex("test1", "bar", Integer.toString(1)).setSource("{\"bar\":\"bar\",\"baz\":\"baz\"}").execute().actionGet();
|
client().prepareIndex("test1", "bar", Integer.toString(1)).setSource("{\"bar\":\"bar\",\"baz\":\"baz\"}").execute().actionGet();
|
||||||
|
|
|
@ -345,7 +345,7 @@ public class SimpleIndexTemplateIT extends ESIntegTestCase {
|
||||||
|
|
||||||
client().admin().indices().preparePutTemplate("template_with_aliases")
|
client().admin().indices().preparePutTemplate("template_with_aliases")
|
||||||
.setTemplate("te*")
|
.setTemplate("te*")
|
||||||
.addMapping("type1", "{\"type1\" : {\"properties\" : {\"value\" : {\"type\" : \"string\"}}}}")
|
.addMapping("type1", "{\"type1\" : {\"properties\" : {\"value\" : {\"type\" : \"text\"}}}}")
|
||||||
.addAlias(new Alias("simple_alias"))
|
.addAlias(new Alias("simple_alias"))
|
||||||
.addAlias(new Alias("templated_alias-{index}"))
|
.addAlias(new Alias("templated_alias-{index}"))
|
||||||
.addAlias(new Alias("filtered_alias").filter("{\"type\":{\"value\":\"type2\"}}"))
|
.addAlias(new Alias("filtered_alias").filter("{\"type\":{\"value\":\"type2\"}}"))
|
||||||
|
|
|
@ -1683,10 +1683,10 @@ public class PercolatorIT extends ESIntegTestCase {
|
||||||
String mapping = "{\n" +
|
String mapping = "{\n" +
|
||||||
" \"doc\": {\n" +
|
" \"doc\": {\n" +
|
||||||
" \"properties\": {\n" +
|
" \"properties\": {\n" +
|
||||||
" \"name\": {\"type\":\"string\"},\n" +
|
" \"name\": {\"type\":\"text\"},\n" +
|
||||||
" \"persons\": {\n" +
|
" \"persons\": {\n" +
|
||||||
" \"type\": \"nested\"\n," +
|
" \"type\": \"nested\"\n," +
|
||||||
" \"properties\" : {\"foo\" : {\"type\" : \"string\"}}" +
|
" \"properties\" : {\"foo\" : {\"type\" : \"text\"}}" +
|
||||||
" }\n" +
|
" }\n" +
|
||||||
" }\n" +
|
" }\n" +
|
||||||
" }\n" +
|
" }\n" +
|
||||||
|
|
|
@ -61,12 +61,12 @@ public class DiversifiedSamplerIT extends ESIntegTestCase {
|
||||||
@Override
|
@Override
|
||||||
public void setupSuiteScopeCluster() throws Exception {
|
public void setupSuiteScopeCluster() throws Exception {
|
||||||
assertAcked(prepareCreate("test").setSettings(SETTING_NUMBER_OF_SHARDS, NUM_SHARDS, SETTING_NUMBER_OF_REPLICAS, 0).addMapping(
|
assertAcked(prepareCreate("test").setSettings(SETTING_NUMBER_OF_SHARDS, NUM_SHARDS, SETTING_NUMBER_OF_REPLICAS, 0).addMapping(
|
||||||
"book", "author", "type=string,index=not_analyzed", "name", "type=string,index=analyzed", "genre",
|
"book", "author", "type=keyword", "name", "type=keyword", "genre",
|
||||||
"type=string,index=not_analyzed", "price", "type=float"));
|
"type=keyword", "price", "type=float"));
|
||||||
createIndex("idx_unmapped");
|
createIndex("idx_unmapped");
|
||||||
// idx_unmapped_author is same as main index but missing author field
|
// idx_unmapped_author is same as main index but missing author field
|
||||||
assertAcked(prepareCreate("idx_unmapped_author").setSettings(SETTING_NUMBER_OF_SHARDS, NUM_SHARDS, SETTING_NUMBER_OF_REPLICAS, 0)
|
assertAcked(prepareCreate("idx_unmapped_author").setSettings(SETTING_NUMBER_OF_SHARDS, NUM_SHARDS, SETTING_NUMBER_OF_REPLICAS, 0)
|
||||||
.addMapping("book", "name", "type=string,index=analyzed", "genre", "type=string,index=not_analyzed", "price",
|
.addMapping("book", "name", "type=keyword", "genre", "type=keyword", "price",
|
||||||
"type=float"));
|
"type=float"));
|
||||||
|
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class SignificantTermsSignificanceScoreIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPlugin() throws Exception {
|
public void testPlugin() throws Exception {
|
||||||
String type = randomBoolean() ? "string" : "long";
|
String type = randomBoolean() ? "text" : "long";
|
||||||
String settings = "{\"index.number_of_shards\": 1, \"index.number_of_replicas\": 0}";
|
String settings = "{\"index.number_of_shards\": 1, \"index.number_of_replicas\": 0}";
|
||||||
SharedSignificantTermsTestMethods.index01Docs(type, settings, this);
|
SharedSignificantTermsTestMethods.index01Docs(type, settings, this);
|
||||||
SearchResponse response = client().prepareSearch(INDEX_NAME).setTypes(DOC_TYPE)
|
SearchResponse response = client().prepareSearch(INDEX_NAME).setTypes(DOC_TYPE)
|
||||||
|
@ -257,7 +257,7 @@ public class SignificantTermsSignificanceScoreIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testXContentResponse() throws Exception {
|
public void testXContentResponse() throws Exception {
|
||||||
String type = randomBoolean() ? "string" : "long";
|
String type = randomBoolean() ? "text" : "long";
|
||||||
String settings = "{\"index.number_of_shards\": 1, \"index.number_of_replicas\": 0}";
|
String settings = "{\"index.number_of_shards\": 1, \"index.number_of_replicas\": 0}";
|
||||||
SharedSignificantTermsTestMethods.index01Docs(type, settings, this);
|
SharedSignificantTermsTestMethods.index01Docs(type, settings, this);
|
||||||
SearchResponse response = client().prepareSearch(INDEX_NAME).setTypes(DOC_TYPE)
|
SearchResponse response = client().prepareSearch(INDEX_NAME).setTypes(DOC_TYPE)
|
||||||
|
@ -333,7 +333,7 @@ public class SignificantTermsSignificanceScoreIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBackgroundVsSeparateSet() throws Exception {
|
public void testBackgroundVsSeparateSet() throws Exception {
|
||||||
String type = randomBoolean() ? "string" : "long";
|
String type = randomBoolean() ? "text" : "long";
|
||||||
String settings = "{\"index.number_of_shards\": 1, \"index.number_of_replicas\": 0}";
|
String settings = "{\"index.number_of_shards\": 1, \"index.number_of_replicas\": 0}";
|
||||||
SharedSignificantTermsTestMethods.index01Docs(type, settings, this);
|
SharedSignificantTermsTestMethods.index01Docs(type, settings, this);
|
||||||
testBackgroundVsSeparateSet(new MutualInformation(true, true), new MutualInformation(true, false));
|
testBackgroundVsSeparateSet(new MutualInformation(true, true), new MutualInformation(true, false));
|
||||||
|
@ -460,7 +460,7 @@ public class SignificantTermsSignificanceScoreIT extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testScriptScore() throws ExecutionException, InterruptedException, IOException {
|
public void testScriptScore() throws ExecutionException, InterruptedException, IOException {
|
||||||
indexRandomFrequencies01(randomBoolean() ? "string" : "long");
|
indexRandomFrequencies01(randomBoolean() ? "text" : "long");
|
||||||
ScriptHeuristic scriptHeuristic = getScriptSignificanceHeuristic();
|
ScriptHeuristic scriptHeuristic = getScriptSignificanceHeuristic();
|
||||||
ensureYellow();
|
ensureYellow();
|
||||||
SearchResponse response = client().prepareSearch(INDEX_NAME)
|
SearchResponse response = client().prepareSearch(INDEX_NAME)
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class TermsShardMinDocCountIT extends ESIntegTestCase {
|
||||||
|
|
||||||
// see https://github.com/elasticsearch/elasticsearch/issues/5998
|
// see https://github.com/elasticsearch/elasticsearch/issues/5998
|
||||||
public void testShardMinDocCountSignificantTermsTest() throws Exception {
|
public void testShardMinDocCountSignificantTermsTest() throws Exception {
|
||||||
String termtype = "string";
|
String termtype = "text";
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
termtype = "long";
|
termtype = "long";
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ public class TermsShardMinDocCountIT extends ESIntegTestCase {
|
||||||
|
|
||||||
// see https://github.com/elasticsearch/elasticsearch/issues/5998
|
// see https://github.com/elasticsearch/elasticsearch/issues/5998
|
||||||
public void testShardMinDocCountTermsTest() throws Exception {
|
public void testShardMinDocCountTermsTest() throws Exception {
|
||||||
final String [] termTypes = {"string", "long", "integer", "float", "double"};
|
final String [] termTypes = {"text", "long", "integer", "float", "double"};
|
||||||
String termtype = termTypes[randomInt(termTypes.length - 1)];
|
String termtype = termTypes[randomInt(termTypes.length - 1)];
|
||||||
|
|
||||||
assertAcked(prepareCreate(index).setSettings(SETTING_NUMBER_OF_SHARDS, 1, SETTING_NUMBER_OF_REPLICAS, 0).addMapping(type, "{\"properties\":{\"text\": {\"type\": \"" + termtype + "\"}}}"));
|
assertAcked(prepareCreate(index).setSettings(SETTING_NUMBER_OF_SHARDS, 1, SETTING_NUMBER_OF_REPLICAS, 0).addMapping(type, "{\"properties\":{\"text\": {\"type\": \"" + termtype + "\"}}}"));
|
||||||
|
|
|
@ -1078,7 +1078,7 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
|
||||||
// Issue #3818
|
// Issue #3818
|
||||||
public void testHasChildQueryOnlyReturnsSingleChildType() {
|
public void testHasChildQueryOnlyReturnsSingleChildType() {
|
||||||
assertAcked(prepareCreate("grandissue")
|
assertAcked(prepareCreate("grandissue")
|
||||||
.addMapping("grandparent", "name", "type=string")
|
.addMapping("grandparent", "name", "type=text")
|
||||||
.addMapping("parent", "_parent", "type=grandparent")
|
.addMapping("parent", "_parent", "type=grandparent")
|
||||||
.addMapping("child_type_one", "_parent", "type=parent")
|
.addMapping("child_type_one", "_parent", "type=parent")
|
||||||
.addMapping("child_type_two", "_parent", "type=parent"));
|
.addMapping("child_type_two", "_parent", "type=parent"));
|
||||||
|
|
|
@ -638,7 +638,7 @@ public class DecayFunctionScoreIT extends ESIntegTestCase {
|
||||||
public void testParsingExceptionIfFieldDoesNotExist() throws Exception {
|
public void testParsingExceptionIfFieldDoesNotExist() throws Exception {
|
||||||
assertAcked(prepareCreate("test").addMapping(
|
assertAcked(prepareCreate("test").addMapping(
|
||||||
"type",
|
"type",
|
||||||
jsonBuilder().startObject().startObject("type").startObject("properties").startObject("test").field("type", "string")
|
jsonBuilder().startObject().startObject("type").startObject("properties").startObject("test").field("type", "text")
|
||||||
.endObject().startObject("geo").field("type", "geo_point").endObject().endObject().endObject().endObject()));
|
.endObject().startObject("geo").field("type", "geo_point").endObject().endObject().endObject().endObject()));
|
||||||
ensureYellow();
|
ensureYellow();
|
||||||
int numDocs = 2;
|
int numDocs = 2;
|
||||||
|
|
|
@ -113,55 +113,6 @@ public class HighlighterSearchIT extends ESIntegTestCase {
|
||||||
assertHighlight(search, 0, "text", 0, equalTo("<em>text</em>"));
|
assertHighlight(search, 0, "text", 0, equalTo("<em>text</em>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPlainHighlighterWithLongUnanalyzedStringTerm() throws IOException {
|
|
||||||
XContentBuilder mappings = jsonBuilder();
|
|
||||||
mappings.startObject();
|
|
||||||
mappings.startObject("type")
|
|
||||||
.startObject("properties")
|
|
||||||
.startObject("long_text")
|
|
||||||
.field("type", "string")
|
|
||||||
.field("analyzer", "keyword")
|
|
||||||
.field("index_options", "offsets")
|
|
||||||
.field("term_vector", "with_positions_offsets")
|
|
||||||
.field("ignore_above", 1)
|
|
||||||
.endObject()
|
|
||||||
.startObject("text")
|
|
||||||
.field("type", "text")
|
|
||||||
.field("analyzer", "keyword")
|
|
||||||
.field("index_options", "offsets")
|
|
||||||
.field("term_vector", "with_positions_offsets")
|
|
||||||
.endObject()
|
|
||||||
.endObject()
|
|
||||||
.endObject();
|
|
||||||
mappings.endObject();
|
|
||||||
assertAcked(prepareCreate("test")
|
|
||||||
.addMapping("type", mappings));
|
|
||||||
ensureYellow();
|
|
||||||
// crate a term that is larger than the allowed 32766, index it and then try highlight on it
|
|
||||||
// the search request should still succeed
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
for (int i = 0; i < 32767; i++) {
|
|
||||||
builder.append('a');
|
|
||||||
}
|
|
||||||
client().prepareIndex("test", "type", "1")
|
|
||||||
.setSource(jsonBuilder().startObject().field("long_text", builder.toString()).field("text", "text").endObject())
|
|
||||||
.get();
|
|
||||||
refresh();
|
|
||||||
String highlighter = randomFrom("plain", "postings", "fvh");
|
|
||||||
SearchResponse search = client().prepareSearch().setQuery(constantScoreQuery(matchQuery("text", "text")))
|
|
||||||
.highlighter(new HighlightBuilder().field(new Field("*").highlighterType(highlighter))).get();
|
|
||||||
assertHighlight(search, 0, "text", 0, equalTo("<em>text</em>"));
|
|
||||||
search = client().prepareSearch().setQuery(constantScoreQuery(matchQuery("text", "text")))
|
|
||||||
.highlighter(new HighlightBuilder().field(new Field("long_text").highlighterType(highlighter))).get();
|
|
||||||
assertNoFailures(search);
|
|
||||||
assertThat(search.getHits().getAt(0).getHighlightFields().size(), equalTo(0));
|
|
||||||
|
|
||||||
search = client().prepareSearch().setQuery(prefixQuery("text", "te"))
|
|
||||||
.highlighter(new HighlightBuilder().field(new Field("long_text").highlighterType(highlighter))).get();
|
|
||||||
assertNoFailures(search);
|
|
||||||
assertThat(search.getHits().getAt(0).getHighlightFields().size(), equalTo(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testHighlightingWhenFieldsAreNotStoredThereIsNoSource() throws IOException {
|
public void testHighlightingWhenFieldsAreNotStoredThereIsNoSource() throws IOException {
|
||||||
XContentBuilder mappings = jsonBuilder();
|
XContentBuilder mappings = jsonBuilder();
|
||||||
mappings.startObject();
|
mappings.startObject();
|
||||||
|
|
|
@ -180,41 +180,6 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIssue6639() throws ExecutionException, InterruptedException {
|
|
||||||
assertAcked(prepareCreate("$index")
|
|
||||||
.addMapping(
|
|
||||||
"$type",
|
|
||||||
"{\"$type\": "
|
|
||||||
+ " {\"properties\": "
|
|
||||||
+ " {\"grantee\": "
|
|
||||||
+ " { \"index\": \"not_analyzed\", "
|
|
||||||
+ " \"term_vector\": \"with_positions_offsets\", "
|
|
||||||
+ " \"type\": \"string\", "
|
|
||||||
+ " \"analyzer\": \"snowball\", "
|
|
||||||
+ " \"boost\": 1.0, "
|
|
||||||
+ " \"store\": true}}}}"));
|
|
||||||
indexRandom(true,
|
|
||||||
client().prepareIndex(
|
|
||||||
"$index",
|
|
||||||
"$type",
|
|
||||||
"data.activity.5").setSource("{\"django_ct\": \"data.activity\", \"grantee\": \"Grantee 1\"}"),
|
|
||||||
client().prepareIndex(
|
|
||||||
"$index",
|
|
||||||
"$type",
|
|
||||||
"data.activity.6").setSource("{\"django_ct\": \"data.activity\", \"grantee\": \"Grantee 2\"}"));
|
|
||||||
ensureYellow();
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort("grantee", SortOrder.ASC)
|
|
||||||
.execute().actionGet();
|
|
||||||
assertOrderedSearchHits(searchResponse, "data.activity.5", "data.activity.6");
|
|
||||||
searchResponse = client().prepareSearch()
|
|
||||||
.setQuery(matchAllQuery())
|
|
||||||
.addSort("grantee", SortOrder.DESC)
|
|
||||||
.execute().actionGet();
|
|
||||||
assertOrderedSearchHits(searchResponse, "data.activity.6", "data.activity.5");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testTrackScores() throws Exception {
|
public void testTrackScores() throws Exception {
|
||||||
createIndex("test");
|
createIndex("test");
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
|
@ -928,7 +893,7 @@ public class FieldSortIT extends ESIntegTestCase {
|
||||||
|
|
||||||
SearchResponse searchResponse = client().prepareSearch()
|
SearchResponse searchResponse = client().prepareSearch()
|
||||||
.setQuery(matchAllQuery())
|
.setQuery(matchAllQuery())
|
||||||
.addSort(SortBuilders.fieldSort("kkk").unmappedType("string"))
|
.addSort(SortBuilders.fieldSort("kkk").unmappedType("keyword"))
|
||||||
.execute().actionGet();
|
.execute().actionGet();
|
||||||
assertNoFailures(searchResponse);
|
assertNoFailures(searchResponse);
|
||||||
}
|
}
|
||||||
|
|
|
@ -280,7 +280,7 @@ public class GeoDistanceSortBuilderIT extends ESIntegTestCase {
|
||||||
|
|
||||||
public void testCrossIndexIgnoreUnmapped() throws Exception {
|
public void testCrossIndexIgnoreUnmapped() throws Exception {
|
||||||
assertAcked(prepareCreate("test1").addMapping(
|
assertAcked(prepareCreate("test1").addMapping(
|
||||||
"type", "str_field1", "type=text",
|
"type", "str_field1", "type=keyword",
|
||||||
"long_field", "type=long",
|
"long_field", "type=long",
|
||||||
"double_field", "type=double").get());
|
"double_field", "type=double").get());
|
||||||
assertAcked(prepareCreate("test2").get());
|
assertAcked(prepareCreate("test2").get());
|
||||||
|
@ -292,8 +292,8 @@ public class GeoDistanceSortBuilderIT extends ESIntegTestCase {
|
||||||
ensureYellow("test1", "test2");
|
ensureYellow("test1", "test2");
|
||||||
|
|
||||||
SearchResponse resp = client().prepareSearch("test1", "test2")
|
SearchResponse resp = client().prepareSearch("test1", "test2")
|
||||||
.addSort(fieldSort("str_field").order(SortOrder.ASC).unmappedType("string"))
|
.addSort(fieldSort("str_field").order(SortOrder.ASC).unmappedType("keyword"))
|
||||||
.addSort(fieldSort("str_field2").order(SortOrder.DESC).unmappedType("string")).get();
|
.addSort(fieldSort("str_field2").order(SortOrder.DESC).unmappedType("keyword")).get();
|
||||||
|
|
||||||
assertSortValues(resp,
|
assertSortValues(resp,
|
||||||
new Object[] {new Text("bcd"), null},
|
new Object[] {new Text("bcd"), null},
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class SharedSignificantTermsTestMethods {
|
||||||
public static final String CLASS_FIELD = "class";
|
public static final String CLASS_FIELD = "class";
|
||||||
|
|
||||||
public static void aggregateAndCheckFromSeveralShards(ESIntegTestCase testCase) throws ExecutionException, InterruptedException {
|
public static void aggregateAndCheckFromSeveralShards(ESIntegTestCase testCase) throws ExecutionException, InterruptedException {
|
||||||
String type = ESTestCase.randomBoolean() ? "string" : "long";
|
String type = ESTestCase.randomBoolean() ? "text" : "long";
|
||||||
String settings = "{\"index.number_of_shards\": 5, \"index.number_of_replicas\": 0}";
|
String settings = "{\"index.number_of_shards\": 5, \"index.number_of_replicas\": 0}";
|
||||||
index01Docs(type, settings, testCase);
|
index01Docs(type, settings, testCase);
|
||||||
testCase.ensureGreen();
|
testCase.ensureGreen();
|
||||||
|
|
|
@ -6,12 +6,12 @@
|
||||||
"match":"multi*",
|
"match":"multi*",
|
||||||
"mapping":{
|
"mapping":{
|
||||||
"type":"{dynamic_type}",
|
"type":"{dynamic_type}",
|
||||||
"index":"analyzed",
|
"index":true,
|
||||||
"store":true,
|
"store":true,
|
||||||
"fields":{
|
"fields":{
|
||||||
"org":{
|
"org":{
|
||||||
"type":"{dynamic_type}",
|
"type":"keyword",
|
||||||
"index":"not_analyzed",
|
"index":true,
|
||||||
"store":true
|
"store":true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,10 +69,10 @@ public class CardinalityTests extends ESIntegTestCase {
|
||||||
prepareCreate("idx").addMapping("type",
|
prepareCreate("idx").addMapping("type",
|
||||||
jsonBuilder().startObject().startObject("type").startObject("properties")
|
jsonBuilder().startObject().startObject("type").startObject("properties")
|
||||||
.startObject("str_value")
|
.startObject("str_value")
|
||||||
.field("type", "string")
|
.field("type", "keyword")
|
||||||
.endObject()
|
.endObject()
|
||||||
.startObject("str_values")
|
.startObject("str_values")
|
||||||
.field("type", "string")
|
.field("type", "keyword")
|
||||||
.endObject()
|
.endObject()
|
||||||
.startObject("l_value")
|
.startObject("l_value")
|
||||||
.field("type", "long")
|
.field("type", "long")
|
||||||
|
|
|
@ -136,7 +136,7 @@ public class IndexLookupTests extends ESIntegTestCase {
|
||||||
expectedEndOffsetsArray.put("3", ends3);
|
expectedEndOffsetsArray.put("3", ends3);
|
||||||
|
|
||||||
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties")
|
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties")
|
||||||
.startObject("int_payload_field").field("type", "string").field("index_options", "offsets")
|
.startObject("int_payload_field").field("type", "text").field("index_options", "offsets")
|
||||||
.field("analyzer", "payload_int").endObject().endObject().endObject().endObject();
|
.field("analyzer", "payload_int").endObject().endObject().endObject().endObject();
|
||||||
assertAcked(prepareCreate("test").addMapping("type1", mapping).setSettings(
|
assertAcked(prepareCreate("test").addMapping("type1", mapping).setSettings(
|
||||||
Settings.settingsBuilder()
|
Settings.settingsBuilder()
|
||||||
|
@ -399,10 +399,10 @@ public class IndexLookupTests extends ESIntegTestCase {
|
||||||
|
|
||||||
public void testAllExceptPosAndOffset() throws Exception {
|
public void testAllExceptPosAndOffset() throws Exception {
|
||||||
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties")
|
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("properties")
|
||||||
.startObject("float_payload_field").field("type", "string").field("index_options", "offsets").field("term_vector", "no")
|
.startObject("float_payload_field").field("type", "text").field("index_options", "offsets").field("term_vector", "no")
|
||||||
.field("analyzer", "payload_float").endObject().startObject("string_payload_field").field("type", "string")
|
.field("analyzer", "payload_float").endObject().startObject("string_payload_field").field("type", "text")
|
||||||
.field("index_options", "offsets").field("term_vector", "no").field("analyzer", "payload_string").endObject()
|
.field("index_options", "offsets").field("term_vector", "no").field("analyzer", "payload_string").endObject()
|
||||||
.startObject("int_payload_field").field("type", "string").field("index_options", "offsets")
|
.startObject("int_payload_field").field("type", "text").field("index_options", "offsets")
|
||||||
.field("analyzer", "payload_int").endObject().endObject().endObject().endObject();
|
.field("analyzer", "payload_int").endObject().endObject().endObject().endObject();
|
||||||
assertAcked(prepareCreate("test").addMapping("type1", mapping).setSettings(
|
assertAcked(prepareCreate("test").addMapping("type1", mapping).setSettings(
|
||||||
Settings.settingsBuilder()
|
Settings.settingsBuilder()
|
||||||
|
|
|
@ -552,7 +552,7 @@ public class IndicesRequestTests extends ESIntegTestCase {
|
||||||
public void testPutMapping() {
|
public void testPutMapping() {
|
||||||
interceptTransportActions(PutMappingAction.NAME);
|
interceptTransportActions(PutMappingAction.NAME);
|
||||||
|
|
||||||
PutMappingRequest putMappingRequest = new PutMappingRequest(randomUniqueIndicesOrAliases()).type("type").source("field", "type=string");
|
PutMappingRequest putMappingRequest = new PutMappingRequest(randomUniqueIndicesOrAliases()).type("type").source("field", "type=text");
|
||||||
internalCluster().clientNodeClient().admin().indices().putMapping(putMappingRequest).actionGet();
|
internalCluster().clientNodeClient().admin().indices().putMapping(putMappingRequest).actionGet();
|
||||||
|
|
||||||
clearInterceptedActions();
|
clearInterceptedActions();
|
||||||
|
|
|
@ -123,7 +123,7 @@ public class RandomScoreFunctionTests extends ESIntegTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testScoreAccessWithinScript() throws Exception {
|
public void testScoreAccessWithinScript() throws Exception {
|
||||||
assertAcked(prepareCreate("test").addMapping("type", "body", "type=string", "index",
|
assertAcked(prepareCreate("test").addMapping("type", "body", "type=text", "index",
|
||||||
"type=" + randomFrom("short", "float", "long", "integer", "double")));
|
"type=" + randomFrom("short", "float", "long", "integer", "double")));
|
||||||
ensureYellow();
|
ensureYellow();
|
||||||
|
|
||||||
|
|
|
@ -87,9 +87,9 @@ public class SearchFieldsTests extends ESIntegTestCase {
|
||||||
// _timestamp is randomly enabled via templates but we don't want it here to test stored fields behaviour
|
// _timestamp is randomly enabled via templates but we don't want it here to test stored fields behaviour
|
||||||
.startObject("_timestamp").field("enabled", false).endObject()
|
.startObject("_timestamp").field("enabled", false).endObject()
|
||||||
.startObject("properties")
|
.startObject("properties")
|
||||||
.startObject("field1").field("type", "string").field("store", true).endObject()
|
.startObject("field1").field("type", "text").field("store", true).endObject()
|
||||||
.startObject("field2").field("type", "string").field("store", false).endObject()
|
.startObject("field2").field("type", "text").field("store", false).endObject()
|
||||||
.startObject("field3").field("type", "string").field("store", true).endObject()
|
.startObject("field3").field("type", "text").field("store", true).endObject()
|
||||||
.endObject().endObject().endObject().string();
|
.endObject().endObject().endObject().string();
|
||||||
|
|
||||||
client().admin().indices().preparePutMapping().setType("type1").setSource(mapping).execute().actionGet();
|
client().admin().indices().preparePutMapping().setType("type1").setSource(mapping).execute().actionGet();
|
||||||
|
@ -487,7 +487,7 @@ public class SearchFieldsTests extends ESIntegTestCase {
|
||||||
.startObject("field1").field("type", "object").startObject("properties")
|
.startObject("field1").field("type", "object").startObject("properties")
|
||||||
.startObject("field2").field("type", "object").startObject("properties")
|
.startObject("field2").field("type", "object").startObject("properties")
|
||||||
.startObject("field3").field("type", "object").startObject("properties")
|
.startObject("field3").field("type", "object").startObject("properties")
|
||||||
.startObject("field4").field("type", "string").field("store", true)
|
.startObject("field4").field("type", "text").field("store", true)
|
||||||
.endObject().endObject()
|
.endObject().endObject()
|
||||||
.endObject().endObject()
|
.endObject().endObject()
|
||||||
.endObject().endObject()
|
.endObject().endObject()
|
||||||
|
@ -554,7 +554,8 @@ public class SearchFieldsTests extends ESIntegTestCase {
|
||||||
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForYellowStatus().execute().actionGet();
|
client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForYellowStatus().execute().actionGet();
|
||||||
|
|
||||||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("_source").field("enabled", false).endObject().startObject("properties")
|
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type1").startObject("_source").field("enabled", false).endObject().startObject("properties")
|
||||||
.startObject("string_field").field("type", "string").endObject()
|
.startObject("text_field").field("type", "text").endObject()
|
||||||
|
.startObject("keyword_field").field("type", "keyword").endObject()
|
||||||
.startObject("byte_field").field("type", "byte").endObject()
|
.startObject("byte_field").field("type", "byte").endObject()
|
||||||
.startObject("short_field").field("type", "short").endObject()
|
.startObject("short_field").field("type", "short").endObject()
|
||||||
.startObject("integer_field").field("type", "integer").endObject()
|
.startObject("integer_field").field("type", "integer").endObject()
|
||||||
|
@ -569,7 +570,8 @@ public class SearchFieldsTests extends ESIntegTestCase {
|
||||||
client().admin().indices().preparePutMapping().setType("type1").setSource(mapping).execute().actionGet();
|
client().admin().indices().preparePutMapping().setType("type1").setSource(mapping).execute().actionGet();
|
||||||
|
|
||||||
client().prepareIndex("test", "type1", "1").setSource(jsonBuilder().startObject()
|
client().prepareIndex("test", "type1", "1").setSource(jsonBuilder().startObject()
|
||||||
.field("string_field", "foo")
|
.field("text_field", "foo")
|
||||||
|
.field("keyword_field", "foo")
|
||||||
.field("byte_field", (byte) 1)
|
.field("byte_field", (byte) 1)
|
||||||
.field("short_field", (short) 2)
|
.field("short_field", (short) 2)
|
||||||
.field("integer_field", 3)
|
.field("integer_field", 3)
|
||||||
|
@ -583,7 +585,8 @@ public class SearchFieldsTests extends ESIntegTestCase {
|
||||||
client().admin().indices().prepareRefresh().execute().actionGet();
|
client().admin().indices().prepareRefresh().execute().actionGet();
|
||||||
|
|
||||||
SearchRequestBuilder builder = client().prepareSearch().setQuery(matchAllQuery())
|
SearchRequestBuilder builder = client().prepareSearch().setQuery(matchAllQuery())
|
||||||
.addFieldDataField("string_field")
|
.addFieldDataField("text_field")
|
||||||
|
.addFieldDataField("keyword_field")
|
||||||
.addFieldDataField("byte_field")
|
.addFieldDataField("byte_field")
|
||||||
.addFieldDataField("short_field")
|
.addFieldDataField("short_field")
|
||||||
.addFieldDataField("integer_field")
|
.addFieldDataField("integer_field")
|
||||||
|
@ -599,7 +602,7 @@ public class SearchFieldsTests extends ESIntegTestCase {
|
||||||
Set<String> fields = new HashSet<>(searchResponse.getHits().getAt(0).fields().keySet());
|
Set<String> fields = new HashSet<>(searchResponse.getHits().getAt(0).fields().keySet());
|
||||||
fields.remove(TimestampFieldMapper.NAME); // randomly enabled via templates
|
fields.remove(TimestampFieldMapper.NAME); // randomly enabled via templates
|
||||||
assertThat(fields, equalTo(newHashSet("byte_field", "short_field", "integer_field", "long_field",
|
assertThat(fields, equalTo(newHashSet("byte_field", "short_field", "integer_field", "long_field",
|
||||||
"float_field", "double_field", "date_field", "boolean_field", "string_field")));
|
"float_field", "double_field", "date_field", "boolean_field", "text_field", "keyword_field")));
|
||||||
|
|
||||||
assertThat(searchResponse.getHits().getAt(0).fields().get("byte_field").value().toString(), equalTo("1"));
|
assertThat(searchResponse.getHits().getAt(0).fields().get("byte_field").value().toString(), equalTo("1"));
|
||||||
assertThat(searchResponse.getHits().getAt(0).fields().get("short_field").value().toString(), equalTo("2"));
|
assertThat(searchResponse.getHits().getAt(0).fields().get("short_field").value().toString(), equalTo("2"));
|
||||||
|
@ -609,7 +612,8 @@ public class SearchFieldsTests extends ESIntegTestCase {
|
||||||
assertThat(searchResponse.getHits().getAt(0).fields().get("double_field").value(), equalTo((Object) 6.0d));
|
assertThat(searchResponse.getHits().getAt(0).fields().get("double_field").value(), equalTo((Object) 6.0d));
|
||||||
assertThat(searchResponse.getHits().getAt(0).fields().get("date_field").value(), equalTo((Object) 1332374400000L));
|
assertThat(searchResponse.getHits().getAt(0).fields().get("date_field").value(), equalTo((Object) 1332374400000L));
|
||||||
assertThat(searchResponse.getHits().getAt(0).fields().get("boolean_field").value(), equalTo((Object) 1L));
|
assertThat(searchResponse.getHits().getAt(0).fields().get("boolean_field").value(), equalTo((Object) 1L));
|
||||||
|
assertThat(searchResponse.getHits().getAt(0).fields().get("text_field").value(), equalTo("foo"));
|
||||||
|
assertThat(searchResponse.getHits().getAt(0).fields().get("keyword_field").value(), equalTo("foo"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testScriptFields() throws Exception {
|
public void testScriptFields() throws Exception {
|
||||||
|
|
|
@ -138,7 +138,7 @@ public class SimpleSortTests extends ESIntegTestCase {
|
||||||
String mapping = jsonBuilder().startObject().startObject("type1").startObject("properties")
|
String mapping = jsonBuilder().startObject().startObject("type1").startObject("properties")
|
||||||
.startObject("lvalue").field("type", "long").endObject()
|
.startObject("lvalue").field("type", "long").endObject()
|
||||||
.startObject("dvalue").field("type", "double").endObject()
|
.startObject("dvalue").field("type", "double").endObject()
|
||||||
.startObject("svalue").field("type", "string").endObject()
|
.startObject("svalue").field("type", "keyword").endObject()
|
||||||
.startObject("gvalue").field("type", "geo_point").endObject()
|
.startObject("gvalue").field("type", "geo_point").endObject()
|
||||||
.endObject().endObject().endObject().string();
|
.endObject().endObject().endObject().string();
|
||||||
assertAcked(prepareCreate("test").addMapping("type1", mapping));
|
assertAcked(prepareCreate("test").addMapping("type1", mapping));
|
||||||
|
@ -317,7 +317,7 @@ public class SimpleSortTests extends ESIntegTestCase {
|
||||||
public void test2920() throws IOException {
|
public void test2920() throws IOException {
|
||||||
assertAcked(prepareCreate("test").addMapping(
|
assertAcked(prepareCreate("test").addMapping(
|
||||||
"test",
|
"test",
|
||||||
jsonBuilder().startObject().startObject("test").startObject("properties").startObject("value").field("type", "string")
|
jsonBuilder().startObject().startObject("test").startObject("properties").startObject("value").field("type", "keyword")
|
||||||
.endObject().endObject().endObject().endObject()));
|
.endObject().endObject().endObject().endObject()));
|
||||||
ensureGreen();
|
ensureGreen();
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
|
|
|
@ -124,7 +124,7 @@ public class SuggestSearchTests extends ESIntegTestCase {
|
||||||
|
|
||||||
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
|
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
|
||||||
.startObject("properties")
|
.startObject("properties")
|
||||||
.startObject("text").field("type", "string").field("analyzer", "keyword").endObject()
|
.startObject("text").field("type", "text").field("analyzer", "keyword").endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject().endObject();
|
.endObject().endObject();
|
||||||
assertAcked(prepareCreate("test_2").addMapping("type1", mapping));
|
assertAcked(prepareCreate("test_2").addMapping("type1", mapping));
|
||||||
|
@ -193,10 +193,10 @@ public class SuggestSearchTests extends ESIntegTestCase {
|
||||||
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
|
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
|
||||||
.startObject("properties")
|
.startObject("properties")
|
||||||
.startObject("name")
|
.startObject("name")
|
||||||
.field("type", "string")
|
.field("type", "text")
|
||||||
.startObject("fields")
|
.startObject("fields")
|
||||||
.startObject("shingled")
|
.startObject("shingled")
|
||||||
.field("type", "string")
|
.field("type", "text")
|
||||||
.field("analyzer", "biword")
|
.field("analyzer", "biword")
|
||||||
.field("search_analyzer", "standard")
|
.field("search_analyzer", "standard")
|
||||||
.endObject()
|
.endObject()
|
||||||
|
@ -264,10 +264,10 @@ public class SuggestSearchTests extends ESIntegTestCase {
|
||||||
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
|
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
|
||||||
.startObject("properties")
|
.startObject("properties")
|
||||||
.startObject("name")
|
.startObject("name")
|
||||||
.field("type", "string")
|
.field("type", "text")
|
||||||
.startObject("fields")
|
.startObject("fields")
|
||||||
.startObject("shingled")
|
.startObject("shingled")
|
||||||
.field("type", "string")
|
.field("type", "text")
|
||||||
.field("analyzer", "biword")
|
.field("analyzer", "biword")
|
||||||
.field("search_analyzer", "standard")
|
.field("search_analyzer", "standard")
|
||||||
.endObject()
|
.endObject()
|
||||||
|
@ -426,7 +426,7 @@ public class SuggestSearchTests extends ESIntegTestCase {
|
||||||
|
|
||||||
// see #2817
|
// see #2817
|
||||||
public void testStopwordsOnlyPhraseSuggest() throws IOException {
|
public void testStopwordsOnlyPhraseSuggest() throws IOException {
|
||||||
assertAcked(prepareCreate("test").addMapping("typ1", "body", "type=string,analyzer=stopwd").setSettings(
|
assertAcked(prepareCreate("test").addMapping("typ1", "body", "type=text,analyzer=stopwd").setSettings(
|
||||||
settingsBuilder()
|
settingsBuilder()
|
||||||
.put("index.analysis.analyzer.stopwd.tokenizer", "whitespace")
|
.put("index.analysis.analyzer.stopwd.tokenizer", "whitespace")
|
||||||
.putArray("index.analysis.analyzer.stopwd.filter", "stop")
|
.putArray("index.analysis.analyzer.stopwd.filter", "stop")
|
||||||
|
@ -458,9 +458,9 @@ public class SuggestSearchTests extends ESIntegTestCase {
|
||||||
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
|
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type1")
|
||||||
.startObject("_all").field("store", true).field("termVector", "with_positions_offsets").endObject()
|
.startObject("_all").field("store", true).field("termVector", "with_positions_offsets").endObject()
|
||||||
.startObject("properties")
|
.startObject("properties")
|
||||||
.startObject("body").field("type", "string").field("analyzer", "body").endObject()
|
.startObject("body").field("type", "text").field("analyzer", "body").endObject()
|
||||||
.startObject("body_reverse").field("type", "string").field("analyzer", "reverse").endObject()
|
.startObject("body_reverse").field("type", "text").field("analyzer", "reverse").endObject()
|
||||||
.startObject("bigram").field("type", "string").field("analyzer", "bigram").endObject()
|
.startObject("bigram").field("type", "text").field("analyzer", "bigram").endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject().endObject();
|
.endObject().endObject();
|
||||||
assertAcked(builder.addMapping("type1", mapping));
|
assertAcked(builder.addMapping("type1", mapping));
|
||||||
|
@ -505,15 +505,15 @@ public class SuggestSearchTests extends ESIntegTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.startObject("properties")
|
.startObject("properties")
|
||||||
.startObject("body").
|
.startObject("body").
|
||||||
field("type", "string").
|
field("type", "text").
|
||||||
field("analyzer", "body")
|
field("analyzer", "body")
|
||||||
.endObject()
|
.endObject()
|
||||||
.startObject("body_reverse").
|
.startObject("body_reverse").
|
||||||
field("type", "string").
|
field("type", "text").
|
||||||
field("analyzer", "reverse")
|
field("analyzer", "reverse")
|
||||||
.endObject()
|
.endObject()
|
||||||
.startObject("bigram").
|
.startObject("bigram").
|
||||||
field("type", "string").
|
field("type", "text").
|
||||||
field("analyzer", "bigram")
|
field("analyzer", "bigram")
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
|
@ -640,15 +640,15 @@ public class SuggestSearchTests extends ESIntegTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.startObject("properties")
|
.startObject("properties")
|
||||||
.startObject("body")
|
.startObject("body")
|
||||||
.field("type", "string")
|
.field("type", "text")
|
||||||
.field("analyzer", "body")
|
.field("analyzer", "body")
|
||||||
.endObject()
|
.endObject()
|
||||||
.startObject("body_reverse")
|
.startObject("body_reverse")
|
||||||
.field("type", "string")
|
.field("type", "text")
|
||||||
.field("analyzer", "reverse")
|
.field("analyzer", "reverse")
|
||||||
.endObject()
|
.endObject()
|
||||||
.startObject("bigram")
|
.startObject("bigram")
|
||||||
.field("type", "string")
|
.field("type", "text")
|
||||||
.field("analyzer", "bigram")
|
.field("analyzer", "bigram")
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
|
@ -707,9 +707,9 @@ public class SuggestSearchTests extends ESIntegTestCase {
|
||||||
.startObject().startObject("type1")
|
.startObject().startObject("type1")
|
||||||
.startObject("_all").field("store", true).field("termVector", "with_positions_offsets").endObject()
|
.startObject("_all").field("store", true).field("termVector", "with_positions_offsets").endObject()
|
||||||
.startObject("properties")
|
.startObject("properties")
|
||||||
.startObject("body").field("type", "string").field("analyzer", "body").endObject()
|
.startObject("body").field("type", "text").field("analyzer", "body").endObject()
|
||||||
.startObject("bigram").field("type", "string").field("analyzer", "bigram").endObject()
|
.startObject("bigram").field("type", "text").field("analyzer", "bigram").endObject()
|
||||||
.startObject("ngram").field("type", "string").field("analyzer", "ngram").endObject()
|
.startObject("ngram").field("type", "text").field("analyzer", "ngram").endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject().endObject();
|
.endObject().endObject();
|
||||||
assertAcked(builder.addMapping("type1", mapping));
|
assertAcked(builder.addMapping("type1", mapping));
|
||||||
|
@ -802,7 +802,7 @@ public class SuggestSearchTests extends ESIntegTestCase {
|
||||||
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type2")
|
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type2")
|
||||||
.startObject("properties")
|
.startObject("properties")
|
||||||
.startObject("name")
|
.startObject("name")
|
||||||
.field("type", "string")
|
.field("type", "text")
|
||||||
.field("analyzer", "suggest")
|
.field("analyzer", "suggest")
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
|
@ -844,7 +844,7 @@ public class SuggestSearchTests extends ESIntegTestCase {
|
||||||
startObject("type1").
|
startObject("type1").
|
||||||
startObject("properties").
|
startObject("properties").
|
||||||
startObject("name").
|
startObject("name").
|
||||||
field("type", "string").
|
field("type", "text").
|
||||||
field("analyzer", "suggest").
|
field("analyzer", "suggest").
|
||||||
endObject().
|
endObject().
|
||||||
endObject().
|
endObject().
|
||||||
|
@ -903,7 +903,7 @@ public class SuggestSearchTests extends ESIntegTestCase {
|
||||||
.endObject()
|
.endObject()
|
||||||
.startObject("properties")
|
.startObject("properties")
|
||||||
.startObject("body")
|
.startObject("body")
|
||||||
.field("type", "string")
|
.field("type", "text")
|
||||||
.field("analyzer", "body")
|
.field("analyzer", "body")
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
|
@ -961,7 +961,7 @@ public class SuggestSearchTests extends ESIntegTestCase {
|
||||||
.startObject("type1")
|
.startObject("type1")
|
||||||
.startObject("properties")
|
.startObject("properties")
|
||||||
.startObject("title")
|
.startObject("title")
|
||||||
.field("type", "string")
|
.field("type", "text")
|
||||||
.field("analyzer", "text")
|
.field("analyzer", "text")
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
|
@ -1106,7 +1106,7 @@ public class SuggestSearchTests extends ESIntegTestCase {
|
||||||
.startObject("type1")
|
.startObject("type1")
|
||||||
.startObject("properties")
|
.startObject("properties")
|
||||||
.startObject("title")
|
.startObject("title")
|
||||||
.field("type", "string")
|
.field("type", "text")
|
||||||
.field("analyzer", "text")
|
.field("analyzer", "text")
|
||||||
.endObject()
|
.endObject()
|
||||||
.endObject()
|
.endObject()
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
type:
|
type:
|
||||||
properties:
|
properties:
|
||||||
text:
|
text:
|
||||||
type: string
|
type: text
|
||||||
analyzer: my_analyzer
|
analyzer: my_analyzer
|
||||||
- do:
|
- do:
|
||||||
cluster.health:
|
cluster.health:
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
type:
|
type:
|
||||||
properties:
|
properties:
|
||||||
text:
|
text:
|
||||||
type: string
|
type: text
|
||||||
analyzer: kuromoji
|
analyzer: kuromoji
|
||||||
- do:
|
- do:
|
||||||
cluster.health:
|
cluster.health:
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
type:
|
type:
|
||||||
properties:
|
properties:
|
||||||
text:
|
text:
|
||||||
type: string
|
type: text
|
||||||
analyzer: my_analyzer
|
analyzer: my_analyzer
|
||||||
- do:
|
- do:
|
||||||
cluster.health:
|
cluster.health:
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
type:
|
type:
|
||||||
properties:
|
properties:
|
||||||
text:
|
text:
|
||||||
type: string
|
type: text
|
||||||
analyzer: smartcn
|
analyzer: smartcn
|
||||||
- do:
|
- do:
|
||||||
cluster.health:
|
cluster.health:
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
type:
|
type:
|
||||||
properties:
|
properties:
|
||||||
text:
|
text:
|
||||||
type: string
|
type: text
|
||||||
analyzer: polish
|
analyzer: polish
|
||||||
- do:
|
- do:
|
||||||
cluster.health:
|
cluster.health:
|
||||||
|
|
|
@ -295,7 +295,7 @@ public class AttachmentMapper extends FieldMapper {
|
||||||
if (typeNode != null) {
|
if (typeNode != null) {
|
||||||
type = typeNode.toString();
|
type = typeNode.toString();
|
||||||
} else {
|
} else {
|
||||||
type = "string";
|
type = "text";
|
||||||
}
|
}
|
||||||
Mapper.TypeParser typeParser = parserContext.typeParser(type);
|
Mapper.TypeParser typeParser = parserContext.typeParser(type);
|
||||||
Mapper.Builder<?, ?> mapperBuilder = typeParser.parse(propName, propNode, parserContext);
|
Mapper.Builder<?, ?> mapperBuilder = typeParser.parse(propName, propNode, parserContext);
|
||||||
|
|
|
@ -13,7 +13,7 @@ setup:
|
||||||
"type": "attachment"
|
"type": "attachment"
|
||||||
"fields":
|
"fields":
|
||||||
"content" :
|
"content" :
|
||||||
"type": "string"
|
"type": "text"
|
||||||
"store" : true
|
"store" : true
|
||||||
"term_vector": "with_positions_offsets"
|
"term_vector": "with_positions_offsets"
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
index: test
|
index: test
|
||||||
body:
|
body:
|
||||||
mappings:
|
mappings:
|
||||||
type1: { "properties": { "foo": { "type": "string", "fields": { "hash": { "type": "murmur3" } } } } }
|
type1: { "properties": { "foo": { "type": "text", "fields": { "hash": { "type": "murmur3" } } } } }
|
||||||
|
|
||||||
- do:
|
- do:
|
||||||
index:
|
index:
|
||||||
|
|
|
@ -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", "string").endObject().endObject();
|
XContentBuilder updateMappingBuilder = jsonBuilder().startObject().startObject("properties").startObject("otherField").field("type", "text").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