Skip to content

Conversation

@bpolaszek
Copy link
Contributor

@bpolaszek bpolaszek commented Nov 15, 2025

Add missing params retrieveVectors and media in SearchQuery.

Summary by CodeRabbit

  • New Features

    • Search queries can now request vector retrieval and include media data, enabling richer result payloads and more flexible result formatting.
    • New options allow callers to toggle vector inclusion and supply structured media information with searches.
  • Tests

    • Added tests confirming search outputs include the vector flag and supplied media structure, ensuring the new options appear in serialized query results.

@coderabbitai
Copy link

coderabbitai bot commented Nov 15, 2025

Walkthrough

Adds two nullable properties to the SearchQuery contract: retrieveVectors and media; introduces public setters setRetrieveVectors() and setMedia(); updates toArray() to include these fields; adds tests validating the new keys appear in toArray().

Changes

Cohort / File(s) Summary
Contract: SearchQuery
src/Contracts/SearchQuery.php
Added nullable properties retrieveVectors (bool
Tests: SearchQuery
tests/Contracts/SearchQueryTest.php
Added tests for setRetrieveVectors() and setMedia() verifying toArray() contains retrieveVectors and media keys with the provided values.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Focus review on the toArray() integration and type annotations.
  • Check tests for correct assertions and null/empty handling.

Poem

🐇 I added two fields with a cheerful twitch,
Vectors and media — now fetched with a switch.
Setters in place, the contract grows spry,
Tests hop along as the changes fly. 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 55.56% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add missing params in SearchQuery' accurately summarizes the main change, which adds two missing parameters (retrieveVectors and media) to the SearchQuery class.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 267a69e and f0f5339.

📒 Files selected for processing (2)
  • src/Contracts/SearchQuery.php (4 hunks)
  • tests/Contracts/SearchQueryTest.php (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/Contracts/SearchQueryTest.php
  • src/Contracts/SearchQuery.php

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.

@codecov
Copy link

codecov bot commented Nov 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.63%. Comparing base (0078a8c) to head (f0f5339).
⚠️ Report is 29 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #817      +/-   ##
==========================================
- Coverage   89.78%   87.63%   -2.16%     
==========================================
  Files          59       63       +4     
  Lines        1449     1569     +120     
==========================================
+ Hits         1301     1375      +74     
- Misses        148      194      +46     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

@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: 1

🧹 Nitpick comments (1)
src/Contracts/SearchQuery.php (1)

439-467: Minor: Consider adding @return PHPDoc for consistency.

The getter and setter implementations are correct and follow the established pattern of returning self for method chaining. However, most other setters in this class include a @return $this PHPDoc comment (e.g., lines 123, 134, 156), which is missing here.

Consider applying this diff for consistency:

+    /**
+     * @return $this
+     */
     public function setRetrieveVectors(?bool $retrieveVectors): self
     {
         $this->retrieveVectors = $retrieveVectors;

         return $this;
     }

     /**
      * @return array<string, mixed>|null
      */
     public function getMedia(): ?array
     {
         return $this->media;
     }

     /**
      * @param array<string, mixed>|null $media
+     *
+     * @return $this
      */
     public function setMedia(?array $media): self
     {
         $this->media = $media;

         return $this;
     }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3bfcda0 and 267a69e.

📒 Files selected for processing (2)
  • src/Contracts/SearchQuery.php (4 hunks)
  • tests/Contracts/SearchQueryTest.php (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
src/Contracts/SearchQuery.php (2)
src/Contracts/DocumentsQuery.php (1)
  • setRetrieveVectors (96-101)
src/Contracts/SimilarDocumentsQuery.php (1)
  • setRetrieveVectors (137-142)
tests/Contracts/SearchQueryTest.php (1)
src/Contracts/SearchQuery.php (4)
  • SearchQuery (7-536)
  • setRetrieveVectors (444-449)
  • toArray (502-535)
  • setMedia (462-467)
🔇 Additional comments (4)
tests/Contracts/SearchQueryTest.php (2)

240-249: LGTM! Test follows established patterns.

The test correctly verifies both boolean values are properly serialized to the array output, consistent with similar boolean property tests in this file.


251-257: LGTM! Test correctly verifies media array serialization.

The test follows the established pattern for array properties and uses a realistic media structure with MIME type and data URI.

src/Contracts/SearchQuery.php (2)

114-119: LGTM! Property declarations are well-typed.

Both properties follow the established pattern with appropriate nullable types and PHPDoc annotations. The flexible array<string, mixed> type for media accommodates various multimedia configuration structures.


497-499: LGTM! PHPDoc accurately reflects new return type fields.

The documentation correctly adds the optional retrieveVectors and media fields to the return type annotation, with types matching the property declarations.

@bpolaszek bpolaszek force-pushed the feature/add-search-params branch from 267a69e to f0f5339 Compare November 15, 2025 07:49
@norkunas
Copy link
Collaborator

Fixes #816 right?

*
* More info: https://www.meilisearch.com/docs/reference/api/experimental-features
*
* @param array<string, mixed>|null $media
Copy link
Collaborator

Choose a reason for hiding this comment

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

to me mixed looks to broad. also i failed to find any info about this media

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, same 🙁 Maybe @Strift do you have more information on how the media's param is supposed to be structured?

Copy link
Collaborator

Choose a reason for hiding this comment

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

You can take a look at how I implemented it in the JS SDK, if that can be helpful: https://github.com/meilisearch/meilisearch-js/pull/1998/files

See src/types/types.ts for the types and tests/multi_modal_search.test.ts for the examples.

@bpolaszek
Copy link
Contributor Author

Fixes #816 right?

Correct!

@Strift Strift linked an issue Nov 17, 2025 that may be closed by this pull request
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.

SearchQuery doesn't have setRetrieveVectors method

3 participants