diff --git a/CHANGELOG.md b/CHANGELOG.md
index 891a1d89fb68302d6ba6e5fdd41cdf3530df8575..eba6f0acc6a2fde88f60e098e6318e245d467b7e 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 5b51592ffd5cf59253e7e20c5ff506307c430c70..7fa01ad4d37efa4fcf016a9d8668ef380e0c4a29 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 ff217b9fe7b970d4a9f52aac6bca6616da1a1b5c..0000000000000000000000000000000000000000
--- 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 c59f367c85cba4a41a4339a5cb79aef2bdea63e1..0000000000000000000000000000000000000000
--- 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 c919c67e57eeb98e121708b65388306a566d8694..0000000000000000000000000000000000000000
--- 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 38e01fe892a5cd354bc525b48753b351f7c56880..1e9791056894e3c9283cf973c515a9acf45e31ff 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 b0b31fd041be4e1592c17b0f46e186a2e1b80db2..0000000000000000000000000000000000000000
--- 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 0485c64e680507ce946a02c79bd01c789037fd84..0000000000000000000000000000000000000000
--- 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 26227c6e7377ced654a426f7e7ba53d9d741cf62..0000000000000000000000000000000000000000
--- 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 3657e6e89238156df4db8992693d2137f3a37abc..0000000000000000000000000000000000000000
--- 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 81bf38f4fce0c91d198773ad2e2f0843e09ccbf0..0000000000000000000000000000000000000000
--- 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 7e00821379df3224dda4494d3978f3ecffb46f43..0000000000000000000000000000000000000000
--- 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 eca616a5b6273ccc4e13325254bd504ab12f53f9..0000000000000000000000000000000000000000
--- 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 d5457ac96541b3fe15f396f44cff5116dca3f1cf..0000000000000000000000000000000000000000
--- 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 3bc9158bbb69f0dd3f9178af024dd20c521b031f..0000000000000000000000000000000000000000
--- 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 02efa21fbef46a81ceffae2f867e449508473a50..0000000000000000000000000000000000000000
--- 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 d792507e8379b6a0b87a3f9d9a06995c45b39551..0000000000000000000000000000000000000000
--- 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 f231cfcac838dd17a046dd4ac67dc4e2ea24d432..0000000000000000000000000000000000000000
--- 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 490a43d50912b51bf393c821b2a6ea3aafe2aeb6..0000000000000000000000000000000000000000
--- 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 bec057699aa3336ef40be552e6bbbaa7ced4140f..0000000000000000000000000000000000000000
--- 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 8244aaf0a2cab02631f437218e4c887548b2b61b..0000000000000000000000000000000000000000
--- 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 d6a1a5d38990a395dc19448533cf2fe414e33459..0000000000000000000000000000000000000000
--- 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 52a1278f61fa94bb7434e6ec7aac68fc94ad0dda..0000000000000000000000000000000000000000
--- 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 98f19ab1ba366089dac400657d91992a3e2998eb..0000000000000000000000000000000000000000
--- 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 351accd29ef0112f064f8a9b93e3a5c49c6b0605..0000000000000000000000000000000000000000
--- 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 63dcd3f73fbabd4bf75af29f012cb9343fb5447e..0000000000000000000000000000000000000000
--- 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 8080859a679186acf4bd4d9fb25d1286a2a77fd8..0000000000000000000000000000000000000000
--- 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 1d1f0f104526f363b4504028809431db9a56c381..0000000000000000000000000000000000000000
--- 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 3a3828ec96f8e66b532175720a0c09fae98ae1c4..0000000000000000000000000000000000000000
--- 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 e96a830c83bf32697f1237654c36f429d405690d..0000000000000000000000000000000000000000
--- 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 6f6a66968804f0bba5a6f02366d609c8474be8e2..0000000000000000000000000000000000000000
--- 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 42d82f7b1159cad57ca6b23fa2a9b43b1ccf7157..0000000000000000000000000000000000000000
--- 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 6e529f8ba5a1542fabaace92d2d461da4f65e4c4..0000000000000000000000000000000000000000
--- 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 bbb036c887aa2fce67481f2f809533e064ca4d90..acfbf5106e546050780034d2d5d5c402aca36ee5 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 d90aae4c6f3d05462ba035264c5d8bb23cb2bfe7..0000000000000000000000000000000000000000
--- 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 c2751a7adfba6fb36837991aff76b4b8dae37eb2..0000000000000000000000000000000000000000
--- 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 f72d73cc5ce41b234e1beb95988b4d7d0eeb6815..0000000000000000000000000000000000000000
--- 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 aea3d41da4cbf3d46b0dd9ee712a0a5f666a074d..0000000000000000000000000000000000000000
--- 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 5383c1c75556356848b71fa877a10caf8d92cdc5..0000000000000000000000000000000000000000
--- 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 0be5cddef6928fd49abc3541fb802d16c52fdd42..e993c0694c789917667efaa61eb1e217a132a563 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 bc2a0d4cb32ba6ac5e33303216ed5ef4d603e7d1..0000000000000000000000000000000000000000
--- 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 cacb66274ab7cdc43e2cf52dfe1c096916086f57..6055b7ed59475613a4bc19533a61035237ee520b 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 41062b34aa1bd36d4defdb9208105010f9472da0..6212b05d6b0bbcdd336b2c29f488d3bf1009e7b7 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 abfcf6112fdb86db708974913a992d2e64d63296..17e6838bd70c5e99932709fa7624e8ae9b72d2cd 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 652c17bfb20bc9919fd4a4db59a643412a8db474..fb8c1dab1fba33b842024e743bc63502de66f016 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 a067b94546004a3dc0122fc3ebca9e5c4c3aac66..7b79c21dd904e97afbacef6c6f05b567bfc618b1 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 2d512341c5badf25a3d968045984ac57d1c3ef8d..1fb042cd9ad697a4301e35d9989289555c1c5985 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 427a2a824abec5675fdbb8c743d9ea9a27d24213..65c18dbd2cbd3c3edcbc76be15e7c433b6e27f62 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 2d3da88ece2957bbd994e149316cb648555e811f..b2e3da14d7cc5213ce0396bc79649ac3bf1c7901 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 f40fee3e7db5322dc0f0f6242fef26969c7f4693..08549bdc8eb992ab732a694b27547bf4df4a521a 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 b7880e78e1fad8aa6209f0665511730050fe0075..e5bb2e21dca61720adcaacf7a09e5cf6ace021d5 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 5b9b007a3585728c6b48cee169560fd3f1d98084..833ad0c50182a7ba08ec650cb02bd476f9f6fba0 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 969bb32b7917992a6394912eb9560e12364f5efa..508881ba4d774cec0165d1e2533db26dea000ffb 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 364e7e4e347d72c148f766afdee1fc2d8d5535f6..268d8a4ccf1cc352d5afae10f8f5e00035718205 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 e25dd552f7b829d847a04ba16a0fa3bd12cff138..4e6e4767c6b29d1e151667f9ccd32a4c835a11c0 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 5aa55d3c944d93c1fe2ecf840cb9b099b013f62e..32c6117aae244e9eeef4169b3ac8f63577b85b6e 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 33570c789397b539044d2c107559e45c44045bb7..6614f0ddfea9ae43bfd1b53ba0aac6606930867f 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 162f26c4514144c5d5a13cc9825af7e4580cc2f5..e186ca43e30d4a6d8409ca863208162a6bb40607 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 49c27b2109ed84b0de99aea347095774f5f3863f..3ee14608009152bba274c479c11ca26a595460b7 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 864d7898fedf8d3206db329e093275f8847994ca..1a07a25b8129bfa535955b5f50bef24790549592 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 55e1ffb40e1330b89144b222d697964b2af6b1d2..396bd3d9070c7ed6f0cadc99ef8f67b728509654 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 c50cfafa0748612b49e118ca804cd39097879d51..63f292b5eb72980558fe957dce34cdf53c3e0f58 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 c5b0412ba3d7b580f4825546000f190bef235baf..959da1342d8cb1c84b368713e429f43dcf2812ac 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 18502669b20bc749a292296924a76ea7e22cf7eb..579d1be3acda3219560be5d69c9093d4019bae96 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 5584bc78df640606c0ea636d49873f71273d0ec8..e1c250c55d390090ff009c023c7a76fafc6980af 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 870cd33c8b1f50644790776ce4ac46a4cd3d00ba..9771144a02d1c76a779e80a5c5873703b48eee91 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 669cdc364d96bf118044934415bf511b1bc25630..0000000000000000000000000000000000000000
--- 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 10ba8910161ec236175b9496d451c724d0808b02..93dc7d51164de0de2875bce7b062669c73aa903a 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 fe7a5ba5788d679f2d085073393b088545198102..570246a253e00e74b3cfd424c99f390503147d4e 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 a25360f9867c0652c7b94870aac28e4317e3e184..dc273b49a7b2896a4d51aeff89c1d3fad9abacb3 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 89c10633121de1ad44b57f888b8c4cb9a24e8fe3..44e62dbd77d0b28be2f6ff93e3b54fc20ea7a0ef 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 c520bd2bcaca234af167a90baa645fb4731d3f5a..27c265fee1de426ceb2d6de36d53379c776c131f 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 8d2a444bb8b07327ac275d9484d848dab30d9892..3ede55e3319bde2a54deea6667a441916cd5a1e4 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 99138b011e58e46284777fbfc20889de32afc5a7..07c739ff562dab4238e1004208718acf614a9a44 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 7b1b3b5c13253927960d85d162d56838ba85ff23..0433205d75d131a0f56beca9f3ed0a14e0ee1133 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 5db765029bb99f85e9d18240e31d79bf15993def..d29c305d8a2b43e6cf16951c2a9920bfc9802bb9 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 610756c73835a5908e34ee9d0b7295d34c8ea673..caafbbca641e64801fe693465717431071755915 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 97cfc93570a4d33dc68b3db5842f3016a8885947..ad6ee1ac469d1208905caefee72e5f8ad3acf5fe 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 2636fb057fbf49a47013fe66920a83935f81ffd7..7bc78c6876f9a168b15b40d7a4e21f3c5d6afb31 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 b6aa73b9fc70d7cb9a39243bdd539cd572fda1e2..339938b3e5d22b073a7be34cb35bb63b0937446a 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 a3567ccd9a253d26dab2f0345bbe3eb8f87e5e2e..ba34dc5116e53435a039d173d59bac7ad39bcd27 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 be1cf8f6d23268e75a434f46d6a9ed4ff194e6ba..038c6d8d18066994d189504568b891f98c37bfee 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 cf17483f278a5fefe8e169dffefe1a37f64fa259..2dbd1196287fd747210192a05c2bf8a7f79c59b3 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 adfc847ade830448cefcef28c1d3cd7f6795dd90..0000000000000000000000000000000000000000
--- 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 0862c3795044efc9aa33464984489290064b0ae3..4b3b6b8f4175c6b469bf4674e3221149c67a2e41 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 2dd69a9f2f5efa7619c2be0c9697d91aa889ab38..9d4c0d210f0f82463ed30e5f7e7c42e42d5106c9 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 a6c9db1cd9e9fa53198b2d08f6fcdd3872f8e5a7..c7ac6a457efd8725aac91682137ba80bf20fe1d0 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());
-    }
 }