Skip to content

Commit

Permalink
Merge pull request 10up#2134 from 10up/fix/no-mapping-found-name-sort…
Browse files Browse the repository at this point in the history
…able-issue-2044

Update to use name.raw instead of name.sortable for version 5.x
  • Loading branch information
brandwaffle authored Mar 15, 2021
2 parents e0e47c6 + 09f72ac commit 6ce1597
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions includes/classes/Indexable/Term/Term.php
Original file line number Diff line number Diff line change
Expand Up @@ -949,11 +949,21 @@ protected function parse_orderby( $orderby, $order, $args ) {

if ( ! empty( $orderby ) ) {
if ( 'name' === $orderby ) {
$sort[] = array(
'name.sortable' => array(
'order' => $order,
),
);
$es_version = Elasticsearch::factory()->get_elasticsearch_version();

if ( version_compare( $es_version, '7.0', '>=' ) ) {
$sort[] = array(
'name.sortable' => array(
'order' => $order,
),
);
} else {
$sort[] = array(
'name.raw' => array(
'order' => $order,
),
);
}
} elseif ( 'slug' === $orderby ) {
$sort[] = array(
'slug.raw' => array(
Expand Down

0 comments on commit 6ce1597

Please sign in to comment.