bOZdZd&dZdZdZdZdZdZd'dZGdd ZGd d eZ Gd d eZ GddeZ GddeZ GddZ Gdde ZGdde ZGdde ZGddeZGddeZGddeZd Zd!Zd"Zd#Zd$Zy%)(c,|s tdt|S)zx 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) ValueErrorTagValue)ts C/usr/lib/python3/dist-packages/redis/commands/search/querystring.pytagsrs =>> Q<c t||||S)z0 Indicate that value is a numeric range ) inclusive_min inclusive_max) RangeValue)abr r s rbetweenrs a-} UUrct||S)z Match a numeric value rns requalrs 1a=rctd|dS)z% Match any value less than n NFr rrs rltrs 4% 00rctd|dS)z, Match any value less or equal to n NTrrrs rler#s 4$ //rct|ddS)z( Match any value greater than n NFr rrs rgtr*s 1d% 00rct|ddS)z/ Match any value greater or equal to n NTrrrs rger1s 1d$ //rct||||S)z- Indicate that value is a geo region )GeoValue)latlonradiusunits rgeor%8s Cfd ++rc8eZdZedZedZdZdZy)Valuecy)z Whether this type of value may be combined with other values for the same field. This makes the filter potentially more efficient Fselfs r combinablezValue.combinable@s rc<t|tr|St|S)zL Convert an object to a value, if it is not a value already ) isinstancer' ScalarValuevs r make_valuezValue.make_valueHs a H1~rctNNotImplementedErrorr*s r to_stringzValue.to_stringQs !##rc"|jSr4r7r*s r__str__z Value.__str__T~~rN) __name__ __module__ __qualname__propertyr, staticmethodr2r7r:r)rrr'r'?s2 $ rr'ceZdZdZddZdZy)r Fcf|d}|d}t|t|g|_||_||_y)Nz-infinf)strranger r )r+r rr r s r__init__zRangeValue.__init__[s: 9A 9A!fc!f% **rc|dj|j|jsdnd|jsdSdS)Nz[{1}{0[0]} {2}{0[1]}]()formatrEr r r*s rr7zRangeValue.to_stringdsC&-- JJ))Cr))C  02  rN)FFr<r=r>r,rFr7r)rrr r XsJ+ rr ceZdZdZdZdZy)r/Tc$t||_yr4)rDr1)r+r1s rrFzScalarValue.__init__os Qrc|jSr4r0r*s rr7zScalarValue.to_stringr vv rNrKr)rrr/r/lsJrr/ceZdZdZdZdZy)rFc||_yr4)r)r+rs rrFzTagValue.__init__ys  rcRddjd|jDzdzS)N{z | c32K|]}t|ywr4)rD).0rs r z%TagValue.to_string..}s:1A:s})joinrr*s rr7zTagValue.to_string|s%UZZ: :::S@@rNrKr)rrrrvsJArrceZdZddZy)r c<||_||_||_||_yr4)r"r!r#r$)r+r"r!r#r$s rrFzGeoValue.__init__s  rNkm)r<r=r>rFr)rrr r srr cLeZdZdZdZedZedZd dZ dZ dZ y) NodecZg|_i}|jD]\}}|j|g}t|tt t fr%|jtj|Xt|tr|j|z|jd|D|xj|Dcgc]}tj|c}z c_|jD]0\}}|jj|j||2ycc}w)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")) ``` c3FK|]}tj|ywr4)r'r2)rUsubvs rrVz Node.__init__..sD$u//5Ds!N)paramsitems setdefaultr.rDintfloatappendr'r2extendr^to_node join_fields)r+childrenkwparamskvparamskr1curvalsps rrFz Node.__init__sV NN$ EDAq))!R0G!c3./u//23Au%q!D!DD E :A Q:: NN$ 7DAq KK  t//15 6 7;s>D(c Pt|dk(r#td|d|djgS|djs-|Dcgc]!}td|d|j#c}Std|d|jj d|Dd}|gScc}w)N@:z:(c3<K|]}|jywr4r9)rUr1s rrVz#Node.join_fields..s1NA!++-1N))lenBaseNoder7r,JOINSTRrX)r+keyvalsr1ss rrjzNode.join_fieldss t9>qQtAw'8'8':&;<=> >Aw!!AEFAHqQq{{}o67F F qR 1 11N1N NOqQ Rs Gs&B#c<t|tr|St|Sr4)r.r^rz)clsobjs rriz Node.to_nodes c4 J}rctr4r5r*s rr{z Node.JOINSTRs !##rNc|j|}|rdnd\}}||jjd|jD|S)N)rHrx)rIrIc3<K|]}|jywr4r9)rUrs rrVz!Node.to_string..s(L1(Lrw)_should_use_parenr{rXrb)r+ with_parenspreposts rr7zNode.to_stringsL,,[9 "-J8 Tt||(((L (LLMdVTTrc:||St|jdkDS)Nrr)ryrb)r+optvals rrzNode._should_use_parens!  M4;;!##rc"|jSr4r9r*s rr:z Node.__str__r;rr4) r<r=r>rFrj classmethodrir?r{r7rr:r)rrr^r^sE:7x $$U $  rr^c&eZdZfdZddZxZS)rzcBt|t||_yr4)superrFrDr~)r+r~ __class__s rrFzBaseNode.__init__s Qrc|jSr4)r~)r+rs rr7zBaseNode.to_stringrOrr4)r<r=r>rFr7 __classcell__rs@rrzrzs rrzceZdZdZdZy) IntersectNodezw Create an intersection node. All children need to be satisfied in order for this node to evaluate as true  Nr<r=r>__doc__r{r)rrrr GrrceZdZdZdZy) UnionNodezv Create a union node. Any of the children need to be satisfied in order for this node to evaluate as true |Nrr)rrrrrrrc$eZdZdZdfd ZxZS) DisjunctNodezs Create a disjunct node. In order for this node to be true, all of its children must evaluate to false cd|j|}t| d}|rd|zdzSd|zS)NFrz(-rx-rrr7r+rretrs rr7zDisjunctNode.to_stringA,,[9 gE2 #:# #9 rr4r<r=r>rr7rrs@rrr rrceZdZdZdZy)DistjunctUnionz~ This node is true if *all* of its children are false. This is equivalent to ``` disjunct(union(...)) ``` rNrr)rrrrsGrrc$eZdZdZdfd ZxZS) OptionalNodez} Create an optional node. If this nodes evaluates to true, then the document will be rated higher in score/rank. cd|j|}t| d}|rd|zdzSd|zS)NFrz(~rx~rrs rr7zOptionalNode.to_string rrr4rrs@rrrrrrct|i|Sr4)rargskwargss r intersectr)s $ )& ))rct|i|Sr4)rrs runionr-s d %f %%rct|i|Sr4)rrs rdisjunctr1s  ( ((rct|i|Sr4)rrs rdisjunct_unionr5s 4 *6 **rc4t|i|jSr4)rr7rs r querystringr9s d %f % / / 11rN)TTr[)rrrrrrrr%r'r r/rr r^rzrrrrrrrrrrr)rrrs V1010,  2  (%AuAuZ Z ztD = \ = *&)+2r