Skip to content
Snippets Groups Projects
MultiMatchQuery.php 1.03 KiB
Newer Older
ONGR Team's avatar
ONGR Team committed
<?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\ElasticsearchBundle\DSL\Query;

use ONGR\ElasticsearchBundle\DSL\BuilderInterface;

/**
 * Elasticsearch multi_match query class.
 */
class MultiMatchQuery implements BuilderInterface
{
    /**
Mantas Jonušas's avatar
Mantas Jonušas committed
     * @param array  $fields
     * @param string $query
ONGR Team's avatar
ONGR Team committed
     */
Mantas Jonušas's avatar
Mantas Jonušas committed
    public function __construct(array $fields, $query)
    {
        $this->fields = $fields;
        $this->query = $query;
    }
ONGR Team's avatar
ONGR Team committed

    /**
     * @var array
     */
    private $fields = [];

    /**
Mantas Jonušas's avatar
Mantas Jonušas committed
     * @var string
ONGR Team's avatar
ONGR Team committed
     */
Mantas Jonušas's avatar
Mantas Jonušas committed
    private $query;
ONGR Team's avatar
ONGR Team committed

    /**
     * {@inheritdoc}
     */
    public function getType()
    {
        return 'multi_match';
    }

    /**
     * {@inheritdoc}
     */
    public function toArray()
    {
        return [
            'fields' => $this->fields,
Mantas Jonušas's avatar
Mantas Jonušas committed
            'query' => $this->query,
ONGR Team's avatar
ONGR Team committed
        ];
    }
}