Only allow indices to have a single type by default. (elastic/x-pack-elasticsearch#1212)
Sibling of elastic/elasticsearch#24317 Original commit: elastic/x-pack-elasticsearch@a57decdf9f
This commit is contained in:
parent
4078b2f1b2
commit
bbb3d008f2
|
@ -290,7 +290,9 @@ public class MachineLearningTemplateRegistry extends AbstractComponent implemen
|
|||
// pick up default mappings and be used in queries
|
||||
.put(MapperService.INDEX_MAPPER_DYNAMIC_SETTING.getKey(), true)
|
||||
// set the default all search field
|
||||
.put(IndexSettings.DEFAULT_FIELD_SETTING.getKey(), ElasticsearchMappings.ALL_FIELD_VALUES);
|
||||
.put(IndexSettings.DEFAULT_FIELD_SETTING.getKey(), ElasticsearchMappings.ALL_FIELD_VALUES)
|
||||
// TODO: fix the template to use a single type
|
||||
.put("index.mapping.single_type", false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -321,7 +323,9 @@ public class MachineLearningTemplateRegistry extends AbstractComponent implemen
|
|||
// Sacrifice durability for performance: in the event of power
|
||||
// failure we can lose the last 5 seconds of changes, but it's
|
||||
// much faster
|
||||
.put(IndexSettings.INDEX_TRANSLOG_DURABILITY_SETTING.getKey(), ASYNC);
|
||||
.put(IndexSettings.INDEX_TRANSLOG_DURABILITY_SETTING.getKey(), ASYNC)
|
||||
// TODO: do not create multiple types
|
||||
.put("index.mapping.single_type", false);
|
||||
}
|
||||
|
||||
public static boolean allTemplatesInstalled(MetaData metaData) {
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
"index": {
|
||||
"number_of_shards": 1,
|
||||
"number_of_replicas": 1,
|
||||
"codec": "best_compression"
|
||||
"codec": "best_compression",
|
||||
"mapping.single_type": false
|
||||
}
|
||||
},
|
||||
"mappings": {
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
"settings": {
|
||||
"index.number_of_shards": 1,
|
||||
"index.number_of_replicas": 1,
|
||||
"index.codec": "best_compression"
|
||||
"index.codec": "best_compression",
|
||||
"index.mapping.single_type": false
|
||||
},
|
||||
"mappings": {
|
||||
"beats_stats": {
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
"settings": {
|
||||
"index.number_of_shards": 1,
|
||||
"index.number_of_replicas": 1,
|
||||
"index.codec": "best_compression"
|
||||
"index.codec": "best_compression",
|
||||
"index.mapping.single_type": false
|
||||
},
|
||||
"mappings": {
|
||||
"_default_": {
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
"index.number_of_shards": 1,
|
||||
"index.number_of_replicas": 1,
|
||||
"index.codec": "best_compression",
|
||||
"index.mapper.dynamic": false
|
||||
"index.mapper.dynamic": false,
|
||||
"index.mapping.single_type": false
|
||||
},
|
||||
"mappings": {
|
||||
"_default_": {
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
"settings": {
|
||||
"index.number_of_shards": 1,
|
||||
"index.number_of_replicas": 1,
|
||||
"index.codec": "best_compression"
|
||||
"index.codec": "best_compression",
|
||||
"index.mapping.single_type": false
|
||||
},
|
||||
"mappings": {
|
||||
"_default_": {
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
"settings": {
|
||||
"index.number_of_shards": 1,
|
||||
"index.number_of_replicas": 1,
|
||||
"index.codec": "best_compression"
|
||||
"index.codec": "best_compression",
|
||||
"index.mapping.single_type": false
|
||||
},
|
||||
"mappings": {
|
||||
"_default_": {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
"index_patterns" : ".security",
|
||||
"order" : 1000,
|
||||
"settings" : {
|
||||
"mapping.single_type": false,
|
||||
"number_of_shards" : 1,
|
||||
"number_of_replicas" : 0,
|
||||
"auto_expand_replicas" : "0-all",
|
||||
|
|
|
@ -563,6 +563,7 @@ public class DocumentLevelSecurityTests extends SecurityIntegTestCase {
|
|||
|
||||
public void testChildrenAggregation() throws Exception {
|
||||
assertAcked(client().admin().indices().prepareCreate("test")
|
||||
.setSettings("mapping.single_type", false)
|
||||
.addMapping("type1", "field1", "type=text", "field2", "type=text")
|
||||
.addMapping("type2", "_parent", "type=type1", "field3", "type=text,fielddata=true")
|
||||
);
|
||||
|
@ -619,6 +620,7 @@ public class DocumentLevelSecurityTests extends SecurityIntegTestCase {
|
|||
|
||||
public void testParentChild() {
|
||||
assertAcked(prepareCreate("test")
|
||||
.setSettings("mapping.single_type", false)
|
||||
.addMapping("parent")
|
||||
.addMapping("child", "_parent", "type=parent", "field1", "type=text", "field2", "type=text", "field3", "type=text"));
|
||||
ensureGreen();
|
||||
|
|
|
@ -1280,6 +1280,7 @@ public class FieldLevelSecurityTests extends SecurityIntegTestCase {
|
|||
|
||||
public void testParentChild() {
|
||||
assertAcked(prepareCreate("test")
|
||||
.setSettings("mapping.single_type", false)
|
||||
.addMapping("parent")
|
||||
.addMapping("child", "_parent", "type=parent"));
|
||||
ensureGreen();
|
||||
|
|
|
@ -156,12 +156,13 @@ public class MachineLearningTemplateRegistryTests extends ESTestCase {
|
|||
new MachineLearningTemplateRegistry(createSettings(), clusterService, client, threadPool);
|
||||
Settings settings = templateRegistry.mlResultsIndexSettings().build();
|
||||
|
||||
assertEquals(4, settings.size());
|
||||
assertEquals(5, settings.size());
|
||||
assertThat(settings.get("index.number_of_shards"), is(nullValue()));
|
||||
assertEquals("async", settings.get("index.translog.durability"));
|
||||
assertEquals("true", settings.get("index.mapper.dynamic"));
|
||||
assertEquals("all_field_values", settings.get("index.query.default_field"));
|
||||
assertEquals("2s", settings.get("index.unassigned.node_left.delayed_timeout"));
|
||||
assertEquals("false", settings.get("index.mapping.single_type"));
|
||||
}
|
||||
|
||||
public void testMlAuditIndexSettings() {
|
||||
|
@ -180,10 +181,11 @@ public class MachineLearningTemplateRegistryTests extends ESTestCase {
|
|||
new MachineLearningTemplateRegistry(createSettings(), clusterService, client, threadPool);
|
||||
Settings settings = templateRegistry.mlStateIndexSettings().build();
|
||||
|
||||
assertEquals(2, settings.size());
|
||||
assertEquals(3, settings.size());
|
||||
assertThat(settings.get("index.number_of_shards"), is(nullValue()));
|
||||
assertEquals("async", settings.get("index.translog.durability"));
|
||||
assertEquals("2s", settings.get("index.unassigned.node_left.delayed_timeout"));
|
||||
assertEquals("false", settings.get("index.mapping.single_type"));
|
||||
}
|
||||
|
||||
public void testPutNotificationIndexTemplate() {
|
||||
|
|
|
@ -187,6 +187,7 @@ public class LocalExporterTemplateTests extends MonitoringIntegTestCase {
|
|||
.startObject("settings")
|
||||
.field("index.number_of_shards", 1)
|
||||
.field("index.number_of_replicas", 1)
|
||||
.field("index.mapping.single_type", false)
|
||||
.endObject()
|
||||
.startObject("mappings")
|
||||
.startObject("_default_")
|
||||
|
|
|
@ -51,6 +51,7 @@ import org.junit.AfterClass;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
@ -186,31 +187,6 @@ public class LocalExporterTests extends MonitoringIntegTestCase {
|
|||
assertAcked(client().admin().cluster().prepareUpdateSettings()
|
||||
.setTransientSettings(exporterSettings));
|
||||
|
||||
if (randomBoolean()) {
|
||||
// export some documents now, before starting the monitoring service
|
||||
final int nbDocs = randomIntBetween(1, 20);
|
||||
List<MonitoringBulkDoc> monitoringDocs = new ArrayList<>(nbDocs);
|
||||
for (int i = 0; i < nbDocs; i++) {
|
||||
monitoringDocs.add(createMonitoringBulkDoc(String.valueOf(i)));
|
||||
}
|
||||
|
||||
assertBusy(() -> {
|
||||
MonitoringBulkRequestBuilder bulk = monitoringClient().prepareMonitoringBulk();
|
||||
monitoringDocs.forEach(bulk::add);
|
||||
assertEquals(RestStatus.OK, bulk.get().status());
|
||||
refresh();
|
||||
|
||||
SearchResponse response = client().prepareSearch(".monitoring-*").get();
|
||||
assertEquals(nbDocs, response.getHits().getTotalHits());
|
||||
});
|
||||
|
||||
checkMonitoringTemplates();
|
||||
checkMonitoringPipeline();
|
||||
checkMonitoringAliases();
|
||||
checkMonitoringMappings();
|
||||
checkMonitoringDocs();
|
||||
}
|
||||
|
||||
// monitoring service is started
|
||||
exporterSettings = Settings.builder()
|
||||
.put(MonitoringSettings.INTERVAL.getKey(), 3L, TimeUnit.SECONDS);
|
||||
|
@ -396,7 +372,7 @@ public class LocalExporterTests extends MonitoringIntegTestCase {
|
|||
expectedIndex.add(".monitoring-data-2");
|
||||
}
|
||||
}
|
||||
assertTrue(expectedIndex.contains(hit.getIndex()));
|
||||
assertTrue("Expected " + expectedIndex + " but got " + hit.getIndex(), expectedIndex.contains(hit.getIndex()));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> sourceNode = (Map<String, Object>) source.get("source_node");
|
||||
|
@ -425,11 +401,7 @@ public class LocalExporterTests extends MonitoringIntegTestCase {
|
|||
source = builder.bytes();
|
||||
}
|
||||
|
||||
// Aligns the type with the monitoring index and monitored system so that we can later
|
||||
// check if the document is indexed in the correct index.
|
||||
String type = index.name().toLowerCase(Locale.ROOT) + "_" + monitoringId;
|
||||
|
||||
return new MonitoringBulkDoc(monitoringId, monitoringVersion, index, type, id, source,
|
||||
return new MonitoringBulkDoc(monitoringId, monitoringVersion, index, monitoringId, id, source,
|
||||
xContentType);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,8 +79,8 @@ public class WatchAckTests extends AbstractWatcherIntegrationTestCase {
|
|||
.input(searchInput(templateRequest(searchSource(), "events")))
|
||||
.condition(new CompareCondition("ctx.payload.hits.total", CompareCondition.Op.GT, 0L))
|
||||
.transform(searchTransform(templateRequest(searchSource(), "events")))
|
||||
.addAction("_a1", indexAction("actions", "action1"))
|
||||
.addAction("_a2", indexAction("actions", "action2"))
|
||||
.addAction("_a1", indexAction("actions1", "doc"))
|
||||
.addAction("_a2", indexAction("actions2", "doc"))
|
||||
.defaultThrottlePeriod(new TimeValue(0, TimeUnit.SECONDS)))
|
||||
.get();
|
||||
|
||||
|
@ -93,8 +93,8 @@ public class WatchAckTests extends AbstractWatcherIntegrationTestCase {
|
|||
assertThat(ackResponse.getStatus().actionStatus("_a2").ackStatus().state(), is(ActionStatus.AckStatus.State.ACKABLE));
|
||||
|
||||
refresh();
|
||||
long a1CountAfterAck = docCount("actions", "action1", matchAllQuery());
|
||||
long a2CountAfterAck = docCount("actions", "action2", matchAllQuery());
|
||||
long a1CountAfterAck = docCount("actions1", "doc", matchAllQuery());
|
||||
long a2CountAfterAck = docCount("actions2", "doc", matchAllQuery());
|
||||
assertThat(a1CountAfterAck, greaterThan(0L));
|
||||
assertThat(a2CountAfterAck, greaterThan(0L));
|
||||
|
||||
|
@ -103,11 +103,11 @@ public class WatchAckTests extends AbstractWatcherIntegrationTestCase {
|
|||
refresh();
|
||||
|
||||
// There shouldn't be more a1 actions in the index after we ack the watch, even though the watch was triggered
|
||||
long a1CountAfterPostAckFires = docCount("actions", "action1", matchAllQuery());
|
||||
long a1CountAfterPostAckFires = docCount("actions1", "doc", matchAllQuery());
|
||||
assertThat(a1CountAfterPostAckFires, equalTo(a1CountAfterAck));
|
||||
|
||||
// There should be more a2 actions in the index after we ack the watch
|
||||
long a2CountAfterPostAckFires = docCount("actions", "action2", matchAllQuery());
|
||||
long a2CountAfterPostAckFires = docCount("actions2", "doc", matchAllQuery());
|
||||
assertThat(a2CountAfterPostAckFires, greaterThan(a2CountAfterAck));
|
||||
|
||||
// Now delete the event and the ack states should change to AWAITS_EXECUTION
|
||||
|
@ -139,8 +139,8 @@ public class WatchAckTests extends AbstractWatcherIntegrationTestCase {
|
|||
.input(searchInput(templateRequest(searchSource(), "events")))
|
||||
.condition(new CompareCondition("ctx.payload.hits.total", CompareCondition.Op.GT, 0L))
|
||||
.transform(searchTransform(templateRequest(searchSource(), "events")))
|
||||
.addAction("_a1", indexAction("actions", "action1"))
|
||||
.addAction("_a2", indexAction("actions", "action2"))
|
||||
.addAction("_a1", indexAction("actions1", "doc"))
|
||||
.addAction("_a2", indexAction("actions2", "doc"))
|
||||
.defaultThrottlePeriod(new TimeValue(0, TimeUnit.SECONDS)))
|
||||
.get();
|
||||
|
||||
|
@ -161,8 +161,8 @@ public class WatchAckTests extends AbstractWatcherIntegrationTestCase {
|
|||
assertThat(ackResponse.getStatus().actionStatus("_a2").ackStatus().state(), is(ActionStatus.AckStatus.State.ACKED));
|
||||
|
||||
refresh();
|
||||
long a1CountAfterAck = docCount("actions", "action1", matchAllQuery());
|
||||
long a2CountAfterAck = docCount("actions", "action2", matchAllQuery());
|
||||
long a1CountAfterAck = docCount("actions1", "doc", matchAllQuery());
|
||||
long a2CountAfterAck = docCount("actions2", "doc", matchAllQuery());
|
||||
assertThat(a1CountAfterAck, greaterThanOrEqualTo((long) 1));
|
||||
assertThat(a2CountAfterAck, greaterThanOrEqualTo((long) 1));
|
||||
|
||||
|
@ -171,11 +171,11 @@ public class WatchAckTests extends AbstractWatcherIntegrationTestCase {
|
|||
refresh();
|
||||
|
||||
// There shouldn't be more a1 actions in the index after we ack the watch, even though the watch was triggered
|
||||
long a1CountAfterPostAckFires = docCount("actions", "action1", matchAllQuery());
|
||||
long a1CountAfterPostAckFires = docCount("actions1", "doc", matchAllQuery());
|
||||
assertThat(a1CountAfterPostAckFires, equalTo(a1CountAfterAck));
|
||||
|
||||
// There shouldn't be more a2 actions in the index after we ack the watch, even though the watch was triggered
|
||||
long a2CountAfterPostAckFires = docCount("actions", "action2", matchAllQuery());
|
||||
long a2CountAfterPostAckFires = docCount("actions2", "doc", matchAllQuery());
|
||||
assertThat(a2CountAfterPostAckFires, equalTo(a2CountAfterAck));
|
||||
|
||||
// Now delete the event and the ack states should change to AWAITS_EXECUTION
|
||||
|
|
Loading…
Reference in New Issue