diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/search/260_sort_double.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/search/260_sort_double.yml new file mode 100644 index 0000000000000..654d3f6c58a61 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/search/260_sort_double.yml @@ -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 ] } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/search/260_sort_long.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/search/260_sort_long.yml new file mode 100644 index 0000000000000..b71e38bccd40c --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/search/260_sort_long.yml @@ -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 ] } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/search/260_sort_unsigned_long.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/search/260_sort_unsigned_long.yml new file mode 100644 index 0000000000000..fb3b1f994fd8c --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/search/260_sort_unsigned_long.yml @@ -0,0 +1,167 @@ +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, 13835058055282163714 ] }' + - '{ "index" : { "_index" : "unsigned_long_sort", "_id" : "3" } }' + - '{"field" : [ 13835058055282163715, 13835058055282163716, 2 ] }' + - '{ "index" : { "_index" : "unsigned_long_sort", "_id" : "4" } }' + - '{"field" : [ 13835058055282163717, 13835058055282163718, 13835058055282163719 ] }' + - '{ "index" : { "_index" : "unsigned_long_sort", "_id" : "5" } }' + - '{"field" : [ 13835058055282163720, 13835058055282163721, 3, 4 ] }' + - '{ "index" : { "_index" : "unsigned_long_sort", "_id" : "6" } }' + - '{"field" : [ 13835058055282163722, 5, 6, 7 ] }' + + - do: + search: + index: unsigned_long_sort + body: + size: 10 + sort: [{ field: { mode: max, order: desc } } ] + - match: {hits.total.value: 6 } + - length: {hits.hits: 6 } + - match: { hits.hits.0._index: unsigned_long_sort } + - match: { hits.hits.0._source.field: [ 13835058055282163722, 5, 6, 7 ] } + - match: { hits.hits.0.sort: [ 13835058055282163722 ] } + - match: { hits.hits.1._source.field: [ 13835058055282163720, 13835058055282163721, 3, 4 ] } + - match: { hits.hits.1.sort: [ 13835058055282163721 ] } + - match: { hits.hits.2._source.field: [ 13835058055282163717, 13835058055282163718, 13835058055282163719 ] } + - match: { hits.hits.2.sort: [ 13835058055282163719 ] } + - match: { hits.hits.3._source.field: [ 13835058055282163715, 13835058055282163716, 2 ] } + - match: { hits.hits.3.sort: [ 13835058055282163716 ] } + - match: { hits.hits.4._source.field: [ 13835058055282163713, 13835058055282163714 ] } + - match: { hits.hits.4.sort: [ 13835058055282163714 ] } + - match: { hits.hits.5._source.field: [ 13835058055282163712, 1 ] } + - match: { hits.hits.5.sort: [ 13835058055282163712 ] } + + - do: + search: + index: unsigned_long_sort + body: + size: 10 + sort: [{ field: { mode: max, order: asc } } ] + - match: {hits.total.value: 6 } + - length: {hits.hits: 6 } + - 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, 13835058055282163714 ] } + - match: { hits.hits.1.sort: [ 13835058055282163714 ] } + - match: { hits.hits.2._source.field: [ 13835058055282163715, 13835058055282163716, 2 ] } + - match: { hits.hits.2.sort: [ 13835058055282163716 ] } + - match: { hits.hits.3._source.field: [ 13835058055282163717, 13835058055282163718, 13835058055282163719 ] } + - match: { hits.hits.3.sort: [ 13835058055282163719 ] } + - match: { hits.hits.4._source.field: [ 13835058055282163720, 13835058055282163721, 3, 4 ] } + - match: { hits.hits.4.sort: [ 13835058055282163721 ] } + - match: { hits.hits.5._source.field: [ 13835058055282163722, 5, 6, 7 ] } + - match: { hits.hits.5.sort: [ 13835058055282163722 ] } + + - do: + search: + index: unsigned_long_sort + body: + size: 10 + sort: [ { field: { mode: median, order: asc } } ] + - match: { hits.total.value: 6 } + - length: { hits.hits: 6 } + - match: { hits.hits.0._index: unsigned_long_sort } + - match: { hits.hits.0._source.field: [ 13835058055282163722, 5, 6, 7 ] } + - match: { hits.hits.0.sort: [ 7 ] } + - match: { hits.hits.1._source.field: [ 13835058055282163713, 13835058055282163714 ] } + - match: { hits.hits.1.sort: [ 4611686018427387906 ] } + - match: { hits.hits.2._source.field: [ 13835058055282163712, 1 ] } + - match: { hits.hits.2.sort: [ 6917529027641081857 ] } + - match: { hits.hits.3._source.field: [ 13835058055282163720, 13835058055282163721, 3, 4 ] } + - match: { hits.hits.3.sort: [ 6917529027641081862 ] } + - match: { hits.hits.4._source.field: [ 13835058055282163715, 13835058055282163716, 2 ] } + - match: { hits.hits.4.sort: [ 13835058055282163715 ] } + - match: { hits.hits.5._source.field: [ 13835058055282163717, 13835058055282163718, 13835058055282163719 ] } + - match: { hits.hits.5.sort: [ 13835058055282163718 ] } + + - do: + search: + index: unsigned_long_sort + body: + size: 10 + sort: [ { field: { mode: sum, order: desc } } ] + - match: { hits.total.value: 6 } + - length: { hits.hits: 6 } + - match: { hits.hits.0._index: unsigned_long_sort } + - match: { hits.hits.0._source.field: [ 13835058055282163722, 5, 6, 7 ] } + - match: { hits.hits.0.sort: [ 13835058055282163740 ] } + - match: { hits.hits.1._source.field: [ 13835058055282163712, 1 ] } + - match: { hits.hits.1.sort: [ 13835058055282163713 ] } + - match: { hits.hits.2._source.field: [ 13835058055282163720, 13835058055282163721, 3, 4 ] } + - match: { hits.hits.2.sort: [ 9223372036854775832 ] } + - match: { hits.hits.3._source.field: [ 13835058055282163715, 13835058055282163716, 2 ] } + - match: { hits.hits.3.sort: [ 9223372036854775817 ] } + - match: { hits.hits.4._source.field: [ 13835058055282163713, 13835058055282163714 ] } + - match: { hits.hits.4.sort: [ 9223372036854775811 ] } + - match: { hits.hits.5._source.field: [ 13835058055282163717, 13835058055282163718, 13835058055282163719 ] } + - match: { hits.hits.5.sort: [ 4611686018427387922 ] } + + - do: + search: + index: unsigned_long_sort + body: + size: 10 + sort: [ { field: { mode: avg, order: desc } } ] + - match: { hits.total.value: 6 } + - length: { hits.hits: 6 } + - match: { hits.hits.0._index: unsigned_long_sort } + - match: { hits.hits.0._source.field: [ 13835058055282163712, 1 ] } + - match: { hits.hits.0.sort: [ 6917529027641081857 ] } + - match: { hits.hits.1._source.field: [ 13835058055282163713, 13835058055282163714 ] } + - match: { hits.hits.1.sort: [ 4611686018427387906 ] } + - match: { hits.hits.2._source.field: [ 13835058055282163722, 5, 6, 7 ] } + - match: { hits.hits.2.sort: [ 3458764513820540935 ] } + - match: { hits.hits.3._source.field: [ 13835058055282163715, 13835058055282163716, 2 ] } + - match: { hits.hits.3.sort: [ 3074457345618258606 ] } + - match: { hits.hits.4._source.field: [ 13835058055282163720, 13835058055282163721, 3, 4 ] } + - match: { hits.hits.4.sort: [ 2305843009213693958 ] } + - match: { hits.hits.5._source.field: [ 13835058055282163717, 13835058055282163718, 13835058055282163719 ] } + - match: { hits.hits.5.sort: [ 1537228672809129307 ] } + + - do: + search: + index: unsigned_long_sort + body: + size: 10 + sort: [ { field: { mode: min, order: asc } } ] + - match: { hits.total.value: 6 } + - length: { hits.hits: 6 } + - match: { hits.hits.0._index: unsigned_long_sort } + - match: { hits.hits.0._source.field: [ 13835058055282163712, 1 ] } + - match: { hits.hits.0.sort: [ 1 ] } + - match: { hits.hits.1._source.field: [ 13835058055282163715, 13835058055282163716, 2 ] } + - match: { hits.hits.1.sort: [ 2 ] } + - match: { hits.hits.2._source.field: [ 13835058055282163720, 13835058055282163721, 3, 4 ] } + - match: { hits.hits.2.sort: [ 3 ] } + - match: { hits.hits.3._source.field: [ 13835058055282163722, 5, 6, 7 ] } + - match: { hits.hits.3.sort: [ 5 ] } + - match: { hits.hits.4._source.field: [ 13835058055282163713, 13835058055282163714 ] } + - match: { hits.hits.4.sort: [ 13835058055282163713 ] } + - match: { hits.hits.5._source.field: [ 13835058055282163717, 13835058055282163718, 13835058055282163719 ] } + - match: { hits.hits.5.sort: [ 13835058055282163717 ] } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/search/280_unsigned_long.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/search/280_unsigned_long.yml deleted file mode 100644 index 4dafae31f23aa..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/search/280_unsigned_long.yml +++ /dev/null @@ -1,61 +0,0 @@ -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 ] } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/search/290_long.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/search/290_long.yml deleted file mode 100644 index 49e79cce88fce..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/search/290_long.yml +++ /dev/null @@ -1,74 +0,0 @@ -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 ] } diff --git a/test/framework/src/main/java/org/opensearch/test/rest/yaml/section/MatchAssertion.java b/test/framework/src/main/java/org/opensearch/test/rest/yaml/section/MatchAssertion.java index 77d8f3154729e..606689d89ddb6 100644 --- a/test/framework/src/main/java/org/opensearch/test/rest/yaml/section/MatchAssertion.java +++ b/test/framework/src/main/java/org/opensearch/test/rest/yaml/section/MatchAssertion.java @@ -40,6 +40,7 @@ import org.opensearch.test.hamcrest.RegexMatcher; import java.io.IOException; +import java.util.ArrayList; import java.util.regex.Pattern; import static org.hamcrest.Matchers.equalTo; @@ -110,6 +111,25 @@ protected void doAssert(Object actualValue, Object expectedValue) { } if (expectedValue.equals(actualValue) == false) { + if (expectedValue instanceof ArrayList + && actualValue instanceof ArrayList + && ((ArrayList) expectedValue).get(0) instanceof Number) { + ArrayList expectedList = (ArrayList) expectedValue; + ArrayList actualList = (ArrayList) actualValue; + if (expectedList.size() == 1 + && actualList.size() == 1 + && expectedList.get(0) instanceof Number + && actualList.get(0) instanceof Number) { + // BigInteger 1 is equal to Integer 1 + assertThat( + "field [" + getField() + "] doesn't match the expected value", + ((Number) actualList.get(0)).longValue(), + equalTo(((Number) expectedList.get(0)).longValue()) + ); + return; + } + } + NotEqualMessageBuilder message = new NotEqualMessageBuilder(); message.compare(getField(), true, actualValue, expectedValue); throw new AssertionError(getField() + " didn't match expected value:\n" + message);