1

I can't get the percolation to work with a script filter using a groovy switch.

I create a document like this

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}

I check that this document matches my query. Note that in my real use case I need to use a switch, hence the weird script query.

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}}]}}

I register the exact same query to the 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}

Then I try to percolate the registered document but it does not work

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

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

Same result with

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":[]}%
Clément Prévost
  • 8,000
  • 2
  • 36
  • 51

0 Answers0