Skip to content

Conversation

@awais786
Copy link
Contributor

@awais786 awais786 commented Jan 21, 2026

#1198

Implements support for the new POST /indexes/{indexUid}/fields endpoint introduced in Meilisearch v1.33.0.

Description

This PR adds the get_fields() method to the Index class, which returns detailed metadata about all fields in an index. The endpoint provides comprehensive information about each field's configuration, including display, search, filtering, sorting, ranking rules, and localization settings.

Summary by CodeRabbit

  • New Features

    • Retrieve detailed index field metadata (name, searchable, filterable, sortable) via a new API method, with optional filtering and offset/limit pagination.
  • Tests

    • Added tests verifying metadata retrieval, configuration-driven visibility changes, filtering behavior, and pagination.

✏️ Tip: You can customize this high-level summary in your review settings.

Usage of AI.

I use cursor for coding help but did manual changes and also did testing locally.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 21, 2026

Warning

Rate limit exceeded

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

⌛ 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 41c8ac8 and 9c4d386.

📒 Files selected for processing (1)
  • meilisearch/index.py
📝 Walkthrough

Walkthrough

Adds a new API path token fields and a public Index.get_fields(...) method that POSTs to the index fields endpoint to retrieve field metadata. Four tests added to verify retrieval, settings reflection, filtering, and pagination.

Changes

Cohort / File(s) Change Summary
API Path Constant
meilisearch/config.py
Added fields = "fields" to Config.Paths.
Index API Implementation
meilisearch/index.py
Added get_fields(self, offset: Optional[int]=None, limit: Optional[int]=None, filter: Optional[MutableMapping[str, Any]]=None) -> List[Dict[str, Any]] which POSTs to /indexes/{uid}/fields and returns field metadata.
Tests
tests/index/test_index.py
Added tests: test_get_fields, test_get_fields_with_configurations, test_get_fields_with_filter, test_get_fields_with_pagination to validate retrieval, settings effects, filtering, and pagination.

Sequence Diagram(s)

sequenceDiagram
  participant Test as Test/Client
  participant Index as Index.get_fields()
  participant HTTP as HTTP Client
  participant Server as Meilisearch Server

  Test->>Index: call get_fields(offset?, limit?, filter?)
  Index->>HTTP: POST /indexes/{uid}/fields with body {offset, limit, filter}
  HTTP->>Server: send request
  Server-->>HTTP: 200 OK + JSON list of field metadata
  HTTP-->>Index: response payload
  Index-->>Test: return List[Dict[str, Any]]
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰
I found a new path simply called "fields",
I hopped, I posted, uncovered tiny yields.
Tests counted, filtered, paged with delight,
A rabbit's nibble on metadata tonight. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title "Api for metadata" is vague and overly broad. While it refers to the PR's general purpose, it doesn't clearly convey that this specifically implements a get_fields() method to fetch field metadata from the Meilisearch API. Consider a more specific title such as "Add get_fields() method to fetch index field metadata" or "Implement POST /indexes/{indexUid}/fields endpoint support" to better describe the concrete change.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 87.50% which is sufficient. The required threshold is 80.00%.

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


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.

Copy link
Contributor

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

🤖 Fix all issues with AI agents
In `@meilisearch/index.py`:
- Around line 2608-2610: Remove the trailing whitespace after the statement that
initializes the request body (the line "body: Dict[str, Any] = {}") so the file
no longer contains an extra space at end-of-line; update the block around the
body/offset handling (the code referencing the variable body and the subsequent
if offset is not None) to ensure there are no trailing spaces on any lines.
- Around line 2553-2558: The parameter name 'filter' in get_fields is shadowing
the built-in and triggers pylint W0622; rename the parameter (e.g., to filter_
or filters) and update all internal references within the get_fields function
signature and body to the new name (preserving type Optional[MutableMapping[str,
Any]] and behavior), or if you prefer consistency with nearby methods add the
same local pylint disable used elsewhere instead of renaming; ensure only
get_fields and its internals are changed so the API remains non-breaking.

In `@tests/index/test_index.py`:
- Around line 350-371: The failing linter is due to trailing whitespace in the
new test block that exercises index.get_fields (variables: page1, page2,
limited); open the test_index.py test that contains the pagination assertions
for index.get_fields and remove any trailing spaces at the ends of the affected
lines (the lines with the page1/page2/limited assertions and surrounding
comments) so there are no trailing whitespace characters left, then save and
re-run linting.

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.

1 participant