pbojinov
7/12/2015 - 7:45 PM

Updated script to avoid org.elasticsearch.index.mapper.Uid.idFromUid which no longer works. Cast the doc['id'].value as needed to enable arr

Updated script to avoid org.elasticsearch.index.mapper.Uid.idFromUid which no longer works. Cast the doc['id'].value as needed to enable array look up. This is based on a comment by the original author elsewhere.

q = {
  "query": {
    "function_score": {
      "boost_mode": "replace",
      "query": {
        "ids": {
          "values": [
            50,
            80,
            44,
            12
          ]
        }
      },
      "script_score": {
        "params": {
          "ids": [
              50,
              80,
              44,
              12
          ]
        },
        "script": "return -ids.indexOf((int)doc['id'].value);"
      }
    }
  },
  "size": 20,
  "from": 0
}