Skip to content

feat(query): Add TermsQuery#53

Merged
MatusBoa merged 3 commits into
mainfrom
feat-terms-query
Apr 16, 2026
Merged

feat(query): Add TermsQuery#53
MatusBoa merged 3 commits into
mainfrom
feat-terms-query

Conversation

@MatusBoa
Copy link
Copy Markdown
Contributor

No description provided.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 16, 2026

Warning

Rate limit exceeded

@MatusBoa has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 48 minutes and 48 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 48 minutes and 48 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: b1d56fe9-d7a2-4ec0-9548-1540a630e7e2

📥 Commits

Reviewing files that changed from the base of the PR and between 995cd60 and 8379548.

📒 Files selected for processing (1)
  • .github/workflows/phpstan.yaml

Walkthrough

Introduces a new TermsQuery class implementing QueryInterface for Elasticsearch terms queries with corresponding exception handling, updates GitHub Actions workflows for PHP version matrix support with version-specific caching, and adds comprehensive documentation and test coverage.

Changes

Cohort / File(s) Summary
GitHub Actions Workflows
.github/workflows/phpstan.yaml, .github/workflows/phpunit.yaml
Updated build matrix configuration to support PHP 8.4 and 8.5 with PHP-version-specific Composer cache keys and restore-prefix entries for efficient cache reuse across versions.
Documentation Updates
AGENTS.md, src/Query/AGENTS.md, README.md
Added TermsQuery to project type hierarchy documentation, included usage example with BoostableQuery trait demonstration, and documented Elasticsearch terms query integration.
TermsQuery Implementation
src/Query/TermsQuery.php, src/Exception/Query/EmptyTermsQueryException.php
New TermsQuery class implementing QueryInterface with field and values parameters; throws EmptyTermsQueryException when values array is empty; serializes to Elasticsearch terms query structure with boost support.
Test Suite
tests/Unit/Query/TermsQueryTest.php
Comprehensive PHPUnit test coverage for TermsQuery including structure validation, boost application, empty values exception handling, type preservation (string, int, float, boolean), and single-element array scenarios.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive No description was provided by the author; however, the changeset is self-documenting through code, tests, and documentation updates. Consider adding a brief description explaining the TermsQuery implementation, use cases, or any breaking changes for clarity.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding a new TermsQuery feature to the query functionality.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat-terms-query

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented Apr 16, 2026

Coverage Report for CI Build 24506753412

Coverage remained the same at 100.0%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: 9 of 9 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 425
Covered Lines: 425
Line Coverage: 100.0%
Coverage Strength: 10.37 hits per line

💛 - Coveralls

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/phpstan.yaml:
- Line 14: The inline list for php-version currently has extra spaces inside the
brackets ([ '8.4', '8.5' ]) which violates YAML lint rules; update the
declaration for php-version to remove the leading/trailing spaces inside the
brackets so it reads php-version: ['8.4', '8.5'] (keeping the comma/space
between items) to satisfy YAMLlint.

In `@README.md`:
- Around line 104-112: Update the TermsQuery docs to warn that constructing a
TermsQuery with an empty values array will throw an EmptyTermsQueryException;
specifically, add a one-line note to the TermsQuery section (near the example
using new TermsQuery('status', ['active', 'pending'])->boost(5)) stating that
providing an empty values list (e.g., new TermsQuery('field', [])) triggers
EmptyTermsQueryException so users can avoid the runtime surprise and handle the
error accordingly.

In `@src/Query/TermsQuery.php`:
- Line 10: Update the class-level PHPDoc `@see` annotation in TermsQuery
(src/Query/TermsQuery.php) to use the canonical Query DSL URL format by
replacing the legacy path with the stable one: reference
https://www.elastic.co/docs/reference/query-languages/query-dsl/terms-query so
the `@see` points to the query-dsl/terms-query page.
- Around line 23-24: The constructor-promoted properties "field" and "values" in
the TermsQuery class lack the required property PHPDoc `@var` annotations; update
the class to either convert the promoted properties into explicit class
properties with PHPDoc comments (e.g., add protected string|\Stringable $field;
protected array $values; each preceded by an `@var` line) or add equivalent
property-level docblocks so both "field" and "values" have `@var` annotations as
mandated by the repository rules.

In `@tests/Unit/Query/TermsQueryTest.php`:
- Around line 20-80: Add a unit test that covers the edge case where the
TermsQuery constructor receives a \Stringable object for $field (e.g., implement
a small stub class with __toString or use an existing Stringable value) to
verify the field key is properly cast to string in TermsQuery::toArray(); create
a new test method (e.g., itCorrectlyHandlesStringableField) in
Tests/Unit/Query/TermsQueryTest.php that constructs new TermsQuery(new
StringableStub('foo'), ['bar']) and asserts the resulting array contains the
'terms' key with 'foo' as the field name and the expected values and boost.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 74310494-90c0-4e8d-b758-6af30f2fb78f

📥 Commits

Reviewing files that changed from the base of the PR and between 0242c57 and 995cd60.

📒 Files selected for processing (8)
  • .github/workflows/phpstan.yaml
  • .github/workflows/phpunit.yaml
  • AGENTS.md
  • README.md
  • src/Exception/Query/EmptyTermsQueryException.php
  • src/Query/AGENTS.md
  • src/Query/TermsQuery.php
  • tests/Unit/Query/TermsQueryTest.php

Comment thread .github/workflows/phpstan.yaml Outdated
Comment thread README.md
Comment thread src/Query/TermsQuery.php
Comment thread src/Query/TermsQuery.php
Comment thread tests/Unit/Query/TermsQueryTest.php
@MatusBoa MatusBoa merged commit b0976f5 into main Apr 16, 2026
9 checks passed
@MatusBoa MatusBoa deleted the feat-terms-query branch April 16, 2026 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants