1

我无法使用 groovy 开关让渗透与脚本过滤器一起工作。

我创建这样的文档

curl -XPUT http://localhost:9200/perc_test/perc_type/1 -d'{"v": true}'

=> (OK) {"_index":"perc_test","_type":"perc_type","_id":"1","_version":1,"created":true}

我检查此文档是否与我的查询匹配。请注意,在我的实际用例中,我需要使用开关,因此会出现奇怪的脚本查询。

curl -XPOST http://localhost:9200/perc_test/_search -d'
{
  "query": {
    "filtered": {
      "query": {"match_all": {}},
      "filter": {
        "script": {
          "script": "switch (_source[\"v\"]) {\n case { it == true }:\n return true \n default: \n return false\n}"
        }
      }
    }
  }
}'

=> (OK) {"took":1,"timed_out":false,"_shards":{"total":1,"successful":1,"failed":0},"hits":{"total":1,"max_score":1.0,"hits":[{"_index":"perc_test","_type":"perc_type","_id":"1","_score":1.0,"_source":{"v": true}}]}}

我将完全相同的查询注册到 percolator api。

curl -XPOST http://localhost:9200/perc_test/.percolator/1 -d'
{
  "query": {
    "filtered": {
      "query": {"match_all": {}},
      "filter": {
        "script": {
          "script": "switch (_source[\"v\"]) {\n case { it == true }:\n return true \n default: \n return false\n}"
        }
      }
    }
  }
}'

=> (OK){"_index":"perc_test","_type":".percolator","_id":"1","_version":1,"created":true}

然后我尝试渗透注册文件,但它不起作用

curl -XGET http://localhost:9200/perc_test/perc_type/1/_percolate

=> (KO) {"took":1,"_shards":{"total":1,"successful":1,"failed":0},"total":0,"matches":[]}%

结果相同

curl -XPOST http://localhost:9200/perc_test/perc_type/_percolate -d'{"doc": {"v": true}}'

=> (KO) {"took":1,"_shards":{"total":1,"successful":1,"failed":0},"total":0,"matches":[]}%
4

0 回答 0