我无法使用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":[]}%