Skip to content

Add notes on script sorting to the docs #145

@nagyt234

Description

@nagyt234

It would be good to have the possibility to use script sorting of ElasticSearch. E.g.:

{
  "sort": {
    "_script": {
      "type": "number",
      "script": "return rdoc['nutrient_220_rda_rate'].value + doc['nutrient_221_rda_rate'].value",
      "lang": "groovy",
      "order": "asc"
    }
  }
}

It is possible to use script field:

$query->fields = array_merge($allFields, [
    'rda_sum' => "doc['nutrient_220_rda_rate'].value + doc['nutrient_221_rda_rate'].value",
]);

It would be the best if we could use such a script field in the orderBy method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions