Illegal_argument_exception when extract a random subset of an index


(Mike Hung) #1

Hello,

According to the Elasticsearch 5.6 Reindex API document.
I have encountered the problem when running _reindex API as following command:

curl -XPOST 'localhost:9200/_reindex?pretty' -H 'Content-Type: application/json' -d'
{
  "size": 10,
  "source": {
    "index": "twitter",
    "query": {
      "function_score" : {
        "query" : { "match_all": {} },
        "random_score" : {}
      }
    },
    "sort": "_score"    
  },
  "dest": {
    "index": "random_twitter"
  }
}
'

Error message:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "Unsupported sort [{\n  \"_score\" : {\n    \"order\" : \"desc\"\n  }\n}]"
      }
    ],
    "type" : "illegal_argument_exception",
    "reason" : "Unsupported sort [{\n  \"_score\" : {\n    \"order\" : \"desc\"\n  }\n}]"
  },
  "status" : 400
}

(David Pilato) #3

I just tried this:

DELETE twitter
DELETE random_twitter
PUT twitter/doc/1
{
  "foo": "bar"
}
PUT random_twitter
POST _reindex
{
  "size": 10,
  "source": {
    "index": "twitter",
    "query": {
      "function_score" : {
        "query" : { "match_all": {} },
        "random_score" : {}
      }
    },
    "sort": "_score"    
  },
  "dest": {
    "index": "random_twitter"
  }
}

And it worked well. Tested on 5.6.5 and 6.1.1.

{
  "took": 33,
  "timed_out": false,
  "total": 10,
  "updated": 0,
  "created": 10,
  "deleted": 0,
  "batches": 1,
  "version_conflicts": 0,
  "noops": 0,
  "retries": {
    "bulk": 0,
    "search": 0
  },
  "throttled_millis": 0,
  "requests_per_second": -1,
  "throttled_until_millis": 0,
  "failures": []
}

(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.