Merge pull request #12356 from rjernst/fix/12329
Remove ability to configure _index
This commit is contained in:
commit
8f6398a8f7
|
@ -102,10 +102,11 @@ public class IndexFieldMapper extends MetadataFieldMapper {
|
|||
@Override
|
||||
public Mapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
|
||||
Builder builder = new Builder(parserContext.mapperService().fullName(NAME));
|
||||
if (parserContext.indexVersionCreated().before(Version.V_2_0_0_beta1)) {
|
||||
parseField(builder, builder.name, node, parserContext);
|
||||
if (parserContext.indexVersionCreated().onOrAfter(Version.V_2_0_0_beta1)) {
|
||||
return builder;
|
||||
}
|
||||
|
||||
parseField(builder, builder.name, node, parserContext);
|
||||
for (Iterator<Map.Entry<String, Object>> iterator = node.entrySet().iterator(); iterator.hasNext();) {
|
||||
Map.Entry<String, Object> entry = iterator.next();
|
||||
String fieldName = Strings.toUnderscoreCase(entry.getKey());
|
||||
|
|
|
@ -32,12 +32,13 @@ import org.elasticsearch.test.ElasticsearchSingleNodeTest;
|
|||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
public class IndexTypeMapperTests extends ElasticsearchSingleNodeTest {
|
||||
private Settings bwcSettings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_1_4_2.id).build();
|
||||
|
||||
public void testSimpleIndexMapper() throws Exception {
|
||||
public void testSimpleIndexMapperEnabledBackcompat() throws Exception {
|
||||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
|
||||
.startObject("_index").field("enabled", true).endObject()
|
||||
.endObject().endObject().string();
|
||||
DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse(mapping);
|
||||
DocumentMapper docMapper = createIndex("test", bwcSettings).mapperService().documentMapperParser().parse(mapping);
|
||||
IndexFieldMapper indexMapper = docMapper.indexMapper();
|
||||
assertThat(indexMapper.enabled(), equalTo(true));
|
||||
|
||||
|
@ -51,11 +52,11 @@ public class IndexTypeMapperTests extends ElasticsearchSingleNodeTest {
|
|||
assertThat(doc.rootDoc().get("field"), equalTo("value"));
|
||||
}
|
||||
|
||||
public void testExplicitDisabledIndexMapper() throws Exception {
|
||||
public void testExplicitDisabledIndexMapperBackcompat() throws Exception {
|
||||
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
|
||||
.startObject("_index").field("enabled", false).endObject()
|
||||
.endObject().endObject().string();
|
||||
DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse(mapping);
|
||||
DocumentMapper docMapper = createIndex("test", bwcSettings).mapperService().documentMapperParser().parse(mapping);
|
||||
IndexFieldMapper indexMapper = docMapper.rootMapper(IndexFieldMapper.class);
|
||||
assertThat(indexMapper.enabled(), equalTo(false));
|
||||
|
||||
|
@ -86,11 +87,11 @@ public class IndexTypeMapperTests extends ElasticsearchSingleNodeTest {
|
|||
assertThat(doc.rootDoc().get("field"), equalTo("value"));
|
||||
}
|
||||
|
||||
public void testThatMergingFieldMappingAllowsDisabling() throws Exception {
|
||||
public void testThatMergingFieldMappingAllowsDisablingBackcompat() throws Exception {
|
||||
String mappingWithIndexEnabled = XContentFactory.jsonBuilder().startObject().startObject("type")
|
||||
.startObject("_index").field("enabled", true).endObject()
|
||||
.endObject().endObject().string();
|
||||
DocumentMapperParser parser = createIndex("test").mapperService().documentMapperParser();
|
||||
DocumentMapperParser parser = createIndex("test", bwcSettings).mapperService().documentMapperParser();
|
||||
DocumentMapper mapperEnabled = parser.parse(mappingWithIndexEnabled);
|
||||
|
||||
|
||||
|
@ -103,11 +104,11 @@ public class IndexTypeMapperTests extends ElasticsearchSingleNodeTest {
|
|||
assertThat(mapperEnabled.IndexFieldMapper().enabled(), is(false));
|
||||
}
|
||||
|
||||
public void testThatDisablingWorksWhenMerging() throws Exception {
|
||||
public void testThatDisablingWorksWhenMergingBackcompat() throws Exception {
|
||||
String enabledMapping = XContentFactory.jsonBuilder().startObject().startObject("type")
|
||||
.startObject("_index").field("enabled", true).endObject()
|
||||
.endObject().endObject().string();
|
||||
DocumentMapperParser parser = createIndex("test").mapperService().documentMapperParser();
|
||||
DocumentMapperParser parser = createIndex("test", bwcSettings).mapperService().documentMapperParser();
|
||||
DocumentMapper enabledMapper = parser.parse(enabledMapping);
|
||||
|
||||
String disabledMapping = XContentFactory.jsonBuilder().startObject().startObject("type")
|
||||
|
@ -125,8 +126,8 @@ public class IndexTypeMapperTests extends ElasticsearchSingleNodeTest {
|
|||
.field("enabled", true)
|
||||
.field("store", "yes").endObject()
|
||||
.endObject().endObject().string();
|
||||
Settings indexSettings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_1_4_2.id).build();
|
||||
DocumentMapper docMapper = createIndex("test", indexSettings).mapperService().documentMapperParser().parse(mapping);
|
||||
|
||||
DocumentMapper docMapper = createIndex("test", bwcSettings).mapperService().documentMapperParser().parse(mapping);
|
||||
IndexFieldMapper indexMapper = docMapper.rootMapper(IndexFieldMapper.class);
|
||||
assertThat(indexMapper.enabled(), equalTo(true));
|
||||
assertThat(indexMapper.fieldType().stored(), equalTo(true));
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
[[mapping-index-field]]
|
||||
=== `_index` field
|
||||
|
||||
The name of the index that contains the document. This field is not indexed
|
||||
but can be automatically derived from the index itself.
|
||||
|
||||
Its value is accessible in queries, aggregations, scripts, and when sorting:
|
||||
When performing queries across multiple indexes, it is sometimes desirable
|
||||
to add query clauses that are associated with documents of only certain
|
||||
indexes. The `_index` field allows matching on the index a document was
|
||||
indexed into. Its value is accessible in queries, aggregations, scripts, and when sorting:
|
||||
|
||||
[source,js]
|
||||
--------------------------
|
||||
|
|
|
@ -290,7 +290,7 @@ to provide special features. They now have limited configuration options.
|
|||
|
||||
* `_id` configuration can no longer be changed. If you need to sort, use `_uid` instead.
|
||||
* `_type` configuration can no longer be changed.
|
||||
* `_index` configuration is limited to enabling the field.
|
||||
* `_index` configuration can no longer be changed.
|
||||
* `_routing` configuration is limited to requiring the field.
|
||||
* `_boost` has been removed.
|
||||
* `_field_names` configuration is limited to disabling the field.
|
||||
|
|
Loading…
Reference in New Issue