query_with_cursor causing internal server error if kind is empty or does not exist
Most likely due to migration to Elasticsearch 8, query_with_cursor started causing internal server error on a subsequent request if kind is empty or does not exist.
Steps to reproduce:
- Send a cursor request for a non-existent kind:
curl --location 'https://community.gcp.gnrg-osdu.projects.epam.com/api/search/v2/query_with_cursor' \
--header 'data-partition-id: osdu' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ' \
--data '{
"kind": "osdu:wks:master-data--not-exist:1.1.1"
}'
Response:
{
"cursor": "4595DE2DE04BD263045415C88134AB2C",
"results": [],
"totalCount": 0
}
- Get a cursor from the response and use it in a new request:
curl --location 'https://community.gcp.gnrg-osdu.projects.epam.com/api/search/v2/query_with_cursor' \
--header 'data-partition-id: osdu' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ' \
--data '{
"cursor": "4595DE2DE04BD263045415C88134AB2C",
"kind": "osdu:wks:master-data--not-exist:1.1.1"
}'
Response:
{
"code": 500,
"reason": "Search error",
"message": "Error processing search request"
}
In Search service logs we may observe the following error:
search.app: Error processing search request
AppException(error=AppError(code=500, reason=Search error, message=Error processing search request, errors=null, debuggingInfo=null, originalException=org.elasticsearch.client.ResponseException: method [POST], host [https://elastic8.es.us-central1.gcp.cloud.es.io:443], URI [/_search/scroll], status line [HTTP/1.1 503 Service Unavailable]
{"error":{"root_cause":[],"type":"search_phase_execution_exception","reason":"no nodes to search on","phase":"query","grouped":true,"failed_shards":[]},"status":503}), originalException=org.elasticsearch.client.ResponseException: method [POST], host [https://elastic8.es.us-central1.gcp.cloud.es.io:443], URI [/_search/scroll], status line [HTTP/1.1 503 Service Unavailable]