Unhandled exception: Missing hash key: "hits" (KeyError) from /usr/lib/crystal/core/hash.cr:0:9 in '[]' from /usr/lib/crystal/core/json/any.cr:102:7 in '[]' from /c/cci/src/scheduler/elasticsearch_client.cr:85:5 in 'search' from /c/cci/src/lib/lifecycle.cr:109:5 in 'get_active_machines' from /c/cci/src/lib/lifecycle.cr:60:5 in 'init_from_es' from /c/cci/src/lifecycle.cr:14:3 in '__crystal_main' from /usr/lib/crystal/core/crystal/main.cr:97:5 in 'main_user_code' from /usr/lib/crystal/core/crystal/main.cr:86:7 in 'main' from /usr/lib/crystal/core/crystal/main.cr:106:3 in 'main' from ???
Signed-off-by: Wu Zhende wuzhende666@163.com --- src/scheduler/elasticsearch_client.cr | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/scheduler/elasticsearch_client.cr b/src/scheduler/elasticsearch_client.cr index f6ff618..219cf3d 100644 --- a/src/scheduler/elasticsearch_client.cr +++ b/src/scheduler/elasticsearch_client.cr @@ -82,7 +82,10 @@ class Elasticsearch::Client results = @client.search({:index => index, :body => query}) raise results unless results.is_a?(JSON::Any)
- results["hits"]["hits"].as_a + return results["hits"]["hits"].as_a unless results.as_h.has_key?("error") + + puts results + Array(JSON::Any).new end
def update_account(account_content : JSON::Any, my_email : String)