Skip to content

Commit

Permalink
Remove remaining eindex.mapping.single_type=false`
Browse files Browse the repository at this point in the history
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 elastic#24961
  • Loading branch information
s1monw committed Jun 22, 2017
1 parent a077fa9 commit 68413ba
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 25 deletions.
20 changes: 5 additions & 15 deletions core/src/test/java/org/elasticsearch/get/GetActionIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -809,34 +809,24 @@ public void testUngeneratedFieldsThatAreAlwaysStored() throws IOException {
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public void testDocValuesSingleType() throws Exception {
}

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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,29 @@
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;
import org.elasticsearch.client.Requests;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.join.ParentJoinPlugin;
import org.elasticsearch.join.query.ParentChildTestCase;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.InternalAggregation;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.elasticsearch.search.aggregations.metrics.sum.Sum;
import org.elasticsearch.search.aggregations.metrics.tophits.TopHits;
import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.test.InternalSettingsPlugin;
import org.junit.Before;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand All @@ -59,7 +65,14 @@
import static org.hamcrest.Matchers.sameInstance;

public class ChildrenIT extends ParentChildTestCase {


private static final Map<String, Control> categoryToControl = new HashMap<>();
protected Collection<Class<? extends Plugin>> nodePlugins() {
ArrayList<Class<? extends Plugin>> plugins = new ArrayList<>(super.nodePlugins());
plugins.add(InternalSettingsPlugin.class);
return plugins;
}

@Before
public void setupCluster() throws Exception {
Expand Down Expand Up @@ -321,7 +334,7 @@ public void testPostCollection() throws Exception {
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")
);
Expand Down Expand Up @@ -396,7 +409,7 @@ public void testHierarchicalChildrenAggs() {
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ protected void initializeAdditionalMappings(MapperService mapperService) throws
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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected Collection<Class<? extends Plugin>> getPlugins() {
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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
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;
Expand Down Expand Up @@ -58,7 +59,7 @@ protected Collection<Class<? extends Plugin>> getPlugins() {
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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,8 +28,10 @@
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;
Expand All @@ -44,7 +47,7 @@ protected boolean ignoreExternalCluster() {

@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return Collections.singleton(ParentJoinPlugin.class);
return Arrays.asList(InternalSettingsPlugin.class, ParentJoinPlugin.class);
}

@Override
Expand All @@ -60,7 +63,7 @@ public Settings indexSettings() {
.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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -56,6 +58,7 @@ protected boolean ignoreExternalCluster() {
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);
}

Expand Down Expand Up @@ -116,7 +119,7 @@ public void testErrorMessageWhenBadParentChild() throws Exception {
*/
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);
Expand Down

0 comments on commit 68413ba

Please sign in to comment.