-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit introduces the formal notion of a private setting. This enables us to register some settings that we had previously not registered as fully-fledged settings to avoid them being exposed via APIs such as the create index API. For example, we had hacks in the codebase to allow index.version.created to be passed around inside of settings objects, but was not registered as a setting so that if a user tried to use the setting on any API then they would get an exception. This prevented users from setting index.version.created on index creation, or updating it via the index settings API. By introducing private settings, we can continue to reject these attempts, yet now we can represent these settings as actual settings. In this change, we register index.version.created as an actual setting. We do not cutover all settings that we had been treating as private in this pull request, it is already quite large due to moving some tests around to account for the fact that some tests need to be able to set the index.version.created. This can be done in a follow-up change.
- Loading branch information
1 parent
4da9f18
commit 4ff1b1d
Showing
116 changed files
with
4,416 additions
and
2,481 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
.../reindex/src/test/java/org/elasticsearch/index/reindex/LegacyDeleteByQueryBasicTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* 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.index.reindex; | ||
|
||
import org.elasticsearch.Version; | ||
import org.elasticsearch.common.settings.Settings; | ||
|
||
import static org.elasticsearch.index.query.QueryBuilders.termQuery; | ||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; | ||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; | ||
|
||
public class LegacyDeleteByQueryBasicTests extends ReindexTestCase { | ||
|
||
@Override | ||
protected boolean forbidPrivateIndexSettings() { | ||
return false; | ||
} | ||
|
||
/** | ||
* Test delete by query support for filtering by type. This entire feature | ||
* can and should be removed when we drop support for types index with | ||
* multiple types from core. | ||
*/ | ||
public void testFilterByType() throws Exception { | ||
assertAcked(client().admin().indices().prepareCreate("test") | ||
.setSettings(Settings.builder().put("index.version.created", Version.V_5_6_0.id))); // allows for multiple types | ||
indexRandom(true, | ||
client().prepareIndex("test", "test1", "1").setSource("foo", "a"), | ||
client().prepareIndex("test", "test2", "2").setSource("foo", "a"), | ||
client().prepareIndex("test", "test2", "3").setSource("foo", "b")); | ||
|
||
assertHitCount(client().prepareSearch("test").setSize(0).get(), 3); | ||
|
||
// Deletes doc of the type "type2" that also matches foo:a | ||
DeleteByQueryRequestBuilder builder = deleteByQuery().source("test").filter(termQuery("foo", "a")).refresh(true); | ||
builder.source().setTypes("test2"); | ||
assertThat(builder.get(), matcher().deleted(1)); | ||
assertHitCount(client().prepareSearch("test").setSize(0).get(), 2); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
...c/test/java/org/elasticsearch/index/mapper/LegacyICUCollationKeywordFieldMapperTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* | ||
* 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.index.mapper; | ||
|
||
import com.ibm.icu.text.Collator; | ||
import com.ibm.icu.text.RawCollationKey; | ||
import com.ibm.icu.util.ULocale; | ||
import org.apache.lucene.index.DocValuesType; | ||
import org.apache.lucene.index.IndexOptions; | ||
import org.apache.lucene.index.IndexableField; | ||
import org.apache.lucene.index.IndexableFieldType; | ||
import org.apache.lucene.util.BytesRef; | ||
import org.elasticsearch.Version; | ||
import org.elasticsearch.common.Strings; | ||
import org.elasticsearch.common.bytes.BytesReference; | ||
import org.elasticsearch.common.compress.CompressedXContent; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.common.xcontent.XContentFactory; | ||
import org.elasticsearch.common.xcontent.XContentType; | ||
import org.elasticsearch.index.IndexService; | ||
import org.elasticsearch.plugin.analysis.icu.AnalysisICUPlugin; | ||
import org.elasticsearch.plugins.Plugin; | ||
import org.elasticsearch.test.ESSingleNodeTestCase; | ||
|
||
import java.util.Collection; | ||
import java.util.Collections; | ||
|
||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
public class LegacyICUCollationKeywordFieldMapperTests extends ESSingleNodeTestCase { | ||
|
||
@Override | ||
protected Collection<Class<? extends Plugin>> getPlugins() { | ||
return Collections.singletonList(AnalysisICUPlugin.class); | ||
} | ||
|
||
@Override | ||
protected boolean forbidPrivateIndexSettings() { | ||
return false; | ||
} | ||
|
||
public void testBackCompat() throws Exception { | ||
final IndexService indexService = createIndex("oldindex", Settings.builder().put("index.version.created", Version.V_5_5_0).build()); | ||
final DocumentMapperParser parser = indexService.mapperService().documentMapperParser(); | ||
|
||
String mapping = Strings.toString(XContentFactory.jsonBuilder().startObject().startObject("type") | ||
.startObject("_all").field("enabled", false).endObject() | ||
.startObject("properties").startObject("field").field("type", "icu_collation_keyword").endObject().endObject() | ||
.endObject().endObject()); | ||
|
||
DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping)); | ||
|
||
assertEquals(mapping, mapper.mappingSource().toString()); | ||
|
||
ParsedDocument doc = mapper.parse(SourceToParse.source("oldindex", "type", "1", BytesReference | ||
.bytes(XContentFactory.jsonBuilder() | ||
.startObject() | ||
.field("field", "1234") | ||
.endObject()), | ||
XContentType.JSON)); | ||
|
||
IndexableField[] fields = doc.rootDoc().getFields("field"); | ||
assertEquals(2, fields.length); | ||
|
||
Collator collator = Collator.getInstance(ULocale.ROOT); | ||
RawCollationKey key = collator.getRawCollationKey("1234", null); | ||
BytesRef expected = new BytesRef(key.bytes, 0, key.size); | ||
|
||
assertEquals(expected, fields[0].binaryValue()); | ||
IndexableFieldType fieldType = fields[0].fieldType(); | ||
assertThat(fieldType.omitNorms(), equalTo(true)); | ||
assertFalse(fieldType.tokenized()); | ||
assertFalse(fieldType.stored()); | ||
assertThat(fieldType.indexOptions(), equalTo(IndexOptions.DOCS)); | ||
assertThat(fieldType.storeTermVectors(), equalTo(false)); | ||
assertThat(fieldType.storeTermVectorOffsets(), equalTo(false)); | ||
assertThat(fieldType.storeTermVectorPositions(), equalTo(false)); | ||
assertThat(fieldType.storeTermVectorPayloads(), equalTo(false)); | ||
assertEquals(DocValuesType.NONE, fieldType.docValuesType()); | ||
|
||
assertEquals(expected, fields[1].binaryValue()); | ||
fieldType = fields[1].fieldType(); | ||
assertThat(fieldType.indexOptions(), equalTo(IndexOptions.NONE)); | ||
assertEquals(DocValuesType.SORTED, fieldType.docValuesType()); | ||
} | ||
|
||
} |
Oops, something went wrong.