Add support for seq_no_primary_term search option and if_seq_no/if_primary_term index options#2284
Conversation
…imary_term index options - Add OPTION_SEQ_NO_PRIMARY_TERM constant to Search class for retrieving sequence numbers and primary terms in search results - Add validation for seq_no_primary_term option in Search::validateOption() - Add if_seq_no and if_primary_term to allowed options in Index::addDocument() for optimistic concurrency control - Add comprehensive tests for both search and index operations - Update CHANGELOG.md with new features This addresses issue #2232 and provides proper optimistic concurrency control support using Elasticsearch's sequence numbers and primary terms. Resolves #2232
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for Elasticsearch's optimistic concurrency control features by implementing seq_no_primary_term search option and if_seq_no/if_primary_term index options.
- Adds
OPTION_SEQ_NO_PRIMARY_TERMconstant to enable retrieval of sequence numbers and primary terms in search results - Extends
Index::addDocument()to supportif_seq_noandif_primary_termoptions for optimistic concurrency control - Includes comprehensive test coverage for both search and index functionality
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/Search.php | Adds OPTION_SEQ_NO_PRIMARY_TERM constant and validation for the new search option |
| src/Index.php | Adds if_seq_no and if_primary_term to allowed options in addDocument() method |
| tests/SearchSeqNoPrimaryTermTest.php | Comprehensive test coverage for the new search option functionality |
| tests/IndexSeqNoPrimaryTermTest.php | Test coverage for optimistic concurrency control in index operations |
| CHANGELOG.md | Documents the new features added in this release |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
- Add mandatory requirement to run make fix-phpcs before each commit - Add dedicated Commit Workflow section with clear steps - Ensure code quality standards are maintained consistently
…ction - Replace real client with mock client in unit tests - Remove dependency on Elasticsearch for unit test execution - Fix 'No alive nodes' error in unit tests - Unit tests now run without requiring Elasticsearch instance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for Elasticsearch's
seq_no_primary_termsearch option and enhances index operations withif_seq_noandif_primary_termoptions for optimistic concurrency control.Changes
Search Options
OPTION_SEQ_NO_PRIMARY_TERMconstant toSearchclassSearch::validateOption()Index Operations
if_seq_noandif_primary_termto allowed options inIndex::addDocument()AbstractUpdateActionbut weren't being passed throughTesting
SearchSeqNoPrimaryTermTest.phpwith comprehensive tests for the search optionIndexSeqNoPrimaryTermTest.phpwith tests for optimistic concurrency controlDocumentation
CHANGELOG.mdwith the new featuresBenefits
seq_no_primary_termoption allows retrieving sequence numbers and primary terms from search resultsRelated Issues
Resolves #2232
Testing
Example Usage