-
Notifications
You must be signed in to change notification settings - Fork 24.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cumulative backport of async search changes (#53635)
* Submit async search to work only with POST (#53368) Currently the submit async search API can be called using both GET and POST at REST, but given that it submits a call and creates internal state, POST should be the only allowed method. * Refine SearchProgressListener internal API (#53373) The following cumulative improvements have been made: - rename `onReduce` and `notifyReduce` to `onFinalReduce` and `notifyFinalReduce` - add unit test for `SearchShard` - on* methods in `SearchProgressListener` shouldn't need to be public as they should never be called directly, they only need to be overridden hence they can be made protected. They are actually called directly from a test which required some adapting, like making `AsyncSearchTask.Listener` class package private instead of private - Instead of overriding `getProgressListener` in `AsyncSearchTask`, as it feels weird to override a getter method, added a specific method that allows to retrieve the Listener directly without needing to cast it. Made the getter and setter for the listener final in the base class. - rename `SearchProgressListener#searchShards` methods to `buildSearchShards` and make it static given that it accesses no instance members - make `SearchShard` and `SearchShardTask` classes final * Move async search yaml tests to x-pack yaml test folder (#53537) The yaml tests for async search currently sit in its qa folder. There is no reason though for them to live in a separate folder as they don't require particular setup. This commit moves them to the main folder together with the other x-pack yaml tests so that they will be run by the client test runners too. * [DOCS] Add temporary redirect for async-search (#53454) The following API spec files contain a link to a not-yet-created async search docs page: * [async_search.delete.json][0] * [async_search.get.json][1] * [async_search.submit.json][2] The Elaticsearch-js client uses these spec files to create their docs. This created a broken link in the Elaticsearch-js docs, which has broken the docs build. This PR adds a temporary redirect for the docs page. This redirect should be removed when the actual API docs are added. [0]: https://github.com/elastic/elasticsearch/blob/master/x-pack/plugin/src/test/resources/rest-api-spec/api/async_search.delete.json [1]: https://github.com/elastic/elasticsearch/blob/master/x-pack/plugin/src/test/resources/rest-api-spec/api/async_search.get.json [2]: https://github.com/elastic/elasticsearch/blob/master/x-pack/plugin/src/test/resources/rest-api-spec/api/async_search.submit.json Co-authored-by: James Rodewig <james.rodewig@elastic.co>
- Loading branch information
Showing
23 changed files
with
151 additions
and
182 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
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
83 changes: 83 additions & 0 deletions
83
server/src/test/java/org/elasticsearch/action/search/SearchShardTests.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,83 @@ | ||
/* | ||
* 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.action.search; | ||
|
||
import org.elasticsearch.index.Index; | ||
import org.elasticsearch.index.shard.ShardId; | ||
import org.elasticsearch.test.ESTestCase; | ||
import org.elasticsearch.test.EqualsHashCodeTestUtils; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class SearchShardTests extends ESTestCase { | ||
|
||
public void testEqualsAndHashcode() { | ||
String index = randomAlphaOfLengthBetween(5, 10); | ||
SearchShard searchShard = new SearchShard(randomBoolean() ? null : randomAlphaOfLengthBetween(3, 10), | ||
new ShardId(index, index + "-uuid", randomIntBetween(0, 1024))); | ||
EqualsHashCodeTestUtils.checkEqualsAndHashCode(searchShard, | ||
s -> new SearchShard(s.getClusterAlias(), s.getShardId()), | ||
s -> { | ||
if (randomBoolean()) { | ||
return new SearchShard(s.getClusterAlias() == null ? randomAlphaOfLengthBetween(3, 10) : null, s.getShardId()); | ||
} else { | ||
String indexName = s.getShardId().getIndexName(); | ||
int shardId = s.getShardId().getId(); | ||
if (randomBoolean()) { | ||
indexName += randomAlphaOfLength(5); | ||
} else { | ||
shardId += randomIntBetween(1, 1024); | ||
} | ||
return new SearchShard(s.getClusterAlias(), new ShardId(indexName, indexName + "-uuid", shardId)); | ||
} | ||
}); | ||
} | ||
|
||
public void testCompareTo() { | ||
List<SearchShard> searchShards = new ArrayList<>(); | ||
Index index0 = new Index("index0", "index0-uuid"); | ||
Index index1 = new Index("index1", "index1-uuid"); | ||
searchShards.add(new SearchShard(null, new ShardId(index0, 0))); | ||
searchShards.add(new SearchShard(null, new ShardId(index1, 0))); | ||
searchShards.add(new SearchShard(null, new ShardId(index0, 1))); | ||
searchShards.add(new SearchShard(null, new ShardId(index1, 1))); | ||
searchShards.add(new SearchShard(null, new ShardId(index0, 2))); | ||
searchShards.add(new SearchShard(null, new ShardId(index1, 2))); | ||
searchShards.add(new SearchShard("", new ShardId(index0, 0))); | ||
searchShards.add(new SearchShard("", new ShardId(index1, 0))); | ||
searchShards.add(new SearchShard("", new ShardId(index0, 1))); | ||
searchShards.add(new SearchShard("", new ShardId(index1, 1))); | ||
|
||
searchShards.add(new SearchShard("remote0", new ShardId(index0, 0))); | ||
searchShards.add(new SearchShard("remote0", new ShardId(index1, 0))); | ||
searchShards.add(new SearchShard("remote0", new ShardId(index0, 1))); | ||
searchShards.add(new SearchShard("remote0", new ShardId(index0, 2))); | ||
searchShards.add(new SearchShard("remote1", new ShardId(index0, 0))); | ||
searchShards.add(new SearchShard("remote1", new ShardId(index1, 0))); | ||
searchShards.add(new SearchShard("remote1", new ShardId(index0, 1))); | ||
searchShards.add(new SearchShard("remote1", new ShardId(index1, 1))); | ||
|
||
List<SearchShard> sorted = new ArrayList<>(searchShards); | ||
Collections.sort(sorted); | ||
assertEquals(searchShards, sorted); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
35 changes: 0 additions & 35 deletions
35
.../async-search/qa/rest/src/test/java/org/elasticsearch/xpack/search/AsyncSearchRestIT.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.