Order of Solr search results is not being maintained
-
I’m reporting a bug that I have already fixed. I’m using your plugin for an eCommerce site. I updated my Solr config to sort the products based on the SKU ID. I noticed, however, that the order changes when the result set is displayed. After debugging for a while, I noticed that the order of the result was getting modified in the class WPSORL_Query.php when the posts were being fetched using Solr documents id’s. Specifically, the parameter ‘orderby’ => ‘post__in’ needs to be added to the method get_posts(). I’ve pasted the relevant line of code below. Suggest adding the changes to your plugin. Good luck!
$posts_in_results = count( $posts_ids ) > 0 ? get_posts( array( 'numberposts' => count( $posts_ids ), 'post_type' => 'any', 'post_status' => 'any', 'orderby' => 'post__in', //RA: This is required to maintain the order in which documents from Solr index are fetched 'post__in' => $posts_ids ) ) : array();
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Order of Solr search results is not being maintained’ is closed to new replies.