-
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.
Browse files
Browse the repository at this point in the history
Reindex sort never gave a guarantee about the order of documents being indexed into the destination, though it could give a sense of locality of source data. It prevents us from doing resilient reindex and other optimizations and it has therefore been deprecated. Related to #47567
- Loading branch information
1 parent
62a891b
commit 5adb33e
Showing
8 changed files
with
98 additions
and
49 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
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
60 changes: 60 additions & 0 deletions
60
modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexSingleNodeTests.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,60 @@ | ||
/* | ||
* 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.index.query.RangeQueryBuilder; | ||
import org.elasticsearch.plugins.Plugin; | ||
import org.elasticsearch.search.sort.SortOrder; | ||
import org.elasticsearch.test.ESSingleNodeTestCase; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
|
||
import static org.elasticsearch.index.reindex.ReindexTestCase.matcher; | ||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; | ||
|
||
public class ReindexSingleNodeTests extends ESSingleNodeTestCase { | ||
@Override | ||
protected Collection<Class<? extends Plugin>> getPlugins() { | ||
return Arrays.asList(ReindexPlugin.class); | ||
} | ||
|
||
public void testDeprecatedSort() { | ||
int max = between(2, 20); | ||
for (int i = 0; i < max; i++) { | ||
client().prepareIndex("source", "_doc").setId(Integer.toString(i)).setSource("foo", i).get(); | ||
} | ||
|
||
client().admin().indices().prepareRefresh("source").get(); | ||
assertHitCount(client().prepareSearch("source").setSize(0).get(), max); | ||
|
||
// Copy a subset of the docs sorted | ||
int subsetSize = randomIntBetween(1, max - 1); | ||
ReindexRequestBuilder copy = new ReindexRequestBuilder(client(), ReindexAction.INSTANCE) | ||
.source("source").destination("dest").refresh(true); | ||
copy.maxDocs(subsetSize); | ||
copy.request().addSortField("foo", SortOrder.DESC); | ||
assertThat(copy.get(), matcher().created(subsetSize)); | ||
|
||
assertHitCount(client().prepareSearch("dest").setSize(0).get(), subsetSize); | ||
assertHitCount(client().prepareSearch("dest").setQuery(new RangeQueryBuilder("foo").gte(0).lt(max-subsetSize)).get(), 0); | ||
assertWarnings(Reindexer.SORT_DEPRECATED_MESSAGE); | ||
} | ||
} |
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