diff --git a/adapters/vip-search.php b/adapters/vip-search.php index 31ef997..dd84f6c 100644 --- a/adapters/vip-search.php +++ b/adapters/vip-search.php @@ -135,6 +135,7 @@ function vip_es_field_map( $es_map ) { 'post_content.analyzed' => 'post_content', 'post_title' => 'post_title', 'post_title.analyzed' => 'post_title', + 'post_type' => 'post_type.raw', 'post_excerpt' => 'post_excerpt', 'post_password' => 'post_password', // This isn't indexed on VIP. 'post_name' => 'post_name', diff --git a/class-es-wp-query-wrapper.php b/class-es-wp-query-wrapper.php index 6ddbe6a..f0c9c2b 100644 --- a/class-es-wp-query-wrapper.php +++ b/class-es-wp-query-wrapper.php @@ -169,7 +169,9 @@ protected function no_results() { * @access public */ public function set_found_posts( $q, $es_response ) { - if ( isset( $es_response['hits']['total'] ) ) { + if ( isset( $es_response['hits']['total']['value'] ) ) { + $this->found_posts = absint( $es_response['hits']['total']['value'] ); + } elseif ( isset( $es_response['hits']['total'] ) ) { $this->found_posts = absint( $es_response['hits']['total'] ); } else { $this->found_posts = 0; @@ -253,7 +255,7 @@ public function get_posts() { 'tag_slug' => 'terms.%s.slug', 'tag_name' => 'terms.%s.name', 'tag_tt_id' => 'terms.%s.term_taxonomy_id', - ) + ) ); $this->parse_query(); @@ -424,7 +426,7 @@ public function get_posts() { 'after' => $date, 'before' => $date, 'inclusive' => true, - ) + ) ); $date_filter = $date_query->get_dsl( $this ); if ( ! empty( $date_filter ) ) { @@ -995,8 +997,8 @@ public function get_posts() { array( 'protected' => true, 'show_in_admin_all_list' => true, - ) - ) + ) + ) ); } @@ -1153,7 +1155,7 @@ public function get_posts() { 'fields' => $fields, 'size' => $size, 'from' => $from, - ) + ) ); // Filter again for the benefit of caching plugins. Regular plugins should use the hooks above. @@ -1312,7 +1314,7 @@ public function get_posts() { 'post_type' => $post_type, 'post_status' => 'publish', 'nopaging' => true, // phpcs:ignore WordPress.VIP.PostsPerPage.posts_per_page_nopaging - ) + ) ); foreach ( $stickies as $sticky_post ) { @@ -1635,7 +1637,7 @@ public static function dsl_multi_match( $fields, $query, $args = array() ) { 'query' => $query, 'fields' => (array) $fields, ), - $args + $args ), ); }