delete_by_query
Remove documents from an Elasticsearch index that match a specified query. Provide the index name and query criteria to execute the deletion process efficiently.
Instructions
Deletes documents matching the provided query.
Args:
index: Name of the index
body: Query to match documents for deletion
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| body | Yes | ||
| index | Yes |
Implementation Reference
- src/tools/document.py:55-64 (handler)MCP tool handler for 'delete_by_query'. This decorated function defines the tool implementation, including input parameters, description, and logic that delegates to the search client's delete_by_query method.@mcp.tool() def delete_by_query(index: str, body: Dict) -> Dict: """ Deletes documents matching the provided query. Args: index: Name of the index body: Query to match documents for deletion """ return self.search_client.delete_by_query(index=index, body=body)
- src/clients/common/document.py:34-36 (helper)Helper method in DocumentClient that wraps the underlying search engine client's delete_by_query operation.def delete_by_query(self, index: str, body: Dict) -> Dict: """Deletes documents matching the provided query.""" return self.client.delete_by_query(index=index, body=body)