mardi 21 avril 2015

Elasticsearch query with sort by script [syntax]

I'm trying to sort my query by using a random script as suggested here

I'm having a hard time to validate and run my query as it keeps returning me errors.

The query I'm running is:

{
  "sort": {
    "_script": {
      "script": "(doc['_id'].value + salt).hashCode()",
      "type": "string",
      "params": {
        "salt": "some_random_string"
      },
      "order": "asc"
    }
  },
  "query": {
    "filtered": {
      "filter": {
        "and": [
          {
            "exists": {
              "field": "location"
            }
          },
          {
            "terms": {
              "streamIds": [
                796
              ]
            }
          }
        ]
      }
    }
  }
}

The query without the sorting works and returns results.

What am I doing wrong?

I've tried following the queries suggested here but to no avail.




Aucun commentaire:

Enregistrer un commentaire