Open TatianaNeuer opened 1 month ago
Looks like a bug. Would you have a moment to try and write a YAML REST test for this?
https://github.com/opensearch-project/OpenSearch/blob/main/TESTING.md#testing-the-rest-layer
I tried writing a YAML REST test, heavily inspired from https://github.com/opensearch-project/OpenSearch/blob/main/rest-api-spec/src/main/resources/rest-api-spec/test/search/90_search_after.yml, I did not run the test so I hope the syntax is correct:
"null values":
- do:
indices.create:
index: test
- do:
bulk:
refresh: true
index: test
body: |
{"index":{}}
{ "doc": "doc1", "name": "bob"}
{"index":{}}
{ "doc": "doc2", "name": null}
{"index":{}}
{ "doc": "doc3", "name": null}
- do:
search:
rest_total_hits_as_int: true
index: test
body:
size: 2
track_total_hits: false
sort: [{ name.keyword: desc }, { doc.keyword: desc }]
- match: {hits.total: 3 }
- length: {hits.hits: 2 }
- match: {hits.hits.0._index: test }
- match: {hits.hits.0._source.doc: doc1 }
- match: {hits.hits.1._index: test }
- match: {hits.hits.1._source.doc: doc2 }
- match: {hits.hits.1.sort: [null, "doc2"] }
- do:
search:
rest_total_hits_as_int: true
index: test
body:
size: 1
track_total_hits: false
sort: [{ name.keyword: desc }, { doc.keyword: desc }]
search_after: [null, "doc2"]
- match: {hits.total: 1 }
- length: {hits.hits: 1 }
- match: {hits.hits.0._index: test }
- match: {hits.hits.0._source.doc: doc3 }
- match: {hits.hits.1.sort: [null, "doc3"] }
Try running it? :)
Describe the bug
OpenSearch returns a 500 Internal server error when search_after contains a null field and "track_total_hits:false". This is the error:
Related component
Search
To Reproduce
{ "size": 20, "track_total_hits": false, "sort": [ { "name.keyword": { "order": "desc" } }, { "doc.keyword": { "order": "asc" } } ], "search_after": [ null, "doc2" ] }
version: '3' services: opensearch: image: opensearchproject/opensearch:2.15.0 container_name: opensearch environment:
volumes: opensearch:
networks: opensearch-net: