from collections.abc import Iterable
from typing import Any

from django.db import models
from wagtail.search.backends.base import BaseSearchBackend, BaseSearchQueryCompiler, BaseSearchResults

class Elasticsearch7Mapping:
    all_field_name: str
    edgengrams_field_name: str
    type_map: dict[str, str]
    def __init__(self, model: type) -> None: ...
    def get_mapping(self) -> dict[str, Any]: ...
    def get_document_id(self, item: models.Model) -> str: ...
    def get_document(self, item: models.Model) -> dict[str, Any]: ...

class Elasticsearch7Index:
    backend: Elasticsearch7SearchBackend
    name: str
    es: Any
    mapping_class: type[Elasticsearch7Mapping]
    def __init__(self, backend: Elasticsearch7SearchBackend, name: str) -> None: ...
    def put(self) -> None: ...
    def delete(self) -> None: ...
    def refresh(self) -> None: ...
    def add_model(self, model: type) -> None: ...
    def add_item(self, item: models.Model) -> None: ...
    def add_items(self, model: type, items: Iterable[models.Model]) -> None: ...
    def delete_item(self, item: models.Model) -> None: ...

class Elasticsearch7SearchQueryCompiler(BaseSearchQueryCompiler):
    mapping_class: type[Elasticsearch7Mapping]

class Elasticsearch7SearchResults(BaseSearchResults): ...
class Elasticsearch7AutocompleteQueryCompiler(Elasticsearch7SearchQueryCompiler): ...

class Elasticsearch7SearchBackend(BaseSearchBackend):
    mapping_class: type[Elasticsearch7Mapping]
    index_class: type[Elasticsearch7Index]
    query_compiler_class: type[Elasticsearch7SearchQueryCompiler]
    autocomplete_query_compiler_class: type[Elasticsearch7AutocompleteQueryCompiler]
    results_class: type[Elasticsearch7SearchResults]
    es: Any
    def __init__(self, params: dict[str, Any]) -> None: ...
    def get_index_for_model(self, model: type) -> Elasticsearch7Index: ...

SearchBackend = Elasticsearch7SearchBackend
