-
Notifications
You must be signed in to change notification settings - Fork 735
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add request method parameter for search and count (#1441)
- Loading branch information
1 parent
f070d3b
commit f06c105
Showing
9 changed files
with
181 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
use Elastica\Query\FunctionScore; | ||
use Elastica\Query\MatchAll; | ||
use Elastica\Query\QueryString; | ||
use Elastica\Request; | ||
use Elastica\Response; | ||
use Elastica\ResultSet; | ||
use Elastica\Script\Script; | ||
|
@@ -456,6 +457,18 @@ public function testSearchWithVersionOption() | |
$this->assertEquals(1, $hit->getParam('_version')); | ||
} | ||
|
||
/** | ||
* @group functional | ||
*/ | ||
public function testSearchGet() | ||
{ | ||
$client = $this->_getClient(); | ||
$search1 = new Search($client); | ||
|
||
$result = $search1->search([], [], 'GET'); | ||
$this->assertFalse($result->getResponse()->hasError()); | ||
} | ||
|
||
/** | ||
* @group functional | ||
*/ | ||
|
@@ -501,6 +514,51 @@ public function testCountRequest() | |
$this->assertEquals(0, $count); | ||
} | ||
|
||
/** | ||
* @group functional | ||
*/ | ||
public function testCountRequestGet() | ||
{ | ||
$client = $this->_getClient(); | ||
$search = new Search($client); | ||
|
||
$index = $client->getIndex('zero'); | ||
$index->create(['settings' => ['index' => ['number_of_shards' => 1, 'number_of_replicas' => 0]]], true); | ||
|
||
$type = $index->getType('_doc'); | ||
$type->addDocuments([ | ||
new Document(1, ['id' => 1, 'email' => '[email protected]', 'username' => 'farrelley']), | ||
new Document(2, ['id' => 1, 'email' => '[email protected]', 'username' => 'farrelley']), | ||
new Document(3, ['id' => 1, 'email' => '[email protected]', 'username' => 'farrelley']), | ||
new Document(4, ['id' => 1, 'email' => '[email protected]', 'username' => 'farrelley']), | ||
new Document(5, ['id' => 1, 'email' => '[email protected]', 'username' => 'farrelley']), | ||
new Document(6, ['id' => 1, 'email' => '[email protected]', 'username' => 'marley']), | ||
new Document(7, ['id' => 1, 'email' => '[email protected]', 'username' => 'marley']), | ||
new Document(8, ['id' => 1, 'email' => '[email protected]', 'username' => 'marley']), | ||
new Document(9, ['id' => 1, 'email' => '[email protected]', 'username' => 'marley']), | ||
new Document(10, ['id' => 1, 'email' => '[email protected]', 'username' => 'marley']), | ||
new Document(11, ['id' => 1, 'email' => '[email protected]', 'username' => 'marley']), | ||
]); | ||
$index->refresh(); | ||
|
||
$search->addIndex($index)->addType($type); | ||
|
||
$count = $search->count('farrelley', false, Request::GET); | ||
$this->assertEquals(5, $count); | ||
|
||
$count = $search->count('marley', false, Request::GET); | ||
$this->assertEquals(6, $count); | ||
|
||
$count = $search->count('', false, Request::GET); | ||
$this->assertEquals(6, $count, 'Uses previous query set'); | ||
|
||
$count = $search->count(new MatchAll(), false, Request::GET); | ||
$this->assertEquals(11, $count); | ||
|
||
$count = $search->count('bunny', false, Request::GET); | ||
$this->assertEquals(0, $count); | ||
} | ||
|
||
/** | ||
* @group functional | ||
*/ | ||
|
Oops, something went wrong.