
    ph                     ^   S  r S&S jrS rS rS rS rS rS'S jr " S S	5      r " S
 S\5      r	 " S S\5      r
 " S S\5      r " S S\5      r " S S5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      rS  rS! rS" rS# rS$ rg%)(c                  6    U (       d  [        S5      e[        U 6 $ )zh
Indicate that the values should be matched to a tag field

### Parameters

- **t**: Tags to search for
z"At least one tag must be specified)
ValueErrorTagValue)ts    [/home/james-whalen/.local/lib/python3.13/site-packages/redis/commands/search/querystring.pytagsr      s     =>>Q<    c                     [        XX#S9$ )z(
Indicate that value is a numeric range
)inclusive_mininclusive_max)
RangeValue)abr
   r   s       r   betweenr      s     a-UUr   c                     [        X 5      $ )z
Match a numeric value
r   ns    r   equalr      s     1=r   c                     [        SU SS9$ )z
Match any value less than n
NFr   r   r   s    r   ltr      s     4%00r   c                     [        SU SS9$ )z$
Match any value less or equal to n
NTr   r   r   s    r   ler   #   s     4$//r   c                     [        U SSS9$ )z 
Match any value greater than n
NFr
   r   r   s    r   gtr   *   s     1d%00r   c                     [        U SSS9$ )z'
Match any value greater or equal to n
NTr   r   r   s    r   ger   1   s     1d$//r   c                     [        XX#5      $ )z%
Indicate that value is a geo region
)GeoValuelatlonradiusunits       r   geor&   8   s     Cf++r   c                   @    \ rS rSr\S 5       r\S 5       rS rS r	Sr
g)Value?   c                     g)z
Whether this type of value may be combined with other values
for the same field. This makes the filter potentially more efficient
F selfs    r   
combinableValue.combinable@   s     r   c                 F    [        U [        5      (       a  U $ [        U 5      $ )z<
Convert an object to a value, if it is not a value already
)
isinstancer(   ScalarValuevs    r   
make_valueValue.make_valueH   s     
 aH1~r   c                     [        5       eNNotImplementedErrorr,   s    r   	to_stringValue.to_stringQ   s    !##r   c                 "    U R                  5       $ r8   r;   r,   s    r   __str__Value.__str__T       ~~r   r+   N)__name__
__module____qualname____firstlineno__propertyr.   staticmethodr5   r;   r?   __static_attributes__r+   r   r   r(   r(   ?   s2       $ r   r(   c                   (    \ rS rSrSrSS jrS rSrg)r   X   Fc                 f    Uc  SnUc  Sn[        U5      [        U5      /U l        X0l        X@l        g )Nz-infinf)strranger
   r   )r-   r   r   r
   r   s        r   __init__RangeValue.__init__[   s6    9A9A!fc!f%
**r   c                     SR                  U R                  U R                  (       d  SOSU R                  (       d  S5      $ S5      $ )Nz[{1}{0[0]} {2}{0[1]}]( )formatrN   r
   r   r,   s    r   r;   RangeValue.to_stringd   sC    &--JJ))Cr))C
 	
 02
 	
r   )r   r
   rN   N)FFrB   rC   rD   rE   r.   rO   r;   rH   r+   r   r   r   r   X   s    J+
r   r   c                   $    \ rS rSrSrS rS rSrg)r2   l   Tc                 $    [        U5      U l        g r8   )rM   r4   )r-   r4   s     r   rO   ScalarValue.__init__o   s    Qr   c                     U R                   $ r8   r3   r,   s    r   r;   ScalarValue.to_stringr       vvr   r3   NrV   r+   r   r   r2   r2   l   s    Jr   r2   c                   $    \ rS rSrSrS rS rSrg)r   v   Fc                     Xl         g r8   r   )r-   r   s     r   rO   TagValue.__init__y   s    	r   c                 R    SSR                  S U R                   5       5      -   S-   $ )N{z | c              3   8   #    U  H  n[        U5      v   M     g 7fr8   )rM   ).0r   s     r   	<genexpr>%TagValue.to_string.<locals>.<genexpr>}   s     :	1A	s   })joinr   r,   s    r   r;   TagValue.to_string|   s%    UZZ:		:::S@@r   ra   NrV   r+   r   r   r   r   v   s    JAr   r   c                   $    \ rS rSrSS jrS rSrg)r       c                 4    Xl         X l        X0l        X@l        g r8   r#   r"   r$   r%   )r-   r#   r"   r$   r%   s        r   rO   GeoValue.__init__   s    	r   c           	      p    SU R                    SU R                   SU R                   SU R                   S3	$ )N[ ]ro   r,   s    r   r;   GeoValue.to_string   s3    488*AdhhZqQtyykCCr   r!   Nkm)rB   rC   rD   rE   rO   r;   rH   r+   r   r   r    r       s    Dr   r    c                   V    \ rS rSrS rS r\S 5       r\S 5       r	SS jr
S rS	 rS
rg)Node   c                 z   / U l         0 nUR                  5        H  u  pEUR                  U/ 5      n[        U[        [
        [        45      (       a&  UR                  [        R                  U5      5        M]  [        U[        5      (       a  UR                  U5        M  UR                  S U 5       5        M     U =R                   U Vs/ s H  n[        R                  U5      PM     sn-  sl         UR                  5        H/  u  pEU R                   R                  U R                  XE5      5        M1     gs  snf )a  
Create a node

### Parameters

- **children**: One or more sub-conditions. These can be additional
    `intersect`, `disjunct`, `union`, `optional`, or any other `Node`
    type.

    The semantics of multiple conditions are dependent on the type of
    query. For an `intersection` node, this amounts to a logical AND,
    for a `union` node, this amounts to a logical `OR`.

- **kwparams**: key-value parameters. Each key is the name of a field,
    and the value should be a field value. This can be one of the
    following:

    - Simple string (for text field matches)
    - value returned by one of the helper functions
    - list of either a string or a value


### Examples

Field `num` should be between 1 and 10
```
intersect(num=between(1, 10)
```

Name can either be `bob` or `john`

```
union(name=("bob", "john"))
```

Don't select countries in Israel, Japan, or US

```
disjunct_union(country=("il", "jp", "us"))
```
c              3   L   #    U  H  n[         R                  U5      v   M     g 7fr8   )r(   r5   )rf   subvs     r   rg    Node.__init__.<locals>.<genexpr>   s     D!$u//55!s   "$N)paramsitems
setdefaultr1   rM   intfloatappendr(   r5   extendry   to_nodejoin_fields)r-   childrenkwparamskvparamskr4   curvalsps           r   rO   Node.__init__   s    V NN$DA))!R0G!c3.//u//23Au%%q!D!DD % 	:AQ::NN$DAKKt//56 % ;s   D8c           
      b   [        U5      S:X  a#  [        SU SUS   R                  5        35      /$ US   R                  (       d0  U Vs/ s H"  n[        SU SUR                  5        35      PM$     sn$ [        SU SU R                  R                  S U 5       5       S35      nU/$ s  snf )N   @:    z:(c              3   @   #    U  H  oR                  5       v   M     g 7fr8   r>   )rf   r4   s     r   rg   #Node.join_fields.<locals>.<genexpr>   s     1NA++--   ))lenBaseNoder;   r.   JOINSTRrj   )r-   keyvalsr4   ss        r   r   Node.join_fields   s    t9>qQtAw'8'8':&;<=>>Aw!!AEFAHqQq{{}o67FFqR 1 11N1N NOqQRs
 Gs   )B,c                 F    [        U[        5      (       a  U$ [        U5      $ r8   )r1   ry   r   )clsobjs     r   r   Node.to_node   s    c4  J}r   c                     [        5       er8   r9   r,   s    r   r   Node.JOINSTR   s    !##r   Nc                     U R                  U5      nU(       a  SOSu  p#U U R                  R                  S U R                   5       5       U 3$ )N)rR   r   )rS   rS   c              3   @   #    U  H  oR                  5       v   M     g 7fr8   r>   )rf   r   s     r   rg   !Node.to_string.<locals>.<genexpr>   s     (L1r   )_should_use_parenr   rj   r   )r-   with_parenspreposts       r   r;   Node.to_string   sJ    ,,[9"-J8	t||(((L(LLMdVTTr   c                 <    Ub  U$ [        U R                  5      S:  $ )Nr   )r   r   )r-   optvals     r   r   Node._should_use_paren   s!    M4;;!##r   c                 "    U R                  5       $ r8   r>   r,   s    r   r?   Node.__str__   rA   r   )r   r8   )rB   rC   rD   rE   rO   r   classmethodr   rF   r   r;   r   r?   rH   r+   r   r   ry   ry      sE    :7x  
 $ $U
$
 r   ry   c                   2   ^  \ rS rSrU 4S jrSS jrSrU =r$ )r      c                 B   > [         TU ]  5         [        U5      U l        g r8   )superrO   rM   r   )r-   r   	__class__s     r   rO   BaseNode.__init__   s    Qr   c                     U R                   $ r8   r   )r-   r   s     r   r;   BaseNode.to_string   r]   r   r   r8   )rB   rC   rD   rE   rO   r;   rH   __classcell__r   s   @r   r   r      s     r   r   c                       \ rS rSrSrSrSrg)IntersectNode   zk
Create an intersection node. All children need to be satisfied in order for
this node to evaluate as true
rs   r+   NrB   rC   rD   rE   __doc__r   rH   r+   r   r   r   r          
 Gr   r   c                       \ rS rSrSrSrSrg)	UnionNode   zj
Create a union node. Any of the children need to be satisfied in order for
this node to evaluate as true
|r+   Nr   r+   r   r   r   r      r   r   r   c                   0   ^  \ rS rSrSrSU 4S jjrSrU =r$ )DisjunctNodei  zg
Create a disjunct node. In order for this node to be true, all of its
children must evaluate to false
c                 h   > U R                  U5      n[        TU ]	  SS9nU(       a  SU-   S-   $ SU-   $ )NFr   z(-r   -r   r   r;   r-   r   retr   s      r   r;   DisjunctNode.to_string	  A    ,,[9gE2#:##9r   r+   r8   rB   rC   rD   rE   r   r;   rH   r   r   s   @r   r   r         
 r   r   c                       \ rS rSrSrSrSrg)DistjunctUnioni  zj
This node is true if *all* of its children are false. This is equivalent to
```
disjunct(union(...))
```
r   r+   Nr   r+   r   r   r   r     s     Gr   r   c                   0   ^  \ rS rSrSrSU 4S jjrSrU =r$ )OptionalNodei  zq
Create an optional node. If this nodes evaluates to true, then the document
will be rated higher in score/rank.
c                 h   > U R                  U5      n[        TU ]	  SS9nU(       a  SU-   S-   $ SU-   $ )NFr   z(~r   ~r   r   s      r   r;   OptionalNode.to_string#  r   r   r+   r8   r   r   s   @r   r   r     r   r   r   c                      [        U 0 UD6$ r8   )r   argskwargss     r   	intersectr   ,  s    $)&))r   c                      [        U 0 UD6$ r8   )r   r   s     r   unionr   0  s    d%f%%r   c                      [        U 0 UD6$ r8   )r   r   s     r   disjunctr   4  s    (((r   c                      [        U 0 UD6$ r8   )r   r   s     r   disjunct_unionr   8  s    4*6**r   c                  4    [        U 0 UD6R                  5       $ r8   )r   r;   r   s     r   querystringr   <  s    d%f%//11r   N)TTrv   )r   r   r   r   r   r   r   r&   r(   r   r2   r   r    ry   r   r   r   r   r   r   r   r   r   r   r   r+   r   r   <module>r      s   
V1010,   2
 
(% Au ADu DZ  Z zt D  = \ = *&)+2r   