Skip to content
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

Enabling sort optimization back for half_float with custom comparators #11024

Merged
merged 15 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- [AdmissionControl] Added changes for AdmissionControl Interceptor and AdmissionControlService for RateLimiting ([#9286](https://github.com/opensearch-project/OpenSearch/pull/9286))
- GHA to verify checklist items completion in PR descriptions ([#10800](https://github.com/opensearch-project/OpenSearch/pull/10800))
- [Remote cluster state] Restore cluster state version during remote state auto restore ([#10853](https://github.com/opensearch-project/OpenSearch/pull/10853))
- Add back half_float BKD based sort query optimization ([#11024](https://github.com/opensearch-project/OpenSearch/pull/11024))

### Dependencies
- Bump `log4j-core` from 2.18.0 to 2.19.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,23 @@
query: {"range": { "rank": { "from": 0 } } }
track_total_hits: false
size: 3

---
"Index Sort half float":
- do:
catch: bad_request
indices.create:
index: test
body:
settings:
number_of_shards: 1
number_of_replicas: 0
index.sort.field: rank
mappings:
properties:
rank:
type: half_float

# This should failed with 400 as half_float is not supported for index sort
- match: { status: 400 }
- match: { error.type: illegal_argument_exception }
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
properties:
counter:
type: double

- do:
bulk:
refresh: true
Expand Down Expand Up @@ -119,3 +120,87 @@
- match: { status: 400 }
- match: { error.type: search_phase_execution_exception }
- match: { error.caused_by.reason: "Can't do sort across indices, as a field has [unsigned_long] type in one index, and different type in another index!" }

---
"search across indices with mixed long and double and float numeric types":
- skip:
version: " - 2.10.99"
reason: half float was broken before 2.11
gashutos marked this conversation as resolved.
Show resolved Hide resolved

- do:
indices.create:
index: test_1
body:
mappings:
properties:
counter:
type: long

- do:
indices.create:
index: test_2
body:
mappings:
properties:
counter:
type: double

- do:
indices.create:
index: test_3
body:
mappings:
properties:
counter:
type: half_float

- do:
bulk:
refresh: true
body:
- index:
_index: test_1
- counter: 223372036854775800
- index:
_index: test_2
- counter: 1223372036854775800.23
- index:
_index: test_2
- counter: 184.4
- index:
_index: test_3
- counter: 187.4
- index:
_index: test_3
- counter: 194.4

- do:
search:
index: test_*
rest_total_hits_as_int: true
body:
sort: [{ counter: desc }]
- match: { hits.total: 5 }
- length: { hits.hits: 5 }
- match: { hits.hits.0._index: test_2 }
- match: { hits.hits.0._source.counter: 1223372036854775800.23 }
- match: { hits.hits.0.sort.0: 1223372036854775800.23 }
- match: { hits.hits.1._index: test_1 }
- match: { hits.hits.1._source.counter: 223372036854775800 }
- match: { hits.hits.1.sort.0: 223372036854775800 }
gashutos marked this conversation as resolved.
Show resolved Hide resolved
- match: { hits.hits.2._index: test_3 }
- match: { hits.hits.2._source.counter: 194.4 }

- do:
search:
index: test_*
rest_total_hits_as_int: true
body:
sort: [{ counter: asc }]
- match: { hits.total: 5 }
- length: { hits.hits: 5 }
- match: { hits.hits.0._index: test_2 }
- match: { hits.hits.0._source.counter: 184.4 }
- match: { hits.hits.0.sort.0: 184.4 }
- match: { hits.hits.1._index: test_3 }
- match: { hits.hits.1._source.counter: 187.4 }
Loading
Loading