Skip to content

Conversation

@srtfisher
Copy link
Member

No description provided.

@srtfisher srtfisher requested a review from mboynes May 3, 2017 02:21
usort( $posts, function( $a, $b ) use ( $order, $key, $use_source ) {
// Add support for using the Elasticsearch _source field.
if ( $use_source ) {
// Elasticsearch stores the `ID` field as `post_id`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessarily; VIP's ES mapping != SearchPress'. All fields need to be "translated" to the adapter's map, e.g. $this->es_map( 'post_id' ) to get the right field. Same goes for the switch above where $key gets set.

return;
}

$this->posts = $this->post_query_sort_handler( $this->posts, $q );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency with the rest of the switch, I would add a return; after this statement.

}
}

if ( ! isset( $order[ $a->$key ] ) || ! isset( $order[ $b->$key ] ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you also need to check if $a->$key and $b->$key exist

@srtfisher
Copy link
Member Author

@mboynes pushed up a fix that will translate the $key when it is using the ES source. I've also added ID to the mapping for each adapter we have. Should I not do that and just use post_id instead with $this->es_map( ... )?

@kjbenk
Copy link
Contributor

kjbenk commented May 10, 2017

@mboynes Just an FYI that I will be taking this PR over from Sean. If you have any more feedback please let me know :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants