File tree 1 file changed +53
-0
lines changed
test/lib/Elastica/Test/Query
1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -141,6 +141,59 @@ public function testSetWeights()
141
141
$ this ->assertEquals ($ expected , $ data );
142
142
}
143
143
144
+ public function testMultipleQueries ()
145
+ {
146
+ $ query = new Query ();
147
+ $ mainQuery = new Match ();
148
+ $ mainQuery = $ mainQuery ->setFieldQuery ('test1 ' , 'foo ' );
149
+ $ secQuery1 = new Term ();
150
+ $ secQuery1 = $ secQuery1 ->setTerm ('test2 ' , 'bar ' , 1 );
151
+ $ secQuery2 = new Term ();
152
+ $ secQuery2 = $ secQuery2 ->setTerm ('test2 ' , 'tom ' , 2 );
153
+ $ queryRescore = new QueryRescore (array ($ secQuery1 , $ secQuery2 ));
154
+ $ query ->setQuery ($ mainQuery );
155
+ $ query ->setRescore ($ queryRescore );
156
+ $ data = $ query ->toArray ();
157
+
158
+ $ expected = array (
159
+ 'query ' => array (
160
+ 'match ' => array (
161
+ 'test1 ' => array (
162
+ 'query ' => 'foo ' ,
163
+ ),
164
+ ),
165
+ ),
166
+ 'rescore ' => array (
167
+ array (
168
+ 'query ' => array (
169
+ 'rescore_query ' => array (
170
+ 'term ' => array (
171
+ 'test2 ' => array (
172
+ 'value ' => 'bar ' ,
173
+ 'boost ' => 1 ,
174
+ ),
175
+ ),
176
+ ),
177
+ ),
178
+ ),
179
+ array (
180
+ 'query ' => array (
181
+ 'rescore_query ' => array (
182
+ 'term ' => array (
183
+ 'test2 ' => array (
184
+ 'value ' => 'tom ' ,
185
+ 'boost ' => 2 ,
186
+ ),
187
+ ),
188
+ ),
189
+ ),
190
+ ),
191
+ ),
192
+ );
193
+
194
+ $ this ->assertEquals ($ expected , $ data );
195
+ }
196
+
144
197
public function testQuery ()
145
198
{
146
199
$ query = new Query ();
You can’t perform that action at this time.
0 commit comments