Skip to content

add show performance details field to related endpoints - #938

Merged
Strift merged 2 commits into
meilisearch:mainfrom
valkrypton:add/showPerformanceDetails
Jul 28, 2026
Merged

add show performance details field to related endpoints#938
Strift merged 2 commits into
meilisearch:mainfrom
valkrypton:add/showPerformanceDetails

Conversation

@valkrypton

@valkrypton valkrypton commented Feb 17, 2026

Copy link
Copy Markdown
Contributor

Pull Request

Related issue

Fixes #933

What does this PR do?

  • Adds showPerformanceDetails to all related endpoints
  • Update response class to match the updated response
  • Updated tests to check for the performanceDetailsField

PR checklist

Please check if your PR fulfills the following requirements:

  • Did you use any AI tool while implementing this PR (code, tests, docs, etc.)? If yes, disclose it in the PR description and describe what it was used for. AI usage is allowed when it is disclosed.
  • Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • Have you read the contributing guidelines?
  • Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!

Summary by CodeRabbit

  • New Features

    • Users can opt to include performance details with search, multi-search/federation, and similar-document requests; responses will include performance metrics and execution details when enabled.
  • Tests

    • Added integration tests that validate requesting performance details and confirm returned results include the new metrics.

@coderabbitai

coderabbitai Bot commented Feb 17, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds support for requesting and returning raw performance traces: request types gain a showPerformanceDetails Boolean; result models gain a performanceDetails HashMap; integration tests updated to exercise and assert the new option.

Changes

Cohort / File(s) Summary
Request configuration
src/main/java/com/meilisearch/sdk/MultiSearchFederation.java, src/main/java/com/meilisearch/sdk/SearchRequest.java, src/main/java/com/meilisearch/sdk/SimilarDocumentRequest.java
Added showPerformanceDetails Boolean fields and a fluent setter on MultiSearchFederation; SearchRequest.toString() now serializes showPerformanceDetails.
Response models
src/main/java/com/meilisearch/sdk/model/MultiSearchResult.java, src/main/java/com/meilisearch/sdk/model/SearchResult.java, src/main/java/com/meilisearch/sdk/model/SimilarDocumentsResults.java
Added performanceDetails field (HashMap<String, Object>) to hold raw performance trace data returned by the API.
Integration tests
src/test/java/com/meilisearch/integration/SearchTest.java
Tests updated to set showPerformanceDetails(true) for search, multi-search, and similar-docs flows; added testSearchWithPerformanceDetails() and assertions checking presence/non-empty performanceDetails.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant SDK as "SDK (Request classes)"
  participant Meili as "Meilisearch Server"
  participant Models as "Response models"

  Client->>SDK: build request with showPerformanceDetails=true
  SDK->>Meili: send search/multi-search/similar-docs request (flag included)
  Meili-->>SDK: response including performanceDetails object
  SDK->>Models: deserialize raw performanceDetails into HashMap<String,Object>
  SDK-->>Client: return result containing performanceDetails
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hopped through lines to poke and see,

a tiny flag for traces came with glee,
raw timings tucked in maps so neat,
now results hum with performance beat,
I nibble bugs and celebrate this feat.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately summarizes the main change: adding showPerformanceDetails field to search-related endpoints.
Linked Issues check ✅ Passed All coding requirements from issue #933 are met: showPerformanceDetails option added to search, multi-search, and similar document endpoints, performanceDetails field added to response classes as raw HashMap data, and test cases validate the functionality.
Out of Scope Changes check ✅ Passed All changes directly support the linked issue objectives; the Hamcrest import refactoring in tests is a minor housekeeping change consistent with the test updates required.

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

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/test/java/com/meilisearch/integration/SearchTest.java (1)

837-847: ⚠️ Potential issue | 🔴 Critical

Federation test may fail — showPerformanceDetails is not serialized in MultiSearchFederation.toString().

As flagged in MultiSearchFederation.java, the toString() method doesn't include showPerformanceDetails. This means line 837 sets the flag but it's never sent to the server, so getPerformanceDetails() on line 847 will likely be null, causing an NPE on .size().

Consider adding a null-safety assertion (assertThat(results.getPerformanceDetails(), is(notNullValue()))) before checking size, and ensure the serialization bug is fixed first.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/test/java/com/meilisearch/integration/SearchTest.java` around lines 837 -
847, The test sets federation.setShowPerformanceDetails(true) but
MultiSearchFederation.toString() currently omits the showPerformanceDetails
field so the flag never reaches the server and results.getPerformanceDetails()
can be null; update MultiSearchFederation.toString() to serialize
showPerformanceDetails (matching the other federation fields) and then make the
test null-safe by asserting results.getPerformanceDetails() is not null (e.g.,
assertThat(results.getPerformanceDetails(), is(notNullValue()))) before
asserting its size; reference the MultiSearchFederation.toString(),
MultiSearchFederation.setShowPerformanceDetails(), and
MultiSearchResult.getPerformanceDetails() symbols when applying the fixes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/main/java/com/meilisearch/sdk/model/MultiSearchResult.java`:
- Line 26: The performanceDetails field in MultiSearchResult is typed as
HashMap<String, String> but can contain non-string values; change its
declaration to HashMap<String, Object> and update any associated
accessor/mutator (e.g., getPerformanceDetails, setPerformanceDetails,
constructors, and any JSON (de)serialization annotations or usages) to use
HashMap<String, Object> so heterogeneous values are preserved.

In `@src/main/java/com/meilisearch/sdk/model/SearchResult.java`:
- Line 27: Update the performanceDetails field from HashMap<String, String> to
HashMap<String, Object> to allow non-string values during deserialization:
locate the performanceDetails declaration in the SearchResult class (field name
performanceDetails), and make the same change in MultiSearchResult
(performanceDetails) and SimilarDocumentsResults (performanceDetails); ensure
any getters/setters or usages (e.g., getPerformanceDetails(),
setPerformanceDetails(...)) and relevant imports are updated to use
HashMap<String, Object> (or Map<String, Object>) so deserialization won't fail
if the API returns numbers or nested objects.

In `@src/main/java/com/meilisearch/sdk/model/SimilarDocumentsResults.java`:
- Line 23: In SimilarDocumentsResults change the field declaration
performanceDetails from HashMap<String, String> to HashMap<String, Object> and
update any associated accessor/mutator methods, constructors, builders, and
(de)serialization logic that reference performanceDetails to use HashMap<String,
Object> instead; mirror the same adjustments done in SearchResult.java to ensure
type consistency across the models.

In `@src/test/java/com/meilisearch/integration/SearchTest.java`:
- Around line 1319-1325: In SearchTest, the assertion on searchResult hits uses
hasSize(11) but should expect the default page size of 20; update the assertion
for searchResult.getHits() from hasSize(11) to hasSize(20) so that
SearchRequest.builder().q("a").showPerformanceDetails(true).build() correctly
validates 20 returned hits; keep the other assertions (getEstimatedTotalHits and
getPerformanceDetails) unchanged.

---

Outside diff comments:
In `@src/test/java/com/meilisearch/integration/SearchTest.java`:
- Around line 837-847: The test sets federation.setShowPerformanceDetails(true)
but MultiSearchFederation.toString() currently omits the showPerformanceDetails
field so the flag never reaches the server and results.getPerformanceDetails()
can be null; update MultiSearchFederation.toString() to serialize
showPerformanceDetails (matching the other federation fields) and then make the
test null-safe by asserting results.getPerformanceDetails() is not null (e.g.,
assertThat(results.getPerformanceDetails(), is(notNullValue()))) before
asserting its size; reference the MultiSearchFederation.toString(),
MultiSearchFederation.setShowPerformanceDetails(), and
MultiSearchResult.getPerformanceDetails() symbols when applying the fixes.

Comment thread src/main/java/com/meilisearch/sdk/model/MultiSearchResult.java Outdated
Comment thread src/main/java/com/meilisearch/sdk/model/SearchResult.java Outdated
Comment thread src/main/java/com/meilisearch/sdk/model/SimilarDocumentsResults.java Outdated
Comment thread src/test/java/com/meilisearch/integration/SearchTest.java Outdated
@valkrypton
valkrypton force-pushed the add/showPerformanceDetails branch from 4199f96 to d323fc5 Compare February 18, 2026 07:45

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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/main/java/com/meilisearch/sdk/SearchRequest.java (1)

51-57: Minor: Javadoc constructor comment omits showPerformanceDetails.

The constructor doc lists defaults for all serialized fields but showPerformanceDetails is missing.

📝 Suggested Javadoc update
  * Constructor for SearchRequest for building search queries with the default values: offset: 0,
  * limit: 20, attributesToRetrieve: ["*"], attributesToCrop: null, cropLength: 200,
  * attributesToHighlight: null, filter: null, showMatchesPosition: false, facets: null, sort:
- * null, showRankingScore: false, showRankingScoreDetails: false, rankingScoreThreshold: null,
- * retrieveVectors: false
+ * null, showRankingScore: false, showRankingScoreDetails: false, rankingScoreThreshold: null,
+ * retrieveVectors: false, showPerformanceDetails: false
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/java/com/meilisearch/sdk/SearchRequest.java` around lines 51 - 57,
The Javadoc for the SearchRequest constructor omits the default for the
showPerformanceDetails field; update the constructor comment in
SearchRequest.java to include showPerformanceDetails (with its default value)
alongside the other serialized field defaults so the documentation accurately
reflects all fields initialized by the constructor—locate the constructor
comment for SearchRequest and add the showPerformanceDetails default to the
list.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/test/java/com/meilisearch/integration/SearchTest.java`:
- Line 847: Replace the direct size() assertions on the possibly-null map with a
Hamcrest map matcher that handles nulls: change usages of
assertThat(results.getPerformanceDetails().size(), greaterThan(0)) to
assertThat(results.getPerformanceDetails(), aMapWithSize(greaterThan(0))) in
SearchTest (references to getPerformanceDetails), and apply the same replacement
at the other two locations flagged (the occurrences around lines 1114 and 1325).

---

Duplicate comments:
In `@src/main/java/com/meilisearch/sdk/model/MultiSearchResult.java`:
- Line 26: No change needed: the field declaration performanceDetails of type
HashMap<String, Object> in class MultiSearchResult is correct and matches the
fix applied in SearchResult.java; leave the declaration "HashMap<String, Object>
performanceDetails" as-is and no further modifications are required.

In `@src/test/java/com/meilisearch/integration/SearchTest.java`:
- Line 1323: The assertion expecting 11 hits is a copy-paste error; update the
test that asserts on searchResult.getHits() to expect 20 hits instead of 11 (the
test invokes q("a") with default offset and default limit 20, so
searchResult.getHits() should have size 20). Locate the failing assertion in
SearchTest.java referencing searchResult.getHits() (the hasSize(11) call) and
change it to hasSize(20).

---

Nitpick comments:
In `@src/main/java/com/meilisearch/sdk/SearchRequest.java`:
- Around line 51-57: The Javadoc for the SearchRequest constructor omits the
default for the showPerformanceDetails field; update the constructor comment in
SearchRequest.java to include showPerformanceDetails (with its default value)
alongside the other serialized field defaults so the documentation accurately
reflects all fields initialized by the constructor—locate the constructor
comment for SearchRequest and add the showPerformanceDetails default to the
list.

Comment thread src/test/java/com/meilisearch/integration/SearchTest.java Outdated
@valkrypton
valkrypton force-pushed the add/showPerformanceDetails branch from d323fc5 to 9a70d02 Compare February 18, 2026 08:11

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Duplicate comments:
In `@src/test/java/com/meilisearch/integration/SearchTest.java`:
- Around line 1319-1325: The assertion for hit count is wrong: update the test
in SearchTest where SearchRequest searchRequest =
SearchRequest.builder().q("a").showPerformanceDetails(true).build() and
SearchResult searchResult = (SearchResult) index.search(searchRequest) to expect
20 hits (change the hasSize matcher from 11 to 20); verify getHits() is asserted
with hasSize(20) to reflect the default limit of 20 when no offset/limit is
provided.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Strift Strift added the enhancement New feature or request label Jul 28, 2026

@Strift Strift left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hello @valkrypton and thanks for your contribution 🙌 LGTM!

@Strift
Strift added this pull request to the merge queue Jul 28, 2026
Merged via the queue into meilisearch:main with commit 69def58 Jul 28, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Meilisearch 1.35] Add showPerformanceDetails option to search endpoints

2 participants