HEX
Server: LiteSpeed
System: Linux kapuas.iixcp.rumahweb.net 5.14.0-427.42.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 14:58:02 EDT 2024 x86_64
User: mirz4654 (1666)
PHP: 8.1.33
Disabled: system,exec,escapeshellarg,escapeshellcmd,passthru,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,popen,pclose,dl,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setsid,posix_setuid,posix_setpgid,ini_alter,show_source,define_syslog_variables,symlink,syslog,openlog,openlog,closelog,ocinumcols,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dll,ftp,myshellexec,socket_bind,mail,posix_getwpuid
Upload Files
File: //lib/python3.9/site-packages/redis/commands/search/__pycache__/commands.cpython-39.pyc
a

��b؉�@sVddlZddlZddlmZmZmZddlmZddlm	Z	ddl
mZddlm
Z
mZmZdd	lmZdd
lmZddlmZddlmZd
ZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(dZ)dZ*d Z+d!Z,d"Z-d#Z.d$Z/d%Z0d&Z1d'Z2d(Z3d)Z4d*Z5d+Z6d,Z7d-Z8d.Z9d/Z:d0Z;d1Z<d2Z=d3Z>d4Z?d5Z@d6ZAGd7d8�d8�ZBGd9d:�d:eB�ZCdS);�N)�Dict�Optional�Union)�Pipeline�)�
parse_to_dict���	to_string)�AggregateRequest�AggregateResult�Cursor)�Document)�Query)�Result)�SuggestionParser�NUMERICz	FT.CREATEzFT.ALTERz	FT.SEARCHzFT.ADDz
FT.ADDHASHzFT.DROPz
FT.EXPLAINz
FT.EXPLAINCLIzFT.DELzFT.AGGREGATEz
FT.PROFILEz	FT.CURSORz
FT.SPELLCHECKz
FT.DICTADDz
FT.DICTDELzFT.DICTDUMPzFT.GETzFT.MGETz	FT.CONFIGz
FT.TAGVALSzFT.ALIASADDzFT.ALIASUPDATEzFT.ALIASDELzFT.INFOz	FT.SUGADDz	FT.SUGDELz	FT.SUGLENz	FT.SUGGETzFT.SYNUPDATEz
FT.SYNDUMP�	NOOFFSETS�NOFIELDS�NOHL�NOFREQS�
MAXTEXTFIELDS�	TEMPORARY�	STOPWORDS�SKIPINITIALSCAN�
WITHSCORES�FUZZY�WITHPAYLOADSc
@s$eZdZdZdSdd�ZdTdd�Zd	d
�ZdUdd�ZdVdd�ZdWdd�Z	dXdd�Z
dYdd�ZdZdd�Zdd�Z
dd�Zdd�Zeeeeeeeffdfd�dd �Zeeeeeeffd�d!d"�Zd[eeefeeeeeeffd#�d$d%�Zd\eeefeeeeeeffd#�d&d'�Zeeefd(�d)d*�Zd]eeefeeeeeeffd#�d+d,�Zd-d.�Zd^eeeefeeeeeeeeffd/�d0d1�Z d_d2d3�Z!d4d5�Z"d6d7�Z#d8d9�Z$d:d;�Z%d<d=�Z&d>d?�Z'd@dA�Z(dBdC�Z)dDdE�Z*dFdG�Z+dHdI�Z,dJdK�Z-d`dMdN�Z.dadOdP�Z/dQdR�Z0dS)b�SearchCommandszSearch commands.�dcCs|j||d�S)zT
        Create a new batch indexer from the client with a given chunk size
        )�
chunk_size)ZBatchIndexer)�selfr �r"�B/usr/lib/python3.9/site-packages/redis/commands/search/commands.py�
batch_indexer@szSearchCommands.batch_indexerFNcCs,t|jg}|dur||j7}|r*|�t�|durPt|t�rP|�t�|�|�|r^|�t�|rl|�t	�|rz|�t
�|	r�|�t�|
r�|�t�|dur�t|t
ttf�r�|tt|�g7}t|�dkr�|t
|�7}|�d�z |t
tjdd�|D���7}Wn t�y ||��7}Yn0|j|�S)a�
        Create the search index. The index must not already exist.

        ### Parameters:

        - **fields**: a list of TextField or NumericField objects
        - **no_term_offsets**: If true, we will not save term offsets in
        the index
        - **no_field_flags**: If true, we will not save field flags that
        allow searching in specific fields
        - **stopwords**: If not None, we create the index with this custom
        stopword list. The list can be empty
        - **max_text_fields**: If true, we will encode indexes as if there
        were more than 32 text fields which allows you to add additional
        fields (beyond 32).
        - **temporary**: Create a lightweight temporary index which will
        expire after the specified period of inactivity (in seconds). The
        internal idle timer is reset whenever the index is searched or added to.
        - **no_highlight**: If true, disabling highlighting support.
        Also implied by no_term_offsets.
        - **no_term_frequencies**: If true, we avoid saving the term frequencies
        in the index.
        - **skip_initial_scan**: If true, we do not scan and index.

        For more information see `FT.CREATE <https://redis.io/commands/ft.create>`_.
        Nr�SCHEMAcss|]}|��VqdS�N��
redis_args��.0�fr"r"r#�	<genexpr>��z.SearchCommands.create_index.<locals>.<genexpr>)�
CREATE_CMD�
index_name�args�appendr�
isinstance�intrrrrrr�list�tuple�setr�len�	itertools�chain�	TypeErrorr(�execute_command)r!�fieldsZno_term_offsetsZno_field_flagsZ	stopwordsZ
definitionZmax_text_fieldsZ	temporaryZno_highlightZno_term_frequenciesZskip_initial_scanr0r"r"r#�create_indexFs8(










 zSearchCommands.create_indexcCsXt|jddg}z |ttjdd�|D���7}WntyL||��7}Yn0|j|�S)a
        Alter the existing search index by adding new fields. The index
        must already exist.

        ### Parameters:

        - **fields**: a list of Field objects to add for the index

        For more information see `FT.ALTER <https://redis.io/commands/ft.alter>`_.
        r%ZADDcss|]}|��VqdSr&r'r)r"r"r#r,�r-z2SearchCommands.alter_schema_add.<locals>.<genexpr>)�	ALTER_CMDr/r4r8r9r:r(r;)r!r<r0r"r"r#�alter_schema_add�s zSearchCommands.alter_schema_addcCs|rdnd}|�t|j|�S)ai
        Drop the index if it exists.
        Replaced `drop_index` in RediSearch 2.0.
        Default behavior was changed to not delete the indexed documents.

        ### Parameters:

        - **delete_documents**: If `True`, all documents will be deleted.

        For more information see `FT.DROPINDEX <https://redis.io/commands/ft.dropindex>`_.
        �ZKEEPDOCS)r;�DROP_CMDr/)r!Zdelete_documentsZkeep_strr"r"r#�	dropindex�szSearchCommands.dropindex��?c
Ks�|s|	rd}t|j||g}|r(|�d�|durD|�d�|�|�|rn|�d�|r`|�d�|	rn|�d�|r~|d|g7}|�d	�|ttj|
����7}|dur�|j|�S|j|�S)
zS
        Internal add_document used for both batch and single doc indexing
        TZNOSAVEN�PAYLOAD�REPLACEZPARTIALZNOCREATE�LANGUAGEZFIELDS)�ADD_CMDr/r1r4r8r9�itemsr;)r!�doc_id�conn�nosave�score�payload�replace�partial�language�	no_creater<r0r"r"r#�
_add_document�s*







zSearchCommands._add_documentcCsHt|j||g}|r|�d�|r,|d|g7}|dur>|j|�S|j|�S)zX
        Internal add_document_hash used for both batch and single doc indexing
        rErFN)�ADDHASH_CMDr/r1r;)r!rIrJrLrPrNr0r"r"r#�_add_document_hash�s

z!SearchCommands._add_document_hashc	
Ks$|j|fd|||||||d�|	��S)a�
        Add a single document to the index.

        ### Parameters

        - **doc_id**: the id of the saved document.
        - **nosave**: if set to true, we just index the document, and don't
                      save a copy of it. This means that searches will just
                      return ids.
        - **score**: the document ranking, between 0.0 and 1.0
        - **payload**: optional inner-index payload we can save for fast
        i              access in scoring functions
        - **replace**: if True, and the document already is in the index,
        we perform an update and reindex the document
        - **partial**: if True, the fields specified will be added to the
                       existing document.
                       This has the added benefit that any fields specified
                       with `no_index`
                       will not be reindexed again. Implies `replace`
        - **language**: Specify the language used for document tokenization.
        - **no_create**: if True, the document is only updated and reindexed
                         if it already exists.
                         If the document does not exist, an error will be
                         returned. Implies `replace`
        - **fields** kwargs dictionary of the document fields to be saved
                         and/or indexed.
                     NOTE: Geo points shoule be encoded as strings of "lon,lat"
        N)rJrKrLrMrNrOrPrQ)rR)
r!rIrKrLrMrNrOrPrQr<r"r"r#�add_document�s(��
�zSearchCommands.add_documentcCs|j|d|||d�S)a�
        Add a hash document to the index.

        ### Parameters

        - **doc_id**: the document's id. This has to be an existing HASH key
                      in Redis that will hold the fields the index needs.
        - **score**:  the document ranking, between 0.0 and 1.0
        - **replace**: if True, and the document already is in the index, we
                      perform an update and reindex the document
        - **language**: Specify the language used for document tokenization.
        N)rJrLrPrN)rT)r!rIrLrPrNr"r"r#�add_document_hash#s

�z SearchCommands.add_document_hashcCs6t|j|g}|r|�d�|dur,|j|�S|j|�S)a
        Delete a document from index
        Returns 1 if the document was deleted, 0 if not

        ### Parameters

        - **delete_actual_document**: if set to True, RediSearch also delete
                                      the actual document if it is in the index
        ZDDN)�DEL_CMDr/r1r;)r!rIrJZdelete_actual_documentr0r"r"r#�delete_document4s


zSearchCommands.delete_documentcCsR|j�|�}dd�|��D�}|}z
|d=Wnty>Yn0tfd|i|��S)�.
        Load a single document by id
        cSsi|]\}}t|�t|��qSr"r	�r*�k�vr"r"r#�
<dictcomp>Lr-z0SearchCommands.load_document.<locals>.<dictcomp>�id�ZclientZhgetallrH�KeyErrorr�r!r^r<�f2r"r"r#�
load_documentGs
zSearchCommands.load_documentcGs|jt|jg|�R�S)z�
        Returns the full contents of multiple documents.

        ### Parameters

        - **ids**: the ids of the saved documents.

        )r;�MGET_CMDr/)r!Zidsr"r"r#�getVs
zSearchCommands.getcCs&|�t|j�}tt|�}tt||��S)��
        Get info an stats about the the current index, including the number of
        documents, memory consumption, etc

        For more information see `FT.INFO <https://redis.io/commands/ft.info>`_.
        �r;�INFO_CMDr/�mapr
�dict�zip�r!�res�itr"r"r#�infobs
zSearchCommands.info��query_paramscCsb|durgSg}t|�dkr^|�d�|�t|�d�|��D]\}}|�|�|�|�q@|S)Nr�paramsr)r7r1rH)r!rqr0�key�valuer"r"r#�get_params_argsns

zSearchCommands.get_params_argscCsX|jg}t|t�rt|�}t|t�s6tdt|�����||��7}||�|�7}||fS)NzBad query type )r/r2�strr�
ValueError�type�get_argsru)r!�queryrqr0r"r"r#�_mk_query_args|s

zSearchCommands._mk_query_args�rzrqcCs`|j||d�\}}t��}|jtg|�R�}t|t�r:|St||jt��|d|j|j	d�S)�
        Search the index for a given query, and return a result of documents

        ### Parameters

        - **query**: the search query. Either a text for simple queries with
                     default parameters, or a Query object for complex queries.
                     See RediSearch's documentation on query format

        For more information see `FT.SEARCH <https://redis.io/commands/ft.search>`_.
        rp�@�@�ZdurationZhas_payload�with_scores�
r{�timer;�
SEARCH_CMDr2rr�_no_content�_with_payloads�_with_scores�r!rzrqr0�strmr"r"r#�search�s
�zSearchCommands.searchcCs$|j||d�\}}|jtg|�R�S)z�Returns the execution plan for a complex query.

        For more information see `FT.EXPLAIN <https://redis.io/commands/ft.explain>`_.
        rp)r{r;�EXPLAIN_CMD)r!rzrqr0Z
query_textr"r"r#�explain�s	zSearchCommands.explain)rzcCstd��dS)Nz#EXPLAINCLI will not be implemented.)�NotImplementedError)r!rzr"r"r#�explain_cli�szSearchCommands.explain_clicCs|t|t�r(t|j�}t|jg|��}n.t|t�rLd}td|jg|��}n
t	d|��||�
|�7}|j|�}|�|||�S)�
        Issue an aggregation query.

        ### Parameters

        **query**: This can be either an `AggregateRequest`, or a `Cursor`

        An `AggregateResult` object is returned. You can access the rows from
        its `rows` property, which will always yield the rows of the result.

        For more information see `FT.AGGREGATE <https://redis.io/commands/ft.aggregate>`_.
        T�READ�	Bad query�
r2r�bool�_cursor�
AGGREGATE_CMDr/�
build_argsr
�
CURSOR_CMDrwrur;�_get_aggregate_result�r!rzrq�
has_cursor�cmd�rawr"r"r#�	aggregate�s




zSearchCommands.aggregatecCsz|r4t|t�r|d|_|}nt|d�}|d}nd}t|t�r^|jr^|d}|dd�}nd}|dd�}t|||�S)Nrrr)r2r
ZcidrZ_with_schemar)r!r�rzr�ZcursorZschemaZrowsr"r"r#r��s


z$SearchCommands._get_aggregate_result)rz�limitedrqcCs�t��}t|jdg}|r"|�d�|�d�t|t�rLd|d<||��7}n6t|t�rzd|d<||��7}||�	|�7}nt
d��|j|�}t|t�r�|�|d||j
�}n*t|d|jt��|d	|j|jd
�}|t|d�fS)a�
        Performs a search or aggregate command and collects performance
        information.

        ### Parameters

        **query**: This can be either an `AggregateRequest`, `Query` or string.
        **limited**: If set to True, removes details of reader iterator.
        **query_params**: Define one or more value parameters.
        Each parameter has a name and a value.

        r@ZLIMITEDZQUERYZ	AGGREGATErZSEARCHz5Must provide AggregateRequest object or Query object.rr~rr)r��PROFILE_CMDr/r1r2rr�rryrurwr;r�r�rr�r�r�r)r!rzr�rqr�r�rm�resultr"r"r#�profile�s0





�zSearchCommands.profilec	Cs�t|j|g}|r|�d|g�|r2|�dd|g�|rF|�dd|g�|j|�}i}|dkr`|S|D]X}t|t�r||dkr|qdt|�dkr�qd|ds�qd|dds�qddd	�|dD�||d
<qd|S)�
        Issue a spellcheck query

        ### Parameters

        **query**: search query.
        **distance***: the maximal Levenshtein distance for spelling
                       suggestions (default: 1, max: 4).
        **include**: specifies an inclusion custom dictionary.
        **exclude**: specifies an exclusion custom dictionary.

        For more information see `FT.SPELLCHECK <https://redis.io/commands/ft.spellcheck>`_.
        �DISTANCE�TERMS�INCLUDE�EXCLUDEr�rcSsg|]}|d|dd��qS�rr)rL�
suggestionr"�r*Z_itemr"r"r#�
<listcomp>Ssz-SearchCommands.spellcheck.<locals>.<listcomp>r��SPELLCHECK_CMDr/�extendr;r2r3r7�	r!rzZdistanceZincludeZexcluder�r�ZcorrectionsZ_correctionr"r"r#�
spellchecks0
�zSearchCommands.spellcheckcGst|g}|�|�|j|�S)z�Adds terms to a dictionary.

        ### Parameters

        - **name**: Dictionary name.
        - **terms**: List of items for adding to the dictionary.

        For more information see `FT.DICTADD <https://redis.io/commands/ft.dictadd>`_.
        )�DICT_ADD_CMDr�r;�r!�name�termsr�r"r"r#�dict_addYs

zSearchCommands.dict_addcGst|g}|�|�|j|�S)aDeletes terms from a dictionary.

        ### Parameters

        - **name**: Dictionary name.
        - **terms**: List of items for removing from the dictionary.

        For more information see `FT.DICTDEL <https://redis.io/commands/ft.dictdel>`_.
        )�DICT_DEL_CMDr�r;r�r"r"r#�dict_delgs

zSearchCommands.dict_delcCst|g}|j|�S)z�Dumps all terms in the given dictionary.

        ### Parameters

        - **name**: Dictionary name.

        For more information see `FT.DICTDUMP <https://redis.io/commands/ft.dictdump>`_.
        )�
DICT_DUMP_CMDr;)r!r�r�r"r"r#�	dict_dumpus	zSearchCommands.dict_dumpcCstd||g}|j|�}|dkS)�Set runtime configuration option.

        ### Parameters

        - **option**: the name of the configuration option.
        - **value**: a value for the configuration option.

        For more information see `FT.CONFIG SET <https://redis.io/commands/ft.config-set>`_.
        �SET�OK��
CONFIG_CMDr;�r!�optionrtr�r�r"r"r#�
config_set�s

zSearchCommands.config_setcCs:td|g}i}|j|�}|r6|D]}|d||d<q |S)��Get runtime configuration option value.

        ### Parameters

        - **option**: the name of the configuration option.

        For more information see `FT.CONFIG GET <https://redis.io/commands/ft.config-get>`_.
        �GETrrr��r!r�r�rmr�Zkvsr"r"r#�
config_get�s	

zSearchCommands.config_getcCs|�t|j|�S)z�
        Return a list of all possible tag values

        ### Parameters

        - **tagfield**: Tag field name

        For more information see `FT.TAGVALS <https://redis.io/commands/ft.tagvals>`_.
        )r;�TAGVALS_CMDr/)r!Ztagfieldr"r"r#�tagvals�szSearchCommands.tagvalscCs|�t||j�S)z�
        Alias a search index - will fail if alias already exists

        ### Parameters

        - **alias**: Name of the alias to create

        For more information see `FT.ALIASADD <https://redis.io/commands/ft.aliasadd>`_.
        )r;�
ALIAS_ADD_CMDr/�r!�aliasr"r"r#�aliasadd�szSearchCommands.aliasaddcCs|�t||j�S)z�
        Updates an alias - will fail if alias does not already exist

        ### Parameters

        - **alias**: Name of the alias to create

        For more information see `FT.ALIASUPDATE <https://redis.io/commands/ft.aliasupdate>`_.
        )r;�ALIAS_UPDATE_CMDr/r�r"r"r#�aliasupdate�szSearchCommands.aliasupdatecCs|�t|�S)z�
        Removes an alias to a search index

        ### Parameters

        - **alias**: Name of the alias to delete

        For more information see `FT.ALIASDEL <https://redis.io/commands/ft.aliasdel>`_.
        )r;�
ALIAS_DEL_CMDr�r"r"r#�aliasdel�s
zSearchCommands.aliasdelcOsl|jdd�}|D]N}t||j|jg}|�d�r8|�d�|jrT|�d�|�|j�|j|�q|��dS)aJ
        Add suggestion terms to the AutoCompleter engine. Each suggestion has
        a score and string.
        If kwargs["increment"] is true and the terms are already in the
        server's dictionary, we increment their scores.

        For more information see `FT.SUGADD <https://redis.io/commands/ft.sugadd/>`_.
        F�Ztransaction�	increment�INCRrD����	Zpipeline�SUGADD_COMMAND�stringrLrer1rMr;Zexecute�r!rsZsuggestions�kwargs�pipeZsugr0r"r"r#�sugadd�s



zSearchCommands.sugaddcCs|�t|�S)z�
        Return the number of entries in the AutoCompleter index.

        For more information see `FT.SUGLEN <https://redis.io/commands/ft.suglen>`_.
        )r;�SUGLEN_COMMAND)r!rsr"r"r#�suglen�szSearchCommands.suglencCs|�t||�S)z�
        Delete a string from the AutoCompleter index.
        Returns 1 if the string was found and deleted, 0 otherwise.

        For more information see `FT.SUGDEL <https://redis.io/commands/ft.sugdel>`_.
        )r;�SUGDEL_COMMAND)r!rsr�r"r"r#�sugdel�szSearchCommands.sugdel�
cCsht||d|g}|r|�t�|r*|�t�|r8|�t�|j|�}g}	|sN|	St|||�}
dd�|
D�S)�t
        Get a list of suggestions from the AutoCompleter, for a given prefix.

        Parameters:

        prefix : str
            The prefix we are searching. **Must be valid ascii or utf-8**
        fuzzy : bool
            If set to true, the prefix search is done in fuzzy mode.
            **NOTE**: Running fuzzy searches on short (<3 letters) prefixes
            can be very
            slow, and even scan the entire index.
        with_scores : bool
            If set to true, we also return the (refactored) score of
            each suggestion.
            This is normally not needed, and is NOT the original score
            inserted into the index.
        with_payloads : bool
            Return suggestion payloads
        num : int
            The maximum number of results we return. Note that we might
            return less. The algorithm trims irrelevant suggestions.

        Returns:

        list:
             A list of Suggestion objects. If with_scores was False, the
             score of all suggestions is 1.

        For more information see `FT.SUGGET <https://redis.io/commands/ft.sugget>`_.
        �MAXcSsg|]}|�qSr"r"�r*�sr"r"r#r�+r-z)SearchCommands.sugget.<locals>.<listcomp>��SUGGET_COMMANDr1rrrr;r�r!rs�prefixZfuzzyZnumr�Z
with_payloadsr0�ret�results�parserr"r"r#�sugget�s"



zSearchCommands.suggetcGs0t|j|g}|r|�dg�|�|�|j|�S)a�
        Updates a synonym group.
        The command is used to create or update a synonym group with
        additional terms.
        Only documents which were indexed after the update will be affected.

        Parameters:

        groupid :
            Synonym group id.
        skipinitial : bool
            If set to true, we do not scan and index.
        terms :
            The terms.

        For more information see `FT.SYNUPDATE <https://redis.io/commands/ft.synupdate>`_.
        r)�
SYNUPDATE_CMDr/r�r;)r!ZgroupidZskipinitialr�r�r"r"r#�	synupdate-s

zSearchCommands.synupdatecs,|�t|j���fdd�tdt��d�D�S)a
        Dumps the contents of a synonym group.

        The command is used to dump the synonyms data structure.
        Returns a list of synonym terms and their synonym group ids.

        For more information see `FT.SYNDUMP <https://redis.io/commands/ft.syndump>`_.
        csi|]}�|�|d�qS)rr")r*�i�r�r"r#r]Or-z*SearchCommands.syndump.<locals>.<dictcomp>rr)r;�SYNDUMP_CMDr/�ranger7)r!r"r�r#�syndumpEs	zSearchCommands.syndump)r)	FFNNFNFFF)F)NFrCNFFNF)NrCNF)FrCNFFNF)rCNF)NF)N)N)N)FN)NNN)Fr�FF)F)1�__name__�
__module__�__qualname__�__doc__r$r=r?rBrRrTrUrVrXrcrerorrrvr3�floatrur{rr�r�r�r�r�rr�rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r"r"r"r#r=s�
	�
G
�
+�
�
5


� �
�"�
��
���1
>



�
2
rc@s�eZdZdd�Zdeeefeeeeee	ffd�dd�Z
deeefeeeeee	ffd�dd�Zdd	d
�Zdd�Z
d
d�Zdd�Zdd�Zddd�ZdS)�AsyncSearchCommandsc�s,|�t|j�IdH}tt|�}tt||��S)rfNrgrlr"r"r#roSs
zAsyncSearchCommands.infoNr|c�sf|j||d�\}}t��}|jtg|�R�IdH}t|t�r@|St||jt��|d|j|j	d�S)r}rpNr~rr�r�r"r"r#r�_s
�zAsyncSearchCommands.searchc�s�t|t�r(t|j�}t|jg|��}n.t|t�rLd}td|jg|��}n
t	d|��||�
|�7}|j|�IdH}|�|||�S)r�Tr�r�Nr�r�r"r"r#r�~s



zAsyncSearchCommands.aggregatec	�s�t|j|g}|r|�d|g�|r2|�dd|g�|rF|�dd|g�|j|�IdH}i}|dkrf|S|D]X}t|t�r�|dkr�qjt|�dkr�qj|ds�qj|dds�qjd	d
�|dD�||d<qj|S)r�r�r�r�r�Nrr�rcSsg|]}|d|dd��qSr�r"r�r"r"r#r��sz2AsyncSearchCommands.spellcheck.<locals>.<listcomp>rr�r�r"r"r#r��s0�zAsyncSearchCommands.spellcheckc�s$td||g}|j|�IdH}|dkS)r�r�Nr�r�r�r"r"r#r��s
zAsyncSearchCommands.config_setc�s@td|g}i}|j|�IdH}|r<|D]}|d||d<q&|S)r�r�Nrrr�r�r"r"r#r��s	
zAsyncSearchCommands.config_getc�sX|j�|�IdH}dd�|��D�}|}z
|d=WntyDYn0tfd|i|��S)rYNcSsi|]\}}t|�t|��qSr"r	rZr"r"r#r]�r-z5AsyncSearchCommands.load_document.<locals>.<dictcomp>r^r_rar"r"r#rc�s
z!AsyncSearchCommands.load_documentc�sr|jdd�}|D]N}t||j|jg}|�d�r8|�d�|jrT|�d�|�|j�|j|�q|��IdHdS)aI
        Add suggestion terms to the AutoCompleter engine. Each suggestion has
        a score and string.
        If kwargs["increment"] is true and the terms are already in the
        server's dictionary, we increment their scores.

        For more information see `FT.SUGADD <https://redis.io/commands/ft.sugadd>`_.
        Fr�r�r�rDNr�r�r�r"r"r#r��s



zAsyncSearchCommands.sugaddFr�c�snt||d|g}|r|�t�|r*|�t�|r8|�t�|j|�IdH}g}	|sT|	St|||�}
dd�|
D�S)r�r�NcSsg|]}|�qSr"r"r�r"r"r#r�@r-z.AsyncSearchCommands.sugget.<locals>.<listcomp>r�r�r"r"r#r�s"


zAsyncSearchCommands.sugget)N)N)NNN)Fr�FF)r�r�r�rorrvrrr3r�r�r�r�r�r�rcr�r�r"r"r"r#r�Rs$�
�"�
�
/�r�)Dr8r��typingrrrZredis.clientrZhelpersrZ_utilr
Zaggregationrrr
Zdocumentrrzrr�rr�rrr.r>r�rGrSrAr�ZEXPLAINCLI_CMDrWr�r�r�r�r�r�r�ZGET_CMDrdr�r�r�r�r�rhr�r�r�r�r�r�rrrrrrrrrrrrr�r"r"r"r#�<module>sx