Skip to content

Commit b6c4719

Browse files
committed
#819 Add unit tests for multi rescore query
1 parent 86b19f4 commit b6c4719

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

test/lib/Elastica/Test/Query/RescoreTest.php

+53
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,59 @@ public function testSetWeights()
141141
$this->assertEquals($expected, $data);
142142
}
143143

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+
144197
public function testQuery()
145198
{
146199
$query = new Query();

0 commit comments

Comments
 (0)