ElasticSearch script查询报错A document doesn‘t have a value for a field! Use doc[<field>].size==0

时间:2025-02-17 20:53:12
{ "error" : { "root_cause" : [ { "type" : "script_exception", "reason" : "runtime error", "script_stack" : [ "$(:121)", "$(:115)", "doc[\"field\"].value >= 1", " ^---- HERE" ], "script" : "doc[\"field\"].value >= 1", "lang" : "painless" } ], "type" : "search_phase_execution_exception", "reason" : "all shards failed", "phase" : "query", "grouped" : true, "failed_shards" : [ { "shard" : 0, "index" : "...", "node" : "...", "reason" : { "type" : "script_exception", "reason" : "runtime error", "script_stack" : [ "$(:121)", "$(:115)", "doc[\"field\"].value >= 1", " ^---- HERE" ], "script" : "doc[\"field\"].value >= 1", "lang" : "painless", "caused_by" : { "type" : "illegal_state_exception", "reason" : "A document doesn't have a value for a field! Use doc[<field>].size()==0 to check if a document is missing a field!" } } } ] }, "status" : 400 }