Skip to content

Commit

Permalink
add more rest tests
Browse files Browse the repository at this point in the history
Signed-off-by: panguixin <[email protected]>
  • Loading branch information
bugmakerrrrrr committed Dec 12, 2024
1 parent b1f8f7a commit 17940b9
Show file tree
Hide file tree
Showing 6 changed files with 460 additions and 135 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
setup:
- do:
indices.create:
index: double_sort
body:
settings:
number_of_shards: 3
number_of_replicas: 0
mappings:
properties:
field:
type: double

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

- do:
bulk:
refresh: true
body:
- '{ "index" : { "_index" : "double_sort", "_id" : "1" } }'
- '{"field" : [ 900719925474099.1, 1.1 ] }'
- '{ "index" : { "_index" : "double_sort", "_id" : "2" } }'
- '{"field" : [ 900719925474099.2, 900719925474099.3 ] }'
- '{ "index" : { "_index" : "double_sort", "_id" : "3" } }'
- '{"field" : [ 450359962737049.4, 3.5, 4.6 ] }'
- '{ "index" : { "_index" : "double_sort", "_id" : "4" } }'
- '{"field" : [ 450359962737049.7, 5.8, -1.9, -2.0 ] }'

- do:
search:
index: double_sort
body:
size: 5
sort: [{ field: { mode: max, order: desc } } ]
- match: {hits.total.value: 4 }
- length: {hits.hits: 4 }
- match: { hits.hits.0._index: double_sort }
- match: { hits.hits.0._source.field: [ 900719925474099.2, 900719925474099.2 ] }
- match: { hits.hits.0.sort: [ 900719925474099.2 ] }
- match: { hits.hits.1._source.field: [ 900719925474099.1, 1.1 ] }
- match: { hits.hits.1.sort: [ 900719925474099.1 ] }
- match: { hits.hits.2._source.field: [ 450359962737049.7, 5.8, -1.9, -2.0 ] }
- match: { hits.hits.2.sort: [ 450359962737049.7 ] }
- match: { hits.hits.3._source.field: [ 450359962737049.4, 3.5, 4.6 ] }
- match: { hits.hits.3.sort: [ 450359962737049.4 ] }

- do:
search:
index: double_sort
body:
size: 5
sort: [ { field: { mode: max, order: asc } } ]
- match: { hits.total.value: 4 }
- length: { hits.hits: 4 }
- match: { hits.hits.0._index: double_sort }
- match: { hits.hits.0._source.field: [ 450359962737049.4, 3.5, 4.6 ] }
- match: { hits.hits.0.sort: [ 450359962737049.4 ] }
- match: { hits.hits.1._source.field: [ 450359962737049.7, 5.8, -1.9, -2.0 ] }
- match: { hits.hits.1.sort: [ 450359962737049.7 ] }
- match: { hits.hits.2._source.field: [ 900719925474099.1, 1.1 ] }
- match: { hits.hits.2.sort: [ 900719925474099.1 ] }
- match: { hits.hits.3._source.field: [ 900719925474099.2, 900719925474099.2 ] }
- match: { hits.hits.3.sort: [ 900719925474099.2 ] }

- do:
search:
index: double_sort
body:
size: 5
sort: [ { field: { mode: min, order: asc } } ]
- match: { hits.total.value: 4 }
- length: { hits.hits: 4 }
- match: { hits.hits.0._index: double_sort }
- match: { hits.hits.0._source.field: [ 450359962737049.7, 5.8, -1.9, -2.0 ] }
- match: { hits.hits.0.sort: [ -2.0 ] }
- match: { hits.hits.1._source.field: [ 900719925474099.1, 1.1 ] }
- match: { hits.hits.1.sort: [ 1.1 ] }
- match: { hits.hits.2._source.field: [ 450359962737049.4, 3.5, 4.6 ] }
- match: { hits.hits.2.sort: [ 3.5 ] }
- match: { hits.hits.3._source.field: [ 900719925474099.2, 900719925474099.2 ] }
- match: { hits.hits.3.sort: [ 900719925474099.2 ] }

- do:
search:
index: double_sort
body:
size: 5
sort: [ { field: { mode: median, order: desc } } ]
- match: { hits.total.value: 4 }
- length: { hits.hits: 4 }
- match: { hits.hits.0._index: double_sort }
- match: { hits.hits.0._source.field: [ 900719925474099.2, 900719925474099.2 ] }
- match: { hits.hits.0.sort: [ 900719925474099.2 ] }
- match: { hits.hits.1._source.field: [ 900719925474099.1, 1.1 ] }
- match: { hits.hits.1.sort: [ 450359962737050.1 ] }
- match: { hits.hits.2._source.field: [ 450359962737049.4, 3.5, 4.6 ] }
- match: { hits.hits.2.sort: [ 4.6 ] }
- match: { hits.hits.3._source.field: [ 450359962737049.7, 5.8, -1.9, -2.0 ] }
- match: { hits.hits.3.sort: [ 1.95 ] }

- do:
search:
index: double_sort
body:
size: 5
sort: [ { field: { mode: avg, order: asc } } ]
- match: { hits.total.value: 4 }
- length: { hits.hits: 4 }
- match: { hits.hits.0._index: double_sort }
- match: { hits.hits.0._source.field: [ 450359962737049.7, 5.8, -1.9, -2.0 ] }
- match: { hits.hits.0.sort: [ 112589990684262.89 ] }
- match: { hits.hits.1._source.field: [ 450359962737049.4, 3.5, 4.6 ] }
- match: { hits.hits.1.sort: [ 150119987579019.16 ] }
- match: { hits.hits.2._source.field: [ 900719925474099.1, 1.1 ] }
- match: { hits.hits.2.sort: [ 450359962737050.1 ] }
- match: { hits.hits.3._source.field: [ 900719925474099.2, 900719925474099.2 ] }
- match: { hits.hits.3.sort: [ 900719925474099.2 ] }

- do:
search:
index: double_sort
body:
size: 5
sort: [ { field: { mode: sum, order: desc } } ]
- match: { hits.total.value: 4 }
- length: { hits.hits: 4 }
- match: { hits.hits.0._index: double_sort }
- match: { hits.hits.0._source.field: [ 900719925474099.2, 900719925474099.2 ] }
- match: { hits.hits.0.sort: [ 1801439850948198.5 ] }
- match: { hits.hits.1._source.field: [ 900719925474099.1, 1.1 ] }
- match: { hits.hits.1.sort: [ 900719925474100.2 ] }
- match: { hits.hits.2._source.field: [ 450359962737049.4, 3.5, 4.6 ] }
- match: { hits.hits.2.sort: [ 450359962737057.5 ] }
- match: { hits.hits.3._source.field: [ 450359962737049.7, 5.8, -1.9, -2.0 ] }
- match: { hits.hits.3.sort: [ 450359962737051.56 ] }
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
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" : [ 9223372036854775807, 1 ] }'
- '{ "index" : { "_index" : "long_sort", "_id" : "2" } }'
- '{"field" : [ 922337203685477777, 2 ] }'
- '{ "index" : { "_index" : "long_sort", "_id" : "3" } }'
- '{"field" : [ 2147483647, 3, 4 ] }'
- '{ "index" : { "_index" : "long_sort", "_id" : "4" } }'
- '{"field" : [ 2147483648, 5, -1, -2 ] }'

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

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


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

- do:
search:
index: long_sort
body:
size: 5
sort: [ { field: { mode: median, order: asc } } ]
- match: { hits.total.value: 4 }
- length: { hits.hits: 4 }
- match: { hits.hits.0._index: long_sort }
- match: { hits.hits.0._source.field: [ 2147483648, 5, -1, -2 ] }
- match: { hits.hits.0.sort: [ 2 ] }
- match: { hits.hits.1._source.field: [ 2147483647, 3, 4 ] }
- match: { hits.hits.1.sort: [ 4 ] }
- match: { hits.hits.2._source.field: [ 922337203685477777, 2 ] }
- match: { hits.hits.2.sort: [ 461168601842738880 ] }
- match: { hits.hits.3._source.field: [ 9223372036854775807, 1 ] }
- match: { hits.hits.3.sort: [ 4611686018427387904 ] }

- do:
search:
index: long_sort
body:
size: 5
sort: [ { field: { mode: avg, order: desc } } ]
- match: { hits.total.value: 4 }
- length: { hits.hits: 4 }
- match: { hits.hits.0._index: long_sort }
- match: { hits.hits.0._source.field: [ 922337203685477777, 2 ] }
- match: { hits.hits.0.sort: [ 461168601842738880 ] }
- match: { hits.hits.1._source.field: [ 2147483647, 3, 4 ] }
- match: { hits.hits.1.sort: [ 715827885 ] }
- match: { hits.hits.2._source.field: [ 2147483648, 5, -1, -2 ] }
- match: { hits.hits.2.sort: [ 536870913 ] }
- match: { hits.hits.3._source.field: [ 9223372036854775807, 1 ] }
- match: { hits.hits.3.sort: [ -4611686018427387904 ] }

- do:
search:
index: long_sort
body:
size: 5
sort: [ { field: { mode: sum, order: asc } } ]
- match: { hits.total.value: 4 }
- length: { hits.hits: 4 }
- match: { hits.hits.0._index: long_sort }
- match: { hits.hits.0._source.field: [ 9223372036854775807, 1 ] }
- match: { hits.hits.0.sort: [ -9223372036854775808 ] }
- match: { hits.hits.1._source.field: [ 2147483648, 5, -1, -2 ] }
- match: { hits.hits.1.sort: [ 2147483650 ] }
- match: { hits.hits.2._source.field: [ 2147483647, 3, 4 ] }
- match: { hits.hits.2.sort: [ 2147483654 ] }
- match: { hits.hits.3._source.field: [ 922337203685477777, 2 ] }
- match: { hits.hits.3.sort: [ 922337203685477779 ] }
Loading

0 comments on commit 17940b9

Please sign in to comment.