Merge branch 'master' into docs/add_console_to_search
This commit is contained in:
commit
1e91123555
|
@ -281,8 +281,11 @@ public class MetaDataMappingService extends AbstractComponent {
|
|||
// Also the order of the mappings may be backwards.
|
||||
if (newMapper.parentFieldMapper().active()) {
|
||||
for (ObjectCursor<MappingMetaData> mapping : indexMetaData.getMappings().values()) {
|
||||
if (newMapper.parentFieldMapper().type().equals(mapping.value.type())) {
|
||||
throw new IllegalArgumentException("can't add a _parent field that points to an already existing type");
|
||||
String parentType = newMapper.parentFieldMapper().type();
|
||||
if (parentType.equals(mapping.value.type()) &&
|
||||
indexService.mapperService().getParentTypes().contains(parentType) == false) {
|
||||
throw new IllegalArgumentException("can't add a _parent field that points to an " +
|
||||
"already existing type, that isn't already a parent");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,6 +87,7 @@ import org.elasticsearch.repositories.fs.FsRepository;
|
|||
import org.elasticsearch.repositories.uri.URLRepository;
|
||||
import org.elasticsearch.rest.BaseRestHandler;
|
||||
import org.elasticsearch.script.ScriptService;
|
||||
import org.elasticsearch.search.SearchModule;
|
||||
import org.elasticsearch.search.SearchService;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.Transport;
|
||||
|
@ -420,6 +421,7 @@ public final class ClusterSettings extends AbstractScopedSettings {
|
|||
ResourceWatcherService.ENABLED,
|
||||
ResourceWatcherService.RELOAD_INTERVAL_HIGH,
|
||||
ResourceWatcherService.RELOAD_INTERVAL_MEDIUM,
|
||||
ResourceWatcherService.RELOAD_INTERVAL_LOW
|
||||
ResourceWatcherService.RELOAD_INTERVAL_LOW,
|
||||
SearchModule.INDICES_MAX_CLAUSE_COUNT_SETTING
|
||||
)));
|
||||
}
|
||||
|
|
|
@ -65,7 +65,12 @@ public class SettingsModule extends AbstractModule {
|
|||
protected void configure() {
|
||||
final IndexScopedSettings indexScopedSettings = new IndexScopedSettings(settings, new HashSet<>(this.indexSettings.values()));
|
||||
final ClusterSettings clusterSettings = new ClusterSettings(settings, new HashSet<>(this.nodeSettings.values()));
|
||||
Settings indexSettings = settings.filter((s) -> s.startsWith("index.") && clusterSettings.get(s) == null);
|
||||
Settings indexSettings = settings.filter((s) -> (s.startsWith("index.") &&
|
||||
// special case - we want to get Did you mean indices.query.bool.max_clause_count
|
||||
// which means we need to by-pass this check for this setting
|
||||
// TODO remove in 6.0!!
|
||||
"index.query.bool.max_clause_count".equals(s) == false)
|
||||
&& clusterSettings.get(s) == null);
|
||||
if (indexSettings.isEmpty() == false) {
|
||||
try {
|
||||
String separator = IntStream.range(0, 85).mapToObj(s -> "*").collect(Collectors.joining("")).trim();
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.elasticsearch.common.io.stream.NamedWriteable;
|
|||
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
|
||||
import org.elasticsearch.common.io.stream.Writeable;
|
||||
import org.elasticsearch.common.lucene.search.function.ScoreFunction;
|
||||
import org.elasticsearch.common.settings.Setting;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.ParseFieldRegistry;
|
||||
import org.elasticsearch.index.percolator.PercolatorHighlightSubFetchPhase;
|
||||
|
@ -290,6 +291,8 @@ public class SearchModule extends AbstractModule {
|
|||
|
||||
private final Settings settings;
|
||||
private final NamedWriteableRegistry namedWriteableRegistry;
|
||||
public static final Setting<Integer> INDICES_MAX_CLAUSE_COUNT_SETTING = Setting.intSetting("indices.query.bool.max_clause_count",
|
||||
1024, 1, Integer.MAX_VALUE, Setting.Property.NodeScope);
|
||||
|
||||
// pkg private so tests can mock
|
||||
Class<? extends SearchService> searchServiceImpl = SearchService.class;
|
||||
|
@ -650,8 +653,7 @@ public class SearchModule extends AbstractModule {
|
|||
registerQuery(MatchAllQueryBuilder::new, MatchAllQueryBuilder::fromXContent, MatchAllQueryBuilder.QUERY_NAME_FIELD);
|
||||
registerQuery(QueryStringQueryBuilder::new, QueryStringQueryBuilder::fromXContent, QueryStringQueryBuilder.QUERY_NAME_FIELD);
|
||||
registerQuery(BoostingQueryBuilder::new, BoostingQueryBuilder::fromXContent, BoostingQueryBuilder.QUERY_NAME_FIELD);
|
||||
BooleanQuery.setMaxClauseCount(settings.getAsInt("index.query.bool.max_clause_count",
|
||||
settings.getAsInt("indices.query.bool.max_clause_count", BooleanQuery.getMaxClauseCount())));
|
||||
BooleanQuery.setMaxClauseCount(INDICES_MAX_CLAUSE_COUNT_SETTING.get(settings));
|
||||
registerQuery(BoolQueryBuilder::new, BoolQueryBuilder::fromXContent, BoolQueryBuilder.QUERY_NAME_FIELD);
|
||||
registerQuery(TermQueryBuilder::new, TermQueryBuilder::fromXContent, TermQueryBuilder.QUERY_NAME_FIELD);
|
||||
registerQuery(TermsQueryBuilder::new, TermsQueryBuilder::fromXContent, TermsQueryBuilder.QUERY_NAME_FIELD);
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.elasticsearch.cluster.metadata;
|
||||
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.IndexService;
|
||||
import org.elasticsearch.index.mapper.DocumentMapper;
|
||||
import org.elasticsearch.test.ESSingleNodeTestCase;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
public class MetaDataMappingServiceTests extends ESSingleNodeTestCase {
|
||||
|
||||
// Tests _parent meta field logic, because part of the validation is in MetaDataMappingService
|
||||
public void testAddChildTypePointingToAlreadyExistingType() throws Exception {
|
||||
createIndex("test", Settings.EMPTY, "type", "field", "type=keyword");
|
||||
|
||||
// Shouldn't be able the add the _parent field pointing to an already existing type, which isn't a parent type
|
||||
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> client().admin()
|
||||
.indices()
|
||||
.preparePutMapping("test")
|
||||
.setType("child")
|
||||
.setSource("_parent", "type=type")
|
||||
.get());
|
||||
assertThat(e.getMessage(),
|
||||
equalTo("can't add a _parent field that points to an already existing type, that isn't already a parent"));
|
||||
}
|
||||
|
||||
// Tests _parent meta field logic, because part of the validation is in MetaDataMappingService
|
||||
public void testAddExtraChildTypePointingToAlreadyParentExistingType() throws Exception {
|
||||
IndexService indexService = createIndex("test", client().admin().indices().prepareCreate("test")
|
||||
.addMapping("parent")
|
||||
.addMapping("child1", "_parent", "type=parent")
|
||||
);
|
||||
|
||||
// adding the extra child type that points to an already existing parent type is allowed:
|
||||
client().admin()
|
||||
.indices()
|
||||
.preparePutMapping("test")
|
||||
.setType("child2")
|
||||
.setSource("_parent", "type=parent")
|
||||
.get();
|
||||
|
||||
DocumentMapper documentMapper = indexService.mapperService().documentMapper("child2");
|
||||
assertThat(documentMapper.parentFieldMapper().type(), equalTo("parent"));
|
||||
assertThat(documentMapper.parentFieldMapper().active(), is(true));
|
||||
}
|
||||
|
||||
}
|
|
@ -208,4 +208,13 @@ public class SettingsModuleTests extends ModuleTestCase {
|
|||
assertThat(e.getMessage(), containsString("Cannot register setting [foo.bar] twice"));
|
||||
}
|
||||
}
|
||||
|
||||
public void testOldMaxClauseCountSetting() {
|
||||
Settings settings = Settings.builder().put("index.query.bool.max_clause_count", 1024).build();
|
||||
SettingsModule module = new SettingsModule(settings);
|
||||
IllegalArgumentException ex = expectThrows(IllegalArgumentException.class,
|
||||
() -> assertInstanceBinding(module, Settings.class, (s) -> s == settings));
|
||||
assertEquals("unknown setting [index.query.bool.max_clause_count] did you mean [indices.query.bool.max_clause_count]?",
|
||||
ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ public class MatchQueryBuilderTests extends AbstractQueryTestCase<MatchQueryBuil
|
|||
}
|
||||
|
||||
if (randomBoolean()) {
|
||||
matchQuery.maxExpansions(randomIntBetween(0, 1000));
|
||||
matchQuery.maxExpansions(randomIntBetween(1, 1000));
|
||||
}
|
||||
|
||||
if (randomBoolean()) {
|
||||
|
|
|
@ -1321,29 +1321,6 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
public void testAddParentFieldAfterIndexingParentDocButBeforeIndexingChildDoc() throws Exception {
|
||||
assertAcked(prepareCreate("test")
|
||||
.setSettings(Settings.builder()
|
||||
.put(indexSettings())
|
||||
.put("index.refresh_interval", -1)));
|
||||
ensureGreen();
|
||||
|
||||
String parentId = "p1";
|
||||
client().prepareIndex("test", "parent", parentId).setSource("p_field", "1").get();
|
||||
refresh();
|
||||
|
||||
try {
|
||||
assertAcked(client().admin()
|
||||
.indices()
|
||||
.preparePutMapping("test")
|
||||
.setType("child")
|
||||
.setSource("_parent", "type=parent"));
|
||||
fail("Shouldn't be able the add the _parent field pointing to an already existing parent type");
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertThat(e.getMessage(), equalTo("can't add a _parent field that points to an already existing type"));
|
||||
}
|
||||
}
|
||||
|
||||
public void testParentChildCaching() throws Exception {
|
||||
assertAcked(prepareCreate("test")
|
||||
.setSettings(
|
||||
|
|
|
@ -258,3 +258,9 @@ Previously script mode settings (e.g., "script.inline: true",
|
|||
Prior to 5.0 a third option could be specified for the `script.inline` and
|
||||
`script.stored` settings ("sandbox"). This has been removed, You can now only
|
||||
set `script.line: true` or `script.stored: true`.
|
||||
|
||||
==== Search settings
|
||||
|
||||
The setting `index.query.bool.max_clause_count` has been removed. In order to
|
||||
set the maximum number of boolean clauses `indices.query.bool.max_clause_count`
|
||||
should be used instead.
|
||||
|
|
Loading…
Reference in New Issue