mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 02:14:54 +00:00
Remove remaining index.mapping.single_type=false
(#25369)
This change cleans up remaining tests to not use index.mapping.single_type=false but instead where applicable use a single type or markt the index as created with a pre 6.x version. Yet, there is still on leftover in the client tests that needs special attention. See `org.elasticsearch.client.SearchIT` Relates to #24961
This commit is contained in:
parent
9c511bc447
commit
4ae426a552
@ -809,34 +809,24 @@ public class GetActionIT extends ESIntegTestCase {
|
||||
String createIndexSource = "{\n" +
|
||||
" \"settings\": {\n" +
|
||||
" \"index.translog.flush_threshold_size\": \"1pb\",\n" +
|
||||
" \"index.mapping.single_type\": false," +
|
||||
" \"refresh_interval\": \"-1\"\n" +
|
||||
" },\n" +
|
||||
" \"mappings\": {\n" +
|
||||
" \"parentdoc\": {\n" +
|
||||
" },\n" +
|
||||
" \"doc\": {\n" +
|
||||
" \"_parent\": {\n" +
|
||||
" \"type\": \"parentdoc\"\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
"}";
|
||||
assertAcked(prepareCreate("test")
|
||||
.addAlias(new Alias("alias")).setSource(createIndexSource, XContentType.JSON));
|
||||
ensureGreen();
|
||||
|
||||
client().prepareIndex("test", "doc").setId("1").setSource("{}", XContentType.JSON).setParent("1").get();
|
||||
client().prepareIndex("test", "doc", "1").setRouting("routingValue").setId("1").setSource("{}", XContentType.JSON).get();
|
||||
|
||||
String[] fieldsList = {"_parent"};
|
||||
String[] fieldsList = {"_routing"};
|
||||
// before refresh - document is only in translog
|
||||
assertGetFieldsAlwaysWorks(indexOrAlias(), "doc", "1", fieldsList, "1");
|
||||
assertGetFieldsAlwaysWorks(indexOrAlias(), "doc", "1", fieldsList, "routingValue");
|
||||
refresh();
|
||||
//after refresh - document is in translog and also indexed
|
||||
assertGetFieldsAlwaysWorks(indexOrAlias(), "doc", "1", fieldsList, "1");
|
||||
assertGetFieldsAlwaysWorks(indexOrAlias(), "doc", "1", fieldsList, "routingValue");
|
||||
flush();
|
||||
//after flush - document is in not anymore translog - only indexed
|
||||
assertGetFieldsAlwaysWorks(indexOrAlias(), "doc", "1", fieldsList, "1");
|
||||
assertGetFieldsAlwaysWorks(indexOrAlias(), "doc", "1", fieldsList, "routingValue");
|
||||
}
|
||||
|
||||
public void testUngeneratedFieldsNotPartOfSourceStored() throws IOException {
|
||||
|
@ -62,8 +62,8 @@ public class TypeFieldMapperTests extends ESSingleNodeTestCase {
|
||||
}
|
||||
|
||||
public void testDocValues(boolean singleType) throws IOException {
|
||||
Settings indexSettings = Settings.builder()
|
||||
.put("index.mapping.single_type", singleType)
|
||||
Settings indexSettings = singleType ? Settings.EMPTY : Settings.builder()
|
||||
.put("index.version.created", Version.V_5_6_0)
|
||||
.build();
|
||||
MapperService mapperService = createIndex("test", indexSettings).mapperService();
|
||||
DocumentMapper mapper = mapperService.merge("type", new CompressedXContent("{\"type\":{}}"), MergeReason.MAPPING_UPDATE, false);
|
||||
|
@ -19,6 +19,7 @@
|
||||
package org.elasticsearch.join.aggregations;
|
||||
|
||||
import org.apache.lucene.search.join.ScoreMode;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.index.IndexRequestBuilder;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.action.update.UpdateResponse;
|
||||
@ -59,8 +60,11 @@ import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.sameInstance;
|
||||
|
||||
public class ChildrenIT extends ParentChildTestCase {
|
||||
|
||||
|
||||
private static final Map<String, Control> categoryToControl = new HashMap<>();
|
||||
|
||||
|
||||
@Before
|
||||
public void setupCluster() throws Exception {
|
||||
categoryToControl.clear();
|
||||
@ -321,7 +325,7 @@ public class ChildrenIT extends ParentChildTestCase {
|
||||
prepareCreate(indexName)
|
||||
.setSettings(Settings.builder().put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1)
|
||||
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)
|
||||
.put("index.mapping.single_type", false))
|
||||
.put("index.version.created", Version.V_5_6_0)) // multi type
|
||||
.addMapping(masterType, "brand", "type=text", "name", "type=keyword", "material", "type=text")
|
||||
.addMapping(childType, "_parent", "type=masterprod", "color", "type=keyword", "size", "type=keyword")
|
||||
);
|
||||
@ -396,7 +400,7 @@ public class ChildrenIT extends ParentChildTestCase {
|
||||
assertAcked(
|
||||
prepareCreate(indexName)
|
||||
.setSettings(Settings.builder()
|
||||
.put("index.mapping.single_type", false)
|
||||
.put("index.version.created", Version.V_5_6_0) // multi type
|
||||
).addMapping(grandParentType, "name", "type=keyword")
|
||||
.addMapping(parentType, "_parent", "type=" + grandParentType)
|
||||
.addMapping(childType, "_parent", "type=" + parentType)
|
||||
|
@ -72,7 +72,9 @@ public class InnerHitsIT extends ParentChildTestCase {
|
||||
|
||||
@Override
|
||||
protected Collection<Class<? extends Plugin>> nodePlugins() {
|
||||
return Arrays.asList(ParentJoinPlugin.class, CustomScriptPlugin.class);
|
||||
ArrayList<Class<? extends Plugin>> plugins = new ArrayList<>(super.nodePlugins());
|
||||
plugins.add(CustomScriptPlugin.class);
|
||||
return plugins;
|
||||
}
|
||||
|
||||
public static class CustomScriptPlugin extends MockScriptPlugin {
|
||||
|
@ -114,7 +114,7 @@ public class LegacyHasChildQueryBuilderTests extends AbstractQueryTestCase<HasCh
|
||||
protected Settings indexSettings() {
|
||||
return Settings.builder()
|
||||
.put(super.indexSettings())
|
||||
.put("index.mapping.single_type", false)
|
||||
.put("index.version.created", Version.V_5_6_0) // multi type
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ public class LegacyHasParentQueryBuilderTests extends AbstractQueryTestCase<HasP
|
||||
protected Settings indexSettings() {
|
||||
return Settings.builder()
|
||||
.put(super.indexSettings())
|
||||
.put("index.mapping.single_type", false)
|
||||
.put("index.version.created", Version.V_5_6_0) // legacy needs multi types
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ import org.apache.lucene.search.DocValuesTermsQuery;
|
||||
import org.apache.lucene.search.MatchNoDocsQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.TermQuery;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest;
|
||||
import org.elasticsearch.common.compress.CompressedXContent;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
@ -58,7 +59,7 @@ public class LegacyParentIdQueryBuilderTests extends AbstractQueryTestCase<Paren
|
||||
protected Settings indexSettings() {
|
||||
return Settings.builder()
|
||||
.put(super.indexSettings())
|
||||
.put("index.mapping.single_type", false)
|
||||
.put("index.version.created", Version.V_5_6_0) // legacy needs multi type
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.elasticsearch.join.query;
|
||||
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.index.IndexRequestBuilder;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
@ -27,8 +28,10 @@ import org.elasticsearch.index.IndexModule;
|
||||
import org.elasticsearch.join.ParentJoinPlugin;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.test.ESIntegTestCase;
|
||||
import org.elasticsearch.test.InternalSettingsPlugin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@ -44,7 +47,7 @@ public abstract class ParentChildTestCase extends ESIntegTestCase {
|
||||
|
||||
@Override
|
||||
protected Collection<Class<? extends Plugin>> nodePlugins() {
|
||||
return Collections.singleton(ParentJoinPlugin.class);
|
||||
return Arrays.asList(InternalSettingsPlugin.class, ParentJoinPlugin.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -60,7 +63,7 @@ public abstract class ParentChildTestCase extends ESIntegTestCase {
|
||||
.put(IndexModule.INDEX_QUERY_CACHE_EVERYTHING_SETTING.getKey(), true);
|
||||
|
||||
if (legacy()) {
|
||||
builder.put("index.mapping.single_type", false);
|
||||
builder.put("index.version.created", Version.V_5_6_0);
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
|
@ -19,11 +19,13 @@
|
||||
|
||||
package org.elasticsearch.index.reindex;
|
||||
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
import org.elasticsearch.join.ParentJoinPlugin;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.test.InternalSettingsPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@ -56,6 +58,7 @@ public class ReindexParentChildTests extends ReindexTestCase {
|
||||
protected Collection<Class<? extends Plugin>> nodePlugins() {
|
||||
final List<Class<? extends Plugin>> plugins = new ArrayList<>(super.nodePlugins());
|
||||
plugins.add(ParentJoinPlugin.class);
|
||||
plugins.add(InternalSettingsPlugin.class);
|
||||
return Collections.unmodifiableList(plugins);
|
||||
}
|
||||
|
||||
@ -116,7 +119,7 @@ public class ReindexParentChildTests extends ReindexTestCase {
|
||||
*/
|
||||
private void createParentChildIndex(String indexName) throws Exception {
|
||||
CreateIndexRequestBuilder create = client().admin().indices().prepareCreate(indexName);
|
||||
create.setSettings("index.mapping.single_type", false);
|
||||
create.setSettings("index.version.created", Version.V_5_6_0.id);
|
||||
create.addMapping("city", "{\"_parent\": {\"type\": \"country\"}}", XContentType.JSON);
|
||||
create.addMapping("neighborhood", "{\"_parent\": {\"type\": \"city\"}}", XContentType.JSON);
|
||||
assertAcked(create);
|
||||
|
Loading…
x
Reference in New Issue
Block a user