Skip to content

Commit

Permalink
check addQuery works with array type (#1584)
Browse files Browse the repository at this point in the history
Add a test for DisMax and check addQuery works with array type
  • Loading branch information
p365labs authored and ruflin committed Dec 24, 2018
1 parent 419a508 commit c8e3163
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions test/Elastica/Query/DisMaxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,44 @@ public function testQuery()

$this->assertEquals(3, $resultSet->count());
}

/**
* @group functional
*/
public function testQueryArray()
{
$index = $this->_createIndex();
$type = $index->getType('_doc');

$type->addDocuments([
new Document(1, ['name' => 'Basel-Stadt']),
new Document(2, ['name' => 'New York']),
new Document(3, ['name' => 'Baden']),
new Document(4, ['name' => 'Baden Baden']),
]);

$index->refresh();

$queryString1 = ['query_string' => [
'query' => 'Bade*',
],
];

$queryString2 = ['query_string' => [
'query' => 'Base*',
],
];

$boost = 1.2;
$tieBreaker = 2;

$query = new DisMax();
$query->setBoost($boost);
$query->setTieBreaker($tieBreaker);
$query->addQuery($queryString1);
$query->addQuery($queryString2);
$resultSet = $type->search($query);

$this->assertEquals(3, $resultSet->count());
}
}

0 comments on commit c8e3163

Please sign in to comment.