diff --git a/docs/reference/index.asciidoc b/docs/reference/index.asciidoc index 22dfed06b8dda..a6b4619722c2f 100644 --- a/docs/reference/index.asciidoc +++ b/docs/reference/index.asciidoc @@ -11,6 +11,8 @@ include::setup.asciidoc[] include::migration/migrate_1_0.asciidoc[] +include::migration/migrate_1_x.asciidoc[] + include::api-conventions.asciidoc[] include::docs.asciidoc[] diff --git a/docs/reference/indices/get-field-mapping.asciidoc b/docs/reference/indices/get-field-mapping.asciidoc index 695a0f48c24f8..a70f2b7956d81 100644 --- a/docs/reference/indices/get-field-mapping.asciidoc +++ b/docs/reference/indices/get-field-mapping.asciidoc @@ -60,8 +60,6 @@ You can also use wildcards. The field names can be any of the following: [horizontal] Full names:: the full path, including any parent object name the field is part of (ex. `user.id`). -Index names:: the name of the lucene field (can be different than the - field name if the `index_name` option of the mapping is used). Field names:: the name of the field without the path to it (ex. `id` for `{ "user" : { "id" : 1 } }`). The above options are specified in the order the `field` parameter is resolved. @@ -76,12 +74,12 @@ For example, consider the following mapping: "article": { "properties": { "id": { "type": "string" }, - "title": { "type": "string", "index_name": "text" }, - "abstract": { "type": "string", "index_name": "text" }, + "title": { "type": "string" }, + "abstract": { "type": "string" }, "author": { "properties": { "id": { "type": "string" }, - "name": { "type": "string", "index_name": "author" } + "name": { "type": "string" } } } } @@ -89,8 +87,7 @@ For example, consider the following mapping: } -------------------------------------------------- -To select the `id` of the `author` field, you can use its full name `author.id`. Using `text` will return -the mapping of `abstract` as it is one of the fields which map to the Lucene field `text`. `name` will return +To select the `id` of the `author` field, you can use its full name `author.id`. `name` will return the field `author.name`: [source,js] @@ -108,7 +105,7 @@ returns: "text": { "full_name": "abstract", "mapping": { - "abstract": { "type": "string", "index_name": "text" } + "abstract": { "type": "string" } } }, "author.id": { @@ -120,7 +117,7 @@ returns: "name": { "full_name": "author.name", "mapping": { - "name": { "type": "string", "index_name": "author" } + "name": { "type": "string", } } } } diff --git a/docs/reference/mapping/types/array-type.asciidoc b/docs/reference/mapping/types/array-type.asciidoc index 3f887b1c6f73e..f2dc40ed094c9 100644 --- a/docs/reference/mapping/types/array-type.asciidoc +++ b/docs/reference/mapping/types/array-type.asciidoc @@ -38,7 +38,7 @@ is a sample explicit mapping: "tweet" : { "properties" : { "message" : {"type" : "string"}, - "tags" : {"type" : "string", "index_name" : "tag"}, + "tags" : {"type" : "string"}, "lists" : { "properties" : { "name" : {"type" : "string"}, @@ -67,8 +67,3 @@ the fact that the following JSON document is perfectly fine: } -------------------------------------------------- -Note also, that thanks to the fact that we used the `index_name` to use -the non plural form (`tag` instead of `tags`), we can actually refer to -the field using the `index_name` as well. For example, we can execute a -query using `tweet.tags:wow` or `tweet.tag:wow`. We could, of course, -name the field as `tag` and skip the `index_name` all together). diff --git a/docs/reference/mapping/types/core-types.asciidoc b/docs/reference/mapping/types/core-types.asciidoc index 219f4fc1fecb0..e60b6f9947ca3 100644 --- a/docs/reference/mapping/types/core-types.asciidoc +++ b/docs/reference/mapping/types/core-types.asciidoc @@ -83,9 +83,6 @@ The following table lists all the attributes that can be used with the [cols="<,<",options="header",] |======================================================================= |Attribute |Description -|`index_name` |The name of the field that will be stored in the index. -Defaults to the property/field name. - |`store` |Set to `true` to actually store the field in the index, `false` to not store it. Defaults to `false` (note, the JSON document itself is stored, and it can be retrieved from it). @@ -223,9 +220,6 @@ numbered type: |`type` |The type of the number. Can be `float`, `double`, `integer`, `long`, `short`, `byte`. Required. -|`index_name` |The name of the field that will be stored in the index. -Defaults to the property/field name. - |`store` |Set to `true` to store actual field in the index, `false` to not store it. Defaults to `false` (note, the JSON document itself is stored, and it can be retrieved from it). @@ -330,9 +324,6 @@ date type: [cols="<,<",options="header",] |======================================================================= |Attribute |Description -|`index_name` |The name of the field that will be stored in the index. -Defaults to the property/field name. - |`format` |The <>. Defaults to `dateOptionalTime`. @@ -396,9 +387,6 @@ boolean type: [cols="<,<",options="header",] |======================================================================= |Attribute |Description -|`index_name` |The name of the field that will be stored in the index. -Defaults to the property/field name. - |`store` |Set to `true` to store actual field in the index, `false` to not store it. Defaults to `false` (note, the JSON document itself is stored, and it can be retrieved from it). @@ -441,11 +429,6 @@ binary type: [horizontal] -`index_name`:: - - The name of the field that will be stored in the index. Defaults to the - property/field name. - `store`:: Set to `true` to store actual field in the index, `false` to not store it. diff --git a/docs/reference/mapping/types/ip-type.asciidoc b/docs/reference/mapping/types/ip-type.asciidoc index a3f2556eb1b77..1416d54c60f1d 100644 --- a/docs/reference/mapping/types/ip-type.asciidoc +++ b/docs/reference/mapping/types/ip-type.asciidoc @@ -10,9 +10,6 @@ type: [cols="<,<",options="header",] |======================================================================= |Attribute |Description -|`index_name` |The name of the field that will be stored in the index. -Defaults to the property/field name. - |`store` |Set to `true` to store actual field in the index, `false` to not store it. Defaults to `false` (note, the JSON document itself is stored, and it can be retrieved from it). diff --git a/docs/reference/migration/migrate_1_x.asciidoc b/docs/reference/migration/migrate_1_x.asciidoc new file mode 100644 index 0000000000000..c3d0d8b8a0d0b --- /dev/null +++ b/docs/reference/migration/migrate_1_x.asciidoc @@ -0,0 +1,37 @@ +[[breaking-minor-changes]] += Breaking changes between 1.x releases + +[partintro] +-- +This section discusses the changes that you need to be aware of when migrating +your application from Elasticsearch 1.x to Elasticsearch 1.y. +-- + +== Facets + +Facets are deprecated and will be removed in a future release. You are +encouraged to migrate to <> instead. + +== 1.4.0 + +=== Index names + +As of Elasticsearch 1.4.0, custom `index_name` are not supported anymore. +Indices that have been created prior to Elasticsearch 1.4.0 will still be +allowed to add or modify mappings with custom index names, but indices +that are created on an Elasticsearch version that is greater than or equal +to 1.4.0 will not. + +When custom `index_name` were used to store the content of several fields +into a single index field, it is recommended to use the +<> feature instead. + +See https://github.com/elasticsearch/elasticsearch/issues/6677[#6677] for more +information. + +=== path: just_name + +`path: just_name` is deprecated since Elasticsearch 1.0 and will not be +supported on indices created on or after Elasticsearch 1.4.0. + +It is recommended to use the <> feature instead. diff --git a/docs/reference/setup/upgrade.asciidoc b/docs/reference/setup/upgrade.asciidoc index 182d605acd563..10ec0a432aa67 100644 --- a/docs/reference/setup/upgrade.asciidoc +++ b/docs/reference/setup/upgrade.asciidoc @@ -17,6 +17,8 @@ Elasticsearch can usually be upgraded using a rolling upgrade process, resulting Before upgrading from 0.90.x or any earlier version to 1.x or later, it is a good idea to consult the <> docs. +Before upgrading from 1.x to any more recent version of Elasticsearch, it is a good idea to consult the <> docs. + [float] [[backup]] === Back Up Your Data! diff --git a/rest-api-spec/test/indices.get_field_mapping/50_field_wildcards.yaml b/rest-api-spec/test/indices.get_field_mapping/50_field_wildcards.yaml index 766be059d7831..b90b9e1a60907 100644 --- a/rest-api-spec/test/indices.get_field_mapping/50_field_wildcards.yaml +++ b/rest-api-spec/test/indices.get_field_mapping/50_field_wildcards.yaml @@ -12,16 +12,13 @@ setup: t2: type: string obj: - path: just_name properties: t1: type: string i_t1: type: string - index_name: t1 i_t3: type: string - index_name: t3 - do: indices.create: @@ -35,16 +32,13 @@ setup: t2: type: string obj: - path: just_name properties: t1: type: string i_t1: type: string - index_name: t1 i_t3: type: string - index_name: t3 - do: cluster.health: @@ -75,8 +69,7 @@ setup: # of a field and thus takes precedence. - match: {test_index.mappings.test_type.t1.full_name: t1 } - match: {test_index.mappings.test_type.t2.full_name: t2 } - - match: {test_index.mappings.test_type.t3.full_name: obj.i_t3 } - - length: {test_index.mappings.test_type: 3} + - length: {test_index.mappings.test_type: 2} --- "Get field mapping with *t1 for fields": diff --git a/src/main/java/org/elasticsearch/index/mapper/core/AbstractFieldMapper.java b/src/main/java/org/elasticsearch/index/mapper/core/AbstractFieldMapper.java index fc556f18f49ea..64e044745815b 100644 --- a/src/main/java/org/elasticsearch/index/mapper/core/AbstractFieldMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/core/AbstractFieldMapper.java @@ -34,6 +34,7 @@ import org.apache.lucene.search.*; import org.apache.lucene.util.BytesRef; import org.elasticsearch.ElasticsearchIllegalArgumentException; +import org.elasticsearch.Version; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.collect.ImmutableOpenMap; import org.elasticsearch.common.lucene.BytesRefs; @@ -247,6 +248,10 @@ public Names buildNames(BuilderContext context) { public String buildIndexName(BuilderContext context) { String actualIndexName = indexName == null ? name : indexName; + if (context.indexCreatedVersion().onOrAfter(Version.V_1_4_0) && !name.equals(actualIndexName)) { + throw new MapperParsingException("Custom `index_name`s are not supported on indices created on or after " + + "Elasticsearch 1.4.0. `name` is [" + name + "] while `index_name` is [" + actualIndexName + "]"); + } return context.path().pathAsText(actualIndexName); } diff --git a/src/main/java/org/elasticsearch/index/mapper/object/ObjectMapper.java b/src/main/java/org/elasticsearch/index/mapper/object/ObjectMapper.java index beae08b5dd60f..58c6c1e237611 100644 --- a/src/main/java/org/elasticsearch/index/mapper/object/ObjectMapper.java +++ b/src/main/java/org/elasticsearch/index/mapper/object/ObjectMapper.java @@ -19,7 +19,6 @@ package org.elasticsearch.index.mapper.object; -import com.carrotsearch.hppc.cursors.ObjectObjectCursor; import com.google.common.collect.Iterables; import org.apache.lucene.document.Field; import org.apache.lucene.index.IndexableField; @@ -29,13 +28,12 @@ import org.apache.lucene.util.BytesRef; import org.elasticsearch.ElasticsearchIllegalStateException; import org.elasticsearch.ElasticsearchParseException; +import org.elasticsearch.Version; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.collect.ImmutableOpenMap; import org.elasticsearch.common.collect.UpdateInPlaceMap; import org.elasticsearch.common.joda.FormatDateTimeFormatter; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.util.CollectionUtils; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; @@ -159,6 +157,10 @@ public T add(Mapper.Builder builder) { @Override public Y build(BuilderContext context) { + if (pathType != ContentPath.Type.FULL && context.indexCreatedVersion().onOrAfter(Version.V_1_4_0)) { + throw new MapperParsingException("`path: just_name` is not supported on indices created on or after Elasticsearch 1.4.0"); + } + ContentPath.Type origPathType = context.path().pathType(); context.path().pathType(pathType); context.path().add(name); diff --git a/src/test/java/org/elasticsearch/index/mapper/all/mapping.json b/src/test/java/org/elasticsearch/index/mapper/all/mapping.json index 6c2120ff25201..da5719a35939f 100644 --- a/src/test/java/org/elasticsearch/index/mapper/all/mapping.json +++ b/src/test/java/org/elasticsearch/index/mapper/all/mapping.json @@ -29,8 +29,7 @@ "properties":{ "location":{ "type":"string", - "store":"yes", - "index_name":"firstLocation" + "store":"yes" } } }, @@ -54,4 +53,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/test/java/org/elasticsearch/index/mapper/all/mapping_boost_omit_positions_on_all.json b/src/test/java/org/elasticsearch/index/mapper/all/mapping_boost_omit_positions_on_all.json index f9be13cd1e454..452ef9f083ba8 100644 --- a/src/test/java/org/elasticsearch/index/mapper/all/mapping_boost_omit_positions_on_all.json +++ b/src/test/java/org/elasticsearch/index/mapper/all/mapping_boost_omit_positions_on_all.json @@ -29,8 +29,7 @@ "properties":{ "location":{ "type":"string", - "store":"yes", - "index_name":"firstLocation" + "store":"yes" } } }, diff --git a/src/test/java/org/elasticsearch/index/mapper/all/mapping_offsets_on_all.json b/src/test/java/org/elasticsearch/index/mapper/all/mapping_offsets_on_all.json index 43aa682685fa6..f6b0699beeeda 100644 --- a/src/test/java/org/elasticsearch/index/mapper/all/mapping_offsets_on_all.json +++ b/src/test/java/org/elasticsearch/index/mapper/all/mapping_offsets_on_all.json @@ -29,8 +29,7 @@ "properties":{ "location":{ "type":"string", - "store":"yes", - "index_name":"firstLocation" + "store":"yes" } } }, diff --git a/src/test/java/org/elasticsearch/index/mapper/all/mapping_omit_positions_on_all.json b/src/test/java/org/elasticsearch/index/mapper/all/mapping_omit_positions_on_all.json index e232192d905aa..3e54157200cfb 100644 --- a/src/test/java/org/elasticsearch/index/mapper/all/mapping_omit_positions_on_all.json +++ b/src/test/java/org/elasticsearch/index/mapper/all/mapping_omit_positions_on_all.json @@ -28,8 +28,7 @@ "properties":{ "location":{ "type":"string", - "store":"yes", - "index_name":"firstLocation" + "store":"yes" } } }, @@ -53,4 +52,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/test/java/org/elasticsearch/index/mapper/all/noboost-mapping.json b/src/test/java/org/elasticsearch/index/mapper/all/noboost-mapping.json index ecbf315e73ae5..997ecdd90ad4d 100644 --- a/src/test/java/org/elasticsearch/index/mapper/all/noboost-mapping.json +++ b/src/test/java/org/elasticsearch/index/mapper/all/noboost-mapping.json @@ -27,8 +27,7 @@ "properties":{ "location":{ "type":"string", - "store":"yes", - "index_name":"firstLocation" + "store":"yes" } } }, @@ -52,4 +51,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/test/java/org/elasticsearch/index/mapper/all/store-mapping.json b/src/test/java/org/elasticsearch/index/mapper/all/store-mapping.json index 7fc9283e06820..19e061308116f 100644 --- a/src/test/java/org/elasticsearch/index/mapper/all/store-mapping.json +++ b/src/test/java/org/elasticsearch/index/mapper/all/store-mapping.json @@ -29,8 +29,7 @@ "properties":{ "location":{ "type":"string", - "store":"yes", - "index_name":"firstLocation" + "store":"yes" } } }, @@ -53,4 +52,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/test/java/org/elasticsearch/index/mapper/object/SimpleObjectMappingTests.java b/src/test/java/org/elasticsearch/index/mapper/object/SimpleObjectMappingTests.java index 189289b52a1fe..fa087e56578f9 100644 --- a/src/test/java/org/elasticsearch/index/mapper/object/SimpleObjectMappingTests.java +++ b/src/test/java/org/elasticsearch/index/mapper/object/SimpleObjectMappingTests.java @@ -19,13 +19,23 @@ package org.elasticsearch.index.mapper.object; +import org.elasticsearch.ElasticsearchIllegalArgumentException; +import org.elasticsearch.Version; +import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.common.bytes.BytesArray; +import org.elasticsearch.common.settings.ImmutableSettings; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentFactory; +import org.elasticsearch.index.mapper.ContentPath; import org.elasticsearch.index.mapper.DocumentMapper; +import org.elasticsearch.index.mapper.DocumentMapperParser; import org.elasticsearch.index.mapper.MapperParsingException; +import org.elasticsearch.index.service.IndexService; import org.elasticsearch.test.ElasticsearchSingleNodeTest; import org.junit.Test; +import static org.elasticsearch.index.mapper.MapperBuilders.*; + /** */ public class SimpleObjectMappingTests extends ElasticsearchSingleNodeTest { @@ -63,4 +73,24 @@ public void testEmptyArrayProperties() throws Exception { .endObject().endObject().string(); createIndex("test").mapperService().documentMapperParser().parse(mapping); } + + public void testPathJustName() { + IndexService indexService = createIndex("test"); + Settings settings = indexService.settingsService().getSettings(); + DocumentMapperParser mapperParser = indexService.mapperService().documentMapperParser(); + // fails on the current version + try { + doc("test", settings, rootObject("person").add(object("name").pathType(ContentPath.Type.JUST_NAME).add(stringField("first").indexName("last")))).build(mapperParser); + fail("path: just_name is not supported anymore"); + } catch (ElasticsearchIllegalArgumentException e) { + // expected + } + // but succeeds on < 1.4.0 + Version v = Version.V_1_4_0; + while (v.onOrAfter(Version.V_1_4_0)) { + v = randomFrom(randomVersion()); + } + settings = ImmutableSettings.builder().put(settings).put(IndexMetaData.SETTING_VERSION_CREATED, v).build(); + doc("test", settings, rootObject("person").add(object("name").pathType(ContentPath.Type.JUST_NAME).add(stringField("first").indexName("last")))).build(mapperParser); + } } diff --git a/src/test/java/org/elasticsearch/index/mapper/path/PathMapperTests.java b/src/test/java/org/elasticsearch/index/mapper/path/PathMapperTests.java index 8d5192683e4b6..3032828377123 100644 --- a/src/test/java/org/elasticsearch/index/mapper/path/PathMapperTests.java +++ b/src/test/java/org/elasticsearch/index/mapper/path/PathMapperTests.java @@ -39,33 +39,25 @@ public void testPathMapping() throws IOException { String mapping = copyToStringFromClasspath("/org/elasticsearch/index/mapper/path/test-mapping.json"); DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse(mapping); - assertThat(docMapper.mappers().indexName("first1"), notNullValue()); - assertThat(docMapper.mappers().indexName("name1.first1"), nullValue()); + assertThat(docMapper.mappers().indexName("first1"), nullValue()); + assertThat(docMapper.mappers().indexName("name1.first1"), notNullValue()); assertThat(docMapper.mappers().indexName("last1"), nullValue()); - assertThat(docMapper.mappers().indexName("i_last_1"), notNullValue()); - assertThat(docMapper.mappers().indexName("name1.last1"), nullValue()); - assertThat(docMapper.mappers().indexName("name1.i_last_1"), nullValue()); + assertThat(docMapper.mappers().indexName("name1.last1"), notNullValue()); assertThat(docMapper.mappers().indexName("first2"), nullValue()); assertThat(docMapper.mappers().indexName("name2.first2"), notNullValue()); assertThat(docMapper.mappers().indexName("last2"), nullValue()); - assertThat(docMapper.mappers().indexName("i_last_2"), nullValue()); - assertThat(docMapper.mappers().indexName("name2.i_last_2"), notNullValue()); - assertThat(docMapper.mappers().indexName("name2.last2"), nullValue()); + assertThat(docMapper.mappers().indexName("name2.last2"), notNullValue()); // test full name assertThat(docMapper.mappers().fullName("first1"), nullValue()); assertThat(docMapper.mappers().fullName("name1.first1"), notNullValue()); assertThat(docMapper.mappers().fullName("last1"), nullValue()); - assertThat(docMapper.mappers().fullName("i_last_1"), nullValue()); assertThat(docMapper.mappers().fullName("name1.last1"), notNullValue()); - assertThat(docMapper.mappers().fullName("name1.i_last_1"), nullValue()); assertThat(docMapper.mappers().fullName("first2"), nullValue()); assertThat(docMapper.mappers().fullName("name2.first2"), notNullValue()); assertThat(docMapper.mappers().fullName("last2"), nullValue()); - assertThat(docMapper.mappers().fullName("i_last_2"), nullValue()); - assertThat(docMapper.mappers().fullName("name2.i_last_2"), nullValue()); assertThat(docMapper.mappers().fullName("name2.last2"), notNullValue()); } } diff --git a/src/test/java/org/elasticsearch/index/mapper/path/test-mapping.json b/src/test/java/org/elasticsearch/index/mapper/path/test-mapping.json index 200a45107d380..1453b4774b137 100644 --- a/src/test/java/org/elasticsearch/index/mapper/path/test-mapping.json +++ b/src/test/java/org/elasticsearch/index/mapper/path/test-mapping.json @@ -2,28 +2,22 @@ "person":{ "properties":{ "name1":{ - "type":"object", - "path":"just_name", "properties":{ "first1":{ "type":"string" }, "last1":{ - "type":"string", - "index_name":"i_last_1" + "type":"string" } } }, "name2":{ - "type":"object", - "path":"full", "properties":{ "first2":{ "type":"string" }, "last2":{ - "type":"string", - "index_name":"i_last_2" + "type":"string" } } } diff --git a/src/test/java/org/elasticsearch/index/mapper/simple/SimpleMapperTests.java b/src/test/java/org/elasticsearch/index/mapper/simple/SimpleMapperTests.java index e8b742e8c84bc..2d35c56898745 100644 --- a/src/test/java/org/elasticsearch/index/mapper/simple/SimpleMapperTests.java +++ b/src/test/java/org/elasticsearch/index/mapper/simple/SimpleMapperTests.java @@ -20,6 +20,9 @@ package org.elasticsearch.index.mapper.simple; import com.google.common.base.Charsets; +import org.elasticsearch.ElasticsearchIllegalArgumentException; +import org.elasticsearch.Version; +import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.settings.ImmutableSettings; @@ -151,4 +154,26 @@ public void testTypeWrapperWithSetting() throws Exception { assertThat(doc.get(docMapper.uidMapper().names().indexName()), equalTo(Uid.createUid("person", "1"))); assertThat(doc.get(docMapper.mappers().name("first").mapper().names().indexName()), equalTo("shay")); } + + public void testCustomIndexName() { + IndexService indexService = createIndex("test"); + Settings settings = indexService.settingsService().getSettings(); + DocumentMapperParser mapperParser = indexService.mapperService().documentMapperParser(); + + // fails on current version + try { + doc("test", settings, rootObject("person").add(stringField("first").indexName("last"))).build(mapperParser); + fail("custom index_name is not supported anymore"); + } catch (ElasticsearchIllegalArgumentException e) { + // expected + } + + // but succeeds if version <= 1.3.0 + Version v = Version.V_1_4_0; + while (v.onOrAfter(Version.V_1_4_0)) { + v = randomFrom(randomVersion()); + } + settings = ImmutableSettings.builder().put(settings).put(IndexMetaData.SETTING_VERSION_CREATED, v).build(); + doc("test", settings, rootObject("person").add(stringField("first").indexName("last"))).build(mapperParser); + } } diff --git a/src/test/java/org/elasticsearch/index/mapper/simple/test-mapping.json b/src/test/java/org/elasticsearch/index/mapper/simple/test-mapping.json index d45d55704a132..2a5828c4af317 100644 --- a/src/test/java/org/elasticsearch/index/mapper/simple/test-mapping.json +++ b/src/test/java/org/elasticsearch/index/mapper/simple/test-mapping.json @@ -7,8 +7,7 @@ dynamic:false, enabled:true, _id:{ - name:"_id", - index_name:"_id" + name:"_id" }, _source:{ name:"_source" @@ -42,8 +41,7 @@ properties:{ location:{ type:"string", - store:"yes", - index_name:"firstLocation" + store:"yes" } } }, @@ -68,8 +66,7 @@ type:"boolean" }, dogs:{ - type:"string", - index_name:"dog" + type:"string" }, complex:{ type:"object", @@ -95,4 +92,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/test/java/org/elasticsearch/search/highlight/HighlighterSearchTests.java b/src/test/java/org/elasticsearch/search/highlight/HighlighterSearchTests.java index 8bf1d7b73a40b..6a76f70dc0e0f 100644 --- a/src/test/java/org/elasticsearch/search/highlight/HighlighterSearchTests.java +++ b/src/test/java/org/elasticsearch/search/highlight/HighlighterSearchTests.java @@ -2532,75 +2532,6 @@ public void testPostingsHighlighterManyDocs() throws Exception { } } - @Test //https://github.com/elasticsearch/elasticsearch/issues/4116 - public void testPostingsHighlighterCustomIndexName() { - assertAcked(prepareCreate("test") - .addMapping("type1", "field1", "type=string,index_options=offsets,index_name=my_field")); - ensureGreen(); - - client().prepareIndex("test", "type1", "1").setSource("field1", "First sentence. Second sentence.").get(); - refresh(); - - SearchResponse searchResponse = client().prepareSearch("test").setQuery(matchQuery("field1", "first")).addHighlightedField("field1").get(); - assertHighlight(searchResponse, 0, "field1", 0, 1, equalTo("First sentence.")); - - searchResponse = client().prepareSearch("test").setQuery(matchQuery("my_field", "first")).addHighlightedField("field1").get(); - assertHighlight(searchResponse, 0, "field1", 0, 1, equalTo("First sentence.")); - - searchResponse = client().prepareSearch("test").setQuery(matchQuery("my_field", "first")).addHighlightedField("my_field").get(); - assertHighlight(searchResponse, 0, "my_field", 0, 1, equalTo("First sentence.")); - - searchResponse = client().prepareSearch("test").setQuery(matchQuery("my_field", "first")) - .addHighlightedField("field1").setHighlighterRequireFieldMatch(true).get(); - assertHighlight(searchResponse, 0, "field1", 0, 1, equalTo("First sentence.")); - } - - @Test - public void testFastVectorHighlighterCustomIndexName() { - assertAcked(prepareCreate("test") - .addMapping("type1", "field1", "type=string,term_vector=with_positions_offsets,index_name=my_field")); - ensureGreen(); - - client().prepareIndex("test", "type1", "1").setSource("field1", "First sentence. Second sentence.").get(); - refresh(); - - SearchResponse searchResponse = client().prepareSearch("test").setQuery(matchQuery("field1", "first")).addHighlightedField("field1").get(); - assertHighlight(searchResponse, 0, "field1", 0, 1, equalTo("First sentence. Second sentence.")); - - searchResponse = client().prepareSearch("test").setQuery(matchQuery("my_field", "first")).addHighlightedField("field1").get(); - assertHighlight(searchResponse, 0, "field1", 0, 1, equalTo("First sentence. Second sentence.")); - - searchResponse = client().prepareSearch("test").setQuery(matchQuery("my_field", "first")).addHighlightedField("my_field").get(); - assertHighlight(searchResponse, 0, "my_field", 0, 1, equalTo("First sentence. Second sentence.")); - - searchResponse = client().prepareSearch("test").setQuery(matchQuery("my_field", "first")) - .addHighlightedField("field1").setHighlighterRequireFieldMatch(true).get(); - assertHighlight(searchResponse, 0, "field1", 0, 1, equalTo("First sentence. Second sentence.")); - } - - @Test - public void testPlainHighlighterCustomIndexName() { - assertAcked(prepareCreate("test") - .addMapping("type1", "field1", "type=string,index_name=my_field")); - ensureGreen(); - - client().prepareIndex("test", "type1", "1").setSource("field1", "First sentence. Second sentence.").get(); - refresh(); - - SearchResponse searchResponse = client().prepareSearch("test").setQuery(matchQuery("field1", "first")).addHighlightedField("field1").get(); - assertHighlight(searchResponse, 0, "field1", 0, 1, equalTo("First sentence. Second sentence.")); - - searchResponse = client().prepareSearch("test").setQuery(matchQuery("my_field", "first")).addHighlightedField("field1").get(); - assertHighlight(searchResponse, 0, "field1", 0, 1, equalTo("First sentence. Second sentence.")); - - searchResponse = client().prepareSearch("test").setQuery(matchQuery("my_field", "first")).addHighlightedField("my_field").get(); - assertHighlight(searchResponse, 0, "my_field", 0, 1, equalTo("First sentence. Second sentence.")); - - searchResponse = client().prepareSearch("test").setQuery(matchQuery("my_field", "first")) - .addHighlightedField("field1").setHighlighterRequireFieldMatch(true).get(); - assertHighlight(searchResponse, 0, "field1", 0, 1, equalTo("First sentence. Second sentence.")); - } - @Test public void testFastVectorHighlighterPhraseBoost() throws Exception { assertAcked(prepareCreate("test").addMapping("type1", type1TermVectorMapping()));