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

Open
#2,595 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
elasticsearch, php, wordpress
Domain
backend, search

Research direction

Start with Feature\SearchOrdering::posts_results() in includes/classes/Feature/SearchOrdering/SearchOrdering.php and reproduce the scenario with date decay, custom results, and two posts per page. Done means the configured custom results remain ahead of the naturally scored result across subsequent pages, including the older flowers and trees posts.

Written by the indexing model from the issue text.

Description

confirmed bug module:custom-search-results

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
Dominant language
PHP
Stars
1.3k
Forks
325
Avg merge
2d 11h
Merged PRs (30d)
24

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from 10up/ElasticPress

All issues in 10up/ElasticPress

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.