CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-elasticsearch

Python client for Elasticsearch with comprehensive API coverage and both sync and async support

Pending
Overview
Eval results
Files

client-operations.mddocs/

Client Operations

Core document and search operations that form the foundation of Elasticsearch interactions. These operations handle the primary CRUD (Create, Read, Update, Delete) operations and basic search functionality.

Capabilities

Document Indexing

Index documents into Elasticsearch with automatic or explicit ID assignment, routing, and refresh control.

def index(
    self,
    index: str,
    document: Dict[str, Any],
    id: Optional[str] = None,
    op_type: Optional[str] = None,
    routing: Optional[str] = None,
    refresh: Optional[str] = None,
    timeout: Optional[str] = None,
    version: Optional[int] = None,
    version_type: Optional[str] = None,
    if_seq_no: Optional[int] = None,
    if_primary_term: Optional[int] = None,
    pipeline: Optional[str] = None,
    require_alias: Optional[bool] = None,
    **kwargs
) -> ObjectApiResponse:
    """
    Index a document.
    
    Parameters:
    - index: Target index name
    - document: Document to index
    - id: Document ID (auto-generated if not provided)
    - op_type: Operation type ('index' or 'create')
    - routing: Custom routing value
    - refresh: Refresh policy ('true', 'false', 'wait_for')
    - timeout: Request timeout
    - version: Document version for optimistic concurrency
    - version_type: Version type ('internal', 'external', 'external_gte')
    - if_seq_no: Sequence number for optimistic concurrency
    - if_primary_term: Primary term for optimistic concurrency
    - pipeline: Ingest pipeline to use
    - require_alias: Require index to be an alias
    
    Returns:
    ObjectApiResponse with result metadata
    """

Document Retrieval

Retrieve documents by ID with support for routing, version checking, and field filtering.

def get(
    self,
    index: str,
    id: str,
    routing: Optional[str] = None,
    preference: Optional[str] = None,
    realtime: Optional[bool] = None,
    refresh: Optional[bool] = None,
    stored_fields: Optional[List[str]] = None,
    _source: Optional[Union[bool, List[str]]] = None,
    _source_excludes: Optional[List[str]] = None,
    _source_includes: Optional[List[str]] = None,
    version: Optional[int] = None,
    version_type: Optional[str] = None,
    **kwargs
) -> ObjectApiResponse:
    """
    Get a document by ID.
    
    Parameters:
    - index: Index name
    - id: Document ID
    - routing: Custom routing value
    - preference: Node preference for request routing
    - realtime: Whether to retrieve from real-time refresh
    - refresh: Whether to refresh before retrieval
    - stored_fields: Specific stored fields to retrieve
    - _source: Whether to return source and which fields
    - _source_excludes: Source fields to exclude
    - _source_includes: Source fields to include
    - version: Expected document version
    - version_type: Version type for comparison
    
    Returns:
    ObjectApiResponse with document data
    """

Document Updates

Update documents using partial document updates or scripts with upsert support.

def update(
    self,
    index: str,
    id: str,
    document: Optional[Dict[str, Any]] = None,
    script: Optional[Dict[str, Any]] = None,
    upsert: Optional[Dict[str, Any]] = None,
    routing: Optional[str] = None,
    refresh: Optional[str] = None,
    retry_on_conflict: Optional[int] = None,
    timeout: Optional[str] = None,
    _source: Optional[Union[bool, List[str]]] = None,
    _source_excludes: Optional[List[str]] = None,
    _source_includes: Optional[List[str]] = None,
    version: Optional[int] = None,
    version_type: Optional[str] = None,
    if_seq_no: Optional[int] = None,
    if_primary_term: Optional[int] = None,
    **kwargs
) -> ObjectApiResponse:
    """
    Update a document.
    
    Parameters:
    - index: Index name
    - id: Document ID
    - document: Partial document for update
    - script: Script for programmatic updates
    - upsert: Document to create if it doesn't exist
    - routing: Custom routing value
    - refresh: Refresh policy
    - retry_on_conflict: Number of retries on version conflicts
    - timeout: Request timeout
    - _source: Whether to return updated source
    - _source_excludes: Source fields to exclude from response
    - _source_includes: Source fields to include in response
    - version: Expected current version
    - version_type: Version type for comparison
    - if_seq_no: Expected sequence number
    - if_primary_term: Expected primary term
    
    Returns:
    ObjectApiResponse with update result
    """

Document Deletion

Delete documents by ID with support for routing and version checking.

def delete(
    self,
    index: str,
    id: str,
    routing: Optional[str] = None,
    refresh: Optional[str] = None,
    timeout: Optional[str] = None,
    version: Optional[int] = None,
    version_type: Optional[str] = None,
    if_seq_no: Optional[int] = None,
    if_primary_term: Optional[int] = None,
    **kwargs
) -> ObjectApiResponse:
    """
    Delete a document by ID.
    
    Parameters:
    - index: Index name
    - id: Document ID
    - routing: Custom routing value
    - refresh: Refresh policy
    - timeout: Request timeout
    - version: Expected document version
    - version_type: Version type for comparison
    - if_seq_no: Expected sequence number
    - if_primary_term: Expected primary term
    
    Returns:
    ObjectApiResponse with deletion result
    """

Bulk Operations

Execute multiple operations in a single request for efficient batch processing.

def bulk(
    self,
    operations: List[Dict[str, Any]],
    index: Optional[str] = None,
    routing: Optional[str] = None,
    refresh: Optional[str] = None,
    timeout: Optional[str] = None,
    pipeline: Optional[str] = None,
    require_alias: Optional[bool] = None,
    **kwargs
) -> ObjectApiResponse:
    """
    Perform multiple operations in a single request.
    
    Parameters:
    - operations: List of operation dictionaries
    - index: Default index for operations without explicit index
    - routing: Default routing value
    - refresh: Refresh policy
    - timeout: Request timeout
    - pipeline: Default ingest pipeline
    - require_alias: Require indices to be aliases
    
    Returns:
    ObjectApiResponse with results for each operation
    """

Multi-Get Operations

Retrieve multiple documents in a single request.

def mget(
    self,
    docs: List[Dict[str, Any]],
    index: Optional[str] = None,
    routing: Optional[str] = None,
    preference: Optional[str] = None,
    realtime: Optional[bool] = None,
    refresh: Optional[bool] = None,
    stored_fields: Optional[List[str]] = None,
    _source: Optional[Union[bool, List[str]]] = None,
    _source_excludes: Optional[List[str]] = None,
    _source_includes: Optional[List[str]] = None,
    **kwargs
) -> ObjectApiResponse:
    """
    Get multiple documents.
    
    Parameters:
    - docs: List of document specifiers with _index, _id, and other parameters
    - index: Default index name
    - routing: Default routing value
    - preference: Node preference
    - realtime: Whether to use real-time refresh
    - refresh: Whether to refresh before retrieval
    - stored_fields: Stored fields to retrieve
    - _source: Source field configuration
    - _source_excludes: Source fields to exclude
    - _source_includes: Source fields to include
    
    Returns:
    ObjectApiResponse with array of document results
    """

Document Existence Checks

Check if documents exist without retrieving their content.

def exists(
    self,
    index: str,
    id: str,
    routing: Optional[str] = None,
    preference: Optional[str] = None,
    realtime: Optional[bool] = None,
    refresh: Optional[bool] = None,
    version: Optional[int] = None,
    version_type: Optional[str] = None,
    **kwargs
) -> bool:
    """
    Check if a document exists.
    
    Parameters:
    - index: Index name
    - id: Document ID
    - routing: Custom routing value
    - preference: Node preference
    - realtime: Whether to use real-time refresh
    - refresh: Whether to refresh before check
    - version: Expected document version
    - version_type: Version type for comparison
    
    Returns:
    True if document exists, False otherwise
    """

Basic Search

Execute search queries against one or more indices.

def search(
    self,
    index: Optional[Union[str, List[str]]] = None,
    query: Optional[Dict[str, Any]] = None,
    aggs: Optional[Dict[str, Any]] = None,
    sort: Optional[List[Dict[str, Any]]] = None,
    _source: Optional[Union[bool, List[str]]] = None,
    _source_excludes: Optional[List[str]] = None,
    _source_includes: Optional[List[str]] = None,
    size: Optional[int] = None,
    from_: Optional[int] = None,
    timeout: Optional[str] = None,
    terminate_after: Optional[int] = None,
    routing: Optional[str] = None,
    preference: Optional[str] = None,
    **kwargs
) -> ObjectApiResponse:
    """
    Execute a search query.
    
    Parameters:
    - index: Index name(s) to search
    - query: Query DSL query
    - aggs: Aggregations to compute
    - sort: Sort configuration
    - _source: Source field configuration
    - _source_excludes: Source fields to exclude
    - _source_includes: Source fields to include
    - size: Number of results to return
    - from_: Starting offset for results
    - timeout: Search timeout
    - terminate_after: Terminate after collecting this many documents
    - routing: Custom routing value
    - preference: Node preference
    
    Returns:
    ObjectApiResponse with search results
    """

Connection Management

def ping(self, **kwargs) -> bool:
    """
    Check cluster connectivity.
    
    Returns:
    True if cluster is reachable, False otherwise
    """

def info(self, **kwargs) -> ObjectApiResponse:
    """
    Get basic cluster information.
    
    Returns:
    ObjectApiResponse with cluster info including version and build details
    """

def close(self) -> None:
    """
    Close the client and cleanup resources.
    """

Usage Examples

Basic Document Operations

from elasticsearch import Elasticsearch

client = Elasticsearch(hosts=['http://localhost:9200'])

# Index a document
response = client.index(
    index="products",
    id="1",
    document={
        "name": "Laptop",
        "price": 999.99,
        "category": "Electronics"
    },
    refresh='wait_for'
)

# Get the document
doc = client.get(index="products", id="1")
print(doc.body['_source'])

# Update the document
client.update(
    index="products",
    id="1",
    document={"price": 899.99},
    refresh='wait_for'
)

# Delete the document
client.delete(index="products", id="1", refresh='wait_for')

Bulk Operations

# Bulk indexing
operations = [
    {"index": {"_index": "products", "_id": "1"}},
    {"name": "Laptop", "price": 999.99},
    {"index": {"_index": "products", "_id": "2"}},
    {"name": "Mouse", "price": 29.99},
    {"update": {"_index": "products", "_id": "1"}},
    {"doc": {"price": 899.99}}
]

response = client.bulk(operations=operations, refresh='wait_for')

# Check for errors
if response.body['errors']:
    for item in response.body['items']:
        if 'error' in item.get('index', {}):
            print(f"Error: {item['index']['error']}")

Document Creation

Create documents with explicit ID assignment, ensuring they don't already exist.

def create(
    self,
    index: str,
    id: str,
    document: Dict[str, Any],
    routing: Optional[str] = None,
    refresh: Optional[str] = None,
    timeout: Optional[str] = None,
    version: Optional[int] = None,
    version_type: Optional[str] = None,
    pipeline: Optional[str] = None,
    **kwargs
) -> ObjectApiResponse:
    """
    Create a document with explicit ID, failing if it already exists.
    
    Parameters:
    - index: Target index name
    - id: Document ID (must not exist)
    - document: Document to create
    - routing: Custom routing value
    - refresh: Refresh policy ('true', 'false', 'wait_for')
    - timeout: Request timeout
    - version: Expected version (must be 1 for creation)
    - version_type: Version type ('internal', 'external')
    - pipeline: Ingest pipeline to use
    
    Returns:
    ObjectApiResponse with creation result
    """

Source-Only Operations

Retrieve or check document source without metadata overhead.

def get_source(
    self,
    index: str,
    id: str,
    routing: Optional[str] = None,
    preference: Optional[str] = None,
    realtime: Optional[bool] = None,
    refresh: Optional[bool] = None,
    _source_excludes: Optional[List[str]] = None,
    _source_includes: Optional[List[str]] = None,
    version: Optional[int] = None,
    version_type: Optional[str] = None,
    **kwargs
) -> ObjectApiResponse:
    """
    Get only the source of a document without metadata.
    
    Parameters:
    - index: Index name
    - id: Document ID
    - routing: Custom routing value
    - preference: Node preference for request routing
    - realtime: Whether to retrieve from real-time refresh
    - refresh: Whether to refresh before retrieval
    - _source_excludes: Source fields to exclude
    - _source_includes: Source fields to include
    - version: Expected document version
    - version_type: Version type for comparison
    
    Returns:
    ObjectApiResponse with only document source
    """

def exists_source(
    self,
    index: str,
    id: str,
    routing: Optional[str] = None,
    preference: Optional[str] = None,
    realtime: Optional[bool] = None,
    refresh: Optional[bool] = None,
    _source_excludes: Optional[List[str]] = None,
    _source_includes: Optional[List[str]] = None,
    version: Optional[int] = None,
    version_type: Optional[str] = None,
    **kwargs
) -> HeadApiResponse:
    """
    Check if document source exists.
    
    Parameters:
    - index: Index name
    - id: Document ID
    - routing: Custom routing value
    - preference: Node preference
    - realtime: Whether to check real-time refresh
    - refresh: Whether to refresh before check
    - _source_excludes: Source fields to exclude from check
    - _source_includes: Source fields to include in check
    - version: Expected document version
    - version_type: Version type for comparison
    
    Returns:
    HeadApiResponse (status 200 if exists, 404 if not)
    """

Advanced Search Operations

Extended search capabilities including multi-search, templates, and explanations.

def msearch(
    self,
    searches: List[Dict[str, Any]],
    index: Optional[str] = None,
    allow_no_indices: Optional[bool] = None,
    expand_wildcards: Optional[str] = None,
    ignore_unavailable: Optional[bool] = None,
    max_concurrent_searches: Optional[int] = None,
    rest_total_hits_as_int: Optional[bool] = None,
    typed_keys: Optional[bool] = None,
    **kwargs
) -> ObjectApiResponse:
    """
    Execute multiple search requests in a single API call.
    
    Parameters:
    - searches: List of search request objects
    - index: Default index for searches without explicit index
    - allow_no_indices: Whether to allow searches with no matching indices
    - expand_wildcards: How to expand wildcard patterns
    - ignore_unavailable: Whether to ignore unavailable indices
    - max_concurrent_searches: Maximum concurrent searches
    - rest_total_hits_as_int: Return total hits as integer
    - typed_keys: Return typed keys in response
    
    Returns:
    ObjectApiResponse with responses for each search
    """

def search_template(
    self,
    index: Optional[str] = None,
    id: Optional[str] = None,
    params: Optional[Dict[str, Any]] = None,
    source: Optional[str] = None,
    allow_no_indices: Optional[bool] = None,
    expand_wildcards: Optional[str] = None,
    ignore_unavailable: Optional[bool] = None,
    **kwargs
) -> ObjectApiResponse:
    """
    Execute a search using a stored or inline template.
    
    Parameters:
    - index: Index name(s) to search
    - id: ID of stored search template
    - params: Template parameters
    - source: Inline template source
    - allow_no_indices: Whether to allow no matching indices
    - expand_wildcards: How to expand wildcards
    - ignore_unavailable: Whether to ignore unavailable indices
    
    Returns:
    ObjectApiResponse with search results
    """

def msearch_template(
    self,
    search_templates: List[Dict[str, Any]],
    index: Optional[str] = None,
    **kwargs
) -> ObjectApiResponse:
    """
    Execute multiple search template requests.
    
    Parameters:
    - search_templates: List of search template requests
    - index: Default index name
    
    Returns:
    ObjectApiResponse with results for each template search
    """

def explain(
    self,
    index: str,
    id: str,
    query: Optional[Dict[str, Any]] = None,
    analyzer: Optional[str] = None,
    analyze_wildcard: Optional[bool] = None,
    default_operator: Optional[str] = None,
    df: Optional[str] = None,
    lenient: Optional[bool] = None,
    preference: Optional[str] = None,
    routing: Optional[str] = None,
    **kwargs
) -> ObjectApiResponse:
    """
    Explain why a document matches or doesn't match a query.
    
    Parameters:
    - index: Index name
    - id: Document ID to explain
    - query: Query to explain against
    - analyzer: Analyzer for query analysis
    - analyze_wildcard: Whether to analyze wildcard queries
    - default_operator: Default operator for query parsing
    - df: Default field for query parsing
    - lenient: Whether to ignore format errors
    - preference: Node preference
    - routing: Custom routing
    
    Returns:
    ObjectApiResponse with explanation details
    """

Scroll Operations

Manage scroll contexts for paginating through large result sets efficiently.

def scroll(
    self,
    scroll_id: str,
    scroll: Optional[str] = "5m",
    rest_total_hits_as_int: Optional[bool] = None,
    **kwargs
) -> ObjectApiResponse:
    """
    Continue scrolling through search results.
    
    Parameters:
    - scroll_id: Scroll ID from previous search/scroll request
    - scroll: How long to keep scroll context alive
    - rest_total_hits_as_int: Return total hits as integer
    
    Returns:
    ObjectApiResponse with next batch of results
    """

def clear_scroll(
    self,
    scroll_id: Optional[Union[str, List[str]]] = None,
    **kwargs
) -> ObjectApiResponse:
    """
    Clear scroll contexts to free resources.
    
    Parameters:
    - scroll_id: Scroll ID(s) to clear (clears all if not provided)
    
    Returns:
    ObjectApiResponse confirming cleared contexts
    """

Point in Time Operations

Manage point-in-time contexts for consistent pagination across index changes.

def open_point_in_time(
    self,
    index: str,
    keep_alive: str,
    routing: Optional[str] = None,
    preference: Optional[str] = None,
    expand_wildcards: Optional[str] = None,
    ignore_unavailable: Optional[bool] = None,
    **kwargs
) -> ObjectApiResponse:
    """
    Open a point in time for consistent search across index changes.
    
    Parameters:
    - index: Index name(s) for point in time
    - keep_alive: How long to keep point in time alive
    - routing: Custom routing
    - preference: Node preference
    - expand_wildcards: How to expand wildcards
    - ignore_unavailable: Whether to ignore unavailable indices
    
    Returns:
    ObjectApiResponse with point in time ID
    """

def close_point_in_time(
    self,
    id: str,
    **kwargs
) -> ObjectApiResponse:
    """
    Close a point in time to free resources.
    
    Parameters:
    - id: Point in time ID to close
    
    Returns:
    ObjectApiResponse confirming closure
    """

Term Vector Operations

Analyze term vectors for document fields to understand indexing and scoring.

def termvectors(
    self,
    index: str,
    id: Optional[str] = None,
    doc: Optional[Dict[str, Any]] = None,
    fields: Optional[List[str]] = None,
    field_statistics: Optional[bool] = None,
    offsets: Optional[bool] = None,
    payloads: Optional[bool] = None,
    positions: Optional[bool] = None,
    preference: Optional[str] = None,
    realtime: Optional[bool] = None,
    routing: Optional[str] = None,
    term_statistics: Optional[bool] = None,
    version: Optional[int] = None,
    version_type: Optional[str] = None,
    **kwargs
) -> ObjectApiResponse:
    """
    Get term vectors for document fields.
    
    Parameters:
    - index: Index name
    - id: Document ID (or provide doc)
    - doc: Document to analyze (if no ID)
    - fields: Fields to analyze
    - field_statistics: Include field statistics
    - offsets: Include term offsets
    - payloads: Include term payloads
    - positions: Include term positions
    - preference: Node preference
    - realtime: Use real-time refresh
    - routing: Custom routing
    - term_statistics: Include term statistics
    - version: Document version
    - version_type: Version type
    
    Returns:
    ObjectApiResponse with term vector analysis
    """

def mtermvectors(
    self,
    docs: Optional[List[Dict[str, Any]]] = None,
    ids: Optional[List[str]] = None,
    index: Optional[str] = None,
    field_statistics: Optional[bool] = None,
    fields: Optional[List[str]] = None,
    offsets: Optional[bool] = None,
    payloads: Optional[bool] = None,
    positions: Optional[bool] = None,
    preference: Optional[str] = None,
    realtime: Optional[bool] = None,
    routing: Optional[str] = None,
    term_statistics: Optional[bool] = None,
    **kwargs
) -> ObjectApiResponse:
    """
    Get term vectors for multiple documents.
    
    Parameters:
    - docs: List of documents with their indices and IDs
    - ids: List of document IDs (requires index parameter)
    - index: Default index for IDs list
    - field_statistics: Include field statistics
    - fields: Fields to analyze
    - offsets: Include term offsets
    - payloads: Include term payloads
    - positions: Include term positions
    - preference: Node preference
    - realtime: Use real-time refresh
    - routing: Custom routing
    - term_statistics: Include term statistics
    
    Returns:
    ObjectApiResponse with term vectors for each document
    """

Query Operations

Execute queries that modify documents based on query criteria.

def delete_by_query(
    self,
    index: str,
    query: Optional[Dict[str, Any]] = None,
    analyzer: Optional[str] = None,
    analyze_wildcard: Optional[bool] = None,
    conflicts: Optional[str] = None,
    default_operator: Optional[str] = None,
    df: Optional[str] = None,
    expand_wildcards: Optional[str] = None,
    from_: Optional[int] = None,
    ignore_unavailable: Optional[bool] = None,
    lenient: Optional[bool] = None,
    preference: Optional[str] = None,
    q: Optional[str] = None,
    refresh: Optional[bool] = None,
    request_cache: Optional[bool] = None,
    requests_per_second: Optional[float] = None,
    routing: Optional[str] = None,
    scroll: Optional[str] = None,
    scroll_size: Optional[int] = None,
    search_type: Optional[str] = None,
    search_timeout: Optional[str] = None,
    size: Optional[int] = None,
    slices: Optional[Union[int, str]] = None,
    sort: Optional[List[str]] = None,
    stats: Optional[List[str]] = None,
    terminate_after: Optional[int] = None,
    timeout: Optional[str] = None,
    version: Optional[bool] = None,
    version_type: Optional[bool] = None,
    wait_for_active_shards: Optional[str] = None,
    wait_for_completion: Optional[bool] = None,
    **kwargs
) -> ObjectApiResponse:
    """
    Delete all documents matching a query.
    
    Parameters:
    - index: Index name(s) to delete from
    - query: Query to match documents for deletion
    - conflicts: How to handle version conflicts ('abort' or 'proceed')
    - refresh: Whether to refresh after deletion
    - requests_per_second: Throttle rate for deletions
    - slices: Number of slices for parallel processing
    - wait_for_completion: Whether to wait for completion
    - (many other search parameters)
    
    Returns:
    ObjectApiResponse with deletion results
    """

def update_by_query(
    self,
    index: str,
    query: Optional[Dict[str, Any]] = None,
    script: Optional[Dict[str, Any]] = None,
    analyzer: Optional[str] = None,
    analyze_wildcard: Optional[bool] = None,
    conflicts: Optional[str] = None,
    default_operator: Optional[str] = None,
    df: Optional[str] = None,
    expand_wildcards: Optional[str] = None,
    from_: Optional[int] = None,
    ignore_unavailable: Optional[bool] = None,
    lenient: Optional[bool] = None,
    pipeline: Optional[str] = None,
    preference: Optional[str] = None,
    q: Optional[str] = None,
    refresh: Optional[bool] = None,
    request_cache: Optional[bool] = None,
    requests_per_second: Optional[float] = None,
    routing: Optional[str] = None,
    scroll: Optional[str] = None,
    scroll_size: Optional[int] = None,
    search_type: Optional[str] = None,
    search_timeout: Optional[str] = None,
    size: Optional[int] = None,
    slices: Optional[Union[int, str]] = None,
    sort: Optional[List[str]] = None,
    stats: Optional[List[str]] = None,
    terminate_after: Optional[int] = None,
    timeout: Optional[str] = None,
    version: Optional[bool] = None,
    version_type: Optional[bool] = None,
    wait_for_active_shards: Optional[str] = None,
    wait_for_completion: Optional[bool] = None,
    **kwargs
) -> ObjectApiResponse:
    """
    Update all documents matching a query.
    
    Parameters:
    - index: Index name(s) to update
    - query: Query to match documents for update
    - script: Script to apply to matched documents
    - conflicts: How to handle version conflicts
    - pipeline: Ingest pipeline to use
    - refresh: Whether to refresh after updates
    - requests_per_second: Throttle rate for updates
    - slices: Number of slices for parallel processing
    - wait_for_completion: Whether to wait for completion
    
    Returns:
    ObjectApiResponse with update results
    """

def reindex(
    self,
    source: Dict[str, Any],
    dest: Dict[str, Any],
    conflicts: Optional[str] = None,
    max_docs: Optional[int] = None,
    refresh: Optional[bool] = None,
    requests_per_second: Optional[float] = None,
    script: Optional[Dict[str, Any]] = None,
    scroll: Optional[str] = None,
    size: Optional[int] = None,
    slices: Optional[Union[int, str]] = None,
    timeout: Optional[str] = None,
    wait_for_active_shards: Optional[str] = None,
    wait_for_completion: Optional[bool] = None,
    **kwargs
) -> ObjectApiResponse:
    """
    Copy documents from source to destination index with optional transformation.
    
    Parameters:
    - source: Source index configuration with query, sort, etc.
    - dest: Destination index configuration
    - conflicts: How to handle conflicts ('abort' or 'proceed')
    - max_docs: Maximum documents to reindex
    - refresh: Whether to refresh destination after reindex
    - requests_per_second: Throttle rate
    - script: Transformation script
    - scroll: Scroll context lifetime
    - size: Batch size for reindexing
    - slices: Number of slices for parallel processing
    - timeout: Request timeout
    - wait_for_active_shards: Wait for shard availability
    - wait_for_completion: Whether to wait for completion
    
    Returns:
    ObjectApiResponse with reindex results
    """

Utility Operations

Additional utility operations for document counting, field capabilities, and cluster information.

def count(
    self,
    index: Optional[str] = None,
    query: Optional[Dict[str, Any]] = None,
    analyzer: Optional[str] = None,
    analyze_wildcard: Optional[bool] = None,
    default_operator: Optional[str] = None,
    df: Optional[str] = None,
    expand_wildcards: Optional[str] = None,
    ignore_unavailable: Optional[bool] = None,
    lenient: Optional[bool] = None,
    min_score: Optional[float] = None,
    preference: Optional[str] = None,
    q: Optional[str] = None,
    routing: Optional[str] = None,
    terminate_after: Optional[int] = None,
    **kwargs
) -> ObjectApiResponse:
    """
    Count documents matching a query.
    
    Parameters:
    - index: Index name(s) to count in
    - query: Query to match documents
    - analyzer: Analyzer for query string
    - analyze_wildcard: Whether to analyze wildcards
    - default_operator: Default operator for query string
    - df: Default field for query string
    - expand_wildcards: How to expand wildcards
    - ignore_unavailable: Whether to ignore unavailable indices
    - lenient: Whether to ignore format errors
    - min_score: Minimum score threshold
    - preference: Node preference
    - q: Query string
    - routing: Custom routing
    - terminate_after: Stop counting after this many matches
    
    Returns:
    ObjectApiResponse with document count
    """

def field_caps(
    self,
    index: Optional[str] = None,
    fields: Optional[List[str]] = None,
    allow_no_indices: Optional[bool] = None,
    expand_wildcards: Optional[str] = None,
    ignore_unavailable: Optional[bool] = None,
    include_unmapped: Optional[bool] = None,
    **kwargs
) -> ObjectApiResponse:
    """
    Get field capabilities across indices.
    
    Parameters:
    - index: Index name(s) to analyze
    - fields: Field names to analyze
    - allow_no_indices: Whether to allow no matching indices
    - expand_wildcards: How to expand wildcards
    - ignore_unavailable: Whether to ignore unavailable indices
    - include_unmapped: Whether to include unmapped fields
    
    Returns:
    ObjectApiResponse with field capabilities
    """

def rank_eval(
    self,
    requests: List[Dict[str, Any]],
    index: Optional[str] = None,
    allow_no_indices: Optional[bool] = None,
    expand_wildcards: Optional[str] = None,
    ignore_unavailable: Optional[bool] = None,
    **kwargs
) -> ObjectApiResponse:
    """
    Evaluate search quality using ranked evaluation.
    
    Parameters:
    - requests: List of evaluation requests with queries and ratings
    - index: Index name(s) to evaluate against
    - allow_no_indices: Whether to allow no matching indices
    - expand_wildcards: How to expand wildcards
    - ignore_unavailable: Whether to ignore unavailable indices
    
    Returns:
    ObjectApiResponse with evaluation metrics
    """

def terms_enum(
    self,
    index: str,
    field: str,
    string: Optional[str] = None,
    case_insensitive: Optional[bool] = None,
    index_filter: Optional[Dict[str, Any]] = None,
    search_after: Optional[str] = None,
    size: Optional[int] = None,
    timeout: Optional[str] = None,
    **kwargs
) -> ObjectApiResponse:
    """
    Enumerate terms in a field for autocomplete and term exploration.
    
    Parameters:
    - index: Index name
    - field: Field name to enumerate terms from
    - string: String prefix to match terms
    - case_insensitive: Whether matching is case insensitive
    - index_filter: Filter to apply to documents
    - search_after: Term to search after for pagination
    - size: Maximum number of terms to return
    - timeout: Request timeout
    
    Returns:
    ObjectApiResponse with enumerated terms
    """

def info(
    self,
    **kwargs
) -> ObjectApiResponse:
    """
    Get basic information about the cluster and node.
    
    Returns:
    ObjectApiResponse with cluster information
    """

def ping(
    self,
    **kwargs
) -> HeadApiResponse:
    """
    Ping the cluster to check connectivity.
    
    Returns:
    HeadApiResponse (200 if cluster is available)
    """

Script Operations

Manage stored scripts for reuse across search and update operations.

def put_script(
    self,
    id: str,
    script: Dict[str, Any],
    context: Optional[str] = None,
    timeout: Optional[str] = None,
    **kwargs
) -> ObjectApiResponse:
    """
    Store a script for later execution.
    
    Parameters:
    - id: Script ID
    - script: Script definition with source and lang
    - context: Script context (default is search and update)
    - timeout: Request timeout
    
    Returns:
    ObjectApiResponse confirming script storage
    """

def get_script(
    self,
    id: str,
    **kwargs
) -> ObjectApiResponse:
    """
    Retrieve a stored script.
    
    Parameters:
    - id: Script ID to retrieve
    
    Returns:
    ObjectApiResponse with script definition
    """

def delete_script(
    self,
    id: str,
    timeout: Optional[str] = None,
    **kwargs
) -> ObjectApiResponse:
    """
    Delete a stored script.
    
    Parameters:
    - id: Script ID to delete
    - timeout: Request timeout
    
    Returns:
    ObjectApiResponse confirming deletion
    """

Install with Tessl CLI

npx tessl i tessl/pypi-elasticsearch

docs

client-operations.md

cluster-management.md

esql-operations.md

exception-handling.md

helper-functions.md

index-management.md

index.md

inference-api.md

lifecycle-management.md

machine-learning.md

query-dsl.md

search-operations.md

security-operations.md

vectorstore-helpers.md

tile.json