|
| 1 | +/* |
| 2 | + * Licensed to Elasticsearch under one or more contributor |
| 3 | + * license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright |
| 5 | + * ownership. Elasticsearch licenses this file to you under |
| 6 | + * the Apache License, Version 2.0 (the "License"); you may |
| 7 | + * not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +package org.elasticsearch.index.mapper.internal; |
| 21 | + |
| 22 | +import org.elasticsearch.Version; |
| 23 | +import org.elasticsearch.cluster.metadata.IndexMetaData; |
| 24 | +import org.elasticsearch.common.settings.Settings; |
| 25 | +import org.elasticsearch.common.xcontent.XContentFactory; |
| 26 | +import org.elasticsearch.index.mapper.DocumentMapper; |
| 27 | +import org.elasticsearch.test.ESSingleNodeTestCase; |
| 28 | + |
| 29 | +public class TypeFieldMapperTests extends ESSingleNodeTestCase { |
| 30 | + |
| 31 | + public void testDocValues() throws Exception { |
| 32 | + String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string(); |
| 33 | + |
| 34 | + DocumentMapper docMapper = createIndex("test").mapperService().documentMapperParser().parse(mapping); |
| 35 | + TypeFieldMapper typeMapper = docMapper.rootMapper(TypeFieldMapper.class); |
| 36 | + assertTrue(typeMapper.fieldType().hasDocValues()); |
| 37 | + } |
| 38 | + |
| 39 | + public void testDocValuesPre21() throws Exception { |
| 40 | + // between 2.0 and 2.1, doc values was disabled for _type |
| 41 | + String mapping = XContentFactory.jsonBuilder().startObject().startObject("type").endObject().endObject().string(); |
| 42 | + Settings bwcSettings = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_2_0_0_beta1.id).build(); |
| 43 | + |
| 44 | + DocumentMapper docMapper = createIndex("test", bwcSettings).mapperService().documentMapperParser().parse(mapping); |
| 45 | + TypeFieldMapper typeMapper = docMapper.rootMapper(TypeFieldMapper.class); |
| 46 | + assertFalse(typeMapper.fieldType().hasDocValues()); |
| 47 | + } |
| 48 | +} |
0 commit comments