-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Enable sort optimization on int, short and byte fields #127968
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mayya-sharipova
wants to merge
12
commits into
elastic:main
Choose a base branch
from
mayya-sharipova:sort_optimization_int_short_byte
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ee28fc1
Enable sort optimizaiton on int, short and byte fields
mayya-sharipova 7beadf3
Update docs/changelog/127968.yaml
mayya-sharipova a9f5a8b
Fix tests
mayya-sharipova 44e64b2
Fix test failures
mayya-sharipova 25cebb8
Merge branch 'main' into sort_optimization_int_short_byte
mayya-sharipova 2ea6efd
Fix test and add clarification to SearchAfterBuilder
mayya-sharipova 443e7df
Fix BWC tests
mayya-sharipova 2cfaacd
Merge branch 'main' into sort_optimization_int_short_byte
mayya-sharipova 4341c8d
Update docs/changelog/127968.yaml
mayya-sharipova 2796301
Merge branch 'main' into sort_optimization_int_short_byte
mayya-sharipova b13cba1
Merge branch 'main' into sort_optimization_int_short_byte
mayya-sharipova 8404d0f
Add more tests
mayya-sharipova File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,5 @@ | ||
pr: 127968 | ||
summary: "Enable sort optimization on int, short and byte fields" | ||
area: Search | ||
type: enhancement | ||
issues: [] |
87 changes: 87 additions & 0 deletions
87
qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/IndexSortUpgradeIT.java
This file contains hidden or 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,87 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
package org.elasticsearch.upgrades; | ||
|
||
import com.carrotsearch.randomizedtesting.annotations.Name; | ||
|
||
import org.elasticsearch.client.Request; | ||
import org.elasticsearch.common.settings.Settings; | ||
|
||
/** | ||
* Tests that index sorting works correctly after a rolling upgrade. | ||
*/ | ||
public class IndexSortUpgradeIT extends AbstractRollingUpgradeTestCase { | ||
|
||
public IndexSortUpgradeIT(@Name("upgradedNodes") int upgradedNodes) { | ||
super(upgradedNodes); | ||
} | ||
|
||
public void testIndexSortForNumericTypes() throws Exception { | ||
record IndexConfig(String indexName, String fieldName, String fieldType) {} | ||
var configs = new IndexConfig[] { | ||
new IndexConfig("index_byte", "byte_field", "byte"), | ||
new IndexConfig("index_short", "short_field", "short"), | ||
new IndexConfig("index_int", "int_field", "integer") }; | ||
|
||
if (isOldCluster()) { | ||
int numShards = randomIntBetween(1, 3); | ||
for (var config : configs) { | ||
createIndex( | ||
config.indexName(), | ||
Settings.builder() | ||
.put("index.number_of_shards", numShards) | ||
.put("index.number_of_replicas", 0) | ||
.put("index.sort.field", config.fieldName()) | ||
.put("index.sort.order", "desc") | ||
.build(), | ||
""" | ||
{ | ||
"properties": { | ||
"%s": { | ||
"type": "%s" | ||
} | ||
} | ||
} | ||
""".formatted(config.fieldName(), config.fieldType()) | ||
); | ||
} | ||
} | ||
|
||
final int numDocs = randomIntBetween(10, 25); | ||
for (var config : configs) { | ||
var bulkRequest = new Request("POST", "/" + config.indexName() + "/_bulk"); | ||
StringBuilder bulkBody = new StringBuilder(); | ||
for (int i = 0; i < numDocs; i++) { | ||
bulkBody.append("{\"index\": {}}\n"); | ||
bulkBody.append("{\"" + config.fieldName() + "\": ").append(i).append("}\n"); | ||
} | ||
bulkRequest.setJsonEntity(bulkBody.toString()); | ||
bulkRequest.addParameter("refresh", "true"); | ||
var bulkResponse = client().performRequest(bulkRequest); | ||
assertOK(bulkResponse); | ||
|
||
var searchRequest = new Request("GET", "/" + config.indexName() + "/_search"); | ||
searchRequest.setJsonEntity(""" | ||
{ | ||
"query": { | ||
"match_all": {} | ||
}, | ||
"sort": { | ||
"%s": { | ||
"order": "desc" | ||
} | ||
} | ||
} | ||
""".formatted(config.fieldName())); | ||
var searchResponse = client().performRequest(searchRequest); | ||
assertOK(searchResponse); | ||
} | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.