带有传递参数的Elasticserach SQL查询,因此我们防止SQL注入

问题描述

我正在使用弹性搜索7.6.2版本。将参数传递给在kibana中不起作用的查询。当我尝试添加参数查询时,如果我们尝试使用参数查询,将无法在kibana开发工具中正常工作。

       POST /_sql?format=txt
                   {
                     "query": "SELECT count(*) as aa  from student where  st_category = ?","params": [
                       39
                     ]
                   }
       ```  
                     {
                     "error" : {
                       "root_cause" : [
                         {
                           "type" : "x_content_parse_exception","reason" : "[5:3] [params] Expected START_OBJECT but was: END_ARRAY"
                         }
                       ],"type" : "x_content_parse_exception","reason" : "[5:3] [sql/query] Failed to parse field [params]","caused_by" : {
                         "type" : "x_content_parse_exception","reason" : "[5:3] [params] Expected START_OBJECT but was: END_ARRAY"
                       }
                     },"status" : 400
                   }

解决方法

转载于7.6.0群集上,但不适用于我的7.9+ 此功能首先出现在7.7。 因此,不幸的是,如果要使用群集,则必须对其进行升级。