Add showPerformanceDetails option to search endpoints#502
Add showPerformanceDetails option to search endpoints#502William-Laverty wants to merge 1 commit intomeilisearch:mainfrom
Conversation
Adds support for the new showPerformanceDetails parameter introduced in Meilisearch v1.35.0. Changes: - Added showPerformanceDetails parameter to SearchParameters - Added PerformanceDetails and PerformanceValue types for response handling - Added performanceDetails property to Searchable class The PerformanceValue type is designed to handle arbitrary JSON structures since the performance details format may change between Meilisearch versions. Closes meilisearch#501
📝 WalkthroughWalkthroughIntroduces performance tracing support for Meilisearch 1.35 by adding a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@Sources/MeiliSearch/Model/SearchParameters.swift`:
- Around line 71-76: Add unit and integration tests that mirror the existing
tests for showRankingScore/showRankingScoreDetails/showMatchesPosition to cover
the new SearchParameters.showPerformanceDetails optional Bool: (1) a unit test
that verifies request encoding includes the "showPerformanceDetails" flag when
SearchParameters.showPerformanceDetails is true/false and omits it when nil, and
(2) an integration test that sends a search request with
showPerformanceDetails=true and asserts the decoded response contains a non-nil
performanceDetails object (and that its fields deserialize correctly). Locate
tests that reference
showRankingScore/showRankingScoreDetails/showMatchesPosition and copy their
structure, replacing those symbols with showPerformanceDetails and validation of
the performanceDetails payload.
| /// Whether to return performance details or not. | ||
| /// When set to `true`, the search response contains a `performanceDetails` object | ||
| /// with the performance trace. Available from Meilisearch v1.35.0. | ||
| /// Note: The fields of the `performanceDetails` object are subject to change. | ||
| public let showPerformanceDetails: Bool? | ||
|
|
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# Search for tests covering showPerformanceDetails/performanceDetails
rg -n 'showPerformanceDetails|performanceDetails' --type swift -g '*test*' -g '*Test*' -g '*Tests*'Repository: meilisearch/meilisearch-swift
Length of output: 55
🏁 Script executed:
# Also search more broadly in test directories
fd -e swift '(test|Test)' | xargs rg -l 'showPerformanceDetails|performanceDetails' 2>/dev/null || echo "No matches found in test files"Repository: meilisearch/meilisearch-swift
Length of output: 103
🏁 Script executed:
# Examine the SearchParameters.swift file to see the full scope of changes
cat -n Sources/MeiliSearch/Model/SearchParameters.swift | head -160Repository: meilisearch/meilisearch-swift
Length of output: 5674
🏁 Script executed:
# Look for test files related to SearchParameters
fd -e swift '(test|Test)' | xargs grep -l 'SearchParameters' 2>/dev/null | head -10Repository: meilisearch/meilisearch-swift
Length of output: 169
🏁 Script executed:
# Check the unit test file for SearchParameters tests
wc -l Tests/MeiliSearchUnitTests/SearchTests.swiftRepository: meilisearch/meilisearch-swift
Length of output: 121
🏁 Script executed:
# Look for tests covering similar boolean parameters
rg -n 'showRankingScore|showMatchesPosition' Tests/MeiliSearchUnitTests/SearchTests.swift Tests/MeiliSearchIntegrationTests/SearchTests.swift -A 3 -B 3Repository: meilisearch/meilisearch-swift
Length of output: 3893
🏁 Script executed:
# Search for any test that encodes SearchParameters or checks request bodies
rg -n 'SearchParameters|encode|request' Tests/MeiliSearchUnitTests/SearchTests.swift -A 2 | head -50Repository: meilisearch/meilisearch-swift
Length of output: 854
🏁 Script executed:
# Get a sample of the unit test file to see the encoding test pattern
sed -n '180,220p' Tests/MeiliSearchUnitTests/SearchTests.swiftRepository: meilisearch/meilisearch-swift
Length of output: 1523
Add test coverage for showPerformanceDetails request encoding and response handling.
Code implementation is correct, but test coverage is missing. Similar boolean parameters (showRankingScore, showRankingScoreDetails, showMatchesPosition) have both unit and integration tests—add corresponding tests for the new showPerformanceDetails parameter to verify request encoding and response deserialization.
🤖 Prompt for AI Agents
In `@Sources/MeiliSearch/Model/SearchParameters.swift` around lines 71 - 76, Add
unit and integration tests that mirror the existing tests for
showRankingScore/showRankingScoreDetails/showMatchesPosition to cover the new
SearchParameters.showPerformanceDetails optional Bool: (1) a unit test that
verifies request encoding includes the "showPerformanceDetails" flag when
SearchParameters.showPerformanceDetails is true/false and omits it when nil, and
(2) an integration test that sends a search request with
showPerformanceDetails=true and asserts the decoded response contains a non-nil
performanceDetails object (and that its fields deserialize correctly). Locate
tests that reference
showRankingScore/showRankingScoreDetails/showMatchesPosition and copy their
structure, replacing those symbols with showPerformanceDetails and validation of
the performanceDetails payload.
Summary
Adds support for the new
showPerformanceDetailsparameter introduced in Meilisearch v1.35.0.Changes
showPerformanceDetailsparameter toSearchParametersPerformanceDetailsandPerformanceValuetypes for response handlingperformanceDetailsproperty toSearchableclassImplementation Notes
As specified in #501, the performance details are returned as "raw" data without imposing a specific schema. The
PerformanceValuetype is a recursive enum that can represent arbitrary JSON structures, allowing the SDK to handle any format changes in future Meilisearch versions.Usage Example
Closes #501
Summary by CodeRabbit