o
    gZh"j                     @   sH   d dl Zd dlmZ ddlmZ ddlmZmZm	Z	 G dd deZ
dS )    N)ObjectApiResponse   )NamespacedClient)SKIP_IN_PATH_quote_rewrite_parametersc                   @   sR  e Zd Ze ddddddedeje dejejeej	e f  deje deje de
ej fd	d
Ze dddddddddedeje dejejeej	e f  deje dejejddef  deje deje dejejddef  de
ej fddZe ddddddedeje dejejeej	e f  deje deje de
ej fddZeddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddFdejejeej	e f  dejejeejeejf f  dejejeejeejf f  d eje d!eje d"eje d#eje d$eje d%eje d&ejejeejf  d'ejejd(ef  d)eje d*ejej	ejeejf   deje d+ejejej	ejd,ef  ejd,ef f  d-eje d.ejejeejf  d/ejej	ejeejf   dejejeej	e f  deje d0ejejeejf  deje d1eje d2eje d3ejej	ejeef   dejejddef  d4eje d5ejejejeejf ej	ejeejf  f  d6eje d7eje d8eje d9eje d:ejejeejf  d;ejejeejf  d<eje d=eje deje d>eje d?eje d@ejejeejf  dAeje dBejejejeejf ej	ejeejf  f  dCeje dDeje dEejejeejeejf f  dFejejeejeejf f  dGejejddef  dHejej	ejdeeeeejf   dIejejdJef  dKeje dLeje dMejejeejf  dNejejej	ejeejeejf f  ejeejeejf f f  dejejeejeejf f  dejejeej	e f  dejejeej	e f  dOejej	e  dPejejeej	e f  dQejejeejf  dReje dSejejdTef  dUeje dVeje dWeje dXeje dYeje dZejejeef  deje d[eje dejejddef  de
ej fd\d]ZdS )^AsyncSearchClientN)error_tracefilter_pathhumanprettyidr	   r
   r   r   returnc          	      C   |   |t v rtddt| }i }|dur||d< |dur!||d< |dur)||d< |dur1||d< dd	i}| jd
|||dS )aJ  
        Deletes an async search by ID. If the search is still running, the search request
        will be cancelled. Otherwise, the saved search results are deleted.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/async-search.html>`_

        :param id: A unique identifier for the async search.
        %Empty value passed for parameter 'id'/_async_search/Nr	   r
   r   r   acceptapplication/jsonDELETEparamsheadersr   
ValueErrorr   perform_request	selfr   r	   r
   r   r   _AsyncSearchClient__path_AsyncSearchClient__query_AsyncSearchClient__headers r    ^/var/www/html/lang_env/lib/python3.10/site-packages/elasticsearch/_sync/client/async_search.pydelete       zAsyncSearchClient.delete)r	   r
   r   
keep_aliver   
typed_keyswait_for_completion_timeoutr$   zt.Literal[-1]zt.Literal[0]r%   r&   c                C   s   |t v rtddt| }	i }
|dur||
d< |dur!||
d< |dur)||
d< |dur1||
d< |dur9||
d< |durA||
d	< |durI||
d
< ddi}| jd|	|
|dS )aC  
        Retrieves the results of a previously submitted async search request given its
        ID.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/async-search.html>`_

        :param id: A unique identifier for the async search.
        :param keep_alive: Specifies how long the async search should be available in
            the cluster. When not specified, the `keep_alive` set with the corresponding
            submit async request will be used. Otherwise, it is possible to override
            the value and extend the validity of the request. When this period expires,
            the search, if still running, is cancelled. If the search is completed, its
            saved results are deleted.
        :param typed_keys: Specify whether aggregation and suggester names should be
            prefixed by their respective types in the response
        :param wait_for_completion_timeout: Specifies to wait for the search to be completed
            up until the provided timeout. Final results will be returned if available
            before the timeout expires, otherwise the currently available results will
            be returned once the timeout expires. By default no timeout is set meaning
            that the currently available results will be returned without any additional
            wait.
        r   r   Nr	   r
   r   r$   r   r%   r&   r   r   GETr   r   )r   r   r	   r
   r   r$   r   r%   r&   r   r   r   r    r    r!   get>   s,   %zAsyncSearchClient.getc          	      C   r   )a  
        Retrieves the status of a previously submitted async search request given its
        ID.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/async-search.html>`_

        :param id: A unique identifier for the async search.
        r   z/_async_search/status/Nr	   r
   r   r   r   r   r'   r   r   r   r    r    r!   statusz   r#   zAsyncSearchClient.statusTsourcesource_excludessource_includesfrom_)_source_source_excludes_source_includesfrom)Zbody_fieldsZparameter_aliases)Findexaggregationsaggsallow_no_indicesallow_partial_search_resultsanalyze_wildcardanalyzerbatched_reduce_sizeccs_minimize_roundtripscollapsedefault_operatordfdocvalue_fieldsr	   expand_wildcardsexplainextfieldsr
   r-   	highlightr   ignore_throttledignore_unavailableindices_boostr$   keep_on_completionknnlenientmax_concurrent_shard_requestsmin_compatible_shard_node	min_scorepitpost_filterpre_filter_shard_size
preferencer   profileqqueryrequest_cacherescorerest_total_hits_as_introutingruntime_mappingsscript_fieldsscrollsearch_aftersearch_typeseq_no_primary_termsizeslicesortr*   r+   r,   statsstored_fieldssuggestsuggest_fieldsuggest_modesuggest_sizesuggest_textterminate_aftertimeouttrack_scorestrack_total_hitsr%   versionr&   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   zt.Literal['and', 'or']r=   r>   r?   z4t.Literal['all', 'closed', 'hidden', 'none', 'open']r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   z5t.Literal['dfs_query_then_fetch', 'query_then_fetch']r]   r^   r_   r`   ra   rb   rc   rd   re   z)t.Literal['always', 'missing', 'popular']rf   rg   rh   ri   rj   rk   rl   c       F   K      C   s`  |t vrdt| d}Gnd}Gi }Hi }I|5dur?t|5tr d|5v s9t|5ttfr?tdd |5D r?tdd |5D r?|5|Id< d}5|durG||Hd	< |durO||Hd
< |durW||Id< |dur_||Id< |durg||Id< |duro||Id< |durw||Id< |	dur|	|Id< |
dur|
|Hd< |dur||Id< |dur||Id< |dur||Hd< |dur||Id< |dur||Id< |dur||Hd< |dur||Hd< |dur||Hd< |dur||Id< |dur||Hd< |dur||Hd< |dur||Id< |dur||Id< |dur||Id< |dur||Hd < |dur||Id!< |dur||Id"< |dur||Hd#< |dur#||Id$< |dur,||Id%< |dur5||Id&< | dur>| |Hd'< |!durG|!|Hd(< |"durP|"|Hd)< |#durY|#|Id*< |$durb|$|Id+< |%durk|%|Id,< |&durt|&|Hd-< |'dur}|'|Id.< |(dur|(|Hd/< |)dur|)|Id0< |*dur|*|Hd1< |+dur|+|Id2< |,dur|,|Id3< |-dur|-|Hd4< |.dur|.|Hd5< |/dur|/|Id6< |0dur|0|Hd7< |1dur|1|Id8< |2dur|2|Hd9< |3dur|3|Hd:< |4dur|4|Hd;< |5dur|5|Hd< |6dur|6|Hd<< |7dur|7|Id=< |8dur|8|Id>< |9dur|9|Hd?< |:dur(|:|Hd@< |;dur1|;|HdA< |<dur:|<|IdB< |=durC|=|IdC< |>durL|>|IdD< |?durU|?|IdE< |@dur^|@|HdF< |Adurg|A|HdG< |Bdurp|B|HdH< |Cdury|C|HdI< |Ddur|D|IdJ< |Edur|E|HdK< |Fdur|F|IdL< |Hsd}HdMdNi}J|HdurdN|JdO< | jdP|G|I|J|HdQS )RuS!  
        Executes a search request asynchronously.

        `<https://www.elastic.co/guide/en/elasticsearch/reference/8.11/async-search.html>`_

        :param index: A comma-separated list of index names to search; use `_all` or
            empty string to perform the operation on all indices
        :param aggregations:
        :param aggs:
        :param allow_no_indices: Whether to ignore if a wildcard indices expression resolves
            into no concrete indices. (This includes `_all` string or when no indices
            have been specified)
        :param allow_partial_search_results: Indicate if an error should be returned
            if there is a partial search failure or timeout
        :param analyze_wildcard: Specify whether wildcard and prefix queries should be
            analyzed (default: false)
        :param analyzer: The analyzer to use for the query string
        :param batched_reduce_size: Affects how often partial results become available,
            which happens whenever shard results are reduced. A partial reduction is
            performed every time the coordinating node has received a certain number
            of new shard responses (5 by default).
        :param ccs_minimize_roundtrips: The default value is the only supported value.
        :param collapse:
        :param default_operator: The default operator for query string query (AND or
            OR)
        :param df: The field to use as default where no field prefix is given in the
            query string
        :param docvalue_fields: Array of wildcard (*) patterns. The request returns doc
            values for field names matching these patterns in the hits.fields property
            of the response.
        :param expand_wildcards: Whether to expand wildcard expression to concrete indices
            that are open, closed or both.
        :param explain: If true, returns detailed information about score computation
            as part of a hit.
        :param ext: Configuration of search extensions defined by Elasticsearch plugins.
        :param fields: Array of wildcard (*) patterns. The request returns values for
            field names matching these patterns in the hits.fields property of the response.
        :param from_: Starting document offset. By default, you cannot page through more
            than 10,000 hits using the from and size parameters. To page through more
            hits, use the search_after parameter.
        :param highlight:
        :param ignore_throttled: Whether specified concrete, expanded or aliased indices
            should be ignored when throttled
        :param ignore_unavailable: Whether specified concrete indices should be ignored
            when unavailable (missing or closed)
        :param indices_boost: Boosts the _score of documents from specified indices.
        :param keep_alive: Specifies how long the async search needs to be available.
            Ongoing async searches and any saved search results are deleted after this
            period.
        :param keep_on_completion: If `true`, results are stored for later retrieval
            when the search completes within the `wait_for_completion_timeout`.
        :param knn: Defines the approximate kNN search to run.
        :param lenient: Specify whether format-based query failures (such as providing
            text to a numeric field) should be ignored
        :param max_concurrent_shard_requests: The number of concurrent shard requests
            per node this search executes concurrently. This value should be used to
            limit the impact of the search on the cluster in order to limit the number
            of concurrent shard requests
        :param min_compatible_shard_node:
        :param min_score: Minimum _score for matching documents. Documents with a lower
            _score are not included in the search results.
        :param pit: Limits the search to a point in time (PIT). If you provide a PIT,
            you cannot specify an <index> in the request path.
        :param post_filter:
        :param pre_filter_shard_size: The default value cannot be changed, which enforces
            the execution of a pre-filter roundtrip to retrieve statistics from each
            shard so that the ones that surely don’t hold any document matching the query
            get skipped.
        :param preference: Specify the node or shard the operation should be performed
            on (default: random)
        :param profile:
        :param q: Query in the Lucene query string syntax
        :param query: Defines the search definition using the Query DSL.
        :param request_cache: Specify if request cache should be used for this request
            or not, defaults to true
        :param rescore:
        :param rest_total_hits_as_int:
        :param routing: A comma-separated list of specific routing values
        :param runtime_mappings: Defines one or more runtime fields in the search request.
            These fields take precedence over mapped fields with the same name.
        :param script_fields: Retrieve a script evaluation (based on different fields)
            for each hit.
        :param scroll:
        :param search_after:
        :param search_type: Search operation type
        :param seq_no_primary_term: If true, returns sequence number and primary term
            of the last modification of each hit. See Optimistic concurrency control.
        :param size: The number of hits to return. By default, you cannot page through
            more than 10,000 hits using the from and size parameters. To page through
            more hits, use the search_after parameter.
        :param slice:
        :param sort:
        :param source: Indicates which source fields are returned for matching documents.
            These fields are returned in the hits._source property of the search response.
        :param source_excludes: A list of fields to exclude from the returned _source
            field
        :param source_includes: A list of fields to extract and return from the _source
            field
        :param stats: Stats groups to associate with the search. Each group maintains
            a statistics aggregation for its associated searches. You can retrieve these
            stats using the indices stats API.
        :param stored_fields: List of stored fields to return as part of a hit. If no
            fields are specified, no stored fields are included in the response. If this
            field is specified, the _source parameter defaults to false. You can pass
            _source: true to return both source fields and stored fields in the search
            response.
        :param suggest:
        :param suggest_field: Specifies which field to use for suggestions.
        :param suggest_mode: Specify suggest mode
        :param suggest_size: How many suggestions to return in response
        :param suggest_text: The source text for which the suggestions should be returned.
        :param terminate_after: Maximum number of documents to collect for each shard.
            If a query reaches this limit, Elasticsearch terminates the query early.
            Elasticsearch collects documents before sorting. Defaults to 0, which does
            not terminate query execution early.
        :param timeout: Specifies the period of time to wait for a response from each
            shard. If no response is received before the timeout expires, the request
            fails and returns an error. Defaults to no timeout.
        :param track_scores: If true, calculate and return document scores, even if the
            scores are not used for sorting.
        :param track_total_hits: Number of hits matching the query to count accurately.
            If true, the exact number of hits is returned at the cost of some performance.
            If false, the response does not include the total number of hits matching
            the query. Defaults to 10,000 hits.
        :param typed_keys: Specify whether aggregation and suggester names should be
            prefixed by their respective types in the response
        :param version: If true, returns document version as part of a hit.
        :param wait_for_completion_timeout: Blocks and waits until the search is completed
            up to a certain timeout. When the async search completes within the timeout,
            the response won’t include the ID as the results are not stored in the cluster.
        /z/_async_searchN:c                 s   s    | ]}t |tV  qd S )N)
isinstancestr.0Z_xr    r    r!   	<genexpr>  s    z+AsyncSearchClient.submit.<locals>.<genexpr>c                 s   s    | ]}d |v V  qdS )rn   Nr    rq   r    r    r!   rs     s    r`   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r	   r?   r@   rA   rB   r
   r1   rC   r   rD   rE   rF   r$   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   r   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r.   r/   r0   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   rk   r%   rl   r&   r   r   zcontent-typePOST)r   r   body)	r   r   ro   rp   listtupleallanyr   )Kr   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r	   r?   r@   rA   rB   r
   r-   rC   r   rD   rE   rF   r$   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   r   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   r*   r+   r,   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   rk   r%   rl   r&   r   Z_AsyncSearchClient__bodyr   r   r    r    r!   submit   sH   o














































zAsyncSearchClient.submit)__name__
__module____qualname__r   rp   tOptionalboolUnionSequencer   Anyr"   r(   r)   Mappingintfloatrz   r    r    r    r!   r      sr   "	
;"	
 !"#$%*()*+,-./012345*89:;<=@CDEFLMNOPQRSVWXYZ[\]^ar   )typingr~   Zelastic_transportr   _baser   utilsr   r   r   r   r    r    r    r!   <module>   s
   