Skip to content

Commit

Permalink
Pull in 10up#3126 (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
rebeccahum authored Nov 8, 2022
1 parent 2112977 commit 0988ef4
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions includes/classes/Elasticsearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ public function query( $index, $type, $query, $query_args, $query_object = null
[
'found_documents' => $total_hits,
'documents' => $documents,
'aggregations' => $response['aggregations'] ?? [],
],
$response,
$query,
Expand Down Expand Up @@ -919,6 +920,28 @@ public function open_index( $index ) {
return ( ! is_wp_error( $request ) && 200 === wp_remote_retrieve_response_code( $request ) );
}

/**
* Get index settings.
*
* @param string $index Index name.
* @since 4.4.0
* @return array|WP_Error Raw ES response from the $index/_settings?flat_settings=true endpoint
*/
public function get_index_settings( string $index ) {
$endpoint = trailingslashit( $index ) . '_settings?flat_settings=true';
$request = $this->remote_request( $endpoint, [], [], 'get_index_settings' );

if ( is_wp_error( $request ) ) {
return $request;
}

$response_body = wp_remote_retrieve_body( $request );

$settings = json_decode( $response_body, true );

return $settings;
}

/**
* Update index settings.
*
Expand Down

0 comments on commit 0988ef4

Please sign in to comment.