Support partial document updates in the index
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 18/100
Research direction
This is design work spanning the Indexable and Elasticsearch classes, the sync queue, and the Documents feature. Start by reading how action_edited_term() decides to skip syncs above the Content Items per Index Cycle limit, and how the existing full-sync path builds and sends documents. Done would mean an agreed API for _bulk update actions, handling of missing documents, and hooks, agreed with maintainers before any code is written.
Written by the indexing model from the issue text.
Description
Is your enhancement related to a problem? Please describe.
Every sync sends whole documents. When only one or two fields of an object change, ElasticPress still prepares and sends the entire document. Two places where this is expensive:
- Documents: every attachment sync reads the file from disk, base64-encodes it, and sends it through the ingest pipeline again, even when only the title or caption changed. Re-syncing a set of attachments resends every file, which can mean hundreds of megabytes for a single change.
- Changes that affect many objects: when a term is edited, every post with that term is re-synced in full, just to update the
termsfield.action_edited_term()already skips the sync when there are more posts than "Content Items per Index Cycle", and leaves them for the next full sync, because full documents are too heavy to send in one request.
Being able to send only the changed fields would make these updates much lighter and make other targeted updates practical. Examples are fields that depend on a related object, like a post's parent or its author's display name.
Proposal
Add a partial update API to the Indexable and Elasticsearch classes, built on Elasticsearch's _bulk API with update actions:
{ "update": { "_index": "<index>", "_id": "<id>" } }
{ "doc": { "<field>": <value> } }
Points to consider:
- Missing documents: an
updateon a document that isn't in the index fails. That should not create a partial document: either skip it or fall back to a full sync of that object. - Ingest pipelines: the update API doesn't run the ingest pipeline. That works for Documents, since the pipeline already removes the raw file data and keeps the extracted text, but it should be documented.
- Sync queue: today the queue holds object IDs only. Partial updates would need to store which fields to update, or a callback that builds them, and merge with a full sync when one is already queued for the same object.
- Hooks: add hooks before and after partial updates, like the existing ones for full syncs, so integrations can follow them.
- Elasticsearch versions: handle versions older than 7.0, which need the document type in the action line. Check that it works on ElasticPress.io.
- Use it in core: update
action_edited_term()and Documents to use it.
Designs
N/A
Describe alternatives you've considered
_update_by_querywith a script: a single request can update every document matching a query, for example all posts with a given term. It's very efficient, but it needs inline scripts on the cluster, and some proxies or clusters may block it. It could be offered as an option where available.- Keep sending full documents but in smaller batches: this doesn't solve the Documents case, where the file itself is the cost.
Code of Conduct
- I agree to follow this project's Code of Conduct
This was done by Claude under my supervision.
- Dominant language
- PHP
- Stars
- 1.3k
- Forks
- 323
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 24
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from 10up/ElasticPress
-
wpvc
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
10up/ElasticPress#4420 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 45/100
10up/ElasticPress#4390 ·
Maintainers usually reply within 1 day
-
Move AI Features from ElasticPress Labs to the ElasticPress PluginPossibly taken @ZacharyRener claimed this 140 days ago. Openenhancement
10up/ElasticPress#4316 · 2 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
Convert Pointers class to functional componentPossibly taken @ZacharyRener claimed this 304 days ago. Openenhancement
10up/ElasticPress#4261 · 1 assignee ·
Maintainers usually reply within 1 day
-
Remove posts in Custom Search ResultPossibly taken @faisalahammad claimed this 159 days ago. Openenhancement module:custom-search-results
Difficulty 3/5 1-2 days Newbie friendliness 45/100
10up/ElasticPress#4245 · 1 comment ·
Maintainers usually reply within 1 day
All issues in 10up/ElasticPress
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
taskforcesh/bullmq#5238 ·
Maintainers usually reply within 1 day
-
[Bug] v-change-database-password reports success but doesn't change the password when MySQL validate_password rejects itPossibly taken @bfs2021 claimed this today. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Automattic/jetpack#55517 ·
Maintainers usually reply within 1 day
-
Major
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
PrestaShop/ps_onepagecheckout#245 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 84/100