Same code on query script and sort script

Hi, how can I avoid this?

GET /repository/_search
{
  "query": {
    "script": {
      "script": {
        "source": "6371 * Math.acos( Math.cos((Math.PI / 180)*(39.9874542)) * Math.cos((Math.PI / 180)*(doc['destinationY'].value)) * Math.cos((Math.PI / 180)*(doc['destinationX'].value) - (Math.PI / 180)*(-0.0830824)) + Math.sin((Math.PI / 180)*(39.9874542)) * Math.sin((Math.PI / 180)*(doc['destinationY'].value))) < 12",
        "lang": "painless"
      }
    }
  },
  "sort": {
    "_script": {
      "type": "number",
      "script": {
        "lang": "painless",
        "source": "6371 * Math.acos( Math.cos((Math.PI / 180)*(39.9874542)) * Math.cos((Math.PI / 180)*(doc['destinationY'].value)) * Math.cos((Math.PI / 180)*(doc['destinationX'].value) - (Math.PI / 180)*(-0.0830824)) + Math.sin((Math.PI / 180)*(39.9874542)) * Math.sin((Math.PI / 180)*(doc['destinationY'].value)))"
      },
      "order": "asc"
    }
  }
}

Thanks.

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