Skip to content

Commit

Permalink
Add initial rest-api-spec tests
Browse files Browse the repository at this point in the history
Signed-off-by: Andriy Redko <[email protected]>
  • Loading branch information
reta authored and bugmakerrrrrr committed Dec 11, 2024
1 parent 0e58cf2 commit b1f8f7a
Show file tree
Hide file tree
Showing 2 changed files with 135 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
setup:
- do:
indices.create:
index: unsigned_long_sort
body:
settings:
number_of_shards: 3
number_of_replicas: 0
mappings:
properties:
field:
type: unsigned_long

---
"test sorting against unsigned_long only fields":
- skip:
version: " - 2.19.99"
reason: "this change is added in 3.0.0"

- do:
bulk:
refresh: true
body:
- '{ "index" : { "_index" : "unsigned_long_sort", "_id" : "1" } }'
- '{"field" : [ 13835058055282163712, 1 ] }'
- '{ "index" : { "_index" : "unsigned_long_sort", "_id" : "2" } }'
- '{"field" : [ 13835058055282163713, 2 ] }'
- '{ "index" : { "_index" : "unsigned_long_sort", "_id" : "3" } }'
- '{"field" : [ 13835058055282163714, 3 ] }'

- do:
search:
index: unsigned_long_sort
body:
size: 5
sort: [{ field: { mode: max, order: desc } } ]
- match: {hits.total.value: 3 }
- length: {hits.hits: 3 }
- match: { hits.hits.0._index: unsigned_long_sort }
- match: { hits.hits.0._source.field: [ 13835058055282163714, 3 ] }
- match: { hits.hits.0.sort: [ 13835058055282163714 ] }
- match: { hits.hits.1._source.field: [ 13835058055282163713, 2 ] }
- match: { hits.hits.1.sort: [ 13835058055282163713 ] }
- match: { hits.hits.2._source.field: [ 13835058055282163712, 1 ] }
- match: { hits.hits.2.sort: [ 13835058055282163712 ] }

- do:
search:
index: unsigned_long_sort
body:
size: 5
sort: [{ field: { mode: max, order: asc } } ]
- match: {hits.total.value: 3 }
- length: {hits.hits: 3 }
- match: { hits.hits.0._index: unsigned_long_sort }
- match: { hits.hits.0._source.field: [ 13835058055282163712, 1 ] }
- match: { hits.hits.0.sort: [ 13835058055282163712 ] }
- match: { hits.hits.1._source.field: [ 13835058055282163713, 2 ] }
- match: { hits.hits.1.sort: [ 13835058055282163713 ] }
- match: { hits.hits.2._source.field: [ 13835058055282163714, 3 ] }
- match: { hits.hits.2.sort: [ 13835058055282163714 ] }
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
setup:
- do:
indices.create:
index: long_sort
body:
settings:
number_of_shards: 3
number_of_replicas: 0
mappings:
properties:
field:
type: long

---
"test sorting against long only fields":

- do:
bulk:
refresh: true
body:
- '{ "index" : { "_index" : "long_sort", "_id" : "1" } }'
- '{"field" : [ 55282163712, 1 ] }'
- '{ "index" : { "_index" : "long_sort", "_id" : "2" } }'
- '{"field" : [ 55282163713, 2 ] }'
- '{ "index" : { "_index" : "long_sort", "_id" : "3" } }'
- '{"field" : [ 55282163714, 3 ] }'

- do:
search:
index: long_sort
body:
size: 5
sort: [{ field: { mode: max, order: desc } } ]
- match: {hits.total.value: 3 }
- length: {hits.hits: 3 }
- match: { hits.hits.0._index: long_sort }
- match: { hits.hits.0._source.field: [ 55282163714, 3 ] }
- match: { hits.hits.0.sort: [ 55282163714 ] }
- match: { hits.hits.1._source.field: [ 55282163713, 2 ] }
- match: { hits.hits.1.sort: [ 55282163713 ] }
- match: { hits.hits.2._source.field: [ 55282163712, 1 ] }
- match: { hits.hits.2.sort: [ 55282163712 ] }

- do:
search:
index: long_sort
body:
size: 5
sort: [{ field: { mode: min, order: desc } } ]
- match: {hits.total.value: 3 }
- length: {hits.hits: 3 }
- match: { hits.hits.0._index: long_sort }
- match: { hits.hits.0._source.field: [ 55282163714, 3 ] }
- match: { hits.hits.0.sort: [ 3 ] }
- match: { hits.hits.1._source.field: [ 55282163713, 2 ] }
- match: { hits.hits.1.sort: [ 2 ] }
- match: { hits.hits.2._source.field: [ 55282163712, 1 ] }
- match: { hits.hits.2.sort: [ 1 ] }

- do:
search:
index: long_sort
body:
size: 5
sort: [{ field: { mode: max, order: asc } } ]
- match: {hits.total.value: 3 }
- length: {hits.hits: 3 }
- match: { hits.hits.0._index: long_sort }
- match: { hits.hits.0._source.field: [ 55282163712, 1 ] }
- match: { hits.hits.0.sort: [ 55282163712 ] }
- match: { hits.hits.1._source.field: [ 55282163713, 2 ] }
- match: { hits.hits.1.sort: [ 55282163713 ] }
- match: { hits.hits.2._source.field: [ 55282163714, 3 ] }
- match: { hits.hits.2.sort: [ 55282163714 ] }

0 comments on commit b1f8f7a

Please sign in to comment.