Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support order by post__in, post_parent__in and post_name__in #51

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

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.

}

$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.

3 participants