File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -102,27 +102,26 @@ def transform_search_query(q)
102102 # TODO: this is a rough first attempt. should verify edge cases for
103103 # query encoding and other special characters, e.g. %20
104104 return q if q == "*:*"
105+
105106 # a:[* TO *] => a*
106107 q = q . gsub ( /\[ \* [+ ]TO[+ ]\* \] / , '*' )
107108
108109 keyp = '[^ \\+()]+'
109110 lbrak = '[\[{]'
110111 rbrak = '[\]}]'
111- # a:[blah TO *] => content\001[a__=__blah\002TO\002a__=__\ufff0]
112- q = q . gsub ( /(#{ keyp } ):(#{ lbrak } )(.+)[+ ]TO[+ ]\* (#{ rbrak } )/ ) do |m |
113- "content#{ TEMP_SEP } #{ $2} #{ $1} __=__#{ $3} #{ SPC_SEP } TO#{ SPC_SEP } #{ $1} __=__\\ ufff0#{ $4} "
114- end
115-
116- # a:[* TO blah] => content\001[a__=__\002TO\002a__=__blah]
117- q = q . gsub ( /(#{ keyp } ):(#{ lbrak } )\* [+ ]TO[+ ]([^\] ]+)(#{ rbrak } )/ ) do |m |
118- "content#{ TEMP_SEP } #{ $2} #{ $1} __=__#{ SPC_SEP } TO#{ SPC_SEP } #{ $1} __=__#{ $3} #{ $4} "
119- end
120112
121113 # a:[blah TO zah] =>
122114 # content\001[a__=__blah\002TO\002a__=__zah]
123-
124- q = q . gsub ( /(#{ keyp } ):(#{ lbrak } )([^\] }]+)[+ ]TO[+ ]([^\] ]+)(#{ rbrak } )/ ) do |m |
125- "content#{ TEMP_SEP } #{ $2} #{ $1} __=__#{ $3} #{ SPC_SEP } TO#{ SPC_SEP } #{ $1} __=__#{ $4} #{ $5} "
115+ # includes the cases a:[* TO zah] and a:[blah TO *], but not
116+ # [* TO *]; that is caught above
117+ q = q . gsub ( /(#{ keyp } ):(#{ lbrak } )([^\] }]+)[+ ]TO[+ ]([^\] }]+)(#{ rbrak } )/ ) do |m |
118+ if $3 == "*"
119+ "content#{ TEMP_SEP } #{ $2} #{ $1} __=__#{ SPC_SEP } TO#{ SPC_SEP } #{ $1} __=__#{ $4} #{ $5} "
120+ elsif $4 == "*"
121+ "content#{ TEMP_SEP } #{ $2} #{ $1} __=__#{ $3} #{ SPC_SEP } TO#{ SPC_SEP } #{ $1} __=__\\ ufff0#{ $5} "
122+ else
123+ "content#{ TEMP_SEP } #{ $2} #{ $1} __=__#{ $3} #{ SPC_SEP } TO#{ SPC_SEP } #{ $1} __=__#{ $4} #{ $5} "
124+ end
126125 end
127126
128127 # foo:bar => content:foo__=__bar
Original file line number Diff line number Diff line change @@ -54,3 +54,10 @@ content:[animal__=__ape TO animal__=__zebra]
5454
5555animal:{ape TO zebra}
5656content:{animal__=__ape TO animal__=__zebra}
57+
58+ ((value:[1 TO 3] OR nested_b1_a2_a3:B1_A2_A3-c) OR value:[5 TO *])
59+ ((content:[value__=__1 TO value__=__3] OR content:nested_b1_a2_a3__=__B1_A2_A3-c) OR content:[value__=__5 TO value__=__\ufff0])
60+
61+ ((value:{1 TO 3} OR value:{1 TO 3}) OR run_list:recipe\[alpha\])
62+ ((content:{value__=__1 TO value__=__3} OR content:{value__=__1 TO value__=__3}) OR content:run_list__=__recipe\[alpha\])
63+
You can’t perform that action at this time.
0 commit comments