update-distinct-attribute
Modify the distinct attribute setting in a Meilisearch index to control how duplicate results are handled during search operations.
Instructions
Update the distinct attribute setting
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| indexUid | Yes | Unique identifier of the index | |
| value | Yes | JSON value for the setting |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"indexUid": {
"description": "Unique identifier of the index",
"type": "string"
},
"value": {
"description": "JSON value for the setting",
"type": "string"
}
},
"required": [
"indexUid",
"value"
],
"type": "object"
}
Implementation Reference
- src/tools/settings-tools.ts:236-249 (handler)Handler function that executes the tool logic for 'update-distinct-attribute' (shared with other update settings tools). Parses the JSON value input, sends a PUT request to the Meilisearch API endpoint for distinct-attribute settings, and returns the response or handles errors.async ({ indexUid, value }) => { try { // Parse the value string to ensure it's valid JSON const parsedValue = JSON.parse(value); const response = await apiClient.put(`/indexes/${indexUid}/settings/${endpoint}`, parsedValue); return { content: [{ type: "text", text: JSON.stringify(response.data, null, 2) }], }; } catch (error) { return createErrorResponse(error); } } );
- src/tools/settings-tools.ts:232-235 (schema)Input schema definition using Zod for the tool, specifying indexUid and value parameters (shared with other update tools).{ indexUid: z.string().describe("Unique identifier of the index"), value: z.string().describe("JSON value for the setting"), },
- src/tools/settings-tools.ts:205-209 (registration)Configuration object within the updateSettingsTools array used to dynamically register the 'update-distinct-attribute' tool via a forEach loop calling server.tool() with shared schema and handler.{ name: "update-distinct-attribute", endpoint: "distinct-attribute", description: "Update the distinct attribute setting", },
- src/index.ts:67-67 (registration)Top-level call to registerSettingsTools which includes the registration of 'update-distinct-attribute' among other settings tools.registerSettingsTools(server);