ElasticPress icon indicating copy to clipboard operation
ElasticPress copied to clipboard

Custom Search Result, Date decay, and result sets larger than the posts per page number

Open felipeelia opened this issue 3 years ago • 0 comments

Is your enhancement related to a problem? Please describe.

Currently, if the administrator sets a custom search result and has date decay enabled, the results can be wrongly ordered if the number of posts returned is larger than the number of posts displayed per page.

Although we add terms.ep_custom_result.name^9999 to the query, to boost custom search results, for older documents the score is lowered by the date decay. That is not a problem for small result sets because the plugin reorders the results in Feature\SearchOrdering::posts_results(). That can't happen when the post is on the following page though.

Steps to reproduce

  1. Enable Weight results by date under Post Search on the Features page
  2. Create a post titled Post about flowers and set its date to 10 years ago
  3. Create a post titled Post about trees and also set its date to 10 years ago
  4. Create a post titled Post about gardens with the current date
  5. Create a Custom Search Result to gardens and set the flowers and trees posts to be displayed first
  6. Set WordPress to only display 2 posts per page
  7. Search for gardens and see the Post about gardens being displayed on the first page

felipeelia avatar Feb 17 '22 15:02 felipeelia