diff --git a/README.md b/README.md index 553756ab8ae83169d3b79b0d0a02df0a5a4367b2..ad0504694fc264a2b9442972cbf3e31473a49e56 100644 --- a/README.md +++ b/README.md @@ -15,15 +15,15 @@ is the preffered and recommended way to ask ONGR support questions. | Elasticsearch version | ElasticsearchDSL version | | --------------------- | --------------------------- | -| >= 5.0 | >= 5.0 | -| >= 2.0, < 5.0 | >= 2.0, < 5.0 | +| >= 6.0 | >= 6.0 | +| >= 5.0, < 6.0 | >= 5.0 | +| >= 2.0, < 5.0 | >= 2.0 | | >= 1.0, < 2.0 | 1.x | -| <= 0.90.x | 0.x | +| <= 0.90.x | not supported | ## Documentation -The latest library online documentation of the bundle [is here](http://docs.ongr.io/ElasticsearchDSL). If you need 2.x -docs you can find it in [the github branch here](https://github.com/ongr-io/ElasticsearchDSL/tree/2.x/docs). +[The online documentation of the bundle is here](docs/index.md) ## Try it! @@ -44,7 +44,7 @@ Elasticsearch DSL was extracted from [Elasticsearch Bundle](https://github.com/o If you dont want to use Symfony or Elasticsearch bundle, no worries, you can use it in any project together with [elasticsearch-php](https://github.com/elastic/elasticsearch-php). Here's the example: If you are using Symfony there is also the [ElasticsearchBundle](https://github.com/ongr-io/ElasticsearchBundle) -which provides full integration with Elasticsearch DSL. +which provides full integration with Elasticsearch DSL. The library is standalone and is not coupled with any framework. You can use it in any PHP project, the only requirement is composer. Here's the example: @@ -54,7 +54,7 @@ Create search: ```php <?php require 'vendor/autoload.php'; //Composer autoload - + $client = ClientBuilder::create()->build(); //elasticsearch-php client $matchAll = new ONGR\ElasticsearchDSL\Query\MatchAllQuery(); diff --git a/composer.json b/composer.json index f8eeb5bc876c96d4e84b4119dfbec7b624f66771..c9db5e9594461366223b55894b99ffd501f93322 100644 --- a/composer.json +++ b/composer.json @@ -11,14 +11,14 @@ } ], "require": { - "php": ">=5.6", - "symfony/serializer": "~2.7|~3.0", + "php": ">=7.0", + "symfony/serializer": "~3.0|~4.0", "paragonie/random_compat": "^2.0", - "elasticsearch/elasticsearch": "~5.0" + "elasticsearch/elasticsearch": "~6.0" }, "require-dev": { - "phpunit/phpunit": "~5.6", - "squizlabs/php_codesniffer": "~2.0", + "phpunit/phpunit": "~6.0", + "squizlabs/php_codesniffer": "~3.0", "satooshi/php-coveralls": "~1.0" }, "autoload": { @@ -34,7 +34,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-master": "5.1-dev" + "dev-master": "6.1-dev" } } } diff --git a/docs/Aggregation/Children.md b/docs/Aggregation/Bucketing/Children.md similarity index 100% rename from docs/Aggregation/Children.md rename to docs/Aggregation/Bucketing/Children.md diff --git a/docs/Aggregation/DateHistogram.md b/docs/Aggregation/Bucketing/DateHistogram.md similarity index 100% rename from docs/Aggregation/DateHistogram.md rename to docs/Aggregation/Bucketing/DateHistogram.md diff --git a/docs/Aggregation/DateRange.md b/docs/Aggregation/Bucketing/DateRange.md similarity index 100% rename from docs/Aggregation/DateRange.md rename to docs/Aggregation/Bucketing/DateRange.md diff --git a/docs/Aggregation/Bucketing/DiversifiedSampler.md b/docs/Aggregation/Bucketing/DiversifiedSampler.md new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/docs/Aggregation/Filter.md b/docs/Aggregation/Bucketing/Filter.md similarity index 100% rename from docs/Aggregation/Filter.md rename to docs/Aggregation/Bucketing/Filter.md diff --git a/docs/Aggregation/Filters.md b/docs/Aggregation/Bucketing/Filters.md similarity index 100% rename from docs/Aggregation/Filters.md rename to docs/Aggregation/Bucketing/Filters.md diff --git a/docs/Aggregation/GeoDistance.md b/docs/Aggregation/Bucketing/GeoDistance.md similarity index 100% rename from docs/Aggregation/GeoDistance.md rename to docs/Aggregation/Bucketing/GeoDistance.md diff --git a/docs/Aggregation/GeoHashGrid.md b/docs/Aggregation/Bucketing/GeoHashGrid.md similarity index 100% rename from docs/Aggregation/GeoHashGrid.md rename to docs/Aggregation/Bucketing/GeoHashGrid.md diff --git a/docs/Aggregation/Global.md b/docs/Aggregation/Bucketing/Global.md similarity index 100% rename from docs/Aggregation/Global.md rename to docs/Aggregation/Bucketing/Global.md diff --git a/docs/Aggregation/Histogram.md b/docs/Aggregation/Bucketing/Histogram.md similarity index 100% rename from docs/Aggregation/Histogram.md rename to docs/Aggregation/Bucketing/Histogram.md diff --git a/docs/Aggregation/Ipv4Range.md b/docs/Aggregation/Bucketing/Ipv4Range.md similarity index 100% rename from docs/Aggregation/Ipv4Range.md rename to docs/Aggregation/Bucketing/Ipv4Range.md diff --git a/docs/Aggregation/Missing.md b/docs/Aggregation/Bucketing/Missing.md similarity index 100% rename from docs/Aggregation/Missing.md rename to docs/Aggregation/Bucketing/Missing.md diff --git a/docs/Aggregation/Nested.md b/docs/Aggregation/Bucketing/Nested.md similarity index 100% rename from docs/Aggregation/Nested.md rename to docs/Aggregation/Bucketing/Nested.md diff --git a/docs/Aggregation/Range.md b/docs/Aggregation/Bucketing/Range.md similarity index 100% rename from docs/Aggregation/Range.md rename to docs/Aggregation/Bucketing/Range.md diff --git a/docs/Aggregation/ReverseNested.md b/docs/Aggregation/Bucketing/ReverseNested.md similarity index 100% rename from docs/Aggregation/ReverseNested.md rename to docs/Aggregation/Bucketing/ReverseNested.md diff --git a/docs/Aggregation/SamplerAgg.md b/docs/Aggregation/Bucketing/SamplerAgg.md similarity index 100% rename from docs/Aggregation/SamplerAgg.md rename to docs/Aggregation/Bucketing/SamplerAgg.md diff --git a/docs/Aggregation/SignificantTerms.md b/docs/Aggregation/Bucketing/SignificantTerms.md similarity index 100% rename from docs/Aggregation/SignificantTerms.md rename to docs/Aggregation/Bucketing/SignificantTerms.md diff --git a/docs/Aggregation/Terms.md b/docs/Aggregation/Bucketing/Terms.md similarity index 100% rename from docs/Aggregation/Terms.md rename to docs/Aggregation/Bucketing/Terms.md diff --git a/docs/Aggregation/Matrix/MatrixStats.md b/docs/Aggregation/Matrix/MatrixStats.md new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/docs/Aggregation/Avg.md b/docs/Aggregation/Metric/Avg.md similarity index 100% rename from docs/Aggregation/Avg.md rename to docs/Aggregation/Metric/Avg.md diff --git a/docs/Aggregation/Cardinality.md b/docs/Aggregation/Metric/Cardinality.md similarity index 100% rename from docs/Aggregation/Cardinality.md rename to docs/Aggregation/Metric/Cardinality.md diff --git a/docs/Aggregation/ExtendedStats.md b/docs/Aggregation/Metric/ExtendedStats.md similarity index 100% rename from docs/Aggregation/ExtendedStats.md rename to docs/Aggregation/Metric/ExtendedStats.md diff --git a/docs/Aggregation/GeoBounds.md b/docs/Aggregation/Metric/GeoBounds.md similarity index 100% rename from docs/Aggregation/GeoBounds.md rename to docs/Aggregation/Metric/GeoBounds.md diff --git a/docs/Aggregation/GeoCentroid.md b/docs/Aggregation/Metric/GeoCentroid.md similarity index 100% rename from docs/Aggregation/GeoCentroid.md rename to docs/Aggregation/Metric/GeoCentroid.md diff --git a/docs/Aggregation/Max.md b/docs/Aggregation/Metric/Max.md similarity index 100% rename from docs/Aggregation/Max.md rename to docs/Aggregation/Metric/Max.md diff --git a/docs/Aggregation/Min.md b/docs/Aggregation/Metric/Min.md similarity index 100% rename from docs/Aggregation/Min.md rename to docs/Aggregation/Metric/Min.md diff --git a/docs/Aggregation/PercentileRanks.md b/docs/Aggregation/Metric/PercentileRanks.md similarity index 100% rename from docs/Aggregation/PercentileRanks.md rename to docs/Aggregation/Metric/PercentileRanks.md diff --git a/docs/Aggregation/Percentiles.md b/docs/Aggregation/Metric/Percentiles.md similarity index 100% rename from docs/Aggregation/Percentiles.md rename to docs/Aggregation/Metric/Percentiles.md diff --git a/docs/Aggregation/Metric/ScriptedMetric.md b/docs/Aggregation/Metric/ScriptedMetric.md new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/docs/Aggregation/Stats.md b/docs/Aggregation/Metric/Stats.md similarity index 100% rename from docs/Aggregation/Stats.md rename to docs/Aggregation/Metric/Stats.md diff --git a/docs/Aggregation/Sum.md b/docs/Aggregation/Metric/Sum.md similarity index 100% rename from docs/Aggregation/Sum.md rename to docs/Aggregation/Metric/Sum.md diff --git a/docs/Aggregation/TopHits.md b/docs/Aggregation/Metric/TopHits.md similarity index 100% rename from docs/Aggregation/TopHits.md rename to docs/Aggregation/Metric/TopHits.md diff --git a/docs/Aggregation/ValueCount.md b/docs/Aggregation/Metric/ValueCount.md similarity index 100% rename from docs/Aggregation/ValueCount.md rename to docs/Aggregation/Metric/ValueCount.md diff --git a/src/Aggregation/Matrix/MatrixStatsAggregation.php b/src/Aggregation/Matrix/MatrixStatsAggregation.php new file mode 100644 index 0000000000000000000000000000000000000000..7e8d96cef448e890b40e7b146a87cef38638838e --- /dev/null +++ b/src/Aggregation/Matrix/MatrixStatsAggregation.php @@ -0,0 +1,110 @@ +<?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\Aggregation\Matrix; +use ONGR\ElasticsearchDSL\Aggregation\AbstractAggregation; +use ONGR\ElasticsearchDSL\Aggregation\Type\MetricTrait; + +/** + * Class representing Max Aggregation. + * + * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-max-aggregation.html + */ +class MaxAggregation extends AbstractAggregation +{ + use MetricTrait; + + /** + * @var string Used for multi value aggregation fields to pick a value. + */ + private $mode; + + /** + * @var array Defines how documents that are missing a value should be treated. + */ + private $missing; + + /** + * Inner aggregations container init. + * + * @param string $name + * @param string|array $field Fields list to aggregate. + * @param array $missing + * @param string $mode + */ + public function __construct($name, $field, $missing = null, $mode = null) + { + parent::__construct($name); + + $this->setField($field); + $this->setMode($mode); + $this->missing = $missing; + } + + /** + * @return string + */ + public function getMode() + { + return $this->mode; + } + + /** + * @param string $mode + */ + public function setMode($mode) + { + $this->mode = $mode; + } + + /** + * @return array + */ + public function getMissing() + { + return $this->missing; + } + + /** + * @param array $missing + */ + public function setMissing($missing) + { + $this->missing = $missing; + } + + /** + * {@inheritdoc} + */ + public function getType() + { + return 'matrix_stats'; + } + + protected function getArray() + { + $out = []; + if ($this->getField()) { + $out['fields'] = $this->getField(); + } + + if($this->getMode()) { + $out['mode'] = $this->getMode(); + } + + + if($this->getMissing()) { + $out['missing'] = $this->getMissing(); + } + + return $out; + } +} diff --git a/src/Search.php b/src/Search.php index 22dbc83a5a7d459e17bf1eaab9ce137c822337a2..5f84bba0cd9c97e91912b1f3618283ccd044235b 100644 --- a/src/Search.php +++ b/src/Search.php @@ -672,6 +672,11 @@ class Search 'size', 'search_type', 'scroll', + 'allow_no_indices', + 'ignore_unavailable', + 'typed_keys', + 'pre_filter_shard_size', + 'ignore_unavailable', ])) { $this->uriParams[$name] = $value; } else {