Skip to content

Commit

Permalink
Merge pull request #4 from Automattic/fix/post_type-in-vip-search-map…
Browse files Browse the repository at this point in the history
…ping

Fix post_type in vip search mapping
  • Loading branch information
nickdaugherty authored Jun 15, 2020
2 parents 8e5869d + d0dc7d0 commit 1741c24
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions adapters/vip-search.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
18 changes: 10 additions & 8 deletions class-es-wp-query-wrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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 ) ) {
Expand Down Expand Up @@ -995,8 +997,8 @@ public function get_posts() {
array(
'protected' => true,
'show_in_admin_all_list' => true,
)
)
)
)
);
}

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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 ) {
Expand Down Expand Up @@ -1635,7 +1637,7 @@ public static function dsl_multi_match( $fields, $query, $args = array() ) {
'query' => $query,
'fields' => (array) $fields,
),
$args
$args
),
);
}
Expand Down

0 comments on commit 1741c24

Please sign in to comment.