2021-08-06 12:59:39 +05:30
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
#
|
|
|
|
|
# The OpenSearch Contributors require contributions made to
|
|
|
|
|
# this file be licensed under the Apache-2.0 license or a
|
|
|
|
|
# compatible open source license.
|
|
|
|
|
#
|
|
|
|
|
# Modifications Copyright OpenSearch Contributors. See
|
|
|
|
|
# GitHub history for details.
|
|
|
|
|
#
|
2020-08-31 11:07:04 -05:00
|
|
|
# Licensed to Elasticsearch B.V. under one or more contributor
|
|
|
|
|
# license agreements. See the NOTICE file distributed with
|
|
|
|
|
# this work for additional information regarding copyright
|
|
|
|
|
# ownership. Elasticsearch B.V. licenses this file to you under
|
|
|
|
|
# the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
|
# not use this file except in compliance with the License.
|
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
|
#
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
#
|
|
|
|
|
# Unless required by applicable law or agreed to in writing,
|
|
|
|
|
# software distributed under the License is distributed on an
|
|
|
|
|
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
|
# KIND, either express or implied. See the License for the
|
|
|
|
|
# specific language governing permissions and limitations
|
|
|
|
|
# under the License.
|
|
|
|
|
|
2021-01-13 14:21:04 -06:00
|
|
|
import logging
|
2020-08-31 11:07:04 -05:00
|
|
|
from typing import (
|
|
|
|
|
Any,
|
|
|
|
|
AsyncIterable,
|
|
|
|
|
Callable,
|
2021-01-13 14:21:04 -06:00
|
|
|
Collection,
|
2020-09-28 09:14:03 -05:00
|
|
|
Dict,
|
2021-01-13 14:21:04 -06:00
|
|
|
Generator,
|
|
|
|
|
Iterable,
|
|
|
|
|
List,
|
|
|
|
|
Mapping,
|
|
|
|
|
Optional,
|
|
|
|
|
Tuple,
|
|
|
|
|
Union,
|
2020-08-31 11:07:04 -05:00
|
|
|
)
|
2021-01-13 14:21:04 -06:00
|
|
|
|
2021-08-13 15:51:50 +05:30
|
|
|
from ..client import OpenSearch
|
2020-08-31 11:07:04 -05:00
|
|
|
from ..serializer import Serializer
|
|
|
|
|
|
|
|
|
|
logger: logging.Logger
|
|
|
|
|
|
2020-09-28 09:14:03 -05:00
|
|
|
def expand_action(data: Any) -> Tuple[Dict[str, Any], Optional[Any]]: ...
|
2020-08-31 11:07:04 -05:00
|
|
|
def _chunk_actions(
|
|
|
|
|
actions: Any, chunk_size: int, max_chunk_bytes: int, serializer: Serializer
|
|
|
|
|
) -> Generator[Any, None, None]: ...
|
|
|
|
|
def _process_bulk_chunk(
|
2021-08-13 15:51:50 +05:30
|
|
|
client: OpenSearch,
|
2020-08-31 11:07:04 -05:00
|
|
|
bulk_actions: Any,
|
|
|
|
|
bulk_data: Any,
|
|
|
|
|
raise_on_exception: bool = ...,
|
|
|
|
|
raise_on_error: bool = ...,
|
|
|
|
|
*args: Any,
|
|
|
|
|
**kwargs: Any
|
|
|
|
|
) -> Generator[Tuple[bool, Any], None, None]: ...
|
|
|
|
|
def streaming_bulk(
|
2021-08-13 15:51:50 +05:30
|
|
|
client: OpenSearch,
|
2020-08-31 11:07:04 -05:00
|
|
|
actions: Union[Iterable[Any], AsyncIterable[Any]],
|
|
|
|
|
chunk_size: int = ...,
|
|
|
|
|
max_chunk_bytes: int = ...,
|
|
|
|
|
raise_on_error: bool = ...,
|
2020-09-28 09:14:03 -05:00
|
|
|
expand_action_callback: Callable[[Any], Tuple[Dict[str, Any], Optional[Any]]] = ...,
|
2020-08-31 11:07:04 -05:00
|
|
|
raise_on_exception: bool = ...,
|
|
|
|
|
max_retries: int = ...,
|
|
|
|
|
initial_backoff: Union[float, int] = ...,
|
|
|
|
|
max_backoff: Union[float, int] = ...,
|
|
|
|
|
yield_ok: bool = ...,
|
2021-04-20 14:35:22 +02:00
|
|
|
ignore_status: Optional[Union[int, Collection[int]]] = ...,
|
2020-08-31 11:07:04 -05:00
|
|
|
*args: Any,
|
|
|
|
|
**kwargs: Any
|
|
|
|
|
) -> Generator[Tuple[bool, Any], None, None]: ...
|
|
|
|
|
def bulk(
|
2021-08-13 15:51:50 +05:30
|
|
|
client: OpenSearch,
|
2020-08-31 11:07:04 -05:00
|
|
|
actions: Iterable[Any],
|
|
|
|
|
stats_only: bool = ...,
|
2021-04-20 14:35:22 +02:00
|
|
|
ignore_status: Optional[Union[int, Collection[int]]] = ...,
|
2020-08-31 11:07:04 -05:00
|
|
|
*args: Any,
|
|
|
|
|
**kwargs: Any
|
|
|
|
|
) -> Tuple[int, Union[int, List[Any]]]: ...
|
|
|
|
|
def parallel_bulk(
|
2021-08-13 15:51:50 +05:30
|
|
|
client: OpenSearch,
|
2020-08-31 11:07:04 -05:00
|
|
|
actions: Iterable[Any],
|
|
|
|
|
thread_count: int = ...,
|
|
|
|
|
chunk_size: int = ...,
|
|
|
|
|
max_chunk_bytes: int = ...,
|
|
|
|
|
queue_size: int = ...,
|
2020-09-28 09:14:03 -05:00
|
|
|
expand_action_callback: Callable[[Any], Tuple[Dict[str, Any], Optional[Any]]] = ...,
|
2021-04-20 14:35:22 +02:00
|
|
|
ignore_status: Optional[Union[int, Collection[int]]] = ...,
|
2020-08-31 11:07:04 -05:00
|
|
|
*args: Any,
|
|
|
|
|
**kwargs: Any
|
|
|
|
|
) -> Generator[Tuple[bool, Any], None, None]: ...
|
|
|
|
|
def scan(
|
2021-08-13 15:51:50 +05:30
|
|
|
client: OpenSearch,
|
2020-08-31 11:07:04 -05:00
|
|
|
query: Optional[Any] = ...,
|
|
|
|
|
scroll: str = ...,
|
|
|
|
|
raise_on_error: bool = ...,
|
|
|
|
|
preserve_order: bool = ...,
|
|
|
|
|
size: int = ...,
|
|
|
|
|
request_timeout: Optional[Union[float, int]] = ...,
|
|
|
|
|
clear_scroll: bool = ...,
|
|
|
|
|
scroll_kwargs: Optional[Mapping[str, Any]] = ...,
|
|
|
|
|
**kwargs: Any
|
|
|
|
|
) -> Generator[Any, None, None]: ...
|
|
|
|
|
def reindex(
|
2021-08-13 15:51:50 +05:30
|
|
|
client: OpenSearch,
|
2020-08-31 11:07:04 -05:00
|
|
|
source_index: Union[str, Collection[str]],
|
|
|
|
|
target_index: str,
|
|
|
|
|
query: Any = ...,
|
2021-08-13 15:51:50 +05:30
|
|
|
target_client: Optional[OpenSearch] = ...,
|
2020-08-31 11:07:04 -05:00
|
|
|
chunk_size: int = ...,
|
|
|
|
|
scroll: str = ...,
|
|
|
|
|
scan_kwargs: Optional[Mapping[str, Any]] = ...,
|
|
|
|
|
bulk_kwargs: Optional[Mapping[str, Any]] = ...,
|
|
|
|
|
) -> Tuple[int, Union[int, List[Any]]]: ...
|