From 48df0dcceb3e910617a348e8f70f0b7c7eaa7523 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Simonas=20=C5=A0erlinskas?=
 <saimaz@users.noreply.github.com>
Date: Mon, 30 Jan 2017 16:45:33 +0200
Subject: [PATCH] Removing deprecated queries (#197)

* remove deprecated queries

* move tests

* added support for 5.x elasticsearch syntax

changed script_score lang to painless

* refactored tests to support elastic 5

* update changelog

* uri parameters was moved to container, introduced 5.0 new request body parameters

* removed filter endpoint, change order for query and postfilter

* search test has too many not necessary test cases

All those tests has to be in specific query or endpoint. Also functional tests make more sense then asserting it in the SearchTest

* moving elasticsearch/elasticsearch to required dependencies
---
 CHANGELOG.md                                  |   2 +
 composer.json                                 |   6 +-
 src/Query/BoolQuery.php                       |  23 -
 src/Query/BoostingQuery.php                   |  23 -
 src/Query/CommonTermsQuery.php                |  23 -
 src/Query/Compound/FunctionScoreQuery.php     |  67 +--
 src/Query/ConstantScoreQuery.php              |  23 -
 src/Query/DisMaxQuery.php                     |  23 -
 src/Query/ExistsQuery.php                     |  23 -
 src/Query/FunctionScoreQuery.php              |  23 -
 src/Query/FuzzyQuery.php                      |  23 -
 src/Query/GeoBoundingBoxQuery.php             |  23 -
 src/Query/GeoDistanceQuery.php                |  23 -
 src/Query/GeoDistanceRangeQuery.php           |  21 -
 src/Query/GeoPolygonQuery.php                 |  23 -
 src/Query/GeoShapeQuery.php                   |  23 -
 src/Query/GeohashCellQuery.php                |  68 ---
 src/Query/HasChildQuery.php                   |  23 -
 src/Query/HasParentQuery.php                  |  23 -
 src/Query/IdsQuery.php                        |  23 -
 src/Query/IndicesQuery.php                    |  23 -
 src/Query/MatchPhrasePrefixQuery.php          |  23 -
 src/Query/MatchPhraseQuery.php                |  25 -
 src/Query/MatchQuery.php                      |  23 -
 src/Query/MoreLikeThisQuery.php               |  23 -
 src/Query/MultiMatchQuery.php                 |  23 -
 src/Query/NestedQuery.php                     |  23 -
 src/Query/PrefixQuery.php                     |  23 -
 src/Query/QueryStringQuery.php                |  23 -
 src/Query/RangeQuery.php                      |  23 -
 src/Query/RegexpQuery.php                     |  23 -
 src/Query/ScriptQuery.php                     |  23 -
 src/Query/SimpleQueryStringQuery.php          |  26 -
 src/Query/Span/SpanTermQuery.php              |   2 +-
 src/Query/TemplateQuery.php                   |  23 -
 src/Query/TermQuery.php                       |  23 -
 src/Query/TermsQuery.php                      |  23 -
 src/Query/TypeQuery.php                       |  23 -
 src/Query/WildcardQuery.php                   |  23 -
 src/Search.php                                | 491 +++++++-----------
 src/SearchEndpoint/FilterEndpoint.php         |  45 --
 src/SearchEndpoint/PostFilterEndpoint.php     |   4 +-
 src/SearchEndpoint/QueryEndpoint.php          |   4 +-
 src/SearchEndpoint/SearchEndpointFactory.php  |   1 -
 .../Query/FunctionScoreQueryTest.php          |  11 +-
 .../Bucketing/FilterAggregationTest.php       |   6 +-
 tests/Unit/InnerHit/NestedInnerHitTest.php    |   4 +-
 tests/Unit/InnerHit/ParentInnerHitTest.php    |   2 +-
 .../Query/{ => Compound}/BoolQueryTest.php    |   6 +-
 .../{ => Compound}/BoostingQueryTest.php      |   4 +-
 .../{ => Compound}/ConstantScoreQueryTest.php |   4 +-
 .../Query/{ => Compound}/DisMaxQueryTest.php  |   4 +-
 .../{ => Compound}/FunctionScoreQueryTest.php |   4 +-
 .../Query/{ => Compound}/IndicesQueryTest.php |   4 +-
 .../{ => FullText}/CommonTermsQueryTest.php   |   4 +-
 .../MatchPhrasePrefixQueryTest.php            |   4 +-
 .../{ => FullText}/MatchPhraseQueryTest.php   |   4 +-
 .../Query/{ => FullText}/MatchQueryTest.php   |   4 +-
 .../{ => FullText}/MultiMatchQueryTest.php    |   4 +-
 .../{ => FullText}/QueryStringQueryTest.php   |   4 +-
 .../SimpleQueryStringQueryTest.php            |   4 +-
 .../{ => Geo}/GeoBoundingBoxQueryTest.php     |   4 +-
 .../Query/{ => Geo}/GeoDistanceQueryTest.php  |   4 +-
 .../{ => Geo}/GeoDistanceRangeQueryTest.php   |   4 +-
 .../Query/{ => Geo}/GeoPolygonQueryTest.php   |   4 +-
 .../Query/{ => Geo}/GeoShapeQueryTest.php     |   4 +-
 tests/Unit/Query/GeohashCellQueryTest.php     |  59 ---
 .../Query/{ => Joining}/HasChildQueryTest.php |   4 +-
 .../{ => Joining}/HasParentQueryTest.php      |   4 +-
 .../Query/{ => Joining}/NestedQueryTest.php   |   6 +-
 .../MoreLikeThisQueryTest.php                 |   4 +-
 .../{ => Specialized}/ScriptQueryTest.php     |   4 +-
 .../{ => Specialized}/TemplateQueryTest.php   |   4 +-
 .../Query/{ => TermLevel}/ExistsQueryTest.php |   4 +-
 .../Query/{ => TermLevel}/FuzzyQueryTest.php  |   4 +-
 .../Query/{ => TermLevel}/IdsQueryTest.php    |   4 +-
 .../Query/{ => TermLevel}/PrefixQueryTest.php |   4 +-
 .../Query/{ => TermLevel}/RangeQueryTest.php  |   4 +-
 .../Query/{ => TermLevel}/RegexpQueryTest.php |   4 +-
 .../Query/{ => TermLevel}/TermQueryTest.php   |   4 +-
 .../Query/{ => TermLevel}/TermsQueryTest.php  |   4 +-
 .../Query/{ => TermLevel}/TypeQueryTest.php   |   4 +-
 .../{ => TermLevel}/WildcardQueryTest.php     |   4 +-
 .../SearchEndpoint/FilterEndpointTest.php     |  87 ----
 .../SearchEndpoint/PostFilterEndpointTest.php |   2 +-
 .../Unit/SearchEndpoint/QueryEndpointTest.php |   2 +-
 tests/Unit/SearchTest.php                     | 278 +---------
 87 files changed, 330 insertions(+), 1736 deletions(-)
 delete mode 100644 src/Query/BoolQuery.php
 delete mode 100644 src/Query/BoostingQuery.php
 delete mode 100644 src/Query/CommonTermsQuery.php
 delete mode 100644 src/Query/ConstantScoreQuery.php
 delete mode 100644 src/Query/DisMaxQuery.php
 delete mode 100644 src/Query/ExistsQuery.php
 delete mode 100644 src/Query/FunctionScoreQuery.php
 delete mode 100644 src/Query/FuzzyQuery.php
 delete mode 100644 src/Query/GeoBoundingBoxQuery.php
 delete mode 100644 src/Query/GeoDistanceQuery.php
 delete mode 100644 src/Query/GeoDistanceRangeQuery.php
 delete mode 100644 src/Query/GeoPolygonQuery.php
 delete mode 100644 src/Query/GeoShapeQuery.php
 delete mode 100644 src/Query/GeohashCellQuery.php
 delete mode 100644 src/Query/HasChildQuery.php
 delete mode 100644 src/Query/HasParentQuery.php
 delete mode 100644 src/Query/IdsQuery.php
 delete mode 100644 src/Query/IndicesQuery.php
 delete mode 100644 src/Query/MatchPhrasePrefixQuery.php
 delete mode 100644 src/Query/MatchPhraseQuery.php
 delete mode 100644 src/Query/MatchQuery.php
 delete mode 100644 src/Query/MoreLikeThisQuery.php
 delete mode 100644 src/Query/MultiMatchQuery.php
 delete mode 100644 src/Query/NestedQuery.php
 delete mode 100644 src/Query/PrefixQuery.php
 delete mode 100644 src/Query/QueryStringQuery.php
 delete mode 100644 src/Query/RangeQuery.php
 delete mode 100644 src/Query/RegexpQuery.php
 delete mode 100644 src/Query/ScriptQuery.php
 delete mode 100644 src/Query/SimpleQueryStringQuery.php
 delete mode 100644 src/Query/TemplateQuery.php
 delete mode 100644 src/Query/TermQuery.php
 delete mode 100644 src/Query/TermsQuery.php
 delete mode 100644 src/Query/TypeQuery.php
 delete mode 100644 src/Query/WildcardQuery.php
 delete mode 100644 src/SearchEndpoint/FilterEndpoint.php
 rename tests/Unit/Query/{ => Compound}/BoolQueryTest.php (96%)
 rename tests/Unit/Query/{ => Compound}/BoostingQueryTest.php (89%)
 rename tests/Unit/Query/{ => Compound}/ConstantScoreQueryTest.php (88%)
 rename tests/Unit/Query/{ => Compound}/DisMaxQueryTest.php (90%)
 rename tests/Unit/Query/{ => Compound}/FunctionScoreQueryTest.php (96%)
 rename tests/Unit/Query/{ => Compound}/IndicesQueryTest.php (95%)
 rename tests/Unit/Query/{ => FullText}/CommonTermsQueryTest.php (86%)
 rename tests/Unit/Query/{ => FullText}/MatchPhrasePrefixQueryTest.php (85%)
 rename tests/Unit/Query/{ => FullText}/MatchPhraseQueryTest.php (86%)
 rename tests/Unit/Query/{ => FullText}/MatchQueryTest.php (85%)
 rename tests/Unit/Query/{ => FullText}/MultiMatchQueryTest.php (85%)
 rename tests/Unit/Query/{ => FullText}/QueryStringQueryTest.php (84%)
 rename tests/Unit/Query/{ => FullText}/SimpleQueryStringQueryTest.php (85%)
 rename tests/Unit/Query/{ => Geo}/GeoBoundingBoxQueryTest.php (95%)
 rename tests/Unit/Query/{ => Geo}/GeoDistanceQueryTest.php (93%)
 rename tests/Unit/Query/{ => Geo}/GeoDistanceRangeQueryTest.php (93%)
 rename tests/Unit/Query/{ => Geo}/GeoPolygonQueryTest.php (95%)
 rename tests/Unit/Query/{ => Geo}/GeoShapeQueryTest.php (94%)
 delete mode 100644 tests/Unit/Query/GeohashCellQueryTest.php
 rename tests/Unit/Query/{ => Joining}/HasChildQueryTest.php (85%)
 rename tests/Unit/Query/{ => Joining}/HasParentQueryTest.php (85%)
 rename tests/Unit/Query/{ => Joining}/NestedQueryTest.php (90%)
 rename tests/Unit/Query/{ => Specialized}/MoreLikeThisQueryTest.php (85%)
 rename tests/Unit/Query/{ => Specialized}/ScriptQueryTest.php (92%)
 rename tests/Unit/Query/{ => Specialized}/TemplateQueryTest.php (92%)
 rename tests/Unit/Query/{ => TermLevel}/ExistsQueryTest.php (82%)
 rename tests/Unit/Query/{ => TermLevel}/FuzzyQueryTest.php (85%)
 rename tests/Unit/Query/{ => TermLevel}/IdsQueryTest.php (84%)
 rename tests/Unit/Query/{ => TermLevel}/PrefixQueryTest.php (84%)
 rename tests/Unit/Query/{ => TermLevel}/RangeQueryTest.php (85%)
 rename tests/Unit/Query/{ => TermLevel}/RegexpQueryTest.php (85%)
 rename tests/Unit/Query/{ => TermLevel}/TermQueryTest.php (83%)
 rename tests/Unit/Query/{ => TermLevel}/TermsQueryTest.php (84%)
 rename tests/Unit/Query/{ => TermLevel}/TypeQueryTest.php (83%)
 rename tests/Unit/Query/{ => TermLevel}/WildcardQueryTest.php (85%)
 delete mode 100644 tests/Unit/SearchEndpoint/FilterEndpointTest.php

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 891a1d8..eba6f0a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,8 @@ v5.0.0 (2017-x)
 ---
 - **[BC break]** Removed deprecated aggregation classes.
 - **[BC break]** Removed deprecated query classes.
+- **[BC break]** `Search::getQueryParams()` changed to `Search::getUriParams()`.
+- **[BC break]** `FilterEndpoint` was removed due deprecated filters.
 
 v2.2.1 (2017-01-26)
 ---
diff --git a/composer.json b/composer.json
index 5b51592..7fa01ad 100644
--- a/composer.json
+++ b/composer.json
@@ -13,13 +13,13 @@
     "require": {
         "php": ">=5.6",
         "symfony/serializer": "~2.7|~3.0",
-        "paragonie/random_compat": "^2.0"
+        "paragonie/random_compat": "^2.0",
+        "elasticsearch/elasticsearch": "~5.0"
     },
     "require-dev": {
         "phpunit/phpunit": "~5.6",
         "squizlabs/php_codesniffer": "~2.0",
-        "satooshi/php-coveralls": "~1.0",
-        "elasticsearch/elasticsearch": "~5.0"
+        "satooshi/php-coveralls": "~1.0"
     },
     "autoload": {
         "psr-4": {
diff --git a/src/Query/BoolQuery.php b/src/Query/BoolQuery.php
deleted file mode 100644
index ff217b9..0000000
--- a/src/Query/BoolQuery.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?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 "bool" query.
- *
- * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html
- *
- * @deprecated Use the extended class instead. This class is left only for BC compatibility.
- */
-class BoolQuery extends \ONGR\ElasticsearchDSL\Query\Compound\BoolQuery
-{
-}
diff --git a/src/Query/BoostingQuery.php b/src/Query/BoostingQuery.php
deleted file mode 100644
index c59f367..0000000
--- a/src/Query/BoostingQuery.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?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 "boosting" query.
- *
- * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-boosting-query.html
- *
- * @deprecated Use the extended class instead. This class is left only for BC compatibility.
- */
-class BoostingQuery extends \ONGR\ElasticsearchDSL\Query\Compound\BoostingQuery
-{
-}
diff --git a/src/Query/CommonTermsQuery.php b/src/Query/CommonTermsQuery.php
deleted file mode 100644
index c919c67..0000000
--- a/src/Query/CommonTermsQuery.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?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 "common" query.
- *
- * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-common-terms-query.html
- *
- * @deprecated Use the extended class instead. This class is left only for BC compatibility.
- */
-class CommonTermsQuery extends \ONGR\ElasticsearchDSL\Query\FullText\CommonTermsQuery
-{
-}
diff --git a/src/Query/Compound/FunctionScoreQuery.php b/src/Query/Compound/FunctionScoreQuery.php
index 38e01fe..1e97910 100644
--- a/src/Query/Compound/FunctionScoreQuery.php
+++ b/src/Query/Compound/FunctionScoreQuery.php
@@ -43,27 +43,6 @@ class FunctionScoreQuery implements BuilderInterface
         $this->setParameters($parameters);
     }
 
-    /**
-     * {@inheritdoc}
-     */
-    public function getType()
-    {
-        return 'function_score';
-    }
-
-    /**
-     * Modifier to apply filter to the function score function.
-     *
-     * @param array            $function
-     * @param BuilderInterface $query
-     */
-    private function applyFilter(array &$function, BuilderInterface $query = null)
-    {
-        if ($query) {
-            $function['filter'] = $query->toArray();
-        }
-    }
-
     /**
      * Creates field_value_factor function.
      *
@@ -91,6 +70,19 @@ class FunctionScoreQuery implements BuilderInterface
         return $this;
     }
 
+    /**
+     * Modifier to apply filter to the function score function.
+     *
+     * @param array            $function
+     * @param BuilderInterface $query
+     */
+    private function applyFilter(array &$function, BuilderInterface $query = null)
+    {
+        if ($query) {
+            $function['filter'] = $query->toArray();
+        }
+    }
+
     /**
      * Add decay function to function score. Weight and query are optional.
      *
@@ -168,7 +160,7 @@ class FunctionScoreQuery implements BuilderInterface
     /**
      * Adds script score function.
      *
-     * @param string           $script
+     * @param string           $inline
      * @param array            $params
      * @param array            $options
      * @param BuilderInterface $query
@@ -176,23 +168,28 @@ class FunctionScoreQuery implements BuilderInterface
      * @return $this
      */
     public function addScriptScoreFunction(
-        $script,
+        $inline,
         array $params = [],
         array $options = [],
         BuilderInterface $query = null
     ) {
         $function = [
-            'script_score' => array_merge(
-                [
-                    'script' => $script,
-                    'params' => $params,
-                ],
-                $options
-            ),
+            'script_score' => [
+                'script' =>
+                    array_filter(
+                        array_merge(
+                            [
+                                'lang' => 'painless',
+                                'inline' => $inline,
+                                'params' => $params
+                            ],
+                            $options
+                        )
+                    )
+            ],
         ];
 
         $this->applyFilter($function, $query);
-
         $this->functions[] = $function;
 
         return $this;
@@ -226,4 +223,12 @@ class FunctionScoreQuery implements BuilderInterface
 
         return [$this->getType() => $output];
     }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function getType()
+    {
+        return 'function_score';
+    }
 }
diff --git a/src/Query/ConstantScoreQuery.php b/src/Query/ConstantScoreQuery.php
deleted file mode 100644
index b0b31fd..0000000
--- a/src/Query/ConstantScoreQuery.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?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 "constant_score" query.
- *
- * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-constant-score-query.html
- *
- * @deprecated Use the extended class instead. This class is left only for BC compatibility.
- */
-class ConstantScoreQuery extends \ONGR\ElasticsearchDSL\Query\Compound\ConstantScoreQuery
-{
-}
diff --git a/src/Query/DisMaxQuery.php b/src/Query/DisMaxQuery.php
deleted file mode 100644
index 0485c64..0000000
--- a/src/Query/DisMaxQuery.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?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 "dis_max" query.
- *
- * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-dis-max-query.html
- *
- * @deprecated Use the extended class instead. This class is left only for BC compatibility.
- */
-class DisMaxQuery extends \ONGR\ElasticsearchDSL\Query\Compound\DisMaxQuery
-{
-}
diff --git a/src/Query/ExistsQuery.php b/src/Query/ExistsQuery.php
deleted file mode 100644
index 26227c6..0000000
--- a/src/Query/ExistsQuery.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?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 "exists" query.
- *
- * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-exists-query.html
- *
- * @deprecated Use the extended class instead. This class is left only for BC compatibility.
- */
-class ExistsQuery extends \ONGR\ElasticsearchDSL\Query\TermLevel\ExistsQuery
-{
-}
diff --git a/src/Query/FunctionScoreQuery.php b/src/Query/FunctionScoreQuery.php
deleted file mode 100644
index 3657e6e..0000000
--- a/src/Query/FunctionScoreQuery.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?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 "function_score" query.
- *
- * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html
- *
- * @deprecated Use the extended class instead. This class is left only for BC compatibility.
- */
-class FunctionScoreQuery extends \ONGR\ElasticsearchDSL\Query\Compound\FunctionScoreQuery
-{
-}
diff --git a/src/Query/FuzzyQuery.php b/src/Query/FuzzyQuery.php
deleted file mode 100644
index 81bf38f..0000000
--- a/src/Query/FuzzyQuery.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?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 "fuzzy" query.
- *
- * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-fuzzy-query.html
- *
- * @deprecated Use the extended class instead. This class is left only for BC compatibility.
- */
-class FuzzyQuery extends \ONGR\ElasticsearchDSL\Query\TermLevel\FuzzyQuery
-{
-}
diff --git a/src/Query/GeoBoundingBoxQuery.php b/src/Query/GeoBoundingBoxQuery.php
deleted file mode 100644
index 7e00821..0000000
--- a/src/Query/GeoBoundingBoxQuery.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?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 "geo_bounding_box" query.
- *
- * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-bounding-box-query.html
- *
- * @deprecated Use the extended class instead. This class is left only for BC compatibility.
- */
-class GeoBoundingBoxQuery extends \ONGR\ElasticsearchDSL\Query\Geo\GeoBoundingBoxQuery
-{
-}
diff --git a/src/Query/GeoDistanceQuery.php b/src/Query/GeoDistanceQuery.php
deleted file mode 100644
index eca616a..0000000
--- a/src/Query/GeoDistanceQuery.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?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 "geo_distance" query.
- *
- * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-query.html
- *
- * @deprecated Use the extended class instead. This class is left only for BC compatibility.
- */
-class GeoDistanceQuery extends \ONGR\ElasticsearchDSL\Query\Geo\GeoDistanceQuery
-{
-}
diff --git a/src/Query/GeoDistanceRangeQuery.php b/src/Query/GeoDistanceRangeQuery.php
deleted file mode 100644
index d5457ac..0000000
--- a/src/Query/GeoDistanceRangeQuery.php
+++ /dev/null
@@ -1,21 +0,0 @@
-<?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 "geo_distance_range" query.
- *
- * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-range-query.html
- */
-class GeoDistanceRangeQuery extends \ONGR\ElasticsearchDSL\Query\Geo\GeoDistanceRangeQuery
-{
-}
diff --git a/src/Query/GeoPolygonQuery.php b/src/Query/GeoPolygonQuery.php
deleted file mode 100644
index 3bc9158..0000000
--- a/src/Query/GeoPolygonQuery.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?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 "geo_polygon" query.
- *
- * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-polygon-query.html
- *
- * @deprecated Use the extended class instead. This class is left only for BC compatibility.
- */
-class GeoPolygonQuery extends \ONGR\ElasticsearchDSL\Query\Geo\GeoPolygonQuery
-{
-}
diff --git a/src/Query/GeoShapeQuery.php b/src/Query/GeoShapeQuery.php
deleted file mode 100644
index 02efa21..0000000
--- a/src/Query/GeoShapeQuery.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?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 "geo_shape" query.
- *
- * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-shape-query.html
- *
- * @deprecated Use the extended class instead. This class is left only for BC compatibility.
- */
-class GeoShapeQuery extends \ONGR\ElasticsearchDSL\Query\Geo\GeoShapeQuery
-{
-}
diff --git a/src/Query/GeohashCellQuery.php b/src/Query/GeohashCellQuery.php
deleted file mode 100644
index d792507..0000000
--- a/src/Query/GeohashCellQuery.php
+++ /dev/null
@@ -1,68 +0,0 @@
-<?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;
-
-use ONGR\ElasticsearchDSL\BuilderInterface;
-use ONGR\ElasticsearchDSL\ParametersTrait;
-
-/**
- * Represents Elasticsearch "geohash_cell" query.
- *
- * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geohash-cell-query.html
- * @deprecated Use geohash_grid aggregation instead.
- */
-class GeohashCellQuery implements BuilderInterface
-{
-    use ParametersTrait;
-
-    /**
-     * @var string
-     */
-    private $field;
-
-    /**
-     * @var mixed
-     */
-    private $location;
-
-    /**
-     * @param string $field
-     * @param mixed  $location
-     * @param array  $parameters
-     */
-    public function __construct($field, $location, array $parameters = [])
-    {
-        $this->field = $field;
-        $this->location = $location;
-
-        $this->setParameters($parameters);
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function getType()
-    {
-        return 'geohash_cell';
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function toArray()
-    {
-        $query = [$this->field => $this->location];
-        $output = $this->processArray($query);
-
-        return [$this->getType() => $output];
-    }
-}
diff --git a/src/Query/HasChildQuery.php b/src/Query/HasChildQuery.php
deleted file mode 100644
index f231cfc..0000000
--- a/src/Query/HasChildQuery.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?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 "has_child" query.
- *
- * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-has-child-query.html
- *
- * @deprecated Use the extended class instead. This class is left only for BC compatibility.
- */
-class HasChildQuery extends \ONGR\ElasticsearchDSL\Query\Joining\HasChildQuery
-{
-}
diff --git a/src/Query/HasParentQuery.php b/src/Query/HasParentQuery.php
deleted file mode 100644
index 490a43d..0000000
--- a/src/Query/HasParentQuery.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?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 "has_parent" query.
- *
- * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-has-parent-query.html
- *
- * @deprecated Use the extended class instead. This class is left only for BC compatibility.
- */
-class HasParentQuery extends \ONGR\ElasticsearchDSL\Query\Joining\HasParentQuery
-{
-}
diff --git a/src/Query/IdsQuery.php b/src/Query/IdsQuery.php
deleted file mode 100644
index bec0576..0000000
--- a/src/Query/IdsQuery.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?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 "ids" query.
- *
- * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-ids-query.html
- *
- * @deprecated Use the extended class instead. This class is left only for BC compatibility.
- */
-class IdsQuery extends \ONGR\ElasticsearchDSL\Query\TermLevel\IdsQuery
-{
-}
diff --git a/src/Query/IndicesQuery.php b/src/Query/IndicesQuery.php
deleted file mode 100644
index 8244aaf..0000000
--- a/src/Query/IndicesQuery.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?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 "indices" query.
- *
- * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-indices-query.html
- *
- * @deprecated Use the extended class instead. This class is left only for BC compatibility.
- */
-class IndicesQuery extends \ONGR\ElasticsearchDSL\Query\Compound\IndicesQuery
-{
-}
diff --git a/src/Query/MatchPhrasePrefixQuery.php b/src/Query/MatchPhrasePrefixQuery.php
deleted file mode 100644
index d6a1a5d..0000000
--- a/src/Query/MatchPhrasePrefixQuery.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?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.
- *
- * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html
- *
- * @deprecated Use the extended class instead. This class is left only for BC compatibility.
- */
-class MatchPhrasePrefixQuery extends \ONGR\ElasticsearchDSL\Query\FullText\MatchPhrasePrefixQuery
-{
-}
diff --git a/src/Query/MatchPhraseQuery.php b/src/Query/MatchPhraseQuery.php
deleted file mode 100644
index 52a1278..0000000
--- a/src/Query/MatchPhraseQuery.php
+++ /dev/null
@@ -1,25 +0,0 @@
-<?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
- *
- * @deprecated Use the extended class instead. This class is left only for BC compatibility.
- *
- */
-class MatchPhraseQuery extends \ONGR\ElasticsearchDSL\Query\FullText\MatchPhraseQuery
-{
-}
diff --git a/src/Query/MatchQuery.php b/src/Query/MatchQuery.php
deleted file mode 100644
index 98f19ab..0000000
--- a/src/Query/MatchQuery.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?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" query.
- *
- * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html
- *
- * @deprecated Use the extended class instead. This class is left only for BC compatibility.
- */
-class MatchQuery extends \ONGR\ElasticsearchDSL\Query\FullText\MatchQuery
-{
-}
diff --git a/src/Query/MoreLikeThisQuery.php b/src/Query/MoreLikeThisQuery.php
deleted file mode 100644
index 351accd..0000000
--- a/src/Query/MoreLikeThisQuery.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?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 "more_like_this" query.
- *
- * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-mlt-query.html
- *
- * @deprecated Use the extended class instead. This class is left only for BC compatibility.
- */
-class MoreLikeThisQuery extends \ONGR\ElasticsearchDSL\Query\Specialized\MoreLikeThisQuery
-{
-}
diff --git a/src/Query/MultiMatchQuery.php b/src/Query/MultiMatchQuery.php
deleted file mode 100644
index 63dcd3f..0000000
--- a/src/Query/MultiMatchQuery.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?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 "multi_match" query.
- *
- * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html
- *
- * @deprecated Use the extended class instead. This class is left only for BC compatibility.
- */
-class MultiMatchQuery extends \ONGR\ElasticsearchDSL\Query\FullText\MultiMatchQuery
-{
-}
diff --git a/src/Query/NestedQuery.php b/src/Query/NestedQuery.php
deleted file mode 100644
index 8080859..0000000
--- a/src/Query/NestedQuery.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?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 "nested" query.
- *
- * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-nested-query.html
- *
- * @deprecated Use the extended class instead. This class is left only for BC compatibility.
- */
-class NestedQuery extends \ONGR\ElasticsearchDSL\Query\Joining\NestedQuery
-{
-}
diff --git a/src/Query/PrefixQuery.php b/src/Query/PrefixQuery.php
deleted file mode 100644
index 1d1f0f1..0000000
--- a/src/Query/PrefixQuery.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?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 "prefix" query.
- *
- * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-prefix-query.html
- *
- * @deprecated Use the extended class instead. This class is left only for BC compatibility.
- */
-class PrefixQuery extends \ONGR\ElasticsearchDSL\Query\TermLevel\PrefixQuery
-{
-}
diff --git a/src/Query/QueryStringQuery.php b/src/Query/QueryStringQuery.php
deleted file mode 100644
index 3a3828e..0000000
--- a/src/Query/QueryStringQuery.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?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 "query_string" query.
- *
- * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html
- *
- * @deprecated Use the extended class instead. This class is left only for BC compatibility.
- */
-class QueryStringQuery extends \ONGR\ElasticsearchDSL\Query\FullText\QueryStringQuery
-{
-}
diff --git a/src/Query/RangeQuery.php b/src/Query/RangeQuery.php
deleted file mode 100644
index e96a830..0000000
--- a/src/Query/RangeQuery.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?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 "range" query.
- *
- * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-query.html
- *
- * @deprecated Use the extended class instead. This class is left only for BC compatibility.
- */
-class RangeQuery extends \ONGR\ElasticsearchDSL\Query\TermLevel\RangeQuery
-{
-}
diff --git a/src/Query/RegexpQuery.php b/src/Query/RegexpQuery.php
deleted file mode 100644
index 6f6a669..0000000
--- a/src/Query/RegexpQuery.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?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 "regexp" query.
- *
- * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-regexp-query.html
- *
- * @deprecated Use the extended class instead. This class is left only for BC compatibility.
- */
-class RegexpQuery extends \ONGR\ElasticsearchDSL\Query\TermLevel\RegexpQuery
-{
-}
diff --git a/src/Query/ScriptQuery.php b/src/Query/ScriptQuery.php
deleted file mode 100644
index 42d82f7..0000000
--- a/src/Query/ScriptQuery.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?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 "script" query.
- *
- * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-script-query.html
- *
- * @deprecated Use the extended class instead. This class is left only for BC compatibility.
- */
-class ScriptQuery extends \ONGR\ElasticsearchDSL\Query\Specialized\ScriptQuery
-{
-}
diff --git a/src/Query/SimpleQueryStringQuery.php b/src/Query/SimpleQueryStringQuery.php
deleted file mode 100644
index 6e529f8..0000000
--- a/src/Query/SimpleQueryStringQuery.php
+++ /dev/null
@@ -1,26 +0,0 @@
-<?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;
-
-use ONGR\ElasticsearchDSL\BuilderInterface;
-use ONGR\ElasticsearchDSL\ParametersTrait;
-
-/**
- * Represents Elasticsearch "simple_query_string" query.
- *
- * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-simple-query-string-query.html
- *
- * @deprecated Use the extended class instead. This class is left only for BC compatibility.
- */
-class SimpleQueryStringQuery extends \ONGR\ElasticsearchDSL\Query\FullText\SimpleQueryStringQuery
-{
-}
diff --git a/src/Query/Span/SpanTermQuery.php b/src/Query/Span/SpanTermQuery.php
index bbb036c..acfbf51 100644
--- a/src/Query/Span/SpanTermQuery.php
+++ b/src/Query/Span/SpanTermQuery.php
@@ -11,7 +11,7 @@
 
 namespace ONGR\ElasticsearchDSL\Query\Span;
 
-use ONGR\ElasticsearchDSL\Query\TermQuery;
+use ONGR\ElasticsearchDSL\Query\TermLevel\TermQuery;
 
 /**
  * Elasticsearch span_term query class.
diff --git a/src/Query/TemplateQuery.php b/src/Query/TemplateQuery.php
deleted file mode 100644
index d90aae4..0000000
--- a/src/Query/TemplateQuery.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?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 "template" query.
- *
- * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-template-query.html
- *
- * @deprecated Use the extended class instead. This class is left only for BC compatibility.
- */
-class TemplateQuery extends \ONGR\ElasticsearchDSL\Query\Specialized\TemplateQuery
-{
-}
diff --git a/src/Query/TermQuery.php b/src/Query/TermQuery.php
deleted file mode 100644
index c2751a7..0000000
--- a/src/Query/TermQuery.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?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 "term" query.
- *
- * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html
- *
- * @deprecated Use the extended class instead. This class is left only for BC compatibility.
- */
-class TermQuery extends \ONGR\ElasticsearchDSL\Query\TermLevel\TermQuery
-{
-}
diff --git a/src/Query/TermsQuery.php b/src/Query/TermsQuery.php
deleted file mode 100644
index f72d73c..0000000
--- a/src/Query/TermsQuery.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?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 "terms" query.
- *
- * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-query.html
- *
- * @deprecated Use the extended class instead. This class is left only for BC compatibility.
- */
-class TermsQuery extends \ONGR\ElasticsearchDSL\Query\TermLevel\TermsQuery
-{
-}
diff --git a/src/Query/TypeQuery.php b/src/Query/TypeQuery.php
deleted file mode 100644
index aea3d41..0000000
--- a/src/Query/TypeQuery.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?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 "type" query.
- *
- * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-type-query.html
- *
- * @deprecated Use the extended class instead. This class is left only for BC compatibility.
- */
-class TypeQuery extends \ONGR\ElasticsearchDSL\Query\TermLevel\TypeQuery
-{
-}
diff --git a/src/Query/WildcardQuery.php b/src/Query/WildcardQuery.php
deleted file mode 100644
index 5383c1c..0000000
--- a/src/Query/WildcardQuery.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?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 "wildcard" query.
- *
- * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-wildcard-query.html
- *
- * @deprecated Use the extended class instead. This class is left only for BC compatibility.
- */
-class WildcardQuery extends \ONGR\ElasticsearchDSL\Query\TermLevel\WildcardQuery
-{
-}
diff --git a/src/Search.php b/src/Search.php
index 0be5cdd..e993c06 100644
--- a/src/Search.php
+++ b/src/Search.php
@@ -14,10 +14,9 @@ namespace ONGR\ElasticsearchDSL;
 use ONGR\ElasticsearchDSL\Aggregation\AbstractAggregation;
 use ONGR\ElasticsearchDSL\Highlight\Highlight;
 use ONGR\ElasticsearchDSL\InnerHit\NestedInnerHit;
-use ONGR\ElasticsearchDSL\Query\BoolQuery;
+use ONGR\ElasticsearchDSL\Query\Compound\BoolQuery;
 use ONGR\ElasticsearchDSL\SearchEndpoint\AbstractSearchEndpoint;
 use ONGR\ElasticsearchDSL\SearchEndpoint\AggregationsEndpoint;
-use ONGR\ElasticsearchDSL\SearchEndpoint\FilterEndpoint;
 use ONGR\ElasticsearchDSL\SearchEndpoint\HighlightEndpoint;
 use ONGR\ElasticsearchDSL\SearchEndpoint\InnerHitsEndpoint;
 use ONGR\ElasticsearchDSL\SearchEndpoint\PostFilterEndpoint;
@@ -36,74 +35,122 @@ use ONGR\ElasticsearchDSL\SearchEndpoint\SuggestEndpoint;
 class Search
 {
     /**
-     * @var int
-     */
-    private $size;
-
-    /**
+     * To retrieve hits from a certain offset. Defaults to 0.
+     *
      * @var int
      */
     private $from;
 
     /**
-     * @var string
-     */
-    private $timeout;
-
-    /**
+     * The number of hits to return. Defaults to 10. If you do not care about getting some
+     * hits back but only about the number of matches and/or aggregations, setting the value
+     * to 0 will help performance.
+     *
      * @var int
      */
-    private $terminateAfter;
-
-    /**
-     * @var string|null
-     */
-    private $scroll;
+    private $size;
 
     /**
-     * @var array|bool|string
+     * Allows to control how the _source field is returned with every hit. By default
+     * operations return the contents of the _source field unless you have used the
+     * stored_fields parameter or if the _source field is disabled.
+     *
+     * @var bool
      */
     private $source;
 
     /**
+     * Allows to selectively load specific stored fields for each document represented by a search hit.
+     *
      * @var array
      */
     private $storedFields;
 
     /**
+     * Allows to return a script evaluation (based on different fields) for each hit.
+     * Script fields can work on fields that are not stored, and allow to return custom
+     * values to be returned (the evaluated value of the script). Script fields can
+     * also access the actual _source document indexed and extract specific elements
+     * to be returned from it (can be an "object" type).
+     *
      * @var array
      */
     private $scriptFields;
 
     /**
-     * @var string
+     * Allows to return the doc value representation of a field for each hit. Doc value
+     * fields can work on fields that are not stored. Note that if the fields parameter
+     * specifies fields without docvalues it will try to load the value from the fielddata
+     * cache causing the terms for that field to be loaded to memory (cached), which will
+     * result in more memory consumption.
+     *
+     * @var array
      */
-    private $searchType;
+    private $docValueFields;
 
     /**
-     * @var string
+     * Enables explanation for each hit on how its score was computed.
+     *
+     * @var bool
      */
-    private $requestCache;
+    private $explain;
 
     /**
+     * Returns a version for each search hit.
+     *
      * @var bool
      */
-    private $explain;
+    private $version;
+
+    /**
+     * Allows to configure different boost level per index when searching across more
+     * than one indices. This is very handy when hits coming from one index matter more
+     * than hits coming from another index (think social graph where each user has an index).
+     *
+     * @var array
+     */
+    private $indicesBoost;
 
     /**
+     * Exclude documents which have a _score less than the minimum specified in min_score.
+     *
+     * @var int
+     */
+    private $minScore;
+
+    /**
+     * Pagination of results can be done by using the from and size but the cost becomes
+     * prohibitive when the deep pagination is reached. The index.max_result_window which
+     * defaults to 10,000 is a safeguard, search requests take heap memory and time
+     * proportional to from + size. The Scroll api is recommended for efficient deep
+     * scrolling but scroll contexts are costly and it is not recommended to use it for
+     * real time user requests. The search_after parameter circumvents this problem by
+     * providing a live cursor. The idea is to use the results from the previous page to
+     * help the retrieval of the next page.
+     *
      * @var array
      */
-    private $stats;
+    private $searchAfter;
 
     /**
-     * @var string[]
+     * URI parameters alongside Request body search.
+     *
+     * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-uri-request.html
+     *
+     * @var array
      */
-    private $preference;
+    private $uriParams = [];
 
     /**
-     * @var float
+     * While a search request returns a single “page” of results, the scroll API can be used to retrieve
+     * large numbers of results (or even all results) from a single search request, in much the same way
+     * as you would use a cursor on a traditional database. Scrolling is not intended for real time user
+     * requests, but rather for processing large amounts of data, e.g. in order to reindex the contents
+     * of one index into a new index with a different configuration.
+     *
+     * @var string
      */
-    private $minScore;
+    private $scroll;
 
     /**
      * @var OrderedSerializer
@@ -128,22 +175,6 @@ class Search
         );
     }
 
-    /**
-     * Returns endpoint instance.
-     *
-     * @param string $type Endpoint type.
-     *
-     * @return SearchEndpointInterface
-     */
-    private function getEndpoint($type)
-    {
-        if (!array_key_exists($type, $this->endpoints)) {
-            $this->endpoints[$type] = SearchEndpointFactory::get($type);
-        }
-
-        return $this->endpoints[$type];
-    }
-
     /**
      * Destroys search endpoint.
      *
@@ -154,19 +185,6 @@ class Search
         unset($this->endpoints[$type]);
     }
 
-    /**
-     * Sets parameters to the endpoint.
-     *
-     * @param string $endpointName
-     * @param array  $parameters
-     */
-    private function setEndpointParameters($endpointName, array $parameters)
-    {
-        /** @var AbstractSearchEndpoint $endpoint */
-        $endpoint = $this->getEndpoint($endpointName);
-        $endpoint->setParameters($parameters);
-    }
-
     /**
      * Adds query to the search.
      *
@@ -184,6 +202,22 @@ class Search
         return $this;
     }
 
+    /**
+     * Returns endpoint instance.
+     *
+     * @param string $type Endpoint type.
+     *
+     * @return SearchEndpointInterface
+     */
+    private function getEndpoint($type)
+    {
+        if (!array_key_exists($type, $this->endpoints)) {
+            $this->endpoints[$type] = SearchEndpointFactory::get($type);
+        }
+
+        return $this->endpoints[$type];
+    }
+
     /**
      * Returns queries inside BoolQuery instance.
      *
@@ -211,52 +245,16 @@ class Search
     }
 
     /**
-     * Adds a filter to the search.
-     *
-     * @param BuilderInterface $filter   Filter.
-     * @param string           $boolType Example boolType values:
-     *                                   - must
-     *                                   - must_not
-     *                                   - should.
-     * @param string           $key
-     *
-     * @return $this
-     */
-    public function addFilter(BuilderInterface $filter, $boolType = BoolQuery::MUST, $key = null)
-    {
-        // Trigger creation of QueryEndpoint as filters depends on it
-        $this->getEndpoint(QueryEndpoint::NAME);
-
-        $endpoint = $this->getEndpoint(FilterEndpoint::NAME);
-        $endpoint->addToBool($filter, $boolType, $key);
-
-        return $this;
-    }
-
-    /**
-     * Returns queries inside BoolFilter instance.
-     *
-     * @return BuilderInterface
-     */
-    public function getFilters()
-    {
-        $endpoint = $this->getEndpoint(FilterEndpoint::NAME);
-
-        return $endpoint->getBool();
-    }
-
-    /**
-     * Sets filter endpoint parameters.
-     *
-     * @param array $parameters
+     * Sets parameters to the endpoint.
      *
-     * @return $this
+     * @param string $endpointName
+     * @param array  $parameters
      */
-    public function setFilterParameters(array $parameters)
+    public function setEndpointParameters($endpointName, array $parameters)
     {
-        $this->setEndpointParameters(FilterEndpoint::NAME, $parameters);
-
-        return $this;
+        /** @var AbstractSearchEndpoint $endpoint */
+        $endpoint = $this->getEndpoint($endpointName);
+        $endpoint->setParameters($parameters);
     }
 
     /**
@@ -269,7 +267,7 @@ class Search
      *                                   - should.
      * @param string           $key
      *
-     * @return int Key of post filter.
+     * @return $this.
      */
     public function addPostFilter(BuilderInterface $filter, $boolType = BoolQuery::MUST, $key = null)
     {
@@ -383,7 +381,7 @@ class Search
      *
      * @param Highlight $highlight
      *
-     * @return int Key of highlight.
+     * @return $this.
      */
     public function addHighlight($highlight)
     {
@@ -397,7 +395,7 @@ class Search
      *
      * @return BuilderInterface
      */
-    public function getHighlight()
+    public function getHighlights()
     {
         /** @var HighlightEndpoint $highlightEndpoint */
         $highlightEndpoint = $this->getEndpoint(HighlightEndpoint::NAME);
@@ -430,194 +428,114 @@ class Search
     }
 
     /**
-     * Exclude documents which have a _score less than the minimum specified.
-     *
-     * @param float $minScore
-     *
-     * @return $this
-     */
-    public function setMinScore($minScore)
-    {
-        $this->minScore = $minScore;
-
-        return $this;
-    }
-
-    /**
-     * Returns min score value.
-     *
-     * @return float
+     * @return int
      */
-    public function getMinScore()
+    public function getFrom()
     {
-        return $this->minScore;
+        return $this->from;
     }
 
     /**
-     * Paginate reed removed lts from.
-     *
      * @param int $from
-     *
      * @return $this
      */
     public function setFrom($from)
     {
         $this->from = $from;
-
         return $this;
     }
 
     /**
-     * Sets timeout for query execution.
-     *
-     * @param string $timeout
-     *
-     * @return $this
-     */
-    public function setTimeout($timeout)
-    {
-        $this->timeout = $timeout;
-
-        return $this;
-    }
-
-    /**
-     * Sets maximum number of documents per shard.
-     *
-     * @param int $terminateAfter
-     *
-     * @return $this
-     */
-    public function setTerminateAfter($terminateAfter)
-    {
-        $this->terminateAfter = $terminateAfter;
-
-        return $this;
-    }
-
-    /**
-     * Returns results offset value.
-     *
      * @return int
      */
-    public function getFrom()
+    public function getSize()
     {
-        return $this->from;
+        return $this->size;
     }
 
     /**
-     * Set maximum number of results.
-     *
      * @param int $size
-     *
      * @return $this
      */
     public function setSize($size)
     {
         $this->size = $size;
-
         return $this;
     }
 
     /**
-     * Returns maximum number of results query can request.
-     *
-     * @return int
+     * @return bool
      */
-    public function getSize()
+    public function isSource()
     {
-        return $this->size;
+        return $this->source;
     }
 
     /**
-     * Allows to control how the _source field is returned with every hit.
-     *
-     * @param array|bool|string $source
-     *
+     * @param bool $source
      * @return $this
      */
     public function setSource($source)
     {
         $this->source = $source;
-
         return $this;
     }
 
     /**
-     * Returns source value.
-     *
-     * @return array|bool|string
+     * @return array
      */
-    public function getSource()
+    public function getStoredFields()
     {
-        return $this->source;
+        return $this->storedFields;
     }
 
     /**
-     * Allows to selectively load specific stored fields for each document represented by a search hit.
-     *
      * @param array $storedFields
-     *
      * @return $this
      */
-    public function setStoredFields(array $storedFields)
+    public function setStoredFields($storedFields)
     {
         $this->storedFields = $storedFields;
-
         return $this;
     }
 
     /**
-     * Returns field value.
-     *
      * @return array
      */
-    public function getStoredFields()
+    public function getScriptFields()
     {
-        return $this->storedFields;
+        return $this->scriptFields;
     }
 
     /**
-     * Allows to return a script evaluation (based on different fields) for each hit.
-     *
      * @param array $scriptFields
-     *
      * @return $this
      */
     public function setScriptFields($scriptFields)
     {
         $this->scriptFields = $scriptFields;
-
         return $this;
     }
 
     /**
-     * Returns containing script fields.
-     *
      * @return array
      */
-    public function getScriptFields()
+    public function getDocValueFields()
     {
-        return $this->scriptFields;
+        return $this->docValueFields;
     }
 
     /**
-     * Sets explain property in request body search.
-     *
-     * @param bool $explain
-     *
+     * @param array $docValueFields
      * @return $this
      */
-    public function setExplain($explain)
+    public function setDocValueFields($docValueFields)
     {
-        $this->explain = $explain;
-
+        $this->docValueFields = $docValueFields;
         return $this;
     }
 
     /**
-     * Returns if explain property is set in request body search.
-     *
      * @return bool
      */
     public function isExplain()
@@ -626,140 +544,137 @@ class Search
     }
 
     /**
-     * Sets a stats group.
-     *
-     * @param array $stats
-     *
+     * @param bool $explain
      * @return $this
      */
-    public function setStats($stats)
+    public function setExplain($explain)
     {
-        $this->stats = $stats;
+        $this->explain = $explain;
+        return $this;
+    }
 
+    /**
+     * @return bool
+     */
+    public function isVersion()
+    {
+        return $this->version;
+    }
+
+    /**
+     * @param bool $version
+     * @return $this
+     */
+    public function setVersion($version)
+    {
+        $this->version = $version;
         return $this;
     }
 
     /**
-     * Returns a stats group.
-     *
      * @return array
      */
-    public function getStats()
+    public function getIndicesBoost()
     {
-        return $this->stats;
+        return $this->indicesBoost;
     }
 
     /**
-     * Setter for scroll duration, effectively setting if search is scrolled or not.
-     *
-     * @param string|null $duration
-     *
+     * @param array $indicesBoost
      * @return $this
      */
-    public function setScroll($duration = '5m')
+    public function setIndicesBoost($indicesBoost)
     {
-        $this->scroll = $duration;
-
+        $this->indicesBoost = $indicesBoost;
         return $this;
     }
 
     /**
-     * Returns scroll duration.
-     *
-     * @return string|null
+     * @return int
      */
-    public function getScroll()
+    public function getMinScore()
     {
-        return $this->scroll;
+        return $this->minScore;
     }
 
     /**
-     * Set search type.
-     *
-     * @param string $searchType
-     *
+     * @param int $minScore
      * @return $this
      */
-    public function setSearchType($searchType)
+    public function setMinScore($minScore)
     {
-        $this->searchType = $searchType;
-
+        $this->minScore = $minScore;
         return $this;
     }
 
     /**
-     * Returns search type used.
-     *
-     * @return string
+     * @return array
      */
-    public function getSearchType()
+    public function getSearchAfter()
     {
-        return $this->searchType;
+        return $this->searchAfter;
     }
 
-
     /**
-     * Set request cache.
-     *
-     * @param string $requestCache
-     *
+     * @param array $searchAfter
      * @return $this
      */
-    public function setRequestCache($requestCache)
+    public function setSearchAfter($searchAfter)
     {
-        $this->requestCache = $requestCache;
-
+        $this->searchAfter = $searchAfter;
         return $this;
     }
 
     /**
-     * Returns request cache.
-     *
      * @return string
      */
-    public function getRequestCache()
+    public function getScroll()
     {
-        return $this->requestCache;
+        return $this->scroll;
     }
 
     /**
-     * Setter for preference.
-     *
-     * Controls which shard replicas to execute the search request on.
-     *
-     * @param mixed $preferenceParams Example values:
-     *                                _primary
-     *                                _primary_first
-     *                                _local
-     *                                _only_node:xyz (xyz - node id)
-     *                                _prefer_node:xyz (xyz - node id)
-     *                                _shards:2,3 (2 and 3 specified shards)
-     *                                custom value
-     *                                string[] combination of params.
-     *
+     * @param string $scroll
      * @return $this
      */
-    public function setPreference($preferenceParams)
+    public function setScroll($scroll = '5m')
     {
-        if (is_string($preferenceParams)) {
-            $this->preference[] = $preferenceParams;
-        }
-
-        if (is_array($preferenceParams) && !empty($preferenceParams)) {
-            $this->preference = $preferenceParams;
-        }
-
+        $this->scroll = $scroll;
         return $this;
     }
 
     /**
-     * Returns preference params as string.
+     * @param string $name
+     * @param string|array|bool $value
      *
-     * @return string
+     * @return $this
      */
-    public function getPreference()
-    {
-        return $this->preference ? implode(';', $this->preference) : null;
+    public function addUriParam($name, $value)
+    {
+        if (in_array($name, [
+            'q',
+            'df',
+            'analyzer',
+            'analyze_wildcard',
+            'default_operator',
+            'lenient',
+            'explain',
+            '_source',
+            'stored_fields',
+            'sort',
+            'track_scores',
+            'timeout',
+            'terminate_after',
+            'from',
+            'size',
+            'search_type',
+        ])) {
+            $this->uriParams[$name] = $value;
+        } else {
+            throw new \InvalidArgumentException(sprintf('Parameter %s is not supported.', $value));
+        }
+
+        return $this;
     }
 
     /**
@@ -767,16 +682,9 @@ class Search
      *
      * @return array
      */
-    public function getQueryParams()
+    public function getUriParams()
     {
-        return array_filter(
-            [
-                'scroll' => $this->getScroll(),
-                'search_type' => $this->getSearchType(),
-                'request_cache' => $this->getRequestCache(),
-                'preference' => $this->getPreference(),
-            ]
-        );
+        return $this->uriParams;
     }
 
     /**
@@ -789,14 +697,15 @@ class Search
         $params = [
             'from' => 'from',
             'size' => 'size',
+            'source' => '_source',
             'storedFields' => 'stored_fields',
             'scriptFields' => 'script_fields',
+            'docValueFields' => 'docvalue_fields',
             'explain' => 'explain',
-            'stats' => 'stats',
+            'version' => 'version',
+            'indicesBoost' => 'indices_boost',
             'minScore' => 'min_score',
-            'source' => '_source',
-            'timeout' => 'timeout',
-            'terminateAfter' => 'terminate_after',
+            'searchAfter' => 'search_after',
         ];
 
         foreach ($params as $field => $param) {
diff --git a/src/SearchEndpoint/FilterEndpoint.php b/src/SearchEndpoint/FilterEndpoint.php
deleted file mode 100644
index bc2a0d4..0000000
--- a/src/SearchEndpoint/FilterEndpoint.php
+++ /dev/null
@@ -1,45 +0,0 @@
-<?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\SearchEndpoint;
-
-use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
-
-/**
- * Search filter dsl endpoint.
- */
-class FilterEndpoint extends QueryEndpoint
-{
-    /**
-     * Endpoint name
-     */
-    const NAME = 'filter';
-
-    /**
-     * {@inheritdoc}
-     */
-    public function normalize(NormalizerInterface $normalizer, $format = null, array $context = [])
-    {
-        if (!$this->getBool()) {
-            return null;
-        }
-
-        $this->addReference('filter_query', $this->getBool());
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function getOrder()
-    {
-        return 1;
-    }
-}
diff --git a/src/SearchEndpoint/PostFilterEndpoint.php b/src/SearchEndpoint/PostFilterEndpoint.php
index cacb662..6055b7e 100644
--- a/src/SearchEndpoint/PostFilterEndpoint.php
+++ b/src/SearchEndpoint/PostFilterEndpoint.php
@@ -16,7 +16,7 @@ use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
 /**
  * Search post filter dsl endpoint.
  */
-class PostFilterEndpoint extends FilterEndpoint
+class PostFilterEndpoint extends QueryEndpoint
 {
     /**
      * Endpoint name
@@ -40,6 +40,6 @@ class PostFilterEndpoint extends FilterEndpoint
      */
     public function getOrder()
     {
-        return 2;
+        return 1;
     }
 }
diff --git a/src/SearchEndpoint/QueryEndpoint.php b/src/SearchEndpoint/QueryEndpoint.php
index 41062b3..6212b05 100644
--- a/src/SearchEndpoint/QueryEndpoint.php
+++ b/src/SearchEndpoint/QueryEndpoint.php
@@ -12,7 +12,7 @@
 namespace ONGR\ElasticsearchDSL\SearchEndpoint;
 
 use ONGR\ElasticsearchDSL\BuilderInterface;
-use ONGR\ElasticsearchDSL\Query\BoolQuery;
+use ONGR\ElasticsearchDSL\Query\Compound\BoolQuery;
 use ONGR\ElasticsearchDSL\Serializer\Normalizer\OrderedNormalizerInterface;
 use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
 
@@ -80,7 +80,7 @@ class QueryEndpoint extends AbstractSearchEndpoint implements OrderedNormalizerI
      */
     public function getOrder()
     {
-        return 3;
+        return 2;
     }
 
     /**
diff --git a/src/SearchEndpoint/SearchEndpointFactory.php b/src/SearchEndpoint/SearchEndpointFactory.php
index abfcf61..17e6838 100644
--- a/src/SearchEndpoint/SearchEndpointFactory.php
+++ b/src/SearchEndpoint/SearchEndpointFactory.php
@@ -21,7 +21,6 @@ class SearchEndpointFactory
      */
     private static $endpoints = [
         'query' => 'ONGR\ElasticsearchDSL\SearchEndpoint\QueryEndpoint',
-        'filter' => 'ONGR\ElasticsearchDSL\SearchEndpoint\FilterEndpoint',
         'post_filter' => 'ONGR\ElasticsearchDSL\SearchEndpoint\PostFilterEndpoint',
         'sort' => 'ONGR\ElasticsearchDSL\SearchEndpoint\SortEndpoint',
         'highlight' => 'ONGR\ElasticsearchDSL\SearchEndpoint\HighlightEndpoint',
diff --git a/tests/Functional/Query/FunctionScoreQueryTest.php b/tests/Functional/Query/FunctionScoreQueryTest.php
index 652c17b..fb8c1da 100644
--- a/tests/Functional/Query/FunctionScoreQueryTest.php
+++ b/tests/Functional/Query/FunctionScoreQueryTest.php
@@ -11,7 +11,7 @@
 
 namespace ONGR\ElasticsearchDSL\Tests\Functional\Query;
 
-use ONGR\ElasticsearchDSL\Query\FunctionScoreQuery;
+use ONGR\ElasticsearchDSL\Query\Compound\FunctionScoreQuery;
 use ONGR\ElasticsearchDSL\Query\MatchAllQuery;
 use ONGR\ElasticsearchDSL\Search;
 use ONGR\ElasticsearchDSL\Tests\Functional\AbstractElasticsearchTestCase;
@@ -61,15 +61,12 @@ class FunctionScoreQueryTest extends AbstractElasticsearchTestCase
     {
         $fquery = new FunctionScoreQuery(new MatchAllQuery());
         $fquery->addScriptScoreFunction(
-            'price  = doc[\'price\'].value; margin = doc[\'margin\'].value;
-             if (price > target) { return price * (1 - discount); };
-             return price;',
+            'if (doc[\'price\'].value > ctx._source.target) 
+             { return doc[\'price\'].value * (1 - ctx._source.discount); }
+             return doc[\'price\'].value;',
             [
                 'target' => 20,
                 'discount' => 0.9,
-            ],
-            [
-                'lang' => 'groovy',
             ]
         );
 
diff --git a/tests/Unit/Aggregation/Bucketing/FilterAggregationTest.php b/tests/Unit/Aggregation/Bucketing/FilterAggregationTest.php
index a067b94..7b79c21 100644
--- a/tests/Unit/Aggregation/Bucketing/FilterAggregationTest.php
+++ b/tests/Unit/Aggregation/Bucketing/FilterAggregationTest.php
@@ -13,10 +13,10 @@ namespace ONGR\ElasticsearchDSL\Tests\Unit\Bucketing\Aggregation;
 
 use ONGR\ElasticsearchDSL\Aggregation\Bucketing\FilterAggregation;
 use ONGR\ElasticsearchDSL\Aggregation\Bucketing\HistogramAggregation;
-use ONGR\ElasticsearchDSL\Query\BoolQuery;
-use ONGR\ElasticsearchDSL\Query\ExistsQuery;
+use ONGR\ElasticsearchDSL\Query\Compound\BoolQuery;
+use ONGR\ElasticsearchDSL\Query\TermLevel\ExistsQuery;
 use ONGR\ElasticsearchDSL\Query\MatchAllQuery;
-use ONGR\ElasticsearchDSL\Query\TermQuery;
+use ONGR\ElasticsearchDSL\Query\TermLevel\TermQuery;
 
 class FilterAggregationTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/Unit/InnerHit/NestedInnerHitTest.php b/tests/Unit/InnerHit/NestedInnerHitTest.php
index 2d51234..1fb042c 100644
--- a/tests/Unit/InnerHit/NestedInnerHitTest.php
+++ b/tests/Unit/InnerHit/NestedInnerHitTest.php
@@ -3,8 +3,8 @@
 namespace ONGR\ElasticsearchDSL\Tests\Unit\InnerHit;
 
 use ONGR\ElasticsearchDSL\InnerHit\NestedInnerHit;
-use ONGR\ElasticsearchDSL\Query\MatchQuery;
-use ONGR\ElasticsearchDSL\Query\NestedQuery;
+use ONGR\ElasticsearchDSL\Query\FullText\MatchQuery;
+use ONGR\ElasticsearchDSL\Query\Joining\NestedQuery;
 use ONGR\ElasticsearchDSL\Search;
 
 class NestedInnerHitTest extends \PHPUnit_Framework_TestCase
diff --git a/tests/Unit/InnerHit/ParentInnerHitTest.php b/tests/Unit/InnerHit/ParentInnerHitTest.php
index 427a2a8..65c18db 100644
--- a/tests/Unit/InnerHit/ParentInnerHitTest.php
+++ b/tests/Unit/InnerHit/ParentInnerHitTest.php
@@ -3,7 +3,7 @@
 namespace ONGR\ElasticsearchDSL\Tests\Unit\InnerHit;
 
 use ONGR\ElasticsearchDSL\InnerHit\ParentInnerHit;
-use ONGR\ElasticsearchDSL\Query\TermQuery;
+use ONGR\ElasticsearchDSL\Query\TermLevel\TermQuery;
 use ONGR\ElasticsearchDSL\Search;
 
 class ParentInnerHitTest extends \PHPUnit_Framework_TestCase
diff --git a/tests/Unit/Query/BoolQueryTest.php b/tests/Unit/Query/Compound/BoolQueryTest.php
similarity index 96%
rename from tests/Unit/Query/BoolQueryTest.php
rename to tests/Unit/Query/Compound/BoolQueryTest.php
index 2d3da88..b2e3da1 100644
--- a/tests/Unit/Query/BoolQueryTest.php
+++ b/tests/Unit/Query/Compound/BoolQueryTest.php
@@ -9,11 +9,11 @@
  * file that was distributed with this source code.
  */
 
-namespace ONGR\ElasticsearchDSL\Tests\Unit\Query;
+namespace ONGR\ElasticsearchDSL\Tests\Unit\Query\Compound;
 
-use ONGR\ElasticsearchDSL\Query\BoolQuery;
+use ONGR\ElasticsearchDSL\Query\Compound\BoolQuery;
 use ONGR\ElasticsearchDSL\Query\MatchAllQuery;
-use ONGR\ElasticsearchDSL\Query\TermQuery;
+use ONGR\ElasticsearchDSL\Query\TermLevel\TermQuery;
 
 /**
  * Unit test for Bool.
diff --git a/tests/Unit/Query/BoostingQueryTest.php b/tests/Unit/Query/Compound/BoostingQueryTest.php
similarity index 89%
rename from tests/Unit/Query/BoostingQueryTest.php
rename to tests/Unit/Query/Compound/BoostingQueryTest.php
index f40fee3..08549bd 100644
--- a/tests/Unit/Query/BoostingQueryTest.php
+++ b/tests/Unit/Query/Compound/BoostingQueryTest.php
@@ -9,9 +9,9 @@
  * file that was distributed with this source code.
  */
 
-namespace ONGR\ElasticsearchDSL\Tests\Unit\Query;
+namespace ONGR\ElasticsearchDSL\Tests\Unit\Query\Compound;
 
-use ONGR\ElasticsearchDSL\Query\BoostingQuery;
+use ONGR\ElasticsearchDSL\Query\Compound\BoostingQuery;
 
 class BoostingQueryTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/Unit/Query/ConstantScoreQueryTest.php b/tests/Unit/Query/Compound/ConstantScoreQueryTest.php
similarity index 88%
rename from tests/Unit/Query/ConstantScoreQueryTest.php
rename to tests/Unit/Query/Compound/ConstantScoreQueryTest.php
index b7880e7..e5bb2e2 100644
--- a/tests/Unit/Query/ConstantScoreQueryTest.php
+++ b/tests/Unit/Query/Compound/ConstantScoreQueryTest.php
@@ -9,9 +9,9 @@
  * file that was distributed with this source code.
  */
 
-namespace ONGR\ElasticsearchDSL\Tests\Unit\Query;
+namespace ONGR\ElasticsearchDSL\Tests\Unit\Query\Compound;
 
-use ONGR\ElasticsearchDSL\Query\ConstantScoreQuery;
+use ONGR\ElasticsearchDSL\Query\Compound\ConstantScoreQuery;
 
 class ConstantScoreQueryTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/Unit/Query/DisMaxQueryTest.php b/tests/Unit/Query/Compound/DisMaxQueryTest.php
similarity index 90%
rename from tests/Unit/Query/DisMaxQueryTest.php
rename to tests/Unit/Query/Compound/DisMaxQueryTest.php
index 5b9b007..833ad0c 100644
--- a/tests/Unit/Query/DisMaxQueryTest.php
+++ b/tests/Unit/Query/Compound/DisMaxQueryTest.php
@@ -9,9 +9,9 @@
  * file that was distributed with this source code.
  */
 
-namespace ONGR\ElasticsearchDSL\Tests\Unit\Query;
+namespace ONGR\ElasticsearchDSL\Tests\Unit\Query\Compound;
 
-use ONGR\ElasticsearchDSL\Query\DisMaxQuery;
+use ONGR\ElasticsearchDSL\Query\Compound\DisMaxQuery;
 
 class DisMaxQueryTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/Unit/Query/FunctionScoreQueryTest.php b/tests/Unit/Query/Compound/FunctionScoreQueryTest.php
similarity index 96%
rename from tests/Unit/Query/FunctionScoreQueryTest.php
rename to tests/Unit/Query/Compound/FunctionScoreQueryTest.php
index 969bb32..508881b 100644
--- a/tests/Unit/Query/FunctionScoreQueryTest.php
+++ b/tests/Unit/Query/Compound/FunctionScoreQueryTest.php
@@ -9,10 +9,10 @@
  * file that was distributed with this source code.
  */
 
-namespace ONGR\ElasticsearchDSL\Tests\Unit\Query;
+namespace ONGR\ElasticsearchDSL\Tests\Unit\Query\Compound;
 
 use ONGR\ElasticsearchDSL\BuilderInterface;
-use ONGR\ElasticsearchDSL\Query\FunctionScoreQuery;
+use ONGR\ElasticsearchDSL\Query\Compound\FunctionScoreQuery;
 use ONGR\ElasticsearchDSL\Query\MatchAllQuery;
 use PHPUnit_Framework_MockObject_MockObject as MockObject;
 
diff --git a/tests/Unit/Query/IndicesQueryTest.php b/tests/Unit/Query/Compound/IndicesQueryTest.php
similarity index 95%
rename from tests/Unit/Query/IndicesQueryTest.php
rename to tests/Unit/Query/Compound/IndicesQueryTest.php
index 364e7e4..268d8a4 100644
--- a/tests/Unit/Query/IndicesQueryTest.php
+++ b/tests/Unit/Query/Compound/IndicesQueryTest.php
@@ -9,10 +9,10 @@
  * file that was distributed with this source code.
  */
 
-namespace ONGR\ElasticsearchDSL\Tests\Unit\Query;
+namespace ONGR\ElasticsearchDSL\Tests\Unit\Query\Compound;
 
 use ONGR\ElasticsearchDSL\BuilderInterface;
-use ONGR\ElasticsearchDSL\Query\IndicesQuery;
+use ONGR\ElasticsearchDSL\Query\Compound\IndicesQuery;
 
 class IndicesQueryTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/Unit/Query/CommonTermsQueryTest.php b/tests/Unit/Query/FullText/CommonTermsQueryTest.php
similarity index 86%
rename from tests/Unit/Query/CommonTermsQueryTest.php
rename to tests/Unit/Query/FullText/CommonTermsQueryTest.php
index e25dd55..4e6e476 100644
--- a/tests/Unit/Query/CommonTermsQueryTest.php
+++ b/tests/Unit/Query/FullText/CommonTermsQueryTest.php
@@ -9,9 +9,9 @@
  * file that was distributed with this source code.
  */
 
-namespace ONGR\ElasticsearchDSL\Tests\Unit\Query;
+namespace ONGR\ElasticsearchDSL\Tests\Unit\Query\FullText;
 
-use ONGR\ElasticsearchDSL\Query\CommonTermsQuery;
+use ONGR\ElasticsearchDSL\Query\FullText\CommonTermsQuery;
 
 class CommonTermsQueryTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/Unit/Query/MatchPhrasePrefixQueryTest.php b/tests/Unit/Query/FullText/MatchPhrasePrefixQueryTest.php
similarity index 85%
rename from tests/Unit/Query/MatchPhrasePrefixQueryTest.php
rename to tests/Unit/Query/FullText/MatchPhrasePrefixQueryTest.php
index 5aa55d3..32c6117 100644
--- a/tests/Unit/Query/MatchPhrasePrefixQueryTest.php
+++ b/tests/Unit/Query/FullText/MatchPhrasePrefixQueryTest.php
@@ -9,9 +9,9 @@
  * file that was distributed with this source code.
  */
 
-namespace ONGR\ElasticsearchDSL\Tests\Unit\Query;
+namespace ONGR\ElasticsearchDSL\Tests\Unit\Query\FullText;
 
-use ONGR\ElasticsearchDSL\Query\MatchPhrasePrefixQuery;
+use ONGR\ElasticsearchDSL\Query\FullText\MatchPhrasePrefixQuery;
 use PHPUnit_Framework_TestCase;
 
 class MatchPhrasePrefixQueryTest extends PHPUnit_Framework_TestCase
diff --git a/tests/Unit/Query/MatchPhraseQueryTest.php b/tests/Unit/Query/FullText/MatchPhraseQueryTest.php
similarity index 86%
rename from tests/Unit/Query/MatchPhraseQueryTest.php
rename to tests/Unit/Query/FullText/MatchPhraseQueryTest.php
index 33570c7..6614f0d 100644
--- a/tests/Unit/Query/MatchPhraseQueryTest.php
+++ b/tests/Unit/Query/FullText/MatchPhraseQueryTest.php
@@ -9,9 +9,9 @@
  * file that was distributed with this source code.
  */
 
-namespace ONGR\ElasticsearchDSL\Tests\Unit\Query;
+namespace ONGR\ElasticsearchDSL\Tests\Unit\Query\FullText;
 
-use ONGR\ElasticsearchDSL\Query\MatchPhraseQuery;
+use ONGR\ElasticsearchDSL\Query\FullText\MatchPhraseQuery;
 use PHPUnit_Framework_TestCase;
 
 class MatchPhraseQueryTest extends PHPUnit_Framework_TestCase
diff --git a/tests/Unit/Query/MatchQueryTest.php b/tests/Unit/Query/FullText/MatchQueryTest.php
similarity index 85%
rename from tests/Unit/Query/MatchQueryTest.php
rename to tests/Unit/Query/FullText/MatchQueryTest.php
index 162f26c..e186ca4 100644
--- a/tests/Unit/Query/MatchQueryTest.php
+++ b/tests/Unit/Query/FullText/MatchQueryTest.php
@@ -9,9 +9,9 @@
  * file that was distributed with this source code.
  */
 
-namespace ONGR\ElasticsearchDSL\Tests\Unit\Query;
+namespace ONGR\ElasticsearchDSL\Tests\Unit\Query\FullText;
 
-use ONGR\ElasticsearchDSL\Query\MatchQuery;
+use ONGR\ElasticsearchDSL\Query\FullText\MatchQuery;
 
 class MatchQueryTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/Unit/Query/MultiMatchQueryTest.php b/tests/Unit/Query/FullText/MultiMatchQueryTest.php
similarity index 85%
rename from tests/Unit/Query/MultiMatchQueryTest.php
rename to tests/Unit/Query/FullText/MultiMatchQueryTest.php
index 49c27b2..3ee1460 100644
--- a/tests/Unit/Query/MultiMatchQueryTest.php
+++ b/tests/Unit/Query/FullText/MultiMatchQueryTest.php
@@ -9,9 +9,9 @@
  * file that was distributed with this source code.
  */
 
-namespace ONGR\ElasticsearchDSL\Tests\Unit\Query;
+namespace ONGR\ElasticsearchDSL\Tests\Unit\Query\FullText;
 
-use ONGR\ElasticsearchDSL\Query\MultiMatchQuery;
+use ONGR\ElasticsearchDSL\Query\FullText\MultiMatchQuery;
 
 class MultiMatchQueryTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/Unit/Query/QueryStringQueryTest.php b/tests/Unit/Query/FullText/QueryStringQueryTest.php
similarity index 84%
rename from tests/Unit/Query/QueryStringQueryTest.php
rename to tests/Unit/Query/FullText/QueryStringQueryTest.php
index 864d789..1a07a25 100644
--- a/tests/Unit/Query/QueryStringQueryTest.php
+++ b/tests/Unit/Query/FullText/QueryStringQueryTest.php
@@ -9,9 +9,9 @@
  * file that was distributed with this source code.
  */
 
-namespace ONGR\ElasticsearchDSL\Tests\Unit\Query;
+namespace ONGR\ElasticsearchDSL\Tests\Unit\Query\FullText;
 
-use ONGR\ElasticsearchDSL\Query\QueryStringQuery;
+use ONGR\ElasticsearchDSL\Query\FullText\QueryStringQuery;
 
 class QueryStringQueryTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/Unit/Query/SimpleQueryStringQueryTest.php b/tests/Unit/Query/FullText/SimpleQueryStringQueryTest.php
similarity index 85%
rename from tests/Unit/Query/SimpleQueryStringQueryTest.php
rename to tests/Unit/Query/FullText/SimpleQueryStringQueryTest.php
index 55e1ffb..396bd3d 100644
--- a/tests/Unit/Query/SimpleQueryStringQueryTest.php
+++ b/tests/Unit/Query/FullText/SimpleQueryStringQueryTest.php
@@ -9,9 +9,9 @@
  * file that was distributed with this source code.
  */
 
-namespace ONGR\ElasticsearchDSL\Tests\Unit\Query;
+namespace ONGR\ElasticsearchDSL\Tests\Unit\Query\FullText;
 
-use ONGR\ElasticsearchDSL\Query\SimpleQueryStringQuery;
+use ONGR\ElasticsearchDSL\Query\FullText\SimpleQueryStringQuery;
 
 class SimpleQueryStringQueryTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/Unit/Query/GeoBoundingBoxQueryTest.php b/tests/Unit/Query/Geo/GeoBoundingBoxQueryTest.php
similarity index 95%
rename from tests/Unit/Query/GeoBoundingBoxQueryTest.php
rename to tests/Unit/Query/Geo/GeoBoundingBoxQueryTest.php
index c50cfaf..63f292b 100644
--- a/tests/Unit/Query/GeoBoundingBoxQueryTest.php
+++ b/tests/Unit/Query/Geo/GeoBoundingBoxQueryTest.php
@@ -9,9 +9,9 @@
  * file that was distributed with this source code.
  */
 
-namespace ONGR\ElasticsearchDSL\Tests\Unit\Query;
+namespace ONGR\ElasticsearchDSL\Tests\Unit\Query\Geo;
 
-use ONGR\ElasticsearchDSL\Query\GeoBoundingBoxQuery;
+use ONGR\ElasticsearchDSL\Query\Geo\GeoBoundingBoxQuery;
 
 class GeoBoundingBoxQueryTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/Unit/Query/GeoDistanceQueryTest.php b/tests/Unit/Query/Geo/GeoDistanceQueryTest.php
similarity index 93%
rename from tests/Unit/Query/GeoDistanceQueryTest.php
rename to tests/Unit/Query/Geo/GeoDistanceQueryTest.php
index c5b0412..959da13 100644
--- a/tests/Unit/Query/GeoDistanceQueryTest.php
+++ b/tests/Unit/Query/Geo/GeoDistanceQueryTest.php
@@ -9,9 +9,9 @@
  * file that was distributed with this source code.
  */
 
-namespace ONGR\ElasticsearchDSL\Tests\Unit\Query;
+namespace ONGR\ElasticsearchDSL\Tests\Unit\Query\Geo;
 
-use ONGR\ElasticsearchDSL\Query\GeoDistanceQuery;
+use ONGR\ElasticsearchDSL\Query\Geo\GeoDistanceQuery;
 
 class GeoDistanceQueryTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/Unit/Query/GeoDistanceRangeQueryTest.php b/tests/Unit/Query/Geo/GeoDistanceRangeQueryTest.php
similarity index 93%
rename from tests/Unit/Query/GeoDistanceRangeQueryTest.php
rename to tests/Unit/Query/Geo/GeoDistanceRangeQueryTest.php
index 1850266..579d1be 100644
--- a/tests/Unit/Query/GeoDistanceRangeQueryTest.php
+++ b/tests/Unit/Query/Geo/GeoDistanceRangeQueryTest.php
@@ -9,9 +9,9 @@
  * file that was distributed with this source code.
  */
 
-namespace ONGR\ElasticsearchDSL\Tests\Unit\Query;
+namespace ONGR\ElasticsearchDSL\Tests\Unit\Query\Geo;
 
-use ONGR\ElasticsearchDSL\Query\GeoDistanceRangeQuery;
+use ONGR\ElasticsearchDSL\Query\Geo\GeoDistanceRangeQuery;
 
 class GeoDistanceRangeQueryTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/Unit/Query/GeoPolygonQueryTest.php b/tests/Unit/Query/Geo/GeoPolygonQueryTest.php
similarity index 95%
rename from tests/Unit/Query/GeoPolygonQueryTest.php
rename to tests/Unit/Query/Geo/GeoPolygonQueryTest.php
index 5584bc7..e1c250c 100644
--- a/tests/Unit/Query/GeoPolygonQueryTest.php
+++ b/tests/Unit/Query/Geo/GeoPolygonQueryTest.php
@@ -9,9 +9,9 @@
  * file that was distributed with this source code.
  */
 
-namespace ONGR\ElasticsearchDSL\Tests\Unit\Query;
+namespace ONGR\ElasticsearchDSL\Tests\Unit\Query\Geo;
 
-use ONGR\ElasticsearchDSL\Query\GeoPolygonQuery;
+use ONGR\ElasticsearchDSL\Query\Geo\GeoPolygonQuery;
 
 class GeoPolygonQueryTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/Unit/Query/GeoShapeQueryTest.php b/tests/Unit/Query/Geo/GeoShapeQueryTest.php
similarity index 94%
rename from tests/Unit/Query/GeoShapeQueryTest.php
rename to tests/Unit/Query/Geo/GeoShapeQueryTest.php
index 870cd33..9771144 100644
--- a/tests/Unit/Query/GeoShapeQueryTest.php
+++ b/tests/Unit/Query/Geo/GeoShapeQueryTest.php
@@ -9,9 +9,9 @@
  * file that was distributed with this source code.
  */
 
-namespace ONGR\ElasticsearchDSL\Tests\Unit\Query;
+namespace ONGR\ElasticsearchDSL\Tests\Unit\Query\Geo;
 
-use ONGR\ElasticsearchDSL\Query\GeoShapeQuery;
+use ONGR\ElasticsearchDSL\Query\Geo\GeoShapeQuery;
 
 class GeoShapeQueryTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/Unit/Query/GeohashCellQueryTest.php b/tests/Unit/Query/GeohashCellQueryTest.php
deleted file mode 100644
index 669cdc3..0000000
--- a/tests/Unit/Query/GeohashCellQueryTest.php
+++ /dev/null
@@ -1,59 +0,0 @@
-<?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\Unit\Query;
-
-use ONGR\ElasticsearchDSL\Query\GeohashCellQuery;
-
-class GeohashCellQueryTest extends \PHPUnit_Framework_TestCase
-{
-    /**
-     * Data provider for testToArray().
-     *
-     * @return array
-     */
-    public function getArrayDataProvider()
-    {
-        return [
-            // Case #1.
-            [
-                'location',
-                ['lat' => 40, 'lon' => -70],
-                [],
-                ['location' => ['lat' => 40, 'lon' => -70]],
-            ],
-            // Case #2.
-            [
-                'location',
-                ['lat' => 0, 'lon' => 0],
-                ['parameter' => 'value'],
-                ['location' => ['lat' => 0, 'lon' => 0], 'parameter' => 'value'],
-            ],
-        ];
-    }
-
-    /**
-     * Tests toArray() method.
-     *
-     * @param string $field      Field name.
-     * @param array  $location   Location.
-     * @param array  $parameters Optional parameters.
-     * @param array  $expected   Expected result.
-     *
-     * @dataProvider getArrayDataProvider
-     */
-    public function testToArray($field, $location, $parameters, $expected)
-    {
-        $query = new GeohashCellQuery($field, $location, $parameters);
-        $result = $query->toArray();
-        $this->assertEquals(['geohash_cell' => $expected], $result);
-    }
-}
diff --git a/tests/Unit/Query/HasChildQueryTest.php b/tests/Unit/Query/Joining/HasChildQueryTest.php
similarity index 85%
rename from tests/Unit/Query/HasChildQueryTest.php
rename to tests/Unit/Query/Joining/HasChildQueryTest.php
index 10ba891..93dc7d5 100644
--- a/tests/Unit/Query/HasChildQueryTest.php
+++ b/tests/Unit/Query/Joining/HasChildQueryTest.php
@@ -9,9 +9,9 @@
  * file that was distributed with this source code.
  */
 
-namespace ONGR\ElasticsearchDSL\Tests\Unit\Query;
+namespace ONGR\ElasticsearchDSL\Tests\Unit\Query\Joining;
 
-use ONGR\ElasticsearchDSL\Query\HasChildQuery;
+use ONGR\ElasticsearchDSL\Query\Joining\HasChildQuery;
 
 class HasChildQueryTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/Unit/Query/HasParentQueryTest.php b/tests/Unit/Query/Joining/HasParentQueryTest.php
similarity index 85%
rename from tests/Unit/Query/HasParentQueryTest.php
rename to tests/Unit/Query/Joining/HasParentQueryTest.php
index fe7a5ba..570246a 100644
--- a/tests/Unit/Query/HasParentQueryTest.php
+++ b/tests/Unit/Query/Joining/HasParentQueryTest.php
@@ -9,9 +9,9 @@
  * file that was distributed with this source code.
  */
 
-namespace ONGR\ElasticsearchDSL\Tests\Unit\Query;
+namespace ONGR\ElasticsearchDSL\Tests\Unit\Query\Joining;
 
-use ONGR\ElasticsearchDSL\Query\HasParentQuery;
+use ONGR\ElasticsearchDSL\Query\Joining\HasParentQuery;
 
 class HasParentQueryTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/Unit/Query/NestedQueryTest.php b/tests/Unit/Query/Joining/NestedQueryTest.php
similarity index 90%
rename from tests/Unit/Query/NestedQueryTest.php
rename to tests/Unit/Query/Joining/NestedQueryTest.php
index a25360f..dc273b4 100644
--- a/tests/Unit/Query/NestedQueryTest.php
+++ b/tests/Unit/Query/Joining/NestedQueryTest.php
@@ -9,10 +9,10 @@
  * file that was distributed with this source code.
  */
 
-namespace ONGR\ElasticsearchDSL\Tests\Unit\Query;
+namespace ONGR\ElasticsearchDSL\Tests\Unit\Query\Joining;
 
-use ONGR\ElasticsearchDSL\Query\NestedQuery;
-use ONGR\ElasticsearchDSL\Query\TermsQuery;
+use ONGR\ElasticsearchDSL\Query\Joining\NestedQuery;
+use ONGR\ElasticsearchDSL\Query\TermLevel\TermsQuery;
 
 class NestedQueryTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/Unit/Query/MoreLikeThisQueryTest.php b/tests/Unit/Query/Specialized/MoreLikeThisQueryTest.php
similarity index 85%
rename from tests/Unit/Query/MoreLikeThisQueryTest.php
rename to tests/Unit/Query/Specialized/MoreLikeThisQueryTest.php
index 89c1063..44e62db 100644
--- a/tests/Unit/Query/MoreLikeThisQueryTest.php
+++ b/tests/Unit/Query/Specialized/MoreLikeThisQueryTest.php
@@ -9,9 +9,9 @@
  * file that was distributed with this source code.
  */
 
-namespace ONGR\ElasticsearchDSL\Tests\Unit\Query;
+namespace ONGR\ElasticsearchDSL\Tests\Unit\Query\Specialized;
 
-use ONGR\ElasticsearchDSL\Query\MoreLikeThisQuery;
+use ONGR\ElasticsearchDSL\Query\Specialized\MoreLikeThisQuery;
 
 class MoreLikeThisQueryTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/Unit/Query/ScriptQueryTest.php b/tests/Unit/Query/Specialized/ScriptQueryTest.php
similarity index 92%
rename from tests/Unit/Query/ScriptQueryTest.php
rename to tests/Unit/Query/Specialized/ScriptQueryTest.php
index c520bd2..27c265f 100644
--- a/tests/Unit/Query/ScriptQueryTest.php
+++ b/tests/Unit/Query/Specialized/ScriptQueryTest.php
@@ -9,9 +9,9 @@
  * file that was distributed with this source code.
  */
 
-namespace ONGR\ElasticsearchDSL\Tests\Unit\Query;
+namespace ONGR\ElasticsearchDSL\Tests\Unit\Query\Specialized;
 
-use ONGR\ElasticsearchDSL\Query\ScriptQuery;
+use ONGR\ElasticsearchDSL\Query\Specialized\ScriptQuery;
 
 class ScriptQueryTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/Unit/Query/TemplateQueryTest.php b/tests/Unit/Query/Specialized/TemplateQueryTest.php
similarity index 92%
rename from tests/Unit/Query/TemplateQueryTest.php
rename to tests/Unit/Query/Specialized/TemplateQueryTest.php
index 8d2a444..3ede55e 100644
--- a/tests/Unit/Query/TemplateQueryTest.php
+++ b/tests/Unit/Query/Specialized/TemplateQueryTest.php
@@ -9,9 +9,9 @@
  * file that was distributed with this source code.
  */
 
-namespace ONGR\ElasticsearchDSL\Tests\Unit\Query;
+namespace ONGR\ElasticsearchDSL\Tests\Unit\Query\Specialized;
 
-use ONGR\ElasticsearchDSL\Query\TemplateQuery;
+use ONGR\ElasticsearchDSL\Query\Specialized\TemplateQuery;
 
 /**
  * Unit test for Template.
diff --git a/tests/Unit/Query/ExistsQueryTest.php b/tests/Unit/Query/TermLevel/ExistsQueryTest.php
similarity index 82%
rename from tests/Unit/Query/ExistsQueryTest.php
rename to tests/Unit/Query/TermLevel/ExistsQueryTest.php
index 99138b0..07c739f 100644
--- a/tests/Unit/Query/ExistsQueryTest.php
+++ b/tests/Unit/Query/TermLevel/ExistsQueryTest.php
@@ -9,9 +9,9 @@
  * file that was distributed with this source code.
  */
 
-namespace ONGR\ElasticsearchDSL\Tests\Unit\Query;
+namespace ONGR\ElasticsearchDSL\Tests\Unit\Query\TermLevel;
 
-use ONGR\ElasticsearchDSL\Query\ExistsQuery;
+use ONGR\ElasticsearchDSL\Query\TermLevel\ExistsQuery;
 
 /**
  * Unit test for ExistsQuery.
diff --git a/tests/Unit/Query/FuzzyQueryTest.php b/tests/Unit/Query/TermLevel/FuzzyQueryTest.php
similarity index 85%
rename from tests/Unit/Query/FuzzyQueryTest.php
rename to tests/Unit/Query/TermLevel/FuzzyQueryTest.php
index 7b1b3b5..0433205 100644
--- a/tests/Unit/Query/FuzzyQueryTest.php
+++ b/tests/Unit/Query/TermLevel/FuzzyQueryTest.php
@@ -9,9 +9,9 @@
  * file that was distributed with this source code.
  */
 
-namespace ONGR\ElasticsearchDSL\Tests\Unit\Query;
+namespace ONGR\ElasticsearchDSL\Tests\Unit\Query\TermLevel;
 
-use ONGR\ElasticsearchDSL\Query\FuzzyQuery;
+use ONGR\ElasticsearchDSL\Query\TermLevel\FuzzyQuery;
 
 class FuzzyQueryTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/Unit/Query/IdsQueryTest.php b/tests/Unit/Query/TermLevel/IdsQueryTest.php
similarity index 84%
rename from tests/Unit/Query/IdsQueryTest.php
rename to tests/Unit/Query/TermLevel/IdsQueryTest.php
index 5db7650..d29c305 100644
--- a/tests/Unit/Query/IdsQueryTest.php
+++ b/tests/Unit/Query/TermLevel/IdsQueryTest.php
@@ -9,9 +9,9 @@
  * file that was distributed with this source code.
  */
 
-namespace ONGR\ElasticsearchDSL\Tests\Unit\Query;
+namespace ONGR\ElasticsearchDSL\Tests\Unit\Query\TermLevel;
 
-use ONGR\ElasticsearchDSL\Query\IdsQuery;
+use ONGR\ElasticsearchDSL\Query\TermLevel\IdsQuery;
 
 class IdsQueryTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/Unit/Query/PrefixQueryTest.php b/tests/Unit/Query/TermLevel/PrefixQueryTest.php
similarity index 84%
rename from tests/Unit/Query/PrefixQueryTest.php
rename to tests/Unit/Query/TermLevel/PrefixQueryTest.php
index 610756c..caafbbc 100644
--- a/tests/Unit/Query/PrefixQueryTest.php
+++ b/tests/Unit/Query/TermLevel/PrefixQueryTest.php
@@ -9,9 +9,9 @@
  * file that was distributed with this source code.
  */
 
-namespace ONGR\ElasticsearchDSL\Tests\Unit\Query;
+namespace ONGR\ElasticsearchDSL\Tests\Unit\Query\TermLevel;
 
-use ONGR\ElasticsearchDSL\Query\PrefixQuery;
+use ONGR\ElasticsearchDSL\Query\TermLevel\PrefixQuery;
 
 class PrefixQueryTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/Unit/Query/RangeQueryTest.php b/tests/Unit/Query/TermLevel/RangeQueryTest.php
similarity index 85%
rename from tests/Unit/Query/RangeQueryTest.php
rename to tests/Unit/Query/TermLevel/RangeQueryTest.php
index 97cfc93..ad6ee1a 100644
--- a/tests/Unit/Query/RangeQueryTest.php
+++ b/tests/Unit/Query/TermLevel/RangeQueryTest.php
@@ -9,9 +9,9 @@
  * file that was distributed with this source code.
  */
 
-namespace ONGR\ElasticsearchDSL\Tests\Unit\Query;
+namespace ONGR\ElasticsearchDSL\Tests\Unit\Query\TermLevel;
 
-use ONGR\ElasticsearchDSL\Query\RangeQuery;
+use ONGR\ElasticsearchDSL\Query\TermLevel\RangeQuery;
 
 class RangeQueryTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/Unit/Query/RegexpQueryTest.php b/tests/Unit/Query/TermLevel/RegexpQueryTest.php
similarity index 85%
rename from tests/Unit/Query/RegexpQueryTest.php
rename to tests/Unit/Query/TermLevel/RegexpQueryTest.php
index 2636fb0..7bc78c6 100644
--- a/tests/Unit/Query/RegexpQueryTest.php
+++ b/tests/Unit/Query/TermLevel/RegexpQueryTest.php
@@ -9,9 +9,9 @@
  * file that was distributed with this source code.
  */
 
-namespace ONGR\ElasticsearchDSL\Tests\Unit\Query;
+namespace ONGR\ElasticsearchDSL\Tests\Unit\Query\TermLevel;
 
-use ONGR\ElasticsearchDSL\Query\RegexpQuery;
+use ONGR\ElasticsearchDSL\Query\TermLevel\RegexpQuery;
 
 class RegexpQueryTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/Unit/Query/TermQueryTest.php b/tests/Unit/Query/TermLevel/TermQueryTest.php
similarity index 83%
rename from tests/Unit/Query/TermQueryTest.php
rename to tests/Unit/Query/TermLevel/TermQueryTest.php
index b6aa73b..339938b 100644
--- a/tests/Unit/Query/TermQueryTest.php
+++ b/tests/Unit/Query/TermLevel/TermQueryTest.php
@@ -9,9 +9,9 @@
  * file that was distributed with this source code.
  */
 
-namespace ONGR\ElasticsearchDSL\Tests\Unit\Query;
+namespace ONGR\ElasticsearchDSL\Tests\Unit\Query\TermLevel;
 
-use ONGR\ElasticsearchDSL\Query\TermQuery;
+use ONGR\ElasticsearchDSL\Query\TermLevel\TermQuery;
 
 class TermQueryTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/Unit/Query/TermsQueryTest.php b/tests/Unit/Query/TermLevel/TermsQueryTest.php
similarity index 84%
rename from tests/Unit/Query/TermsQueryTest.php
rename to tests/Unit/Query/TermLevel/TermsQueryTest.php
index a3567cc..ba34dc5 100644
--- a/tests/Unit/Query/TermsQueryTest.php
+++ b/tests/Unit/Query/TermLevel/TermsQueryTest.php
@@ -9,9 +9,9 @@
  * file that was distributed with this source code.
  */
 
-namespace ONGR\ElasticsearchDSL\Tests\Unit\Query;
+namespace ONGR\ElasticsearchDSL\Tests\Unit\Query\TermLevel;
 
-use ONGR\ElasticsearchDSL\Query\TermsQuery;
+use ONGR\ElasticsearchDSL\Query\TermLevel\TermsQuery;
 
 class TermsQueryTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/Unit/Query/TypeQueryTest.php b/tests/Unit/Query/TermLevel/TypeQueryTest.php
similarity index 83%
rename from tests/Unit/Query/TypeQueryTest.php
rename to tests/Unit/Query/TermLevel/TypeQueryTest.php
index be1cf8f..038c6d8 100644
--- a/tests/Unit/Query/TypeQueryTest.php
+++ b/tests/Unit/Query/TermLevel/TypeQueryTest.php
@@ -9,9 +9,9 @@
  * file that was distributed with this source code.
  */
 
-namespace ONGR\ElasticsearchDSL\Tests\Unit\Query;
+namespace ONGR\ElasticsearchDSL\Tests\Unit\Query\TermLevel;
 
-use ONGR\ElasticsearchDSL\Query\TypeQuery;
+use ONGR\ElasticsearchDSL\Query\TermLevel\TypeQuery;
 
 class TypeQueryTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/Unit/Query/WildcardQueryTest.php b/tests/Unit/Query/TermLevel/WildcardQueryTest.php
similarity index 85%
rename from tests/Unit/Query/WildcardQueryTest.php
rename to tests/Unit/Query/TermLevel/WildcardQueryTest.php
index cf17483..2dbd119 100644
--- a/tests/Unit/Query/WildcardQueryTest.php
+++ b/tests/Unit/Query/TermLevel/WildcardQueryTest.php
@@ -9,9 +9,9 @@
  * file that was distributed with this source code.
  */
 
-namespace ONGR\ElasticsearchDSL\Tests\Unit\Query;
+namespace ONGR\ElasticsearchDSL\Tests\Unit\Query\TermLevel;
 
-use ONGR\ElasticsearchDSL\Query\WildcardQuery;
+use ONGR\ElasticsearchDSL\Query\TermLevel\WildcardQuery;
 
 class WildcardQueryTest extends \PHPUnit_Framework_TestCase
 {
diff --git a/tests/Unit/SearchEndpoint/FilterEndpointTest.php b/tests/Unit/SearchEndpoint/FilterEndpointTest.php
deleted file mode 100644
index adfc847..0000000
--- a/tests/Unit/SearchEndpoint/FilterEndpointTest.php
+++ /dev/null
@@ -1,87 +0,0 @@
-<?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\Unit\Unit\SearchEndpoint;
-
-use ONGR\ElasticsearchDSL\Query\MatchAllQuery;
-use ONGR\ElasticsearchDSL\SearchEndpoint\FilterEndpoint;
-use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
-use PHPUnit_Framework_MockObject_MockObject as MockObject;
-
-/**
- * Class FilterEndpointTest.
- */
-class FilterEndpointTest extends \PHPUnit_Framework_TestCase
-{
-    /**
-     * Tests constructor.
-     */
-    public function testItCanBeInstantiated()
-    {
-        $this->assertInstanceOf(
-            'ONGR\ElasticsearchDSL\SearchEndpoint\FilterEndpoint',
-            new FilterEndpoint()
-        );
-    }
-
-    /**
-     * Tests if correct order is returned. It's very important that filters must be executed first.
-     */
-    public function testGetOrder()
-    {
-        $instance = new FilterEndpoint();
-        $this->assertEquals(1, $instance->getOrder());
-    }
-
-    /**
-     * Test normalization.
-     */
-    public function testNormalization()
-    {
-        $instance = new FilterEndpoint();
-        /** @var NormalizerInterface|MockObject $normalizerInterface */
-        $normalizerInterface = $this->getMockForAbstractClass(
-            'Symfony\Component\Serializer\Normalizer\NormalizerInterface'
-        );
-        $this->assertNull($instance->normalize($normalizerInterface));
-        $this->assertFalse($instance->hasReference('filter_query'));
-
-        $matchAllFilter = new MatchAllQuery();
-        $instance->add($matchAllFilter);
-
-        $this->assertNull($instance->normalize($normalizerInterface));
-        $this->assertTrue($instance->hasReference('filter_query'));
-
-        /** @var \ONGR\ElasticsearchDSL\Query\BoolQuery $bool */
-        $bool = $instance->getReference('filter_query');
-        $this->assertInstanceOf('ONGR\ElasticsearchDSL\Query\BoolQuery', $bool);
-
-        $must = $bool->getQueries('must');
-        $realReference = reset($must);
-
-        $this->assertSame($matchAllFilter, $realReference);
-    }
-
-    /**
-     * Tests if endpoint returns builders.
-     */
-    public function testEndpointGetter()
-    {
-        $filterName = 'acme_filter';
-        $filter = new MatchAllQuery();
-        $endpoint = new FilterEndpoint();
-        $endpoint->add($filter, $filterName);
-        $builders = $endpoint->getAll();
-
-        $this->assertCount(1, $builders);
-        $this->assertSame($filter, $builders[$filterName]);
-    }
-}
diff --git a/tests/Unit/SearchEndpoint/PostFilterEndpointTest.php b/tests/Unit/SearchEndpoint/PostFilterEndpointTest.php
index 0862c37..4b3b6b8 100644
--- a/tests/Unit/SearchEndpoint/PostFilterEndpointTest.php
+++ b/tests/Unit/SearchEndpoint/PostFilterEndpointTest.php
@@ -35,7 +35,7 @@ class PostFilterEndpointTest extends \PHPUnit_Framework_TestCase
     public function testGetOrder()
     {
         $instance = new PostFilterEndpoint();
-        $this->assertEquals(2, $instance->getOrder());
+        $this->assertEquals(1, $instance->getOrder());
     }
 
     /**
diff --git a/tests/Unit/SearchEndpoint/QueryEndpointTest.php b/tests/Unit/SearchEndpoint/QueryEndpointTest.php
index 2dd69a9..9d4c0d2 100644
--- a/tests/Unit/SearchEndpoint/QueryEndpointTest.php
+++ b/tests/Unit/SearchEndpoint/QueryEndpointTest.php
@@ -35,7 +35,7 @@ class QueryEndpointTest extends \PHPUnit_Framework_TestCase
     public function testGetOrder()
     {
         $instance = new QueryEndpoint();
-        $this->assertEquals(3, $instance->getOrder());
+        $this->assertEquals(2, $instance->getOrder());
     }
 
     /**
diff --git a/tests/Unit/SearchTest.php b/tests/Unit/SearchTest.php
index a6c9db1..c7ac6a4 100644
--- a/tests/Unit/SearchTest.php
+++ b/tests/Unit/SearchTest.php
@@ -11,8 +11,8 @@
 
 namespace ONGR\ElasticsearchDSL\Tests\Unit;
 
-use ONGR\ElasticsearchDSL\Query\ExistsQuery;
-use ONGR\ElasticsearchDSL\Query\TermQuery;
+use ONGR\ElasticsearchDSL\Query\TermLevel\ExistsQuery;
+use ONGR\ElasticsearchDSL\Query\TermLevel\TermQuery;
 use ONGR\ElasticsearchDSL\Search;
 use ONGR\ElasticsearchDSL\Sort\FieldSort;
 use ONGR\ElasticsearchDSL\Suggest\Suggest;
@@ -29,278 +29,4 @@ class SearchTest extends \PHPUnit_Framework_TestCase
     {
         $this->assertInstanceOf('ONGR\ElasticsearchDSL\Search', new Search());
     }
-
-    /**
-     * Data provider for test testSettingParams()
-     *
-     * @return array
-     */
-    public function getTestSettingParamsData()
-    {
-        $cases = [];
-
-        $search = new Search();
-        $search->setSize(3);
-        $cases['Only size is set'] = [
-            $search,
-            [
-                'size' => 3,
-            ],
-        ];
-
-        $search = new Search();
-        $search->setFrom(4);
-        $cases['Only from is set'] = [
-            $search,
-            [
-                'from' => 4,
-            ],
-        ];
-
-        $search = new Search();
-        $search->setTimeout('2s');
-        $cases['Only timeout is set'] = [
-            $search,
-            [
-                'timeout' => '2s',
-            ],
-        ];
-
-        $search = new Search();
-        $search->setTerminateAfter(100);
-        $cases['Only terminate_after is set'] = [
-            $search,
-            [
-                'terminate_after' => 100,
-            ],
-        ];
-
-        $search = new Search();
-        $search->setSize(3);
-        $search->setFrom(4);
-        $search->setTimeout('2s');
-        $search->setTerminateAfter(100);
-        $cases['Multiple parameters are set'] = [
-            $search,
-            [
-                'size' => 3,
-                'from' => 4,
-                'timeout' => '2s',
-                'terminate_after' => 100,
-            ],
-        ];
-
-        return $cases;
-    }
-
-    /**
-     * This test checks if parameters are correctly set into Search object.
-     *
-     * @dataProvider getTestSettingParamsData()
-     *
-     * @param Search    $search
-     * @param array     $expected
-     */
-    public function testSettingParams($search, $expected)
-    {
-        $this->assertEquals(
-            $expected,
-            $search->toArray()
-        );
-    }
-
-    /**
-     * Data provider for test testSettingQueryParams()
-     *
-     * @return array
-     */
-    public function getTestSettingQueryParamsData()
-    {
-        $cases = [];
-
-        $search = new Search();
-        $search->setSearchType('dfs_query_then_fetch');
-        $cases['Only search_type is set'] = [
-            $search,
-            [
-                'search_type' => 'dfs_query_then_fetch',
-            ],
-        ];
-
-        $search = new Search();
-        $search->setRequestCache(true);
-        $cases['Only request_cache is set'] = [
-            $search,
-            [
-                'request_cache' => true,
-            ],
-        ];
-
-        $search = new Search();
-        $search->setScroll('1m');
-        $cases['Only scroll is set'] = [
-            $search,
-            [
-                'scroll' => '1m',
-            ],
-        ];
-
-        $search = new Search();
-        $search->setPreference('_local');
-        $cases['Only preference is set'] = [
-            $search,
-            [
-                'preference' => '_local',
-            ],
-        ];
-
-        $search = new Search();
-        $search->setSearchType('dfs_query_then_fetch');
-        $search->setRequestCache(true);
-        $search->setScroll('1m');
-        $search->setPreference('_local');
-        $cases['Multiple parameters are set'] = [
-            $search,
-            [
-                'search_type' => 'dfs_query_then_fetch',
-                'request_cache' => true,
-                'scroll' => '1m',
-                'preference' => '_local',
-            ],
-        ];
-
-        return $cases;
-    }
-
-    /**
-     * Test if query params are constructed correctly.
-     *
-     * @dataProvider getTestSettingQueryParamsData()
-     *
-     * @param Search    $search
-     * @param array     $expected
-     */
-    public function testSettingQueryParams($search, $expected)
-    {
-        $this->assertEquals(
-            $expected,
-            $search->getQueryParams()
-        );
-    }
-
-    /**
-     * Data provider for testToArray().
-     *
-     * @return array
-     */
-    public function getTestToArrayData()
-    {
-        $cases = [];
-
-        $cases['empty_search'] = [
-            [],
-            new Search(),
-        ];
-
-        $cases['single_term_query'] = [
-            [
-                'query' => [
-                    'term' => ['foo' => 'bar'],
-                ],
-            ],
-            (new Search())->addQuery(new TermQuery('foo', 'bar')),
-        ];
-
-        $cases['single_term_filter'] = [
-            [
-                'query' => [
-                    'bool' => [
-                        'filter' => [
-                            [
-                                'term' => ['foo' => 'bar'],
-                            ],
-                        ],
-                    ],
-                ],
-            ],
-            (new Search())->addFilter(new TermQuery('foo', 'bar')),
-        ];
-
-        $cases['single_query_query_and_filter'] = [
-            [
-                'query' => [
-                    'bool' => [
-                        'must' => [
-                            ['term' => ['foo' => 'bar']],
-                        ],
-                        'filter' => [
-                            [
-                                'exists' => ['field' => 'baz'],
-                            ],
-                        ],
-                    ],
-                ],
-            ],
-            (new Search())->addQuery(new TermQuery('foo', 'bar'))->addFilter(new ExistsQuery('baz')),
-        ];
-
-        $cases['sort_by_price'] = [
-            [
-                'sort' => [
-                    [
-                        'price' => [
-                            'order' => 'asc',
-                        ],
-                    ],
-                ],
-            ],
-            (new Search())->addSort(new FieldSort('price', 'asc')),
-        ];
-
-        $cases['single_suggest'] = [
-            [
-                'suggest' => [
-                    'foo' => [
-                        'text' => 'bar',
-                        'term' => ['field' => 'title', 'size' => 2],
-                    ],
-                ],
-            ],
-            (new Search())->addSuggest(new Suggest('foo', 'term', 'bar', 'title', ['size' => 2])),
-        ];
-
-        $cases['multiple_suggests'] = [
-            [
-                'suggest' => [
-                    'foo' => [
-                        'text' => 'bar',
-                        'term' => ['field' => 'title', 'size' => 2],
-                    ],
-                    'bar' => [
-                        'text' => 'foo',
-                        'term' => ['field' => 'title', 'size' => 2],
-                    ],
-                ],
-            ],
-            (new Search())
-                ->addSuggest(new Suggest('foo', 'term', 'bar', 'title', ['size' => 2]))
-                ->addSuggest(new Suggest('bar', 'term', 'foo', 'title', ['size' => 2])),
-        ];
-
-        return $cases;
-    }
-
-    /**
-     * @param array  $expected
-     * @param Search $search
-     *
-     * @dataProvider getTestToArrayData()
-     */
-    public function testToArray($expected, $search)
-    {
-        $this->assertEquals($expected, $search->toArray());
-
-        // Double check
-        $this->assertEquals($expected, $search->toArray());
-    }
 }
-- 
GitLab