diff --git a/src/Query/MatchPhrasePrefixQuery.php b/src/Query/MatchPhrasePrefixQuery.php new file mode 100644 index 0000000000000000000000000000000000000000..a215d440967fc4960509334ae6b687a51506fe7d --- /dev/null +++ b/src/Query/MatchPhrasePrefixQuery.php @@ -0,0 +1,29 @@ +<?php + +/* + * This file is part of the ONGR package. + * + * (c) NFQ Technologies UAB <info@nfq.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace ONGR\ElasticsearchDSL\Query; + +/** + * Represents Elasticsearch "match_phrase_prefix" query. + * + * @author Ron Rademaker + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html#query-dsl-match-query-phrase-prefix + */ +class MatchPhrasePrefixQuery extends MatchQuery +{ + /** + * {@inheritdoc} + */ + public function getType() + { + return 'match_phrase_prefix'; + } +} diff --git a/src/Query/MatchPhraseQuery.php b/src/Query/MatchPhraseQuery.php new file mode 100644 index 0000000000000000000000000000000000000000..6ac5d7ac9b504b80bc97d855e96c1bacddf0082e --- /dev/null +++ b/src/Query/MatchPhraseQuery.php @@ -0,0 +1,29 @@ +<?php + +/* + * This file is part of the ONGR package. + * + * (c) NFQ Technologies UAB <info@nfq.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace ONGR\ElasticsearchDSL\Query; + +/** + * Represents Elasticsearch "match_phrase" query. + * + * @author Ron Rademaker + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html#query-dsl-match-query-phrase + */ +class MatchPhraseQuery extends MatchQuery +{ + /** + * {@inheritdoc} + */ + public function getType() + { + return 'match_phrase'; + } +} diff --git a/tests/Query/MatchPhrasePrefixQueryTest.php b/tests/Query/MatchPhrasePrefixQueryTest.php new file mode 100644 index 0000000000000000000000000000000000000000..ea5c202ae6f487f18d4e7882bae6f9989f9b6f6c --- /dev/null +++ b/tests/Query/MatchPhrasePrefixQueryTest.php @@ -0,0 +1,35 @@ +<?php + +/* + * This file is part of the ONGR package. + * + * (c) NFQ Technologies UAB <info@nfq.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace ONGR\ElasticsearchDSL\Tests\Query; + +use ONGR\ElasticsearchDSL\Query\MatchPhrasePrefixQuery; +use PHPUnit_Framework_TestCase; + +class MatchPhrasePrefixQueryTest extends PHPUnit_Framework_TestCase +{ + /** + * Tests toArray(). + */ + public function testToArray() + { + $query = new MatchPhrasePrefixQuery('message', 'this is a test'); + $expected = [ + 'match_phrase_prefix' => [ + 'message' => [ + 'query' => 'this is a test', + ], + ], + ]; + + $this->assertEquals($expected, $query->toArray()); + } +} diff --git a/tests/Query/MatchPhraseQueryTest.php b/tests/Query/MatchPhraseQueryTest.php new file mode 100644 index 0000000000000000000000000000000000000000..74cf40b48431b53c6621807ea4bba62c0794d190 --- /dev/null +++ b/tests/Query/MatchPhraseQueryTest.php @@ -0,0 +1,35 @@ +<?php + +/* + * This file is part of the ONGR package. + * + * (c) NFQ Technologies UAB <info@nfq.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace ONGR\ElasticsearchDSL\Tests\Query; + +use ONGR\ElasticsearchDSL\Query\MatchPhraseQuery; +use PHPUnit_Framework_TestCase; + +class MatchPhraseQueryTest extends PHPUnit_Framework_TestCase +{ + /** + * Tests toArray(). + */ + public function testToArray() + { + $query = new MatchPhraseQuery('message', 'this is a test'); + $expected = [ + 'match_phrase' => [ + 'message' => [ + 'query' => 'this is a test', + ], + ], + ]; + + $this->assertEquals($expected, $query->toArray()); + } +}