Support for split_the_query

Open
#1,300 1 comment 2 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
elasticsearch, php, wordpress
Domain
backend, search

Research direction

Start by tracing ElasticPress's full query and WP_Query result-population path, then compare it with WordPress's split_the_query and get_post behavior. Done would require a decided design for using Elasticsearch only to collect post IDs, with the performance and data-integrity tradeoffs addressed.

Written by the indexing model from the issue text.

Description

enhancement low priority module:posts

In short, WordPress supports a method of querying with WP_Query called split_the_query that only pulls the post IDs from the database in the main mysql query. It then calls get_post on each ID. This means it will often pull from the object cache per post.

This isn't that important in the default WP_Query class, as it's expected that you have a high degree of trust in synchronization between object cache and database.

I noticed ElasticPress does a "full" query, and then populates the results of WP_Query with the source data from Elasticsearch. So ES is not only used for the searching, it's also used for data population. I wondered if there has been much thought if it might be a good idea to only use ES for "post ID collection", and then use a similar split_the_query method to then pull each post via get_post, as this would reduce risk of data corruption via bad synchronization between elasticsearch and the mysql database.

Doing so should have a pretty small impact on performance, but could increase data integrity.

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.