diff options
Diffstat (limited to 'vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MatchTest.php')
-rw-r--r-- | vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MatchTest.php | 187 |
1 files changed, 0 insertions, 187 deletions
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MatchTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MatchTest.php deleted file mode 100644 index ed164663..00000000 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MatchTest.php +++ /dev/null @@ -1,187 +0,0 @@ -<?php - -namespace Elastica\Test\Query; - -use Elastica\Document; -use Elastica\Query\Match; -use Elastica\Test\Base as BaseTest; - -class MatchTest extends BaseTest -{ - public function testToArray() - { - $field = 'test'; - $testQuery = 'Nicolas Ruflin'; - $type = 'phrase'; - $operator = 'and'; - $analyzer = 'myanalyzer'; - $boost = 2.0; - $minimumShouldMatch = 2; - $fuzziness = 0.3; - $fuzzyRewrite = 'constant_score_boolean'; - $prefixLength = 3; - $maxExpansions = 12; - - $query = new Match(); - $query->setFieldQuery($field, $testQuery); - $query->setFieldType($field, $type); - $query->setFieldOperator($field, $operator); - $query->setFieldAnalyzer($field, $analyzer); - $query->setFieldBoost($field, $boost); - $query->setFieldMinimumShouldMatch($field, $minimumShouldMatch); - $query->setFieldFuzziness($field, $fuzziness); - $query->setFieldFuzzyRewrite($field, $fuzzyRewrite); - $query->setFieldPrefixLength($field, $prefixLength); - $query->setFieldMaxExpansions($field, $maxExpansions); - - $expectedArray = array( - 'match' => array( - $field => array( - 'query' => $testQuery, - 'type' => $type, - 'operator' => $operator, - 'analyzer' => $analyzer, - 'boost' => $boost, - 'minimum_should_match' => $minimumShouldMatch, - 'fuzziness' => $fuzziness, - 'fuzzy_rewrite' => $fuzzyRewrite, - 'prefix_length' => $prefixLength, - 'max_expansions' => $maxExpansions - ) - ) - ); - - $this->assertEquals($expectedArray, $query->toArray()); - } - - public function testMatch() - { - $client = $this->_getClient(); - $index = $client->getIndex('test'); - $index->create(array(), true); - $type = $index->getType('test'); - - $doc = new Document(1, array('name' => 'Basel-Stadt')); - $type->addDocument($doc); - $doc = new Document(2, array('name' => 'New York')); - $type->addDocument($doc); - $doc = new Document(3, array('name' => 'New Hampshire')); - $type->addDocument($doc); - $doc = new Document(4, array('name' => 'Basel Land')); - $type->addDocument($doc); - - $index->refresh(); - - $field = 'name'; - $operator = 'or'; - - $query = new Match(); - $query->setFieldQuery($field, 'Basel New'); - $query->setFieldOperator($field, $operator); - - $resultSet = $index->search($query); - - $this->assertEquals(4, $resultSet->count()); - } - - public function testMatchZeroTerm() - { - $client = $this->_getClient(); - $index = $client->getIndex('test'); - $index->create(array(), true); - $type = $index->getType('test'); - $doc = new Document(1, array('name' => 'Basel-Stadt')); - $type->addDocument($doc); - $doc = new Document(2, array('name' => 'New York')); - $type->addDocument($doc); - $index->refresh(); - - $query = new Match(); - $query->setFieldQuery('name', ''); - $query->setFieldZeroTermsQuery('name', Match::ZERO_TERM_ALL); - - $resultSet = $index->search($query); - - $this->assertEquals(2, $resultSet->count()); - } - - public function testMatchPhrase() - { - $client = $this->_getClient(); - $index = $client->getIndex('test'); - $index->create(array(), true); - $type = $index->getType('test'); - - $doc = new Document(1, array('name' => 'Basel-Stadt')); - $type->addDocument($doc); - $doc = new Document(2, array('name' => 'New York')); - $type->addDocument($doc); - $doc = new Document(3, array('name' => 'New Hampshire')); - $type->addDocument($doc); - $doc = new Document(4, array('name' => 'Basel Land')); - $type->addDocument($doc); - - $index->refresh(); - - $field = 'name'; - $type = 'phrase'; - - $query = new Match(); - $query->setFieldQuery($field, 'New York'); - $query->setFieldType($field, $type); - - $resultSet = $index->search($query); - - $this->assertEquals(1, $resultSet->count()); - } - - public function testMatchPhrasePrefix() - { - $client = $this->_getClient(); - $index = $client->getIndex('test'); - $index->create(array(), true); - $type = $index->getType('test'); - - $doc = new Document(1, array('name' => 'Basel-Stadt')); - $type->addDocument($doc); - $doc = new Document(2, array('name' => 'New York')); - $type->addDocument($doc); - $doc = new Document(3, array('name' => 'New Hampshire')); - $type->addDocument($doc); - $doc = new Document(4, array('name' => 'Basel Land')); - $type->addDocument($doc); - - $index->refresh(); - - $field = 'name'; - $type = 'phrase_prefix'; - - $query = new Match(); - $query->setFieldQuery($field, 'New'); - $query->setFieldType($field, $type); - - $resultSet = $index->search($query); - - $this->assertEquals(2, $resultSet->count()); - } - - - public function testMatchFuzzinessType() - { - $field = 'test'; - $query = new Match(); - - $fuzziness = "AUTO"; - $query->setFieldFuzziness($field, $fuzziness); - - $parameters = $query->getParam($field); - $this->assertEquals($fuzziness, $parameters['fuzziness']); - - - $fuzziness = 0.3; - $query->setFieldFuzziness($field, $fuzziness); - - $parameters = $query->getParam($field); - $this->assertEquals($fuzziness, $parameters['fuzziness']); - } -} |