Skip to content
Snippets Groups Projects
Commit 94d42cb3 authored by Ron Rademaker's avatar Ron Rademaker
Browse files

Added query objects for match_phrase and match_phrase_prefix

parent 3d673e8b
No related branches found
No related tags found
No related merge requests found
<?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';
}
}
<?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';
}
}
<?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());
}
}
<?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());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment