summaryrefslogtreecommitdiff
path: root/vendor/ruflin/elastica
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2015-12-20 09:00:55 +0100
committerPierre Schmitz <pierre@archlinux.de>2015-12-20 09:00:55 +0100
commita2190ac74dd4d7080b12bab90e552d7aa81209ef (patch)
tree8b31f38de9882d18df54cf8d9e0de74167a094eb /vendor/ruflin/elastica
parent15e69f7b20b6596b9148030acce5b59993b95a45 (diff)
parent257401d8b2cf661adf36c84b0e3fd1cf85e33c22 (diff)
Merge branch 'mw-1.26'
Diffstat (limited to 'vendor/ruflin/elastica')
-rw-r--r--vendor/ruflin/elastica/CHANGELOG.md (renamed from vendor/ruflin/elastica/changes.txt)393
-rw-r--r--vendor/ruflin/elastica/CONTRIBUTING.md75
-rw-r--r--vendor/ruflin/elastica/Dockerfile58
-rw-r--r--vendor/ruflin/elastica/Makefile108
-rw-r--r--vendor/ruflin/elastica/README.markdown29
-rw-r--r--vendor/ruflin/elastica/README.md31
-rw-r--r--vendor/ruflin/elastica/Vagrantfile30
-rw-r--r--vendor/ruflin/elastica/ansible/es-playbook.yml20
-rwxr-xr-xvendor/ruflin/elastica/ansible/provision.sh63
-rw-r--r--vendor/ruflin/elastica/ansible/roles/base/tasks/main.yml13
-rw-r--r--vendor/ruflin/elastica/ansible/roles/elasticsearch/handlers/main.yml6
-rw-r--r--vendor/ruflin/elastica/ansible/roles/elasticsearch/tasks/main.yml101
-rw-r--r--vendor/ruflin/elastica/ansible/roles/elasticsearch/templates/config-0.yml10
-rw-r--r--vendor/ruflin/elastica/ansible/roles/elasticsearch/templates/config-1.yml10
-rw-r--r--vendor/ruflin/elastica/ansible/roles/elasticsearch/templates/config-default.yml40
-rwxr-xr-xvendor/ruflin/elastica/ansible/roles/elasticsearch/templates/elasticsearch.service229
-rw-r--r--vendor/ruflin/elastica/ansible/roles/elasticsearch/templates/logging.yml56
-rw-r--r--vendor/ruflin/elastica/ansible/roles/nginx/handlers/main.yml6
-rw-r--r--vendor/ruflin/elastica/ansible/roles/nginx/tasks/main.yml26
-rw-r--r--vendor/ruflin/elastica/ansible/roles/nginx/templates/mime.types.j2109
-rw-r--r--vendor/ruflin/elastica/ansible/roles/nginx/templates/nginx.conf.j235
-rw-r--r--vendor/ruflin/elastica/ansible/roles/php/tasks/main.yml43
-rw-r--r--vendor/ruflin/elastica/build.xml232
-rw-r--r--vendor/ruflin/elastica/composer.json25
-rw-r--r--vendor/ruflin/elastica/docker-compose.yml27
-rw-r--r--vendor/ruflin/elastica/env/elasticsearch/Dockerfile26
-rw-r--r--vendor/ruflin/elastica/env/elasticsearch/elasticsearch.yml39
-rw-r--r--vendor/ruflin/elastica/env/elasticsearch/logging.yml56
-rw-r--r--vendor/ruflin/elastica/env/nginx/mime.types109
-rw-r--r--vendor/ruflin/elastica/env/nginx/nginx.conf38
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/AbstractUpdateAction.php142
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractAggregation.php37
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractSimpleAggregation.php22
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractTermsAggregation.php97
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Avg.php11
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Cardinality.php36
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/DateHistogram.php102
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/DateRange.php15
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/ExtendedStats.php10
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Filter.php36
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Filters.php59
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/GeoDistance.php66
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/GeohashGrid.php41
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/GlobalAggregation.php10
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Histogram.php42
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/IpRange.php38
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Max.php10
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Min.php10
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Missing.php17
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Nested.php17
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Percentiles.php59
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Range.php41
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/ReverseNested.php15
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/ScriptedMetric.php82
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/SignificantTerms.php27
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Stats.php10
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Sum.php10
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/Terms.php96
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/TopHits.php156
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Aggregation/ValueCount.php17
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Bulk.php115
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Bulk/Action.php45
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Bulk/Action/AbstractDocument.php54
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Bulk/Action/CreateDocument.php1
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Bulk/Action/DeleteDocument.php4
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Bulk/Action/IndexDocument.php7
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Bulk/Action/UpdateDocument.php18
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Bulk/Response.php5
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Bulk/ResponseSet.php5
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Client.php312
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Cluster.php67
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Cluster/Health.php16
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Cluster/Health/Index.php13
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Cluster/Health/Shard.php13
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Cluster/Settings.php75
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Connection.php138
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Connection/ConnectionPool.php122
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Connection/Strategy/CallbackStrategy.php51
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Connection/Strategy/RoundRobin.php24
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Connection/Strategy/Simple.php30
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Connection/Strategy/StrategyFactory.php45
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Connection/Strategy/StrategyInterface.php17
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Document.php122
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/Bulk/Response/ActionException.php11
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/Bulk/ResponseException.php21
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/Bulk/UdpException.php1
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/BulkException.php1
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/ClientException.php5
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/Connection/GuzzleException.php9
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/Connection/HttpException.php28
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/Connection/MemcacheException.php13
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/Connection/ThriftException.php10
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/ConnectionException.php17
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/ElasticsearchException.php32
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/ExceptionInterface.php5
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/InvalidException.php5
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/JSONParseException.php5
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/NotFoundException.php5
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/NotImplementedException.php5
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/PartialShardFailureException.php11
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/QueryBuilderException.php11
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/ResponseException.php24
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Exception/RuntimeException.php5
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Facet/AbstractFacet.php56
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Facet/DateHistogram.php30
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Facet/Filter.php14
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Facet/GeoCluster.php36
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Facet/GeoDistance.php33
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Facet/Histogram.php48
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Facet/Query.php14
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Facet/Range.php41
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Facet/Statistical.php25
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Facet/Terms.php46
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Facet/TermsStats.php58
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/AbstractFilter.php32
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/AbstractGeoDistance.php58
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/AbstractGeoShape.php22
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/AbstractMulti.php34
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Bool.php143
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/BoolAnd.php8
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/BoolFilter.php133
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/BoolNot.php17
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/BoolOr.php8
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Exists.php17
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/GeoBoundingBox.php24
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/GeoDistance.php37
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/GeoDistanceRange.php24
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/GeoPolygon.php23
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapePreIndexed.php29
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapeProvided.php35
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/GeohashCell.php32
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/HasChild.php63
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/HasParent.php50
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Ids.php40
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Indices.php57
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Limit.php20
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/MatchAll.php10
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Missing.php41
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Nested.php40
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/NumericRange.php8
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Prefix.php23
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Query.php25
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Range.php44
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Regexp.php62
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Script.php20
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Term.php26
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Terms.php75
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Filter/Type.php33
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Index.php219
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Index/Settings.php188
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Index/Stats.php27
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Index/Status.php46
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/JSON.php24
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Log.php31
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Multi/ResultSet.php39
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Multi/Search.php61
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Node.php77
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Node/Info.php78
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Node/Stats.php30
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Param.php69
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Percolator.php128
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Query.php284
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Query/AbstractQuery.php4
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Query/Bool.php89
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Query/BoolQuery.php111
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Query/Boosting.php28
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Query/Builder.php186
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Query/Common.php92
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Query/ConstantScore.php30
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Query/DisMax.php29
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Query/Filtered.php34
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Query/FunctionScore.php181
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Query/Fuzzy.php47
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Query/FuzzyLikeThis.php96
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Query/HasChild.php34
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Query/HasParent.php35
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Query/Ids.php46
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Query/Image.php187
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Query/Match.php154
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Query/MatchAll.php10
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Query/MatchPhrase.php13
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Query/MatchPhrasePrefix.php13
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Query/MoreLikeThis.php124
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Query/MultiMatch.php113
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Query/Nested.php29
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Query/Prefix.php25
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Query/QueryString.php141
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Query/Range.php19
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Query/Regexp.php40
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Query/Simple.php17
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Query/SimpleQueryString.php56
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Query/Term.php26
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Query/Terms.php48
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Query/TopChildren.php25
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Query/Wildcard.php21
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/QueryBuilder.php114
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/QueryBuilder/DSL.php22
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/QueryBuilder/DSL/Aggregation.php470
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/QueryBuilder/DSL/Filter.php480
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/QueryBuilder/DSL/Query.php586
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/QueryBuilder/DSL/Suggest.php83
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Facade.php64
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version.php101
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version/Version090.php97
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version/Version100.php123
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version/Version110.php131
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version/Version120.php137
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version/Version130.php142
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version/Version140.php145
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version/Version150.php14
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Request.php66
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Rescore/AbstractRescore.php18
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Rescore/Query.php31
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Response.php77
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Result.php67
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/ResultSet.php172
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/ScanAndScroll.php148
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Script.php37
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/ScriptFields.php22
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Scroll.php174
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Search.php167
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/SearchableInterface.php22
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Snapshot.php101
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Status.php60
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Suggest.php35
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Suggest/AbstractSuggest.php33
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Suggest/CandidateGenerator/AbstractCandidateGenerator.php5
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Suggest/CandidateGenerator/DirectGenerator.php77
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Suggest/Completion.php26
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Suggest/Phrase.php102
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Suggest/Term.php76
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Tool/CrossIndex.php160
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Transport/AbstractTransport.php34
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Transport/Guzzle.php146
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Transport/Http.php58
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Transport/HttpAdapter.php156
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Transport/Https.php9
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Transport/Memcache.php65
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Transport/Null.php39
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Transport/NullTransport.php46
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Transport/Thrift.php53
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Type.php217
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Type/AbstractType.php57
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Type/Mapping.php135
-rw-r--r--vendor/ruflin/elastica/lib/Elastica/Util.php101
-rw-r--r--vendor/ruflin/elastica/test/benchmark/BulkMemoryUsageTest.php46
-rw-r--r--vendor/ruflin/elastica/test/benchmark/ClientTest.php31
-rw-r--r--vendor/ruflin/elastica/test/benchmark/phpunit.benchmark.xml10
-rw-r--r--vendor/ruflin/elastica/test/bin/install_php_memcache.sh8
-rw-r--r--vendor/ruflin/elastica/test/bin/run_elasticsearch.sh56
-rw-r--r--vendor/ruflin/elastica/test/bin/run_proxy.sh15
-rw-r--r--vendor/ruflin/elastica/test/bin/show_logs.sh3
-rw-r--r--vendor/ruflin/elastica/test/bootstrap.php2
-rw-r--r--vendor/ruflin/elastica/test/data/test.jpgbin0 -> 4459 bytes
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/AvgTest.php35
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/BaseAggregationTest.php22
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/CardinalityTest.php130
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/DateHistogramTest.php100
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/DateRangeTest.php45
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ExtendedStatsTest.php36
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/FilterTest.php95
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/FiltersTest.php120
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GeoDistanceTest.php43
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GeohashGridTest.php41
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GlobalAggregationTest.php20
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/HistogramTest.php44
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/IpRangeTest.php51
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MaxTest.php73
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MinTest.php36
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MissingTest.php34
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/NestedTest.php75
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/PercentilesTest.php125
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/RangeTest.php75
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ReverseNestedTest.php88
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ScriptTest.php87
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ScriptedMetricTest.php50
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/SignificantTermsTest.php72
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/StatsTest.php36
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/SumTest.php36
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/TermsTest.php38
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/TopHitsTest.php385
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ValueCountTest.php36
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Base.php133
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Bulk/ActionTest.php29
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Bulk/ResponseSetTest.php32
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/BulkTest.php181
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/ClientTest.php402
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/IndexTest.php95
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/ShardTest.php24
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/HealthTest.php38
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/SettingsTest.php25
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/ClusterTest.php42
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/ConnectionPoolTest.php112
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/CallbackStrategyTest.php97
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/CallbackStrategyTestHelper.php20
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/EmptyStrategy.php17
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/RoundRobinTest.php128
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/SimpleTest.php113
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/StrategyFactoryTest.php84
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/ConnectionTest.php22
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/DocumentTest.php48
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/ExampleTest.php37
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/AbstractExceptionTest.php31
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Bulk/Response/ActionExceptionTest.php8
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Bulk/ResponseExceptionTest.php8
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Bulk/UdpExceptionTest.php8
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/BulkExceptionTest.php6
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ClientExceptionTest.php6
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Connection/GuzzleExceptionTest.php14
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Connection/HttpExceptionTest.php8
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Connection/MemcacheExceptionTest.php8
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Connection/ThriftExceptionTest.php14
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ConnectionExceptionTest.php6
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ElasticsearchExceptionTest.php6
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/InvalidExceptionTest.php6
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/JSONParseExceptionTest.php6
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/NotFoundExceptionTest.php6
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/NotImplementedExceptionTest.php (renamed from vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/NotImplementedTest.php)12
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/PartialShardFailureExceptionTest.php15
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/QueryBuilderExceptionTest.php6
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ResponseExceptionTest.php25
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/RuntimeExceptionTest.php6
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/DateHistogramTest.php65
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/FilterTest.php6
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/GeoClusterTest.php36
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/QueryTest.php4
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/StatisticalTest.php20
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/TermsStatsTest.php134
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/TermsTest.php7
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/AbstractTest.php14
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolAndTest.php39
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolFilterTest.php200
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolNotTest.php10
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolOrTest.php56
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolTest.php107
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/ExistsTest.php (renamed from vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/ExistsTests.php)7
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoBoundingBoxTest.php55
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoDistanceRangeTest.php36
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoDistanceTest.php34
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoPolygonTest.php12
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapePreIndexedTest.php64
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapeProvidedTest.php59
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeohashCellTest.php38
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/HasChildTest.php109
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/HasParentTest.php58
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/IdsTest.php115
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/IndicesTest.php140
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/LimitTest.php34
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MatchAllTest.php4
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MissingTest.php78
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MultiTest.php30
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NestedFilterWithSetFilterTest.php139
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NestedTest.php152
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NumericRangeTest.php11
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/PrefixTest.php69
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/QueryTest.php17
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/RangeTest.php47
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/RegexpTest.php83
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/ScriptTest.php13
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TermTest.php5
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TermsTest.php113
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TypeTest.php9
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Index/SettingsTest.php78
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Index/StatsTest.php5
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Index/StatusTest.php10
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/IndexTest.php285
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/LogTest.php61
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Multi/SearchTest.php94
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Node/InfoTest.php43
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/NodeTest.php55
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/ParamTest.php22
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/PercolatorTest.php148
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BoolQueryTest.php (renamed from vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BoolTest.php)75
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BoostingTest.php84
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BuilderTest.php93
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/CommonTest.php32
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/ConstantScoreTest.php52
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/DisMaxTest.php31
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/EscapeStringTest.php36
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FilteredTest.php38
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FunctionScoreTest.php270
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FuzzyLikeThisTest.php112
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FuzzyTest.php87
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HasChildTest.php64
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HasParentTest.php68
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HighlightTest.php17
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/IdsTest.php46
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/ImageTest.php159
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MatchAllTest.php11
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MatchTest.php240
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MoreLikeThisTest.php72
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MultiMatchTest.php151
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/NestedTest.php6
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/PostFilterTest.php57
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/PrefixTest.php5
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/QueryStringTest.php99
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RangeTest.php28
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RegexpTest.php31
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RescoreTest.php103
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/SimpleQueryStringTest.php108
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/SimpleTest.php4
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/TermTest.php5
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/TermsTest.php23
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/WildcardTest.php39
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/AbstractDSLTest.php97
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/AggregationTest.php58
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/FilterTest.php58
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/QueryTest.php85
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/SuggestTest.php32
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/VersionTest.php67
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilderTest.php88
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/QueryTest.php290
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/RequestTest.php16
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/ResponseTest.php141
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/ResultSetTest.php34
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/ResultTest.php22
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/ScanAndScrollTest.php131
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/ScriptFieldsTest.php44
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/ScriptTest.php46
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/ScrollTest.php105
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/SearchTest.php311
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/ShutdownTest.php74
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/SnapshotTest.php55
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/StatusTest.php33
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/CompletionTest.php140
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/PhraseTest.php67
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/TermTest.php71
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Tool/CrossIndexTest.php135
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/AbstractTransportTest.php11
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/GuzzleTest.php85
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/HttpTest.php103
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/MemcacheTest.php181
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/NullTest.php59
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/NullTransportTest.php96
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/ThriftTest.php37
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/TransportBenchmarkTest.php (renamed from vendor/ruflin/elastica/test/benchmark/TransportTest.php)97
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Type/MappingTest.php97
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/TypeTest.php259
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/UtilTest.php78
-rw-r--r--vendor/ruflin/elastica/test/nginx/nginx.conf24
-rw-r--r--vendor/ruflin/elastica/test/phpunit.xhprof.xml (renamed from vendor/ruflin/elastica/test/benchmark/phpunit.xhprof.xml)4
-rw-r--r--vendor/ruflin/elastica/test/phpunit.xml.dist37
442 files changed, 20615 insertions, 7628 deletions
diff --git a/vendor/ruflin/elastica/changes.txt b/vendor/ruflin/elastica/CHANGELOG.md
index 525a6336..1ea98234 100644
--- a/vendor/ruflin/elastica/changes.txt
+++ b/vendor/ruflin/elastica/CHANGELOG.md
@@ -1,60 +1,301 @@
-CHANGES
+# Change Log
+All notable changes to this project will be documented in this file based on the [Keep a Changelog](http://keepachangelog.com/) Standard. This project adheres to [Semantic Versioning](http://semver.org/).
+
+## [Unreleased](https://github.com/ruflin/Elastica/compare/2.2.0...HEAD)
+
+### Backward Compatibility Breaks
+
+### Bugfixes
+
+### Added
+
+### Improvements
+
+### Deprecated
+
+
+## [2.2.0](https://github.com/ruflin/Elastica/releases/tag/2.2.0) - 2015-07-08
+
+
+### Backward Compatibility Breaks
+- Usage of constant DEBUG and method Elastica\Util::debugEnabled is removed. [#868](https://github.com/ruflin/Elastica/pull/868)
+- Elastica\Response::getTransferInfo will not return "request_header" by default. [#868](https://github.com/ruflin/Elastica/pull/868)
+- The Image Plugin is currently not compatible with Elasticearch 1.6.0
+
+### Bugfixes
+- Fixed segmentation fault in PHP7 [#868](https://github.com/ruflin/Elastica/pull/868)
+- Removed deprecation for Elastica\Type::deleteByQuery [#875](https://github.com/ruflin/Elastica/pull/875)
+
+### Improvements
+- `CallbackStrategy` now will accept any `callable` as callback, not only instance of `Closure`. [#871](https://github.com/ruflin/Elastica/pull/871)
+- `StrategyFactory` now will try to find predefined strategy before looking to global namespace. [#877](https://github.com/ruflin/Elastica/pull/877)
+- Update elasticsearch dependency to elasticsearch 1.6.0 https://www.elastic.co/downloads/past-releases/elasticsearch-1-6-0
+- All elasticsearch plugin dependencies were updated to the newest version.
+- Methods of classes in `QueryBuilder\DSL` namespace now have exact same signatures as corresponding constructors. [#878](https://github.com/ruflin/Elastica/pull/878)
+- Constructor of `Aggregation\Filter` now accepts filter as second parameter [#878](https://github.com/ruflin/Elastica/pull/878)
+- Constructor of `Filter\AbstractMulti` (`BoolAnd`, `BooldOr`) now accepts array of filters as parameter [#878](https://github.com/ruflin/Elastica/pull/878)
+- Constructor of `Query\Match` now accepts arguments [#878](https://github.com/ruflin/Elastica/pull/878)
+- Coverage Reporting improved with Codecov [#888](https://github.com/ruflin/Elastica/pull/888)
+- Added 'query_cache' option for search [#886](https://github.com/ruflin/Elastica/pull/886)
+
+## [2.1.0](https://github.com/ruflin/Elastica/releases/tag/2.1.0) - 2015-06-01
+
+### Added
+- Multiple rescore query [#820](https://github.com/ruflin/Elastica/issues/820/)
+- Support for a custom connection timeout through a connectTimeout parameter. [#841](https://github.com/ruflin/Elastica/issues/841/)
+- SignificantTerms Aggregation [#847](https://github.com/ruflin/Elastica/issues/847/)
+- Support for 'precision_threshold' and 'rehash' options for the Cardinality Aggregation [#851]
+- Support for retrieving id node #852
+- Scroll Iterator [#842](https://github.com/ruflin/Elastica/issues/842/)
+- Gitter Elastica Chat Room add for Elastica discussions: https://gitter.im/ruflin/Elastica
+- Introduce PHP7 compatibility and tests. #837
+- `Tool\CrossIndex` for reindexing and copying data and mapping between indices [#853](https://github.com/ruflin/Elastica/pull/853)
+- CONTIRUBTING.md file added for contributor guidelines. #854
+
+### Improvements
+- Introduction of Changelog standard based on http://keepachangelog.com/. changes.txt moved to CHANGELOG.md [#844](https://github.com/ruflin/Elastica/issues/844/)
+- Make host for all tests dynamic to prepare it for a more dynamic test environment #846
+- Node information is retrieved based on id instead of name as multiple nodes can have the same name. #852
+- Guzzle Http dependency updated to 5.3.*
+- Remove NO_DEV builds from travis build matrix to speed up building. All builds include no dev packages.
+- Introduction of benchmark test group to make it easy to run benchmark tests.
+- Make the docker images directly [available](https://hub.docker.com/u/ruflin/) on the docker registry. This speeds up fetching of the images and automates the build of the images.
+
+### Backward Compatibility Breaks
+- `Elastica\ScanAndScroll::$_lastScrollId` removed: `key()` now always returns the next scroll id [#842](https://github.com/ruflin/Elastica/issues/842/)
+
+
+### Deprecated
+- Facets are deprecated. You are encouraged to migrate to aggregations instead. [#855](https://github.com/ruflin/Elastica/pull/855/)
+- Elastica\Query\Builder is deprecated. Use new Elastica\QueryBuilder instead. [#855](https://github.com/ruflin/Elastica/pull/855/)
+- For PHP 7 compatibility Elastica\Query\Bool was renamed to *\BoolQuery, Elastica\Filter\Bool was renamed to BoolFilter, Elastica\Transport\Null was renamed to NullTransport as Null and Bool are reserved phrases in PHP 7. Proxy objects for all three exist to keep backward compatibility. It is recommended to start using the new objects as the proxy classes will be deprecated as soon as PHP 7 is stable. #837
+
+
+
+## [2.0.0](https://github.com/ruflin/Elastica/releases/tag/2.0.0) - 2015-05-11
+
+
+### Backward Compatibility Breaks
+- Elastica\Query\QueryString::setLowercaseExpandedTerms removed [#813](https://github.com/ruflin/Elastica/issues/813/)
+- Update elasticsearch dependency to elasticsearch 1.5.2 https://www.elastic.co/downloads/past-releases/elasticsearch-1-5-2 [#834](https://github.com/ruflin/Elastica/issues/834/)
+- Added deprecation notice to Elastica\Transport\Thrift, Elastica\Transport\Memcached and Elastica\Type::deleteByQuery [#817](https://github.com/ruflin/Elastica/issues/817/)
+- Escape new symbols in Util::escapeTerm [#795](https://github.com/ruflin/Elastica/issues/795/)
+
+### Bugfixes
+- Fix empty bool query to act as match all query [#817](https://github.com/ruflin/Elastica/issues/817/)
+- Fixed short match construction in query DSL [#796](https://github.com/ruflin/Elastica/issues/796/)
+- Index optimize method to return Response object. [#797](https://github.com/ruflin/Elastica/issues/797/)
+- Fix fluent interface inconsistency [#788](https://github.com/ruflin/Elastica/issues/788/)
+
+
+### Improvements
+- Add testing on PHP 7 on Travis [#826](https://github.com/ruflin/Elastica/issues/826/)
+- Allow bool in Query::setSource function [#818](https://github.com/ruflin/Elastica/issues/818/) http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-source-filtering.html
+- deleteByQuery() implemented in Elastica\Index [#816](https://github.com/ruflin/Elastica/issues/816/)
+- Add MLT query against documents [#814](https://github.com/ruflin/Elastica/issues/814/)
+- Added Elastica\Query\SimpleQueryString::setMinimumShouldMatch [#813](https://github.com/ruflin/Elastica/issues/813/)
+- Added Elastica\Query\FunctionScore::setMinScore [#813](https://github.com/ruflin/Elastica/issues/813/)
+- Added Elastica\Query\MoreLikeThis::setMinimumShouldMatch [#813](https://github.com/ruflin/Elastica/issues/813/)
+- Added new methods to Elastica\Aggregation\DateHistogram: setOffset, setTimezone [#813](https://github.com/ruflin/Elastica/issues/813/)
+- Following methods in Elastica\Aggregation\DateHistogram marked as deprecated: setPreOffset, setPostOffset, setPreZone, setPostZone, setPreZoneAdjustLargeInterval [#813](https://github.com/ruflin/Elastica/issues/813/)
+- Add Elastica\Facet\DateHistogram::setFactor() [#806](https://github.com/ruflin/Elastica/issues/806/)
+- Added Elastica\Query\QueryString::setTimezone [#813](https://github.com/ruflin/Elastica/issues/813/)
+- Add .editorconfig [#807](https://github.com/ruflin/Elastica/issues/807/)
+- Added Elastica\Suggest\Completion [#808](https://github.com/ruflin/Elastica/issues/808/)
+- Fix elasticsearch links to elastic domain [#809](https://github.com/ruflin/Elastica/issues/809/)
+- Added Elastica\Query\Image [#787](https://github.com/ruflin/Elastica/issues/787/)
+- Add Scrutinizer Code Quality status badge
+- Added support for percentiles aggregation [#786](https://github.com/ruflin/Elastica/issues/786/)
+
+
+
+## Changelog before 2.0.0
+The changelog before version 2.0.0 was organised by date. All changes can be found below.
+
+2015-02-17
+- Release v1.4.3.0
+- Added Elastica\Query\MatchPhrase [#599](https://github.com/ruflin/Elastica/issues/599/)
+- Added Elastica\Query\MatchPhrasePrefix [#599](https://github.com/ruflin/Elastica/issues/599/)
+
+2015-02-04
+- Reset PHP 5.3 tests and enable compatibility for PHP 5.3 again
+
+2015-02-16
+- Update elasticsearch compatibility to 1.4.3 [#782](https://github.com/ruflin/Elastica/issues/782/)
+- Add support for scripted metric aggrations [#780](https://github.com/ruflin/Elastica/issues/780/)
+
+2015-02-14
+- Added availability to specify regexp options in \Elastica\Filters\Regexp [#583](https://github.com/ruflin/Elastica/issues/583/) [#777](https://github.com/ruflin/Elastica/issues/777/)
+- Add HHVM as build in travis [#649](https://github.com/ruflin/Elastica/issues/649/)
+
+2015-02-11
+- Fixed issue with OutOfMemory exception in travis builds [#775](https://github.com/ruflin/Elastica/issues/775/)
+- Add support for filters aggregation [#773](https://github.com/ruflin/Elastica/issues/773/)
+
+2015-01-27
+- Housekeeping, coding standard [#764](https://github.com/ruflin/Elastica/issues/764/)
+- Exception\ElasticsearchException now can be catched like all other exceptions as Exception\ExceptionInterface [#762](https://github.com/ruflin/Elastica/issues/762/)
+
+2015-01-25
+- Release v1.4.2.0
+
+2015-01-23
+- Added Elastica\Query\Regexp [#757](https://github.com/ruflin/Elastica/issues/757/)
+
+2015-01-19
+- Update to elasticsearch 1.4.2 [#378](https://github.com/ruflin/Elastica/issues/378/)
+- Remove support for PHP 5.3
+
+2015-01-14
+- added @return annotation to top_hits aggregation DSL method [#752](https://github.com/ruflin/Elastica/issues/752/)
+
+2015-01-07
+- Added Elastica\Aggregation\TopHits [#718](https://github.com/ruflin/Elastica/issues/718/)
+
+2015-01-05
+- Vagrantfile updated [#742](https://github.com/ruflin/Elastica/issues/742/)
+- Plugins updated to ES 1.3.4
+- Since new version of thrift plugin is compatible with ES 1.3.4, plugin added back to test environment
+
+2014-12-30
+- Added: Filter\Range::setExecution, Filter\Terms::setExecution, Filter\Missing::setExistence, Filter\Missing::setNullValue, Filter\HasChild::setMinumumChildrenCount, Filter\HasChild::Filter\HasChild::setMaximumChildrenCount, Filter\Indices::addIndex
+- Filter\HasChild::setType, Filter\HasParent::setType now support Type instance as argument
+- Filter\Indices::setIndices, Filter\Indices::addIndex now support Index instance as argument
+- (BC break) Removed as added by mistake: Filter\HasChild::setScope, Filter\HasParent::setScope, Filter\Nested::setScoreMode, Filter\Bool::setBoost
+
+2014-12-23
+- Additional Request Body Options for Percolator [#737](https://github.com/ruflin/Elastica/issues/737/)
+
+2014-12-19
+- making sure id is urlencoded when using updateDocument [#734](https://github.com/ruflin/Elastica/issues/734/)
+- Implement the `weight` in the function score query [#735](https://github.com/ruflin/Elastica/issues/735/)
+
+2014-12-09
+- Changed setRealWorldErrorLikelihood to setRealWordErrorLikelihood [#729](https://github.com/ruflin/Elastica/issues/729/)
+
+2014-11-23
+- allow to customize the key on a range aggregation [#728](https://github.com/ruflin/Elastica/issues/728/)
+
+2014-12-14
+- Added fluent interface to Elastica\Query::setRescore [#733](https://github.com/ruflin/Elastica/issues/733/)
+
+2014-11-30
+- Added transport to support egeloen/http-adapter [#727](https://github.com/ruflin/Elastica/issues/727/)
+
+2014-11-20
+- add cache control parameters support to Elastica\Filter\Bool [#725](https://github.com/ruflin/Elastica/issues/725/)
+
+2014-11-19
+- Avoid remove previously added params when adding a suggest to the query [#726](https://github.com/ruflin/Elastica/issues/726/)
+
+2014-11-16
+- Added Elastica\QueryBuilder [#724](https://github.com/ruflin/Elastica/issues/724/)
+- Update to elasticsearch 1.4.0
+- Disable official support for PHP 5.3
+
+2014-11-13
+- fixed reserved words in queries which composed of upper case letters (Util::replaceBooleanWords) [#722](https://github.com/ruflin/Elastica/issues/722/)
+
+2014-10-31
+- Adding PSR-4 autoloading support [#714](https://github.com/ruflin/Elastica/issues/714/)
+
+2014-10-29
+- Updated Type::getDocument() exception handling. \Elastica\Exception\ResponseException will be thrown instead of \Elastica\Exception\NotFoundException if the ES response contains any error (i.e: Missing index) (BC break) [#687](https://github.com/ruflin/Elastica/issues/687/)
+
+2014-10-22
+- Added Util::convertDateTimeObject to Util class to easily convert \DateTime objects to required format [#709](https://github.com/ruflin/Elastica/issues/709/)
+
+2014-10-15
+- Remove ResponseException catch in Type::getDocument() [#704](https://github.com/ruflin/Elastica/issues/704/)
+
+2014-10-10
+- Fixed Response::isOk() to work better with bulk update api [#702](https://github.com/ruflin/Elastica/issues/702/)
+- Adding magic __call() [#700](https://github.com/ruflin/Elastica/issues/700/)
+
+2014-10-05
+- ResultSet creation moved to static ResultSet::create() method [#690](https://github.com/ruflin/Elastica/issues/690/)
+- Accept an options array at Type::updateDocument() [#686](https://github.com/ruflin/Elastica/issues/686/)
+- Improve exception handling in Type::getDocument() [#693](https://github.com/ruflin/Elastica/issues/693/)
+
+2014-10-04
+- Release v1.3.4.0
+- Update to elasticsearch 1.3.4 [#691](https://github.com/ruflin/Elastica/issues/691/)
+
+2014-09-22
+- Update the branch alias in composer.json to match the library version [#683](https://github.com/ruflin/Elastica/issues/683/)
+
+2014-09-16
+- Update license in composer.json to match project [#681](https://github.com/ruflin/Elastica/issues/681/)
+
+2014-09-08
+- Delete execution permission from non-executable files [#677](https://github.com/ruflin/Elastica/issues/677/)
+
+2014-08-25
+- Top-level filter parameter in search has been renamed to post_filter [#669](https://github.com/ruflin/Elastica/issues/669/) [#670](https://github.com/ruflin/Elastica/issues/670/)
+- Deprecated: Elastica\Query::setFilter() is deprecated. Use Elastica\Query::setPostFilter() instead. [#669](https://github.com/ruflin/Elastica/issues/669/)
+- Deprecated: Elastica\Query::setPostFilter() passing filter as array is deprecated. Pass instance of AbstractFilter instead. [#669](https://github.com/ruflin/Elastica/issues/669/)
+
+2014-08-22
+- Fixed escaping of / character in Elastica\Util::escapeTerm(), removed usage of JSON_UNESCAPED_SLASHES in Elastica\JSON [#660](https://github.com/ruflin/Elastica/issues/660/)
+
+2014-08-06
+- Add connection pool and connection strategy
2014-07-26
- Release v1.3.0.0
- Prepare Elastica Release v1.3.0.0
2014-07-25
-- Update to elasticsearch version 1.3.0 http://www.elasticsearch.org/downloads/1-3-0/
+- Update to elasticsearch version 1.3.0 https://www.elastic.co/downloads/past-releases/1-3-0
2014-07-14
- - Add setQuery() method to Elastica\Query\ConstantScore #653
+ - Add setQuery() method to Elastica\Query\ConstantScore [#653](https://github.com/ruflin/Elastica/issues/653/)
2014-07-12
- - Be able to configure ES host/port via ENV var in test env #652
+ - Be able to configure ES host/port via ENV var in test env [#652](https://github.com/ruflin/Elastica/issues/652/)
2014-07-07
- - Fix FunstionScore Query random_score without seed bug. #647
+ - Fix FunstionScore Query random_score without seed bug. [#647](https://github.com/ruflin/Elastica/issues/647/)
2014-07-02
-- Add setPostFilter method to Elastica\Query (http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/_filtering_queries_and_aggregations.html#_post_filter) #645
+- Add setPostFilter method to Elastica\Query (http://www.elastic.co/guide/en/elasticsearch/guide/current/_post_filter.html) [#645](https://github.com/ruflin/Elastica/issues/645/)
2014-06-30
-- Add Reverse Nested aggregation (http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-reverse-nested-aggregation.html). #642
+- Add Reverse Nested aggregation (http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-reverse-nested-aggregation.html). [#642](https://github.com/ruflin/Elastica/issues/642/)
2014-06-14
- Release v1.2.1.0
-- Removed the requirement to set arguments filter and/or query in Filtered, according to the documentation: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-filtered-query.html #616
+- Removed the requirement to set arguments filter and/or query in Filtered, according to the documentation: http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-filtered-query.html [#616](https://github.com/ruflin/Elastica/issues/616/)
2014-06-13
-- Stop ClientTest->testDeleteIdsIdxStringTypeString from failing 1/3 of the time #634
-- Stop ScanAndScrollTest->testQuerySizeOverride from failing frequently for no reason #635
-- rework Document and Script so they can share some infrastructure allowing scripts to specify things like _retry_on_conflict and _routing #629
+- Stop ClientTest->testDeleteIdsIdxStringTypeString from failing 1/3 of the time [#634](https://github.com/ruflin/Elastica/issues/634/)
+- Stop ScanAndScrollTest->testQuerySizeOverride from failing frequently for no reason [#635](https://github.com/ruflin/Elastica/issues/635/)
+- rework Document and Script so they can share some infrastructure allowing scripts to specify things like _retry_on_conflict and _routing [#629](https://github.com/ruflin/Elastica/issues/629/)
2014-06-11
-- Allow bulk API deletes to be routed #631
+- Allow bulk API deletes to be routed [#631](https://github.com/ruflin/Elastica/issues/631/)
2014-06-10
- Update travis to elasticsearch 1.2.1, disable Thrift plugin as not compatible and fix incompatible tests
2014-06-04
-- Implement Boosting Query (http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-boosting-query.html) #625
+- Implement Boosting Query (http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-boosting-query.html) [#625](https://github.com/ruflin/Elastica/issues/625/)
2014-06-02
-- add retry_on_conflict support to bulk #623
+- add retry_on_conflict support to bulk [#623](https://github.com/ruflin/Elastica/issues/623/)
2014-06-01
-- toString updated to consider doc_as_upsert if sent an array source #622
+- toString updated to consider doc_as_upsert if sent an array source [#622](https://github.com/ruflin/Elastica/issues/622/)
2014-05-27
-- Fix Aggragations/Filter to work with es v1.2.0 #619
+- Fix Aggragations/Filter to work with es v1.2.0 [#619](https://github.com/ruflin/Elastica/issues/619/)
2014-05-25
-- Added Guzzle transport as an alternative to the default Http transport #618
-- Added Elastica\ScanAndScroll Iterator (http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/scan-scroll.html) #617
+- Added Guzzle transport as an alternative to the default Http transport [#618](https://github.com/ruflin/Elastica/issues/618/)
+- Added Elastica\ScanAndScroll Iterator (http://www.elastic.co/guide/en/elasticsearch/guide/current/scan-scroll.html) [#617](https://github.com/ruflin/Elastica/issues/617/)
2014-05-13
-- Add JSON compat library; Elasticsearch JSON flags and nicer error handling #614
+- Add JSON compat library; Elasticsearch JSON flags and nicer error handling [#614](https://github.com/ruflin/Elastica/issues/614/)
2014-05-12
- Update dev builds to phpunit 4.1.*
@@ -63,81 +304,81 @@ CHANGES
- Set processIsolation and backupGlobals to false to speed up tests. processIsolation was very slow with phpunit 4.0.19.
2014-05-05
-- Fix get settings on alaised index #608
-- Added named function for source filtering #605
-- Scroll type constant to Elastica\Search added #607
+- Fix get settings on alaised index [#608](https://github.com/ruflin/Elastica/issues/608/)
+- Added named function for source filtering [#605](https://github.com/ruflin/Elastica/issues/605/)
+- Scroll type constant to Elastica\Search added [#607](https://github.com/ruflin/Elastica/issues/607/)
2014-04-28
-- Added setAnalyzer method to Query\FuzzyLikeThis Class and fixed issue with params not being merged #611
-- Typo fixes #600, #602
-- Remove unreachable return statement #598
+- Added setAnalyzer method to Query\FuzzyLikeThis Class and fixed issue with params not being merged [#611](https://github.com/ruflin/Elastica/issues/611/)
+- Typo fixes [#600](https://github.com/ruflin/Elastica/issues/600/), [#602](https://github.com/ruflin/Elastica/issues/602/)
+- Remove unreachable return statement [#598](https://github.com/ruflin/Elastica/issues/598/)
2014-04-27
- Release v1.1.1.1
-- Fix missing use in TermsStats->setOrder() #597
-- Replace all instances of ElasticSearch with Elasticsearch #597
+- Fix missing use in TermsStats->setOrder() [#597](https://github.com/ruflin/Elastica/issues/597/)
+- Replace all instances of ElasticSearch with Elasticsearch [#597](https://github.com/ruflin/Elastica/issues/597/)
2014-04-24
-- Fixing the Bool filter with Bool filter children bug #594
+- Fixing the Bool filter with Bool filter children bug [#594](https://github.com/ruflin/Elastica/issues/594/)
2014-04-22
-- Remove useless echo in the Memcache Transport object #595
+- Remove useless echo in the Memcache Transport object [#595](https://github.com/ruflin/Elastica/issues/595/)
2014-04-21
-- escape \ by \\ #592
+- escape \ by \\ [#592](https://github.com/ruflin/Elastica/issues/592/)
2014-04-20
-- Handling of HasChild type parsing bug #585
-- Consolidate Index getMapping tests #591
-- Fix Type::getMapping when using an aliased index #588
+- Handling of HasChild type parsing bug [#585](https://github.com/ruflin/Elastica/issues/585/)
+- Consolidate Index getMapping tests [#591](https://github.com/ruflin/Elastica/issues/591/)
+- Fix Type::getMapping when using an aliased index [#588](https://github.com/ruflin/Elastica/issues/588/)
2014-04-19
- Release v1.1.1.0
-- Update to elasticsearch 1.1.1 http://www.elasticsearch.org/downloads/1-1-1/
+- Update to elasticsearch 1.1.1 https://www.elastic.co/downloads/past-releases/1-1-1
- Remove CustomFiltersScore and CustomScore query as removed in elasticsearch 1.1.0 https://github.com/elasticsearch/elasticsearch/pull/5076/files
- Update Node Info to use plugins instead of plugin (https://github.com/elasticsearch/elasticsearch/pull/5072)
-- Fix mapping issue for aliases #588
+- Fix mapping issue for aliases [#588](https://github.com/ruflin/Elastica/issues/588/)
2014-04-17
-- Only trap real JSON parse errors in Response class #586
+- Only trap real JSON parse errors in Response class [#586](https://github.com/ruflin/Elastica/issues/586/)
2014-04-09
-- Added Cardinality aggregation #581
+- Added Cardinality aggregation [#581](https://github.com/ruflin/Elastica/issues/581/)
-2014-04-7
-- Support for Terms filter lookup options #579
+2014-04-07
+- Support for Terms filter lookup options [#579](https://github.com/ruflin/Elastica/issues/579/)
2014-03-29
-- Update to elasticsearch 1.1.0 http://www.elasticsearch.org/downloads/1-1-0/
+- Update to elasticsearch 1.1.0 https://www.elastic.co/downloads/past-releases/1-1-0
2014-03-26
-- Fixed Query\Match Fuzziness parameter type #576
+- Fixed Query\Match Fuzziness parameter type [#576](https://github.com/ruflin/Elastica/issues/576/)
2014-03-24
- Release v1.0.1.2
-- Added Filter\Indices #574
+- Added Filter\Indices [#574](https://github.com/ruflin/Elastica/issues/574/)
2014-03-25
-- Allow json string as data srouce for Bulk\Action on update #575
+- Allow json string as data srouce for Bulk\Action on update [#575](https://github.com/ruflin/Elastica/issues/575/)
2014-03-20
-- Allow for request params in delete by query calls #573
+- Allow for request params in delete by query calls [#573](https://github.com/ruflin/Elastica/issues/573/)
2014-03-17
-- Added filters: AbstractGeoShape, GeoShapePreIndexed, GeoShapeProvided #568
+- Added filters: AbstractGeoShape, GeoShapePreIndexed, GeoShapeProvided [#568](https://github.com/ruflin/Elastica/issues/568/)
2014-03-15
-- Percolate existing documents and add percolate options (#570)
+- Percolate existing documents and add percolate options ([#570](https://github.com/ruflin/Elastica/issues/570/))
2014-03-14
-- Added Query\Rescore #441
+- Added Query\Rescore [#441](https://github.com/ruflin/Elastica/issues/441/)
2014-03-13
-- Added missing query options for MultiMatch (operator, minimum_should_match, zero_terms_query, cutoff_frequency, type, fuzziness, prefix_length, max_expansions, analyzer) #569
-- Added missing query options for Match (zero_terms_query, cutoff_frequency) #569
+- Added missing query options for MultiMatch (operator, minimum_should_match, zero_terms_query, cutoff_frequency, type, fuzziness, prefix_length, max_expansions, analyzer) [#569](https://github.com/ruflin/Elastica/issues/569/)
+- Added missing query options for Match (zero_terms_query, cutoff_frequency) [#569](https://github.com/ruflin/Elastica/issues/569/)
2014-03-11
-- Fixed request body reuse in http transport #567
+- Fixed request body reuse in http transport [#567](https://github.com/ruflin/Elastica/issues/567/)
2014-03-08
- Release v1.0.1.1
@@ -147,28 +388,28 @@ CHANGES
- Update to memcache 3.0.8 for travis
2014-03-07
-- Add snapshot / restore functionality (Elastica\Snapshot) #566
+- Add snapshot / restore functionality (Elastica\Snapshot) [#566](https://github.com/ruflin/Elastica/issues/566/)
2014-03-04
- Add PHP 5.6 to travis test environment
-- Improve performance of Elastica/Status->getIndicesWithAlias and aliasExists on clusters with many indices #563
+- Improve performance of Elastica/Status->getIndicesWithAlias and aliasExists on clusters with many indices [#563](https://github.com/ruflin/Elastica/issues/563/)
2014-03-02
- Release v1.0.1.0
-- Fixed Type->deleteByQuery() not working with Query objects #554
+- Fixed Type->deleteByQuery() not working with Query objects [#554](https://github.com/ruflin/Elastica/issues/554/)
2014-02-27
- Update to elasticsearch 1.0.1. Update Thrift and Geocluster plugin.
2014-02-25
-- Add JSON_UNESCAPED_UNICODE and JSON_UNESCAPED_SLASHES options in Elastica/Transport/Http, Elastica/Bulk/Action #559
+- Add JSON_UNESCAPED_UNICODE and JSON_UNESCAPED_SLASHES options in Elastica/Transport/Http, Elastica/Bulk/Action [#559](https://github.com/ruflin/Elastica/issues/559/)
2014-02-20
-- Fixed unregister percolator (still used _percolator instead of .percolator). removed duplicate slash from register percolator route. #558
+- Fixed unregister percolator (still used _percolator instead of .percolator). removed duplicate slash from register percolator route. [#558](https://github.com/ruflin/Elastica/issues/558/)
2014-02-17
- Throw PartialShardFailureException if response has failed shards
-- Elastica/Aggregations/GlobalAggragation not allowed as sub aggragation #555
+- Elastica/Aggregations/GlobalAggragation not allowed as sub aggragation [#555](https://github.com/ruflin/Elastica/issues/555/)
2014-02-14
- Add methods setSize, setShardSize to Elastica/Aggregation/Terms
@@ -180,13 +421,13 @@ CHANGES
2014-02-12
- Release v1.0.0.0
-- Updated to elasticsearch 1.0: http://www.elasticsearch.org/blog/1-0-0-released/
+- Updated to elasticsearch 1.0: https://www.elastic.co/blog/1-0-0-released/
2014-02-11
- Add aggregations
2014-02-08
-- Setting shard timeout doesn't work #547
+- Setting shard timeout doesn't work [#547](https://github.com/ruflin/Elastica/issues/547/)
2014-02-04
- Remove Elastica\Query\Field and Elastica\Query\Text, which are not supported in ES 1.0.0.RC1
@@ -268,16 +509,16 @@ CHANGES
- \Elastica\Search::addSuggest() has been renamed to \Elastica\Search::setSuggest()
- \Elastica\Query::addSuggest() has been renamed to \Elastica\Query::setSuggest()
- Add \Elastica\Suggest\Phrase, \Elastica\Suggest\CandidateGenerator\AbstractCandidateGenerator, and \Elastica\Suggest\CandidateGenerator\DirectGenerator
- (see http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-suggesters-phrase.html)
+ (see http://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-phrase.html)
2013-12-04
- Remove boost from FunctionScore::addFunction because this is not supported by elasticsearch
2013-12-02
-- Issue #491 resolved
+- Issue [#491](https://github.com/ruflin/Elastica/issues/491/) resolved
2013-12-01
-- Issue #501 resolved
+- Issue [#501](https://github.com/ruflin/Elastica/issues/501/) resolved
- satooshi/php-coveralls package added for coverall.io
- Multiple badges for downloads and latest stable release added
@@ -295,18 +536,18 @@ CHANGES
- Added \Elastica\Filter\Regexp
2013-11-16
-- Remove wrong documentation for "no limit" #496
+- Remove wrong documentation for "no limit" [#496](https://github.com/ruflin/Elastica/issues/496/)
- Update to elasticsearch 0.90.7
2013-11-03
-- Issue #490: Set Elastica\Query\FunctionScore::DECAY_EXPONENTIAL to "exp" instead of "exponential"
+- Issue [#490](https://github.com/ruflin/Elastica/issues/490/): Set Elastica\Query\FunctionScore::DECAY_EXPONENTIAL to "exp" instead of "exponential"
2013-10-29
- Elastica_Type::exists() added
- See http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-types-exists.html#indices-types-exists
+ See http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-types-exists.html#indices-types-exists
2013-10-27
-- Adapted possible values (not only in) for minimum_should_match param based on elasticsearch documetnation http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-minimum-should-match.html
+- Adapted possible values (not only in) for minimum_should_match param based on elasticsearch documetnation http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-minimum-should-match.html
2013-10-27
- Release v0.90.5.0
@@ -323,7 +564,7 @@ CHANGES
2013-09-20
- Update to geocluster-facet 0.0.8
- Add support for term suggest API
- See http://www.elasticsearch.org/guide/reference/api/search/term-suggest/
+ See http://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-term.html
2013-09-18
- Fix \Elastica\Filter\HasChild usage of \Elastica\Query as to not collide with \Elastica\Filter\Query namespace
@@ -418,7 +659,7 @@ CHANGES
- Update Index\Status::getSettings() to use new API
2013-05-29
-- Add _meta to mapping. #330
+- Add _meta to mapping. [#330](https://github.com/ruflin/Elastica/issues/330/)
2013-05-27
- Added parameters to implement scroll
@@ -435,8 +676,8 @@ CHANGES
- Elastica\Index::exists fixed for 0.90.0. HEAD request method introduced
- Elastica\Filter\AbstractMulti::getFilters() added
- Implement Elastica\Type\Mapping::enableAllField
-- Refresh for Elastica\Index::flush implemented #316
-- Added optional parameter to filter result while percolate #384
+- Refresh for Elastica\Index::flush implemented [#316](https://github.com/ruflin/Elastica/issues/316/)
+- Added optional parameter to filter result while percolate [#384](https://github.com/ruflin/Elastica/issues/384/)
2013-05-07
- Added EXPERIMENTAL DocumentObjectInterface to be used with Type::addObject()/addObjects()
@@ -571,7 +812,7 @@ CHANGES
2012-03-04
- Node info call update. The receive os info and more, param is needed. By default, only basics are returned
-- Release v0.19.0.0 which is compatible with ES 0.19.0 http://www.elasticsearch.org/blog/2012/03/01/0.19.0-released.html
+- Release v0.19.0.0 which is compatible with ES 0.19.0 https://www.elastic.co/downloads/past-releases/0-19-0
2012-02-21
- Allow percolate queries in bulk requests
@@ -584,8 +825,8 @@ CHANGES
- Vagrantfile for vagrant environment with elasticsearch added. Run: vagrant up
2012-01-08
-- Allow to set curl params over client config #106 #107
-- Add the possiblity to add path or url in config for a request #120
+- Allow to set curl params over client config [#106](https://github.com/ruflin/Elastica/issues/106/) [#107](https://github.com/ruflin/Elastica/issues/107/)
+- Add the possiblity to add path or url in config for a request [#120](https://github.com/ruflin/Elastica/issues/120/)
2012-01-04
- Elastica_Index::exists() and Elastica_Cluster::getIndexNames() added
@@ -670,7 +911,7 @@ CHANGES
- Https transport layer added
2011-08-22
-- Typo in Terms query fixed (issue #74)
+- Typo in Terms query fixed (issue [#74](https://github.com/ruflin/Elastica/issues/74/))
2011-08-15
- Refactoring HTTP connection to keep alive connection -> speed improvement during using the same client
@@ -727,7 +968,7 @@ CHANGES
- Release tag v0.16.4.0 added
2011-06-19
-- Add support for multiple servers to Elastica_Client (issue #39)
+- Add support for multiple servers to Elastica_Client (issue [#39](https://github.com/ruflin/Elastica/issues/39/))
2011-06-16
- Support for multiple index, type queries and _all queries added through Elastica_Search object
@@ -745,7 +986,7 @@ CHANGES
2011-04-29
- Added getParam to Elastica_Result that more values can be retrieved from the hit array
-- Elastica_Filter_Ids added http://www.elasticsearch.org/guide/reference/query-dsl/ids-filter.html
+- Elastica_Filter_Ids added http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-ids-filter.html
- getMergePolicyMergeFactor and getRefreshInterval to Elastica_Type_Settings added. If no value is set, default values are returned
2011-04-28
@@ -783,7 +1024,7 @@ CHANGES
2011-03-24
- Renaming of Elastica_Status_Index to Elastica_Index_Status => API Change!
-- IndexSettings added for improved bulk updating http://www.elasticsearch.org/blog/2011/03/23/update-settings.html
+- IndexSettings added for improved bulk updating http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html
2011-03-21
- Node object added
diff --git a/vendor/ruflin/elastica/CONTRIBUTING.md b/vendor/ruflin/elastica/CONTRIBUTING.md
new file mode 100644
index 00000000..aff25716
--- /dev/null
+++ b/vendor/ruflin/elastica/CONTRIBUTING.md
@@ -0,0 +1,75 @@
+Contributing
+============
+Help is very welcomed. Code contributions must be done in respect of [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md).
+More details on how to contribute and guidelines for [pull requests](http://elastica.io/contribute/pull-request.html) can be found [here](http://elastica.io/contribute/).
+
+See [Coding guidelines](http://elastica.io/contribute/coding-guidelines.html) for tips on how to do so.
+All changes must be documented in the [CHANGELOG.md](https://github.com/ruflin/Elastica/blob/master/CHANGELOG.md).
+
+
+Issues
+------
+* Bugs & Feature requests: If you found a bug, open an issue on [Github](https://github.com/ruflin/Elastica/issues). Please search for already reported similary issues before opening a new one. You should include code examples (with dependencies if needed) and your Elastica version to the issue description.
+* Questions & Problems: If you have questions or a specific problem, use the [Elastica Gitter](https://gitter.im/ruflin/Elastica) Chat or open an issue on [Stackoverflow](http://stackoverflow.com/questions/tagged/elastica). Make sure to assign the tag Elastica.
+
+
+Setup
+-----
+Elastica currently allows two setups for development. Either through vagrant or docker-compose. To use the vagrant environment, run `vagrant up`. To use the docker environment, check out the Makefile for the necessary commands.
+* Run your changes / tests in the virtual environment to make sure it is reproducible.
+* Run the tests before creating the pull request using vagrant or docker-compose locally.
+
+Commands
+--------
+To run the commands below, you must have docker-compose [installed](https://docs.docker.com/compose/install/). The first time the commands are run it takes some time to download all the partial images. Form then on the commands should run very fast. The advantage in using the commands below is that no local tools and libraries have to be installed and it is guaranteed that everytone is using the same tools.
+
+## Run Tests
+
+To run all tests inside the docker environment, run the following command:
+
+```
+make run RUN="make phpunit"
+```
+
+If you want to run just a specific test or a one specific file, run the following command by replacing your file with the existingpath:
+
+```
+ make run RUN="phpunit -c ./test lib/Elastica/Test/SearchTest.php"
+```
+
+## Check style of your code
+This command will call php-cs-fixer with the predefined settings for the elastica project. No local setup of the tools is needed as everything will happen directly in the container.
+```
+make run RUN="make lint"
+```
+
+
+
+
+Coding
+------
+
+### Rules
+* Pull requests are made to master. Changes are never pushed directly (without pull request) into master.
+* We use the Forking Workflow. https://www.atlassian.com/git/tutorials/comparing-workflows/forking-workflow
+* Follow the coding guidelines.
+* Use a feature branch for every pull request. Don't open a pull request from your master branch.
+
+### Pull Requests
+* One change per pull requests: Keep your pull requests as small as possible. Only one change should happen per pull request. This makes it easier to review and provided feedback. If you have a large pull request, try to split it up in multiple smaller requests.
+* Commit messages: Make sure that your commit messages have meaning and provide an understanding on what was changed without looking at the code.
+* Pull requests should be opened as early as possible as pull requests are also here for communication / discussing changes. Add a comment when your pull request is ready to be merged.
+* Tests: Your addition / change must be tested and the builds must be green. Test your changes locally. Add unit tests and if possible functional tests. Don't forget to add the group to your tests. The 4 available groups are @functional, @unit, @shutdown, @benchmark
+* Update the CHANGELOG.md file with your changes
+* Backward Compatibility breaks: In case you break backward compatibility, provide details on why this is needed.
+* Merge: No one should ever merge his own pull request
+
+
+### Name Spaces & Classes
+Most name spaces and classes are self explanotary and use cases can be taken from classes which already exist.
+
+#### Tool Namespace
+The namespace Tool is used for making more complex functionality of Elastica available to the users. In general it maps existing functionality of Elastica and offers simplified functions.
+
+#### Util Class
+The util class is used for all static functions which are used in the Elastica library but don't access the library itself.
diff --git a/vendor/ruflin/elastica/Dockerfile b/vendor/ruflin/elastica/Dockerfile
new file mode 100644
index 00000000..c5055c5e
--- /dev/null
+++ b/vendor/ruflin/elastica/Dockerfile
@@ -0,0 +1,58 @@
+# PHP 6 Docker file with Composer installed
+FROM composer/composer
+
+RUN apt-get update
+RUN apt-get upgrade -y
+RUN apt-get install -y nano
+RUN apt-get install -y cloc
+
+# XSL and Graphviz for PhpDocumentor
+RUN apt-get install -y php5-xsl
+# TODO: Debian is putting the xsl extension in a different directory, should be in: /usr/local/lib/php/extensions/no-debug-non-zts-20131226
+RUN echo "extension=/usr/lib/php5/20131226/xsl.so" >> /usr/local/etc/php/conf.d/xsl.ini
+RUN apt-get install -y graphviz
+
+
+RUN echo "date.timezone=UTC" >> /usr/local/etc/php/conf.d/timezone.ini
+
+# Xdebug for coverage report
+RUN apt-get install -y php5-xdebug
+RUN echo "zend_extension=/usr/lib/php5/20131226/xdebug.so" >> /usr/local/etc/php/conf.d/xdebug.ini
+
+# Memcache
+RUN apt-get install -y php5-memcache
+RUN echo "extension=/usr/lib/php5/20131226/memcache.so" >> /usr/local/etc/php/conf.d/memcache.ini
+
+# Add composer bin to the environment
+ENV PATH=/root/composer/vendor/bin:$PATH
+
+# Overcome github access limits. GITHUB_OAUTH_TOKEN environment variable must be set with private token
+RUN composer self-update
+
+# Install development tools
+RUN composer global require "phpunit/phpunit=~4.7"
+RUN composer global require "pdepend/pdepend=~2.0"
+RUN composer global require "phpmd/phpmd=~2.2"
+RUN composer global require "mayflower/php-codebrowser=~1.1"
+RUN composer global require "sebastian/phpcpd=~2.0"
+RUN composer global require "squizlabs/php_codesniffer=~2.3"
+RUN composer global require "phploc/phploc=~2.1"
+RUN composer global require "fabpot/php-cs-fixer=1.8.1"
+
+
+# Documentor dependencies
+RUN composer global require "phpdocumentor/template-zend=~1.3"
+RUN composer global require "phpdocumentor/phpdocumentor=~2.8"
+
+# Install depdencies
+WORKDIR /app
+COPY composer.json /app/
+RUN composer install
+
+# Guzzle is not included composer.json because of PHP 5.3
+RUN composer require "guzzlehttp/guzzle=~6.0"
+
+ENTRYPOINT []
+
+ENV ES_HOST elasticsearch
+ENV PROXY_HOST nginx
diff --git a/vendor/ruflin/elastica/Makefile b/vendor/ruflin/elastica/Makefile
new file mode 100644
index 00000000..c033784b
--- /dev/null
+++ b/vendor/ruflin/elastica/Makefile
@@ -0,0 +1,108 @@
+#/bin/bash
+
+BASEDIR = $(shell pwd)
+SOURCE = "${BASEDIR}/lib"
+IMAGE = "elastica"
+
+
+### Setups around project sources. These commands should run ###
+init: prepare
+ composer install
+
+prepare:
+ mkdir -p ${BASEDIR}/build/api
+ mkdir -p ${BASEDIR}/build/code-browser
+ mkdir -p ${BASEDIR}/build/coverage
+ mkdir -p ${BASEDIR}/build/logs
+ mkdir -p ${BASEDIR}/build/docs
+ mkdir -p ${BASEDIR}/build/pdepend
+
+update: init
+
+clean:
+ rm -r -f ${BASEDIR}/build
+ #rm ${BASEDIR}/cache.properties
+
+
+# Handling virtual environment
+
+build:
+ docker-compose build
+
+setup: build
+ docker-compose scale elasticsearch=3
+
+start:
+ docker-compose up
+
+stop:
+ docker-compose stop
+
+destroy: clean
+ docker-compose kill
+ docker-compose rm
+
+# Runs commands inside virtual environemnt. Example usage inside docker: make run RUN="make phpunit"
+run:
+ docker-compose run elastica $(RUN)
+
+
+### Quality checks / development tools ###
+
+checkstyle:
+ phpcs --standard=PSR2 ${SOURCE}
+
+checkstyle-ci: prepare
+ phpcs --report=checkstyle --report-file=${BASEDIR}/build/logs/checkstyle.xml --standard=PSR2 ${SOURCE} > /dev/null
+
+code-browser: prepare
+ phpcb --log ${BASEDIR}/build/logs --source ${SOURCE} --output ${BASEDIR}/build/code-browser
+
+# Copy paste detector
+cpd: prepare
+ phpcpd --log-pmd ${BASEDIR}/build/logs/pmd-cpd.xml ${SOURCE}
+
+messdetector: prepare
+ phpmd ${SOURCE} text codesize,unusedcode,naming,design ${BASEDIR}/build/phpmd.xml
+
+messdetector-ci: prepare
+ phpmd ${SOURCE} xml codesize,unusedcode,naming,design --reportfile ${BASEDIR}/build/logs/pmd.xml
+
+dependencies: prepare
+ pdepend --jdepend-xml=${BASEDIR}/build/logs/jdepend.xml \
+ --jdepend-chart=${BASEDIR}/build/pdepend/dependencies.svg \
+ --overview-pyramid=${BASEDIR}/build/pdepend/overview-pyramid.svg \
+ ${SOURCE}
+
+phpunit: prepare
+ phpunit -c test/ --coverage-clover build/coverage/unit-coverage.xml --group unit
+ phpunit -c test/ --coverage-clover build/coverage/functional-coverage.xml --group functional
+ phpunit -c test/ --coverage-clover build/coverage/shutdown-coverage.xml --group shutdown
+
+doc: prepare
+ phpdoc run -d lib/ -t build/docs
+
+# Uses the preconfigured standards in .php_cs
+lint:
+ php-cs-fixer fix
+
+syntax-check:
+ php -lf ${SOURCE} **/*.php
+ php -lf ${BASEDIR}/test **/*.php
+
+
+loc:
+ cloc --by-file --xml --exclude-dir=build -out=build/cloc.xml .
+
+phploc:
+ phploc --log-csv $(BASEDIR)/build/logs/phploc.csv $(SOURCE)
+
+
+
+# Visualise repo
+gource:
+ gource --log-format git \
+ --seconds-per-day 0.1 \
+ --title 'Elastica (https://github.com/ruflin/Elastica)' \
+ --user-scale 1 \
+ --max-user-speed 50
diff --git a/vendor/ruflin/elastica/README.markdown b/vendor/ruflin/elastica/README.markdown
deleted file mode 100644
index a94e9ba3..00000000
--- a/vendor/ruflin/elastica/README.markdown
+++ /dev/null
@@ -1,29 +0,0 @@
-Elastica: elasticsearch PHP Client
-==================================
-
-[![Latest Stable Version](https://poser.pugx.org/ruflin/Elastica/v/stable.png)](https://packagist.org/packages/ruflin/elastica)
-[![Build Status](https://secure.travis-ci.org/ruflin/Elastica.png?branch=master)](http://travis-ci.org/ruflin/Elastica)
-[![Coverage Status](https://coveralls.io/repos/ruflin/Elastica/badge.png)](https://coveralls.io/r/ruflin/Elastica)
-[![Dependency Status](https://www.versioneye.com/php/ruflin:Elastica/master/badge.png)](https://www.versioneye.com/php/ruflin:elastica/)
-[![Total Downloads](https://poser.pugx.org/ruflin/Elastica/downloads.png)](https://packagist.org/packages/ruflin/elastica)
-
-All documentation for Elastica can be found under [Elastica.io](http://Elastica.io/). If you have questions, don't hesitate to ask them in the [Elastica google group](https://groups.google.com/group/elastica-php-client). All library issues should go to the [issue tracker from github](https://github.com/ruflin/Elastica/issues).
-
-Contributing
-------------
-Help is very welcomed, but code contributions must be done in respect of [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md). More details on how to contribute and guidelines for [pull requests](http://elastica.io/contribute/pull-request.html) can be found [here](http://elastica.io/contribute/).
-
-See [Coding guidelines](http://elastica.io/contribute/coding-guidelines.html) for tips on how to do so. All changes which are made to the project are added to the [changes.txt](https://github.com/ruflin/Elastica/blob/master/changes.txt).
-
-
-Dependencies
-------------
-| Project | Version | Required |
-|---------|---------|----------|
-|[Elasticsearch](https://github.com/elasticsearch/elasticsearch/tree/v1.1.1)|1.1.1|yes|
-|[Elasticsearch mapper attachments plugin](https://github.com/elasticsearch/elasticsearch-mapper-attachments/tree/v2.0.0.RC1)|2.0.0.RC1|no|
-|[Elasticsearch thrift transport plugin](https://github.com/elasticsearch/elasticsearch-transport-thrift/tree/v2.0.0)|2.0.0|no|
-|[Elasticsearch geocluster facet plugin](https://github.com/zenobase/geocluster-facet/tree/0.0.10)|0.0.10|no|
-
-
-
diff --git a/vendor/ruflin/elastica/README.md b/vendor/ruflin/elastica/README.md
new file mode 100644
index 00000000..b6cf5376
--- /dev/null
+++ b/vendor/ruflin/elastica/README.md
@@ -0,0 +1,31 @@
+Elastica: elasticsearch PHP Client
+==================================
+
+[![Latest Stable Version](https://poser.pugx.org/ruflin/Elastica/v/stable.png)](https://packagist.org/packages/ruflin/elastica)
+[![Build Status](https://secure.travis-ci.org/ruflin/Elastica.png?branch=master)](http://travis-ci.org/ruflin/Elastica)
+[![codecov.io](http://codecov.io/github/ruflin/Elastica/coverage.svg?branch=master)](http://codecov.io/github/ruflin/Elastica?branch=master)
+[![Dependency Status](https://www.versioneye.com/php/ruflin:elastica/dev-master/badge.svg)](https://www.versioneye.com/php/ruflin:elastica/dev-master)
+[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/ruflin/Elastica/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/ruflin/Elastica/?branch=master)
+[![Total Downloads](https://poser.pugx.org/ruflin/Elastica/downloads.png)](https://packagist.org/packages/ruflin/elastica)
+[![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=ruflin&url=https://github.com/ruflin/Elastica&title=Elastica&language=PHP&tags=github&category=software)
+[![Join the chat at https://gitter.im/ruflin/Elastica](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ruflin/Elastica?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
+
+All documentation for Elastica can be found under [Elastica.io](http://Elastica.io/).
+If you have questions, don't hesitate to ask them on [Stackoverflow](http://stackoverflow.com/questions/tagged/elastica) and add the Tag "Elastica" or
+in our [Gitter](https://gitter.im/ruflin/Elastica) channel.
+All library issues should go to the [issue tracker from github](https://github.com/ruflin/Elastica/issues).
+
+Contributing
+------------
+Contributions are always welcome. For details on how to contribute, check the [CONTRIBUTING](https://github.com/ruflin/Elastica/blob/master/CONTRIBUTING.md) file.
+
+Dependencies
+------------
+| Project | Version | Required |
+|---------|---------|----------|
+|[Elasticsearch](https://github.com/elasticsearch/elasticsearch/tree/v1.6.0)|1.6.0|yes|
+|[Elasticsearch mapper attachments plugin](https://github.com/elasticsearch/elasticsearch-mapper-attachments/tree/v2.6.0)|2.6.0|no|
+|[Elasticsearch thrift transport plugin](https://github.com/elasticsearch/elasticsearch-transport-thrift/tree/v2.6.0)|2.6.0|no|
+|[Elasticsearch memcached transport plugin](https://github.com/elastic/elasticsearch-transport-memcached/tree/v2.6.0)|2.6.0|no|
+|[Elasticsearch geocluster facet plugin](https://github.com/zenobase/geocluster-facet/tree/0.0.12)|0.0.12|no|
+|[Elasticsearch image plugin](https://github.com/SibaTokyo/elasticsearch-image/tree/1.4.0)|1.4.0|no|
diff --git a/vendor/ruflin/elastica/Vagrantfile b/vendor/ruflin/elastica/Vagrantfile
index e8cd5533..2deebbd4 100644
--- a/vendor/ruflin/elastica/Vagrantfile
+++ b/vendor/ruflin/elastica/Vagrantfile
@@ -1,14 +1,18 @@
-# Elastica debian image
-#
-# All passwords and username (db, ...) are root / root
-#
-# The image has 2GB of memory and a size of 10GB
-
-Vagrant::Config.run do |config|
-
- config.vm.box = "debian-6.0.3-64-elastica-20120115"
- config.vm.box_url = "http://files.ruflin.com/vagrant/debian-6.0.3-64-elastica-20120528.box"
- config.vm.network :hostonly, "10.10.10.10"
-
- config.vm.share_folder "project", "/project", "."
+
+Vagrant.require_version ">= 1.4.0"
+
+Vagrant.configure("2") do |config|
+
+ config.vm.box = "ubuntu/precise32"
+
+ config.vm.network :private_network, ip: "10.10.10.10"
+
+ config.vm.provision "shell" do |sh|
+ sh.inline = "/bin/bash /vagrant/ansible/provision.sh"
+ end
+
+ config.vm.provider :virtualbox do |vb|
+ vb.customize ["modifyvm", :id, "--memory", "1024"]
+ end
+
end
diff --git a/vendor/ruflin/elastica/ansible/es-playbook.yml b/vendor/ruflin/elastica/ansible/es-playbook.yml
new file mode 100644
index 00000000..3a471b64
--- /dev/null
+++ b/vendor/ruflin/elastica/ansible/es-playbook.yml
@@ -0,0 +1,20 @@
+---
+
+- name: Create a virtual machine
+ connection: local
+ hosts: localhost
+ sudo: true
+ vars:
+ - ES_VER: "1.6.0"
+ - ES_SHORT_VER: "1.6"
+ - ES_MAPPER_ATTACHMENTS_VER: "2.6.0"
+ - ES_TRANSPORT_MEMCACHED_VER: "2.6.0"
+ - ES_TRANSPORT_THRIFT_VER: "2.6.0"
+ - ES_GEOCLUSTER_FACET_VER: "0.0.12"
+ - ES_IMAGE_PLUGIN_VER: "1.4.0"
+ - ES_PROJECT_ROOT: "{{ lookup('env', 'ES_PROJECT_ROOT') }}"
+ roles:
+ - base
+ - elasticsearch
+ - nginx
+ - php
diff --git a/vendor/ruflin/elastica/ansible/provision.sh b/vendor/ruflin/elastica/ansible/provision.sh
new file mode 100755
index 00000000..6ea8e575
--- /dev/null
+++ b/vendor/ruflin/elastica/ansible/provision.sh
@@ -0,0 +1,63 @@
+#!/bin/bash
+
+set -o xtrace
+
+install_ansible() {
+ sudo apt-get update
+ sudo apt-get install python python-pip python-dev -y
+ sudo pip install ansible==1.8.2
+ sudo mkdir -p /etc/ansible/
+ echo "localhost" | sudo tee /etc/ansible/hosts
+}
+
+run_playbook() {
+ # Write to stdout directly
+ export PYTHONUNBUFFERED=1
+
+ # No cows >_<
+ export ANSIBLE_NOCOWS=1
+
+ # Root of git repo
+ if [ -z "$ES_PROJECT_ROOT" ]; then
+ export ES_PROJECT_ROOT="$(dirname $(dirname $(readlink -f $0)))"
+ fi
+
+ if [ ! -x $(which ansible-playbook) ]; then
+ echo "Ansible is not installed"
+ return 1
+ fi
+
+ ansible-playbook $ES_PROJECT_ROOT/ansible/es-playbook.yml -v | tee /tmp/ansible-playbook-progress
+
+ if grep -q "FATAL\|ERROR" /tmp/ansible-playbook-progress; then
+ return 1
+ fi
+}
+
+check_cluster() {
+ curl -m 5 -s -o /dev/null "http://localhost:9200" &&
+ curl -m 5 -s -o /dev/null "http://localhost:9201"
+ return $?
+}
+
+travis_retry() {
+ # We don't use builtin Travis CI function, because this script is also used for vagrant provision.
+ # But main idea of restarts is so simple, so lets override it without name change.
+
+ $@ && return 0
+
+ echo "The command $@ failed. Retrying, 2 of 3"
+ sleep 60s && $@ && return 0
+
+ echo "The command $@ failed. Retrying, 3 of 3"
+ sleep 60s && $@ && return 0
+
+ echo "The command $@ failed."
+ return 1
+}
+
+travis_retry install_ansible || exit 1
+
+travis_retry run_playbook || exit 1
+
+travis_retry check_cluster || exit 1
diff --git a/vendor/ruflin/elastica/ansible/roles/base/tasks/main.yml b/vendor/ruflin/elastica/ansible/roles/base/tasks/main.yml
new file mode 100644
index 00000000..061b8155
--- /dev/null
+++ b/vendor/ruflin/elastica/ansible/roles/base/tasks/main.yml
@@ -0,0 +1,13 @@
+---
+
+- name: install base packages
+ apt: >
+ force=yes
+ name={{ item }}
+ state=present
+ update_cache=no
+ with_items:
+ - curl
+ - git
+ - htop
+ - vim
diff --git a/vendor/ruflin/elastica/ansible/roles/elasticsearch/handlers/main.yml b/vendor/ruflin/elastica/ansible/roles/elasticsearch/handlers/main.yml
new file mode 100644
index 00000000..97cccdd2
--- /dev/null
+++ b/vendor/ruflin/elastica/ansible/roles/elasticsearch/handlers/main.yml
@@ -0,0 +1,6 @@
+---
+
+- name: restart elasticsearch
+ service: >
+ name=elasticsearch
+ state=restarted
diff --git a/vendor/ruflin/elastica/ansible/roles/elasticsearch/tasks/main.yml b/vendor/ruflin/elastica/ansible/roles/elasticsearch/tasks/main.yml
new file mode 100644
index 00000000..c2041343
--- /dev/null
+++ b/vendor/ruflin/elastica/ansible/roles/elasticsearch/tasks/main.yml
@@ -0,0 +1,101 @@
+---
+
+- name: import ppa:webupd8team/java gpg key
+ apt_key: >
+ id=EEA14886
+ keyserver=keyserver.ubuntu.com
+ state=present
+
+- name: add ppa:webupd8team/java repository
+ apt_repository: >
+ repo="deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main"
+ state=present
+ update_cache=yes
+
+- name: accept oracle license
+ shell: >
+ echo "oracle-java7-installer shared/accepted-oracle-license-v1-1 select true" | debconf-set-selections
+
+- name: install java
+ apt: >
+ force=yes
+ name={{ item }}
+ state=present
+ update_cache=no
+ with_items:
+ - oracle-java7-installer
+ - oracle-java7-set-default
+
+- name: import elasticsearch gpg key
+ apt_key: >
+ id=D88E42B4
+ url=https://packages.elasticsearch.org/GPG-KEY-elasticsearch
+ state=present
+
+- name: add elasticsearch repository
+ apt_repository: >
+ repo="deb http://packages.elasticsearch.org/elasticsearch/{{ ES_SHORT_VER }}/debian stable main"
+ state=present
+ update_cache=yes
+
+- name: install elasticsearch
+ apt: >
+ force=yes
+ name=elasticsearch={{ ES_VER }}
+ state=present
+ update_cache=no
+
+- name: install image plugin
+ command: >
+ creates=/usr/share/elasticsearch/plugins/image
+ /usr/share/elasticsearch/bin/plugin --url https://github.com/SibaTokyo/elasticsearch-image/releases/download/{{ ES_IMAGE_PLUGIN_VER }}/elasticsearch-image-{{ ES_IMAGE_PLUGIN_VER }}.zip -install image
+
+- name: install mapper-attachments plugin
+ command: >
+ creates=/usr/share/elasticsearch/plugins/mapper-attachments
+ /usr/share/elasticsearch/bin/plugin -install elasticsearch/elasticsearch-mapper-attachments/{{ ES_MAPPER_ATTACHMENTS_VER }}
+
+- name: install geocluster-facet plugin
+ command: >
+ creates=/usr/share/elasticsearch/plugins/geocluster-facet
+ /usr/share/elasticsearch/bin/plugin -install geocluster-facet --url https://github.com/zenobase/geocluster-facet/releases/download/{{ ES_GEOCLUSTER_FACET_VER }}/geocluster-facet-{{ ES_GEOCLUSTER_FACET_VER }}.jar
+
+- name: install transport-thrift plugin
+ command: >
+ creates=/usr/share/elasticsearch/plugins/transport-thrift
+ /usr/share/elasticsearch/bin/plugin -install elasticsearch/elasticsearch-transport-thrift/{{ ES_TRANSPORT_THRIFT_VER }}
+
+- name: install transport-memcached plugin
+ command: >
+ creates=/usr/share/elasticsearch/plugins/transport-memcached
+ /usr/share/elasticsearch/bin/plugin -install elasticsearch/elasticsearch-transport-memcached/{{ ES_TRANSPORT_MEMCACHED_VER }}
+
+- name: remove default config
+ file: >
+ path={{ item }}
+ state=absent
+ with_items:
+ - /etc/default/elasticsearch
+ - /etc/elasticsearch/elasticsearch.yml
+
+- name: create custom config
+ template: >
+ dest=/etc/elasticsearch/{{ item }}
+ src={{ item }}
+ with_items:
+ - config-0.yml
+ - config-1.yml
+ - logging.yml
+ notify: restart elasticsearch
+
+- name: create elasticsearch service script
+ template: >
+ dest=/etc/init.d/elasticsearch
+ src=elasticsearch.service
+ notify: restart elasticsearch
+
+- name: start elasticsearch
+ service: >
+ enabled=yes
+ name=elasticsearch
+ state=started
diff --git a/vendor/ruflin/elastica/ansible/roles/elasticsearch/templates/config-0.yml b/vendor/ruflin/elastica/ansible/roles/elasticsearch/templates/config-0.yml
new file mode 100644
index 00000000..aa956910
--- /dev/null
+++ b/vendor/ruflin/elastica/ansible/roles/elasticsearch/templates/config-0.yml
@@ -0,0 +1,10 @@
+{% extends "config-default.yml" %}
+
+{% block config %}
+
+http.port: 9200
+transport.tcp.port: 9300
+thrift.port: 9500
+memcached.port: 11211
+
+{% endblock %}
diff --git a/vendor/ruflin/elastica/ansible/roles/elasticsearch/templates/config-1.yml b/vendor/ruflin/elastica/ansible/roles/elasticsearch/templates/config-1.yml
new file mode 100644
index 00000000..a54d719e
--- /dev/null
+++ b/vendor/ruflin/elastica/ansible/roles/elasticsearch/templates/config-1.yml
@@ -0,0 +1,10 @@
+{% extends "config-default.yml" %}
+
+{% block config %}
+
+http.port: 9201
+transport.tcp.port: 9301
+thrift.port: 9501
+memcached.port: 11212
+
+{% endblock %}
diff --git a/vendor/ruflin/elastica/ansible/roles/elasticsearch/templates/config-default.yml b/vendor/ruflin/elastica/ansible/roles/elasticsearch/templates/config-default.yml
new file mode 100644
index 00000000..0917f244
--- /dev/null
+++ b/vendor/ruflin/elastica/ansible/roles/elasticsearch/templates/config-default.yml
@@ -0,0 +1,40 @@
+{% block default_config %}
+
+index.number_of_shards: 2
+index.number_of_replicas: 0
+
+# Dont write data to hdd in tests
+index.store.type: memory
+
+# Required plugins
+plugin.mandatory: mapper-attachments, geocluster-facet, transport-thrift, transport-memcached, image
+
+# For bulk tests
+bulk.udp.enabled: true
+bulk.udp.bulk_actions: 5
+
+# For script tests
+script.inline: on
+script.indexed: on
+
+# Disable dynamic memory allocation
+bootstrap.mlockall: true
+
+# Dont accept connections not from localhost
+network.host: "127.0.0.1"
+
+# Limit threadpool by set number of available processors to 1
+# Without this, travis builds will be failed with OutOfMemory error
+processors: 1
+
+# All nodes will be called Elastica
+node.name: Elastica
+
+# Added for snapshot tests
+path.repo: ["/tmp/test_register", "/tmp/test_repository"]
+
+{% endblock %}
+
+{% block config %}
+# Node specific config should be overwritten in child template
+{% endblock %}
diff --git a/vendor/ruflin/elastica/ansible/roles/elasticsearch/templates/elasticsearch.service b/vendor/ruflin/elastica/ansible/roles/elasticsearch/templates/elasticsearch.service
new file mode 100755
index 00000000..0268e230
--- /dev/null
+++ b/vendor/ruflin/elastica/ansible/roles/elasticsearch/templates/elasticsearch.service
@@ -0,0 +1,229 @@
+#!/bin/sh
+#
+# /etc/init.d/elasticsearch -- startup script for Elasticsearch
+#
+# Written by Miquel van Smoorenburg <miquels@cistron.nl>.
+# Modified for Debian GNU/Linux by Ian Murdock <imurdock@gnu.ai.mit.edu>.
+# Modified for Tomcat by Stefan Gybas <sgybas@debian.org>.
+# Modified for Tomcat6 by Thierry Carrez <thierry.carrez@ubuntu.com>.
+# Additional improvements by Jason Brittain <jason.brittain@mulesoft.com>.
+# Modified by Nicolas Huray for Elasticsearch <nicolas.huray@gmail.com>.
+# Modified by Igor Denisenko for Elastica <im.denisenko@yahoo.com>
+#
+### BEGIN INIT INFO
+# Provides: elasticsearch
+# Required-Start: $network $remote_fs $named
+# Required-Stop: $network $remote_fs $named
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Starts elasticsearch
+# Description: Starts elasticsearch using start-stop-daemon
+### END INIT INFO
+
+PATH="/bin:/usr/bin:/sbin:/usr/sbin"
+NAME="elasticsearch"
+DESC="Elasticsearch Server"
+
+if [ `id -u` -ne 0 ]; then
+ echo "You need root privileges to run this script"
+ exit 1
+fi
+
+
+. /lib/lsb/init-functions
+
+if [ -r /etc/default/rcS ]; then
+ . /etc/default/rcS
+fi
+
+
+# Run Elasticsearch as this user ID and group ID
+ES_USER="elasticsearch"
+ES_GROUP="elasticsearch"
+
+# The first existing directory is used for JAVA_HOME (if JAVA_HOME is not defined)
+JDK_DIRS="/usr/lib/jvm/java-8-oracle/ /usr/lib/jvm/j2sdk1.8-oracle/ /usr/lib/jvm/jdk-7-oracle-x64 /usr/lib/jvm/java-7-oracle /usr/lib/jvm/j2sdk1.7-oracle/ /usr/lib/jvm/java-7-openjdk /usr/lib/jvm/java-7-openjdk-amd64/ /usr/lib/jvm/java-7-openjdk-armhf /usr/lib/jvm/java-7-openjdk-i386/ /usr/lib/jvm/default-java"
+
+# Look for the right JVM to use
+for jdir in $JDK_DIRS; do
+ if [ -r "$jdir/bin/java" -a -z "${JAVA_HOME}" ]; then
+ JAVA_HOME="$jdir"
+ fi
+done
+export JAVA_HOME
+
+# Directory where the Elasticsearch binary distribution resides
+ES_HOME="/usr/share/$NAME"
+
+# Heap size defaults to 256m min, 1g max
+# Be modest. Entire cluster will allocate (3*ES_HEAP_SIZE) memory
+ES_HEAP_SIZE="256m"
+export ES_HEAP_SIZE
+
+# Heap new generation
+# ES_HEAP_NEWSIZE=
+# export ES_HEAP_NEWSIZE
+
+# max direct memory
+# ES_DIRECT_SIZE=
+# export ES_DIRECT_SIZE
+
+# Additional Java OPTS
+ES_JAVA_OPTS="-server"
+export ES_JAVA_OPTS
+
+# Maximum number of open files
+MAX_OPEN_FILES="65535"
+
+# Maximum amount of locked memory
+MAX_LOCKED_MEMORY="unlimited"
+
+# Elasticsearch log directory
+LOG_DIR="/var/log/$NAME"
+
+# Elasticsearch data directory
+DATA_DIR="/var/lib/$NAME"
+
+# Elasticsearch work directory
+WORK_DIR="/tmp/$NAME"
+
+# Elasticsearch configuration directory
+CONF_DIR="/etc/$NAME"
+
+# Define other required variables
+DAEMON="$ES_HOME/bin/elasticsearch"
+
+# Check DAEMON exists
+if [ ! -x $DAEMON ]; then
+ exit 0
+fi
+
+checkJava() {
+ if [ -x "$JAVA_HOME/bin/java" ]; then
+ JAVA="$JAVA_HOME/bin/java"
+ else
+ JAVA=`which java`
+ fi
+
+ if [ ! -x "$JAVA" ]; then
+ echo "Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME"
+ exit 1
+ fi
+}
+
+case "$1" in
+ start)
+ checkJava
+
+ if [ -n "$MAX_LOCKED_MEMORY" -a -z "$ES_HEAP_SIZE" ]; then
+ log_failure_msg "MAX_LOCKED_MEMORY is set - ES_HEAP_SIZE must also be set"
+ exit 1
+ fi
+
+
+ mkdir -p "$LOG_DIR" "$DATA_DIR" "$WORK_DIR"
+ chown "$ES_USER":"$ES_GROUP" "$LOG_DIR" "$DATA_DIR" "$WORK_DIR"
+
+ if [ -n "$MAX_OPEN_FILES" ];then
+ ulimit -n $MAX_OPEN_FILES
+ fi
+
+ if [ -n "$MAX_LOCKED_MEMORY" ];then
+ ulimit -l $MAX_LOCKED_MEMORY
+ fi
+
+ ulimit -s 1024
+
+ for node in 0 1; do
+ log_daemon_msg "Starting elasticsearch node #$node"
+
+ PID_FILE="/var/run/$NAME-$node.pid"
+ CONF_FILE="$CONF_DIR/config-$node.yml"
+
+ DAEMON="$ES_HOME/bin/elasticsearch"
+ DAEMON_OPTS="
+ -Des.config=$CONF_FILE \
+ -Des.path.home=$ES_HOME \
+ -Des.path.logs=$LOG_DIR \
+ -Des.path.data=$DATA_DIR \
+ -Des.path.work=$WORK_DIR \
+ -Des.path.conf=$CONF_DIR \
+ -p $PID_FILE
+ "
+
+ pid=`pidofproc -p $PID_FILE elasticsearch`
+ if [ -n "$pid" ] ; then
+ log_begin_msg "Elasticsearch node #$node already running"
+ continue
+ fi
+
+ touch "$PID_FILE"
+ chown "$ES_USER":"$ES_GROUP" "$PID_FILE"
+
+ # Start Daemon
+ start-stop-daemon --start -b --user "$ES_USER" -c "$ES_USER" --pidfile "$PID_FILE" --exec "$DAEMON" -- "$DAEMON_OPTS"
+ return=$?
+ if [ $return -eq 0 ]; then
+ i=0
+ timeout=10
+ # Wait for the process to be properly started before exiting
+ until { cat "$PID_FILE" | xargs kill -0; } >/dev/null 2>&1
+ do
+ sleep 1
+ i=$(($i + 1))
+ [ $i -gt $timeout ] && log_end_msg 1
+ done
+ else
+ log_end_msg $return
+ fi
+ done
+ ;;
+ stop)
+ for node in 0 1; do
+ log_daemon_msg "Stopping elasticsearch node #$node"
+
+ PID_FILE="/var/run/$NAME-$node.pid"
+
+ if [ -f "$PID_FILE" ]; then
+ start-stop-daemon --stop --pidfile "$PID_FILE" \
+ --user "$ES_USER" \
+ --retry=TERM/20/KILL/5 >/dev/null
+ if [ $? -eq 1 ]; then
+ log_progress_msg "$DESC is not running but pid file exists, cleaning up"
+ elif [ $? -eq 3 ]; then
+ PID="`cat $PID_FILE`"
+ log_failure_msg "Failed to stop $DESC (pid $PID)"
+ exit 1
+ fi
+ rm -f "$PID_FILE"
+ else
+ log_progress_msg "(not running)"
+ fi
+ done
+
+ log_end_msg 0
+ ;;
+ status)
+ for node in 0 1; do
+ PID_FILE="/var/run/$NAME-$node.pid"
+ status_of_proc -p $PID_FILE "Elasticsearch node #$node" "Elasticsearch node #$node"
+ done
+ exit 0
+ ;;
+ restart|force-reload)
+ for node in 0 1; do
+ PID_FILE="/var/run/$NAME-$node.pid"
+ if [ -f "$PID_FILE" ]; then
+ $0 stop
+ sleep 1
+ fi
+ done
+ $0 start
+ ;;
+ *)
+ log_success_msg "Usage: $0 {start|stop|restart|force-reload|status}"
+ exit 1
+ ;;
+esac
+
+exit 0
diff --git a/vendor/ruflin/elastica/ansible/roles/elasticsearch/templates/logging.yml b/vendor/ruflin/elastica/ansible/roles/elasticsearch/templates/logging.yml
new file mode 100644
index 00000000..9e00d01c
--- /dev/null
+++ b/vendor/ruflin/elastica/ansible/roles/elasticsearch/templates/logging.yml
@@ -0,0 +1,56 @@
+# you can override this using by setting a system property, for example -Des.logger.level=DEBUG
+es.logger.level: INFO
+rootLogger: ${es.logger.level}, console, file
+logger:
+ # log action execution errors for easier debugging
+ action: DEBUG
+ # reduce the logging for aws, too much is logged under the default INFO
+ com.amazonaws: WARN
+
+ # gateway
+ #gateway: DEBUG
+ #index.gateway: DEBUG
+
+ # peer shard recovery
+ #indices.recovery: DEBUG
+
+ # discovery
+ #discovery: TRACE
+
+ index.search.slowlog: TRACE, index_search_slow_log_file
+ index.indexing.slowlog: TRACE, index_indexing_slow_log_file
+
+additivity:
+ index.search.slowlog: false
+ index.indexing.slowlog: false
+
+appender:
+ console:
+ type: console
+ layout:
+ type: consolePattern
+ conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n"
+
+ file:
+ type: dailyRollingFile
+ file: ${path.logs}/${cluster.name}.log
+ datePattern: "'.'yyyy-MM-dd"
+ layout:
+ type: pattern
+ conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n"
+
+ index_search_slow_log_file:
+ type: dailyRollingFile
+ file: ${path.logs}/${cluster.name}_index_search_slowlog.log
+ datePattern: "'.'yyyy-MM-dd"
+ layout:
+ type: pattern
+ conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n"
+
+ index_indexing_slow_log_file:
+ type: dailyRollingFile
+ file: ${path.logs}/${cluster.name}_index_indexing_slowlog.log
+ datePattern: "'.'yyyy-MM-dd"
+ layout:
+ type: pattern
+ conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n"
diff --git a/vendor/ruflin/elastica/ansible/roles/nginx/handlers/main.yml b/vendor/ruflin/elastica/ansible/roles/nginx/handlers/main.yml
new file mode 100644
index 00000000..fc583f27
--- /dev/null
+++ b/vendor/ruflin/elastica/ansible/roles/nginx/handlers/main.yml
@@ -0,0 +1,6 @@
+---
+
+- name: restart nginx
+ service: >
+ name=nginx
+ state=restarted
diff --git a/vendor/ruflin/elastica/ansible/roles/nginx/tasks/main.yml b/vendor/ruflin/elastica/ansible/roles/nginx/tasks/main.yml
new file mode 100644
index 00000000..6b260531
--- /dev/null
+++ b/vendor/ruflin/elastica/ansible/roles/nginx/tasks/main.yml
@@ -0,0 +1,26 @@
+---
+
+- name: install nginx
+ apt: >
+ force=yes
+ name=nginx
+ state=present
+ update_cache=no
+
+- name: create mime.types
+ template: >
+ dest=/etc/nginx/mime.types
+ src=mime.types.j2
+ notify: restart nginx
+
+- name: create nginx.conf
+ template: >
+ dest=/etc/nginx/nginx.conf
+ src=nginx.conf.j2
+ notify: restart nginx
+
+- name: start nginx
+ service: >
+ enabled=yes
+ name=nginx
+ state=started
diff --git a/vendor/ruflin/elastica/ansible/roles/nginx/templates/mime.types.j2 b/vendor/ruflin/elastica/ansible/roles/nginx/templates/mime.types.j2
new file mode 100644
index 00000000..6c64bf73
--- /dev/null
+++ b/vendor/ruflin/elastica/ansible/roles/nginx/templates/mime.types.j2
@@ -0,0 +1,109 @@
+types {
+
+# Audio
+ audio/midi mid midi kar;
+ audio/mp4 aac f4a f4b m4a;
+ audio/mpeg mp3;
+ audio/ogg oga ogg opus;
+ audio/x-realaudio ra;
+ audio/x-wav wav;
+
+# Images
+ image/bmp bmp;
+ image/gif gif;
+ image/jpeg jpeg jpg;
+ image/png png;
+ image/svg+xml svg svgz;
+ image/tiff tif tiff;
+ image/vnd.wap.wbmp wbmp;
+ image/webp webp;
+ image/x-icon ico cur;
+ image/x-jng jng;
+
+# JavaScript
+ application/javascript js;
+ application/json json;
+
+# Manifest files
+ application/x-web-app-manifest+json webapp;
+ text/cache-manifest manifest appcache;
+
+# Microsoft Office
+ application/msword doc;
+ application/vnd.ms-excel xls;
+ application/vnd.ms-powerpoint ppt;
+ application/vnd.openxmlformats-officedocument.wordprocessingml.document docx;
+ application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx;
+ application/vnd.openxmlformats-officedocument.presentationml.presentation pptx;
+
+# Video
+ video/3gpp 3gpp 3gp;
+ video/mp4 mp4 m4v f4v f4p;
+ video/mpeg mpeg mpg;
+ video/ogg ogv;
+ video/quicktime mov;
+ video/webm webm;
+ video/x-flv flv;
+ video/x-mng mng;
+ video/x-ms-asf asx asf;
+ video/x-ms-wmv wmv;
+ video/x-msvideo avi;
+
+# Web feeds
+ application/xml atom rdf rss xml;
+
+# Web fonts
+ application/font-woff woff;
+ application/font-woff2 woff2;
+ application/vnd.ms-fontobject eot;
+ application/x-font-ttf ttc ttf;
+ font/opentype otf;
+
+# Other
+ application/java-archive jar war ear;
+ application/mac-binhex40 hqx;
+ application/pdf pdf;
+ application/postscript ps eps ai;
+ application/rtf rtf;
+ application/vnd.wap.wmlc wmlc;
+ application/xhtml+xml xhtml;
+ application/vnd.google-earth.kml+xml kml;
+ application/vnd.google-earth.kmz kmz;
+ application/x-7z-compressed 7z;
+ application/x-chrome-extension crx;
+ application/x-opera-extension oex;
+ application/x-xpinstall xpi;
+ application/x-cocoa cco;
+ application/x-java-archive-diff jardiff;
+ application/x-java-jnlp-file jnlp;
+ application/x-makeself run;
+ application/x-perl pl pm;
+ application/x-pilot prc pdb;
+ application/x-rar-compressed rar;
+ application/x-redhat-package-manager rpm;
+ application/x-sea sea;
+ application/x-shockwave-flash swf;
+ application/x-stuffit sit;
+ application/x-tcl tcl tk;
+ application/x-x509-ca-cert der pem crt;
+ application/x-bittorrent torrent;
+ application/zip zip;
+
+ application/octet-stream bin exe dll;
+ application/octet-stream deb;
+ application/octet-stream dmg;
+ application/octet-stream iso img;
+ application/octet-stream msi msp msm;
+ application/octet-stream safariextz;
+
+ text/css css;
+ text/html html htm shtml;
+ text/mathml mml;
+ text/plain txt;
+ text/vnd.sun.j2me.app-descriptor jad;
+ text/vnd.wap.wml wml;
+ text/vtt vtt;
+ text/x-component htc;
+ text/x-vcard vcf;
+
+}
diff --git a/vendor/ruflin/elastica/ansible/roles/nginx/templates/nginx.conf.j2 b/vendor/ruflin/elastica/ansible/roles/nginx/templates/nginx.conf.j2
new file mode 100644
index 00000000..17966f7a
--- /dev/null
+++ b/vendor/ruflin/elastica/ansible/roles/nginx/templates/nginx.conf.j2
@@ -0,0 +1,35 @@
+events {
+ worker_connections 1024;
+}
+
+http {
+ include /etc/nginx/mime.types;
+ default_type application/octet-stream;
+ charset_types text/xml text/plain text/vnd.wap.wml application/x-javascript application/rss+xml text/css application/javascript application/json;
+
+ server {
+ listen 80;
+
+ root {{ ES_PROJECT_ROOT }};
+
+ location / {
+ autoindex on;
+ }
+ }
+
+ server {
+ listen 127.0.0.1:12345;
+
+ location / {
+ proxy_pass http://127.0.0.1:9200;
+ }
+ }
+
+ server {
+ listen 127.0.0.1:12346;
+
+ location / {
+ return 403;
+ }
+ }
+}
diff --git a/vendor/ruflin/elastica/ansible/roles/php/tasks/main.yml b/vendor/ruflin/elastica/ansible/roles/php/tasks/main.yml
new file mode 100644
index 00000000..fff65d52
--- /dev/null
+++ b/vendor/ruflin/elastica/ansible/roles/php/tasks/main.yml
@@ -0,0 +1,43 @@
+---
+- name: import ppa:ondrej/php5 gpg key
+ apt_key: >
+ id=E5267A6C
+ keyserver=keyserver.ubuntu.com
+ state=present
+
+- name: add ppa:ondrej/php5 repository
+ apt_repository: >
+ repo="deb http://ppa.launchpad.net/ondrej/php5/ubuntu precise main"
+ state=present
+ update_cache=yes
+
+- name: install php
+ apt: >
+ force=yes
+ name={{ item }}
+ state=present
+ update_cache=no
+ with_items:
+ - php5-cli
+ - php5-curl
+ - php5-xdebug
+ - php5-memcache
+
+- name: install phar packages
+ get_url: >
+ dest={{ item.dest }}
+ url={{ item.url }}
+ mode=0755
+ with_items:
+ - { dest: "/usr/local/bin/php-cs-fixer", url: "http://get.sensiolabs.org/php-cs-fixer.phar" }
+ - { dest: "/usr/local/bin/phpdoc", url: "http://phpdoc.org/phpDocumentor.phar" }
+ - { dest: "/usr/local/bin/phpunit", url: "https://phar.phpunit.de/phpunit.phar" }
+ - { dest: "/usr/local/bin/composer", url: "https://getcomposer.org/composer.phar" }
+
+- name: install dependencies from composer.json
+ composer: >
+ command=install
+ optimize_autoloader=yes
+ prefer_source=yes
+ no_dev=no
+ working_dir={{ ES_PROJECT_ROOT }}
diff --git a/vendor/ruflin/elastica/build.xml b/vendor/ruflin/elastica/build.xml
deleted file mode 100644
index f24fbec7..00000000
--- a/vendor/ruflin/elastica/build.xml
+++ /dev/null
@@ -1,232 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project name="Elastica" default="build" basedir=".">
-
- <property name="source" value="${basedir}/lib"/>
-
- <target name="parallelTasks">
- <parallel threadCount="2">
- <sequential>
- <antcall target="pdepend"/>
- <antcall target="phpmd-ci"/>
- <antcall target="phpcb"/>
- </sequential>
- <antcall target="phpcpd"/>
- <antcall target="phpcs-ci"/>
- <antcall target="phpdoc-ci"/>
- </parallel>
- </target>
-
- <target name="clean" description="Cleanup build artifacts">
- <delete dir="${basedir}/build/api"/>
- <delete dir="${basedir}/build/code-browser"/>
- <delete dir="${basedir}/build/coverage"/>
- <delete dir="${basedir}/build/logs"/>
- <delete dir="${basedir}/build/pdepend"/>
- <delete dir="${basedir}/build/docs"/>
- <delete file="${basedir}/cache.properties"/>
- </target>
-
- <target name="prepare" depends="clean" description="Prepare for build">
- <mkdir dir="${basedir}/build/api"/>
- <mkdir dir="${basedir}/build/code-browser"/>
- <mkdir dir="${basedir}/build/coverage"/>
- <mkdir dir="${basedir}/build/logs"/>
- <mkdir dir="${basedir}/build/docs"/>
- <mkdir dir="${basedir}/build/pdepend"/>
- </target>
-
- <target name="install" description="installs and starts elasticsearch">
- <exec executable="bash">
- <arg value="-c" />
- <arg value="curl -sS https://getcomposer.org/installer | php" />
- </exec>
- <exec executable="php">
- <arg value="composer.phar" />
- <arg value="self-update" />
- </exec>
- <exec executable="php">
- <arg value="composer.phar" />
- <arg value="--dev" />
- <arg value="install" />
- </exec>
- <exec executable="bash">
- <env key="ES_VER" value="0.90.0"/>
- <env key="ES_MAPPER_ATTACHMENTS_VER" value="1.6.0"/>
- <env key="ES_TRANSPORT_THRIFT_VER" value="1.4.0"/>
- <arg value="test/bin/run_elasticsearch.sh"/>
- </exec>
- </target>
-
- <target name="composer" depends="prepare" description="Install dependencies">
- <exec executable="composer">
- <arg value="--dev"></arg>
- <arg value="install"></arg>
- </exec>
- </target>
-
- <target name="lint">
- <apply executable="php" failonerror="true">
- <arg value="-lf"/>
-
- <fileset dir="${source}">
- <include name="**/*.php"/>
- <modified/>
- </fileset>
-
- <fileset dir="${basedir}/test">
- <include name="**/*.php"/>
- <modified/>
- </fileset>
- </apply>
- </target>
-
- <target name="phpunit" depends="composer">
- <exec executable="phpunit" dir="${basedir}/test" failonerror="off" />
- </target>
-
- <!-- Generate jdepend.xml and software metrics charts -->
- <target name="pdepend">
- <exec executable="pdepend">
- <arg value="--jdepend-xml=${basedir}/build/logs/jdepend.xml" />
- <arg value="--jdepend-chart=${basedir}/build/pdepend/dependencies.svg" />
- <arg value="--overview-pyramid=${basedir}/build/pdepend/overview-pyramid.svg" />
- <arg path="${source}" />
- </exec>
- </target>
-
- <target name="phpmd-ci">
- <exec executable="phpmd">
- <arg path="${source}" />
- <arg value="xml" />
- <arg value="codesize,unusedcode,naming,design" />
- <arg value="--reportfile" />
- <arg value="${basedir}/build/logs/pmd.xml" />
- </exec>
- </target>
-
- <!-- Generate pmd-cpd.xml -->
- <target name="phpcpd">
- <exec executable="phpcpd">
- <arg line="--log-pmd ${basedir}/build/logs/pmd-cpd.xml ${source}" />
- </exec>
- </target>
-
- <!-- Generate checkstyle.xml -->
- <target name="phpcs-ci">
- <exec executable="phpcs" output="/dev/null">
- <arg line="--report=checkstyle --report-file=${basedir}/build/logs/checkstyle.xml --standard=PSR2 ${source}" />
- </exec>
- </target>
-
- <target name="phploc" description="Generate phploc.csv">
- <exec executable="phploc">
- <arg value="--log-csv" />
- <arg value="${basedir}/build/logs/phploc.csv" />
- <arg path="${source}" />
- </exec>
- </target>
-
- <!-- Generate API documentation -->
- <target name="phpdoc">
- <exec executable="phpdoc">
- <arg line="run" />
- <arg line="-d lib/" />
- <arg line="-t build/docs" />
- </exec>
- </target>
-
- <target name="phpdoc-ci">
- <exec executable="phpdoc">
- <arg line="run" />
- <arg line="-d lib/" />
- <arg line="-t build/docs" />
- <arg line="-q" />
- </exec>
- </target>
-
- <target name="phpcb">
- <exec executable="phpcb">
- <arg line="--log ${basedir}/build/logs
- --source ${source}
- --output ${basedir}/build/code-browser" />
- </exec>
- </target>
-
- <target name="build" depends="prepare,composer,lint,parallelTasks,phpunit"/>
-
- <!-- Checkstyle with human output -->
- <target name="phpcs">
- <exec executable="phpcs">
- <arg line="--standard=PSR2 ${source}" />
- </exec>
- </target>
-
- <target name="phpmd" description="Perform phpmd with human readable output">
- <exec executable="phpmd">
- <arg path="${source}"/>
- <arg value="text"/>
- <arg value="codesize,unusedcode,naming,design" />
- <arg value="${basedir}/build/phpmd.xml"/>
- </exec>
- </target>
-
- <!-- Setups test environment -->
- <target name="setup" description="setups php libs for">
- <exec executable="pear">
- <arg line="channel-discover pear.pdepend.org" />
- </exec>
- <exec executable="pear">
- <arg line="channel-discover pear.phpmd.org" />
- </exec>
- <exec executable="pear">
- <arg line="channel-discover pear.phpunit.de" />
- </exec>
- <exec executable="pear">
- <arg line="channel-discover components.ez.no" />
- </exec>
- <exec executable="pear">
- <arg line="channel-discover pear.symfony-project.com" />
- </exec>
- <exec executable="pear">
- <arg line="channel-discover pear.michelf.com" />
- </exec>
- <exec executable="pear">
- <arg line="channel-discover pear.phpdoc.org" />
- </exec>
-
- <exec executable="pear">
- <arg line="install pdepend/PHP_Depend" />
- </exec>
- <exec executable="pear">
- <arg line="install phpmd/PHP_PMD" />
- </exec>
- <exec executable="pear">
- <arg line="install phpunit/phpcpd" />
- </exec>
- <exec executable="pear">
- <arg line="install phpunit/phploc" />
- </exec>
- <exec executable="pear">
- <arg line="install phpdoc/phpDocumentor-alpha" />
- </exec>
- <exec executable="pear">
- <arg line="install PHP_CodeSniffer" />
- </exec>
- <exec executable="pear">
- <arg line="install --alldeps phpunit/PHP_CodeBrowser" />
- </exec>
- <exec executable="pear">
- <arg line="install --alldeps phpunit/PHPUnit" />
- </exec>
- </target>
-
- <target name="gource" description="Visualize repos with gource">
- <exec executable="gource">
- <arg line="--log-format git" />
- <arg line="--seconds-per-day 0.1" />
- <arg line="--title 'Elastica (https://github.com/ruflin/Elastica)'" />
- <arg line="--user-scale 1" />
- <arg line="--max-user-speed 50" />
- </exec>
- </target>
-</project>
diff --git a/vendor/ruflin/elastica/composer.json b/vendor/ruflin/elastica/composer.json
index 70c2832a..8bffc334 100644
--- a/vendor/ruflin/elastica/composer.json
+++ b/vendor/ruflin/elastica/composer.json
@@ -4,7 +4,7 @@
"keywords": ["search","client"],
"homepage": "http://elastica.io/",
"type": "library",
- "license": "Apache 2.0",
+ "license": "MIT",
"authors": [
{
"name": "Nicolas Ruflin",
@@ -12,29 +12,32 @@
}
],
"require": {
- "php": ">=5.3.3"
+ "php": ">=5.3.3",
+ "psr/log": "~1.0"
},
"require-dev": {
- "psr/log": "~1.0",
"munkie/elasticsearch-thrift-php": "1.4.*",
- "phpunit/phpunit": "4.1.*",
- "satooshi/php-coveralls": "dev-master"
+ "guzzlehttp/guzzle": "5.3.*"
},
"suggest": {
"munkie/elasticsearch-thrift-php": "Allow using thrift transport",
- "guzzlehttp/guzzle": "Allow using guzzle 4.x as the http transport (requires php 5.4)",
- "psr/log": "for logging",
+ "guzzlehttp/guzzle": "Allow using guzzle 5.3.x as the http transport (Requires php 5.4)",
+ "egeloen/http-adapter": "Allow using httpadapter transport",
"monolog/monolog": "Logging request"
},
"autoload": {
- "psr-0": {
- "Elastica": "lib/",
- "Elastica\\Test": "test/lib/"
+ "psr-4": {
+ "Elastica\\": "lib/Elastica/"
+ }
+ },
+ "autoload-dev": {
+ "psr-4": {
+ "Elastica\\Test\\": "test/lib/Elastica/Test/"
}
},
"extra": {
"branch-alias": {
- "dev-master": "1.2.x-dev"
+ "dev-master": "2.0.x-dev"
}
}
}
diff --git a/vendor/ruflin/elastica/docker-compose.yml b/vendor/ruflin/elastica/docker-compose.yml
new file mode 100644
index 00000000..674d6e9e
--- /dev/null
+++ b/vendor/ruflin/elastica/docker-compose.yml
@@ -0,0 +1,27 @@
+elastica:
+ #build: . # In case the image must be built locally
+ image: ruflin/elastica
+ ports:
+ - "9200:9200"
+ volumes:
+ - .:/app
+ links:
+ - nginx
+ - elasticsearch
+ environment:
+ - ES_HOST=elasticsearch
+ - PROXY_HOST=nginx
+elasticsearch:
+ #build: ./env/elasticsearch/ # In case image must be built locally
+ image: ruflin/elasticsearch-elastica
+nginx:
+ image: nginx
+ volumes:
+ - ./env/nginx/nginx.conf:/etc/nginx/nginx.conf
+ - ./env/nginx/mime.types:/etc/nginx/mime.types
+ ports:
+ - "12345"
+ - "12346"
+ - "80"
+ links:
+ - elasticsearch
diff --git a/vendor/ruflin/elastica/env/elasticsearch/Dockerfile b/vendor/ruflin/elastica/env/elasticsearch/Dockerfile
new file mode 100644
index 00000000..ae2665a0
--- /dev/null
+++ b/vendor/ruflin/elastica/env/elasticsearch/Dockerfile
@@ -0,0 +1,26 @@
+FROM elasticsearch:1.6.0
+MAINTAINER Nicolas Ruflin <spam@ruflin.com>
+
+# Dependencies
+ENV ES_MAPPER_ATTACHMENTS_VER 2.6.0
+ENV ES_TRANSPORT_MEMCACHED_VER 2.6.0
+ENV ES_TRANSPORT_THRIFT_VER 2.6.0
+ENV ES_GEOCLUSTER_FACET_VER 0.0.12
+ENV ES_IMAGE_PLUGIN_VER 1.4.0
+ENV ES_PLUGIN_BIN /usr/share/elasticsearch/bin/plugin
+
+# Install Plugins
+RUN ${ES_PLUGIN_BIN} -install elasticsearch/elasticsearch-mapper-attachments/${ES_MAPPER_ATTACHMENTS_VER}
+RUN ${ES_PLUGIN_BIN} -install image --url https://github.com/SibaTokyo/elasticsearch-image/releases/download/${ES_IMAGE_PLUGIN_VER}/elasticsearch-image-${ES_IMAGE_PLUGIN_VER}.zip
+RUN ${ES_PLUGIN_BIN} -install geocluster-facet --url https://github.com/zenobase/geocluster-facet/releases/download/${ES_GEOCLUSTER_FACET_VER}/geocluster-facet-${ES_GEOCLUSTER_FACET_VER}.jar
+RUN ${ES_PLUGIN_BIN} -install elasticsearch/elasticsearch-transport-thrift/${ES_TRANSPORT_THRIFT_VER}
+RUN ${ES_PLUGIN_BIN} -install elasticsearch/elasticsearch-transport-memcached/${ES_TRANSPORT_MEMCACHED_VER}
+
+# Debug interface
+RUN ${ES_PLUGIN_BIN} -install mobz/elasticsearch-head
+
+# Copy config files
+COPY *.yml /usr/share/elasticsearch/config/
+
+# Expose standard ports, thrift, udp, memcache
+EXPOSE 9200 9300 9500 9700 9800 11211
diff --git a/vendor/ruflin/elastica/env/elasticsearch/elasticsearch.yml b/vendor/ruflin/elastica/env/elasticsearch/elasticsearch.yml
new file mode 100644
index 00000000..bd0368da
--- /dev/null
+++ b/vendor/ruflin/elastica/env/elasticsearch/elasticsearch.yml
@@ -0,0 +1,39 @@
+
+index.number_of_shards: 2
+index.number_of_replicas: 0
+
+# Dont write data to hdd in tests
+index.store.type: memory
+
+# Required plugins
+plugin.mandatory: mapper-attachments, geocluster-facet, transport-thrift, transport-memcached, image
+
+# For bulk tests
+bulk.udp.enabled: true
+bulk.udp.bulk_actions: 5
+
+# For script tests
+script.inline: on
+script.indexed: on
+
+# Disable dynamic memory allocation
+bootstrap.mlockall: true
+
+# Dont accept connections not from localhost
+#network.host: "127.0.0.1"
+
+# Limit threadpool by set number of available processors to 1
+# Without this, travis builds will be failed with OutOfMemory error
+processors: 1
+
+# All nodes will be called Elastica
+node.name: Elastica
+
+# Ports config
+http.port: 9200
+transport.tcp.port: 9300
+thrift.port: 9500
+memcached.port: 11211
+
+# Added for snapshot tests
+path.repo: ["/tmp/test_register", "/tmp/test_repository"] \ No newline at end of file
diff --git a/vendor/ruflin/elastica/env/elasticsearch/logging.yml b/vendor/ruflin/elastica/env/elasticsearch/logging.yml
new file mode 100644
index 00000000..9e00d01c
--- /dev/null
+++ b/vendor/ruflin/elastica/env/elasticsearch/logging.yml
@@ -0,0 +1,56 @@
+# you can override this using by setting a system property, for example -Des.logger.level=DEBUG
+es.logger.level: INFO
+rootLogger: ${es.logger.level}, console, file
+logger:
+ # log action execution errors for easier debugging
+ action: DEBUG
+ # reduce the logging for aws, too much is logged under the default INFO
+ com.amazonaws: WARN
+
+ # gateway
+ #gateway: DEBUG
+ #index.gateway: DEBUG
+
+ # peer shard recovery
+ #indices.recovery: DEBUG
+
+ # discovery
+ #discovery: TRACE
+
+ index.search.slowlog: TRACE, index_search_slow_log_file
+ index.indexing.slowlog: TRACE, index_indexing_slow_log_file
+
+additivity:
+ index.search.slowlog: false
+ index.indexing.slowlog: false
+
+appender:
+ console:
+ type: console
+ layout:
+ type: consolePattern
+ conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n"
+
+ file:
+ type: dailyRollingFile
+ file: ${path.logs}/${cluster.name}.log
+ datePattern: "'.'yyyy-MM-dd"
+ layout:
+ type: pattern
+ conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n"
+
+ index_search_slow_log_file:
+ type: dailyRollingFile
+ file: ${path.logs}/${cluster.name}_index_search_slowlog.log
+ datePattern: "'.'yyyy-MM-dd"
+ layout:
+ type: pattern
+ conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n"
+
+ index_indexing_slow_log_file:
+ type: dailyRollingFile
+ file: ${path.logs}/${cluster.name}_index_indexing_slowlog.log
+ datePattern: "'.'yyyy-MM-dd"
+ layout:
+ type: pattern
+ conversionPattern: "[%d{ISO8601}][%-5p][%-25c] %m%n"
diff --git a/vendor/ruflin/elastica/env/nginx/mime.types b/vendor/ruflin/elastica/env/nginx/mime.types
new file mode 100644
index 00000000..6c64bf73
--- /dev/null
+++ b/vendor/ruflin/elastica/env/nginx/mime.types
@@ -0,0 +1,109 @@
+types {
+
+# Audio
+ audio/midi mid midi kar;
+ audio/mp4 aac f4a f4b m4a;
+ audio/mpeg mp3;
+ audio/ogg oga ogg opus;
+ audio/x-realaudio ra;
+ audio/x-wav wav;
+
+# Images
+ image/bmp bmp;
+ image/gif gif;
+ image/jpeg jpeg jpg;
+ image/png png;
+ image/svg+xml svg svgz;
+ image/tiff tif tiff;
+ image/vnd.wap.wbmp wbmp;
+ image/webp webp;
+ image/x-icon ico cur;
+ image/x-jng jng;
+
+# JavaScript
+ application/javascript js;
+ application/json json;
+
+# Manifest files
+ application/x-web-app-manifest+json webapp;
+ text/cache-manifest manifest appcache;
+
+# Microsoft Office
+ application/msword doc;
+ application/vnd.ms-excel xls;
+ application/vnd.ms-powerpoint ppt;
+ application/vnd.openxmlformats-officedocument.wordprocessingml.document docx;
+ application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx;
+ application/vnd.openxmlformats-officedocument.presentationml.presentation pptx;
+
+# Video
+ video/3gpp 3gpp 3gp;
+ video/mp4 mp4 m4v f4v f4p;
+ video/mpeg mpeg mpg;
+ video/ogg ogv;
+ video/quicktime mov;
+ video/webm webm;
+ video/x-flv flv;
+ video/x-mng mng;
+ video/x-ms-asf asx asf;
+ video/x-ms-wmv wmv;
+ video/x-msvideo avi;
+
+# Web feeds
+ application/xml atom rdf rss xml;
+
+# Web fonts
+ application/font-woff woff;
+ application/font-woff2 woff2;
+ application/vnd.ms-fontobject eot;
+ application/x-font-ttf ttc ttf;
+ font/opentype otf;
+
+# Other
+ application/java-archive jar war ear;
+ application/mac-binhex40 hqx;
+ application/pdf pdf;
+ application/postscript ps eps ai;
+ application/rtf rtf;
+ application/vnd.wap.wmlc wmlc;
+ application/xhtml+xml xhtml;
+ application/vnd.google-earth.kml+xml kml;
+ application/vnd.google-earth.kmz kmz;
+ application/x-7z-compressed 7z;
+ application/x-chrome-extension crx;
+ application/x-opera-extension oex;
+ application/x-xpinstall xpi;
+ application/x-cocoa cco;
+ application/x-java-archive-diff jardiff;
+ application/x-java-jnlp-file jnlp;
+ application/x-makeself run;
+ application/x-perl pl pm;
+ application/x-pilot prc pdb;
+ application/x-rar-compressed rar;
+ application/x-redhat-package-manager rpm;
+ application/x-sea sea;
+ application/x-shockwave-flash swf;
+ application/x-stuffit sit;
+ application/x-tcl tcl tk;
+ application/x-x509-ca-cert der pem crt;
+ application/x-bittorrent torrent;
+ application/zip zip;
+
+ application/octet-stream bin exe dll;
+ application/octet-stream deb;
+ application/octet-stream dmg;
+ application/octet-stream iso img;
+ application/octet-stream msi msp msm;
+ application/octet-stream safariextz;
+
+ text/css css;
+ text/html html htm shtml;
+ text/mathml mml;
+ text/plain txt;
+ text/vnd.sun.j2me.app-descriptor jad;
+ text/vnd.wap.wml wml;
+ text/vtt vtt;
+ text/x-component htc;
+ text/x-vcard vcf;
+
+}
diff --git a/vendor/ruflin/elastica/env/nginx/nginx.conf b/vendor/ruflin/elastica/env/nginx/nginx.conf
new file mode 100644
index 00000000..edf177d3
--- /dev/null
+++ b/vendor/ruflin/elastica/env/nginx/nginx.conf
@@ -0,0 +1,38 @@
+
+worker_processes 1;
+
+events {
+ worker_connections 1024;
+}
+
+http {
+ include /etc/nginx/mime.types;
+ default_type application/octet-stream;
+ charset_types text/xml text/plain text/vnd.wap.wml application/x-javascript application/rss+xml text/css application/javascript application/json;
+
+ server {
+ listen 80;
+
+ #root {{ ES_PROJECT_ROOT }};
+
+ location / {
+ autoindex on;
+ }
+ }
+
+ server {
+ listen 12345;
+
+ location / {
+ proxy_pass http://elasticsearch:9200;
+ }
+ }
+
+ server {
+ listen 12346;
+
+ location / {
+ return 403;
+ }
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/AbstractUpdateAction.php b/vendor/ruflin/elastica/lib/Elastica/AbstractUpdateAction.php
index 883284ae..468087af 100644
--- a/vendor/ruflin/elastica/lib/Elastica/AbstractUpdateAction.php
+++ b/vendor/ruflin/elastica/lib/Elastica/AbstractUpdateAction.php
@@ -1,13 +1,10 @@
<?php
-
namespace Elastica;
/**
* Base class for things that can be sent to the update api (Document and
* Script).
*
- * @category Xodoa
- * @package Elastica
* @author Nik Everett <nik9000@gmail.com>
*/
class AbstractUpdateAction extends Param
@@ -20,8 +17,9 @@ class AbstractUpdateAction extends Param
/**
* Sets the id of the document.
*
- * @param string $id
- * @return \Elastica\Document
+ * @param string $id
+ *
+ * @return $this
*/
public function setId($id)
{
@@ -29,7 +27,7 @@ class AbstractUpdateAction extends Param
}
/**
- * Returns document id
+ * Returns document id.
*
* @return string|int Document id
*/
@@ -47,10 +45,11 @@ class AbstractUpdateAction extends Param
}
/**
- * Sets lifetime of document
+ * Sets lifetime of document.
*
- * @param string $ttl
- * @return \Elastica\Document
+ * @param string $ttl
+ *
+ * @return $this
*/
public function setTtl($ttl)
{
@@ -74,10 +73,11 @@ class AbstractUpdateAction extends Param
}
/**
- * Sets the document type name
+ * Sets the document type name.
+ *
+ * @param string $type Type name
*
- * @param string $type Type name
- * @return \Elastica\Document Current object
+ * @return $this
*/
public function setType($type)
{
@@ -85,14 +85,16 @@ class AbstractUpdateAction extends Param
$this->setIndex($type->getIndex());
$type = $type->getName();
}
+
return $this->setParam('_type', $type);
}
/**
- * Return document type name
+ * Return document type name.
*
- * @return string Document type name
* @throws \Elastica\Exception\InvalidException
+ *
+ * @return string Document type name
*/
public function getType()
{
@@ -100,24 +102,27 @@ class AbstractUpdateAction extends Param
}
/**
- * Sets the document index name
+ * Sets the document index name.
+ *
+ * @param string $index Index name
*
- * @param string $index Index name
- * @return \Elastica\Document Current object
+ * @return $this
*/
public function setIndex($index)
{
if ($index instanceof Index) {
$index = $index->getName();
}
+
return $this->setParam('_index', $index);
}
/**
- * Get the document index name
+ * Get the document index name.
*
- * @return string Index name
* @throws \Elastica\Exception\InvalidException
+ *
+ * @return string Index name
*/
public function getIndex()
{
@@ -125,11 +130,13 @@ class AbstractUpdateAction extends Param
}
/**
- * Sets the version of a document for use with optimistic concurrency control
+ * Sets the version of a document for use with optimistic concurrency control.
*
- * @param int $version Document version
- * @return \Elastica\Document Current object
- * @link http://www.elasticsearch.org/blog/2011/02/08/versioning.html
+ * @param int $version Document version
+ *
+ * @return $this
+ *
+ * @link https://www.elastic.co/blog/versioning
*/
public function setVersion($version)
{
@@ -137,7 +144,7 @@ class AbstractUpdateAction extends Param
}
/**
- * Returns document version
+ * Returns document version.
*
* @return string|int Document version
*/
@@ -156,11 +163,11 @@ class AbstractUpdateAction extends Param
/**
* Sets the version_type of a document
- * Default in ES is internal, but you can set to external to use custom versioning
+ * Default in ES is internal, but you can set to external to use custom versioning.
+ *
+ * @param int $versionType Document version type
*
- * @param int $versionType Document version type
- * @return \Elastica\Document Current object
- * @link http://www.elasticsearch.org/guide/reference/api/index_.html
+ * @return $this
*/
public function setVersionType($versionType)
{
@@ -168,7 +175,7 @@ class AbstractUpdateAction extends Param
}
/**
- * Returns document version type
+ * Returns document version type.
*
* @return string|int Document version type
*/
@@ -186,11 +193,13 @@ class AbstractUpdateAction extends Param
}
/**
- * Sets parent document id
+ * Sets parent document id.
+ *
+ * @param string|int $parent Parent document id
+ *
+ * @return $this
*
- * @param string|int $parent Parent document id
- * @return \Elastica\Document Current object
- * @link http://www.elasticsearch.org/guide/reference/mapping/parent-field.html
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-parent-field.html
*/
public function setParent($parent)
{
@@ -198,7 +207,7 @@ class AbstractUpdateAction extends Param
}
/**
- * Returns the parent document id
+ * Returns the parent document id.
*
* @return string|int Parent document id
*/
@@ -216,10 +225,11 @@ class AbstractUpdateAction extends Param
}
/**
- * Set operation type
+ * Set operation type.
*
- * @param string $opType Only accept create
- * @return \Elastica\Document Current object
+ * @param string $opType Only accept create
+ *
+ * @return $this
*/
public function setOpType($opType)
{
@@ -227,7 +237,8 @@ class AbstractUpdateAction extends Param
}
/**
- * Get operation type
+ * Get operation type.
+ *
* @return string
*/
public function getOpType()
@@ -244,10 +255,11 @@ class AbstractUpdateAction extends Param
}
/**
- * Set percolate query param
+ * Set percolate query param.
*
- * @param string $value percolator filter
- * @return \Elastica\Document
+ * @param string $value percolator filter
+ *
+ * @return $this
*/
public function setPercolate($value = '*')
{
@@ -255,7 +267,7 @@ class AbstractUpdateAction extends Param
}
/**
- * Get percolate parameter
+ * Get percolate parameter.
*
* @return string
*/
@@ -273,10 +285,11 @@ class AbstractUpdateAction extends Param
}
/**
- * Set routing query param
+ * Set routing query param.
*
- * @param string $value routing
- * @return \Elastica\Document
+ * @param string $value routing
+ *
+ * @return $this
*/
public function setRouting($value)
{
@@ -284,7 +297,7 @@ class AbstractUpdateAction extends Param
}
/**
- * Get routing parameter
+ * Get routing parameter.
*
* @return string
*/
@@ -303,18 +316,20 @@ class AbstractUpdateAction extends Param
/**
* @param array|string $fields
- * @return \Elastica\Document
+ *
+ * @return $this
*/
public function setFields($fields)
{
if (is_array($fields)) {
$fields = implode(',', $fields);
}
+
return $this->setParam('_fields', (string) $fields);
}
/**
- * @return \Elastica\Document
+ * @return $this
*/
public function setFieldsSource()
{
@@ -339,7 +354,8 @@ class AbstractUpdateAction extends Param
/**
* @param int $num
- * @return \Elastica\Document
+ *
+ * @return $this
*/
public function setRetryOnConflict($num)
{
@@ -364,7 +380,8 @@ class AbstractUpdateAction extends Param
/**
* @param string $timestamp
- * @return \Elastica\Document
+ *
+ * @return $this
*/
public function setTimestamp($timestamp)
{
@@ -389,7 +406,8 @@ class AbstractUpdateAction extends Param
/**
* @param bool $refresh
- * @return \Elastica\Document
+ *
+ * @return $this
*/
public function setRefresh($refresh = true)
{
@@ -414,7 +432,8 @@ class AbstractUpdateAction extends Param
/**
* @param string $timeout
- * @return \Elastica\Document
+ *
+ * @return $this
*/
public function setTimeout($timeout)
{
@@ -439,7 +458,8 @@ class AbstractUpdateAction extends Param
/**
* @param string $timeout
- * @return \Elastica\Document
+ *
+ * @return $this
*/
public function setConsistency($timeout)
{
@@ -464,7 +484,8 @@ class AbstractUpdateAction extends Param
/**
* @param string $timeout
- * @return \Elastica\Document
+ *
+ * @return $this
*/
public function setReplication($timeout)
{
@@ -489,7 +510,8 @@ class AbstractUpdateAction extends Param
/**
* @param \Elastica\Document|array $data
- * @return \Elastica\Document
+ *
+ * @return $this
*/
public function setUpsert($data)
{
@@ -516,8 +538,9 @@ class AbstractUpdateAction extends Param
}
/**
- * @param array $fields if empty array all options will be returned, field names can be either with underscored either without, i.e. _percolate, routing
- * @param bool $withUnderscore should option keys contain underscore prefix
+ * @param array $fields if empty array all options will be returned, field names can be either with underscored either without, i.e. _percolate, routing
+ * @param bool $withUnderscore should option keys contain underscore prefix
+ *
* @return array
*/
public function getOptions(array $fields = array(), $withUnderscore = false)
@@ -525,7 +548,7 @@ class AbstractUpdateAction extends Param
if (!empty($fields)) {
$data = array();
foreach ($fields as $field) {
- $key = '_' . ltrim($field, '_');
+ $key = '_'.ltrim($field, '_');
if ($this->hasParam($key) && '' !== (string) $this->getParam($key)) {
$data[$key] = $this->getParam($key);
}
@@ -539,6 +562,7 @@ class AbstractUpdateAction extends Param
unset($data[$key]);
}
}
+
return $data;
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractAggregation.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractAggregation.php
index 5ad5b17e..4cbb6b74 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractAggregation.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractAggregation.php
@@ -1,21 +1,18 @@
<?php
-
namespace Elastica\Aggregation;
-use Elastica\Param;
use Elastica\Exception\InvalidException;
+use Elastica\Param;
abstract class AbstractAggregation extends Param
{
/**
- * The name of this aggregation
- * @var string
+ * @var string The name of this aggregation
*/
protected $_name;
/**
- * Subaggregations belonging to this aggregation
- * @var array
+ * @var array Subaggregations belonging to this aggregation
*/
protected $_aggs = array();
@@ -28,16 +25,22 @@ abstract class AbstractAggregation extends Param
}
/**
- * Set the name of this aggregation
+ * Set the name of this aggregation.
+ *
* @param string $name
+ *
+ * @return $this
*/
public function setName($name)
{
$this->_name = $name;
+
+ return $this;
}
/**
- * Retrieve the name of this aggregation
+ * Retrieve the name of this aggregation.
+ *
* @return string
*/
public function getName()
@@ -46,7 +49,8 @@ abstract class AbstractAggregation extends Param
}
/**
- * Retrieve all subaggregations belonging to this aggregation
+ * Retrieve all subaggregations belonging to this aggregation.
+ *
* @return array
*/
public function getAggs()
@@ -55,18 +59,22 @@ abstract class AbstractAggregation extends Param
}
/**
- * Add a sub-aggregation
+ * Add a sub-aggregation.
+ *
* @param AbstractAggregation $aggregation
+ *
* @throws \Elastica\Exception\InvalidException
- * @return AbstractAggregation
+ *
+ * @return $this
*/
public function addAggregation(AbstractAggregation $aggregation)
{
- if(is_a($aggregation, 'Elastica\Aggregation\GlobalAggregation')) {
+ if ($aggregation instanceof GlobalAggregation) {
throw new InvalidException('Global aggregators can only be placed as top level aggregators');
}
$this->_aggs[$aggregation->getName()] = $aggregation->toArray();
+
return $this;
}
@@ -78,11 +86,12 @@ abstract class AbstractAggregation extends Param
$array = parent::toArray();
if (array_key_exists('global_aggregation', $array)) {
// compensate for class name GlobalAggregation
- $array = array('global' => new \stdClass);
+ $array = array('global' => new \stdClass());
}
if (sizeof($this->_aggs)) {
$array['aggs'] = $this->_aggs;
}
+
return $array;
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractSimpleAggregation.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractSimpleAggregation.php
index af7c1940..02a0fddb 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractSimpleAggregation.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractSimpleAggregation.php
@@ -1,16 +1,16 @@
<?php
-
namespace Elastica\Aggregation;
-
use Elastica\Script;
abstract class AbstractSimpleAggregation extends AbstractAggregation
{
/**
- * Set the field for this aggregation
+ * Set the field for this aggregation.
+ *
* @param string $field the name of the document field on which to perform this aggregation
- * @return AbstractSimpleAggregation
+ *
+ * @return $this
*/
public function setField($field)
{
@@ -18,16 +18,20 @@ abstract class AbstractSimpleAggregation extends AbstractAggregation
}
/**
- * Set a script for this aggregation
+ * Set a script for this aggregation.
+ *
* @param string|Script $script
- * @return AbstractSimpleAggregation
+ *
+ * @return $this
*/
public function setScript($script)
{
if ($script instanceof Script) {
- $this->setParam('params', $script->getParams());
- $script = $script->getScript();
+ $params = array_merge($this->getParams(), $script->toArray());
+
+ return $this->setParams($params);
}
+
return $this->setParam('script', $script);
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractTermsAggregation.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractTermsAggregation.php
new file mode 100644
index 00000000..57b56964
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractTermsAggregation.php
@@ -0,0 +1,97 @@
+<?php
+namespace Elastica\Aggregation;
+
+/**
+ * Class AbstractTermsAggergation.
+ */
+abstract class AbstractTermsAggregation extends AbstractSimpleAggregation
+{
+ /**
+ * Set the minimum number of documents in which a term must appear in order to be returned in a bucket.
+ *
+ * @param int $count
+ *
+ * @return $this
+ */
+ public function setMinimumDocumentCount($count)
+ {
+ return $this->setParam('min_doc_count', $count);
+ }
+
+ /**
+ * Filter documents to include based on a regular expression.
+ *
+ * @param string $pattern a regular expression
+ * @param string $flags Java Pattern flags
+ *
+ * @return $this
+ */
+ public function setInclude($pattern, $flags = null)
+ {
+ if (is_null($flags)) {
+ return $this->setParam('include', $pattern);
+ }
+
+ return $this->setParam('include', array(
+ 'pattern' => $pattern,
+ 'flags' => $flags,
+ ));
+ }
+
+ /**
+ * Filter documents to exclude based on a regular expression.
+ *
+ * @param string $pattern a regular expression
+ * @param string $flags Java Pattern flags
+ *
+ * @return $this
+ */
+ public function setExclude($pattern, $flags = null)
+ {
+ if (is_null($flags)) {
+ return $this->setParam('exclude', $pattern);
+ }
+
+ return $this->setParam('exclude', array(
+ 'pattern' => $pattern,
+ 'flags' => $flags,
+ ));
+ }
+
+ /**
+ * Sets the amount of terms to be returned.
+ *
+ * @param int $size The amount of terms to be returned.
+ *
+ * @return $this
+ */
+ public function setSize($size)
+ {
+ return $this->setParam('size', $size);
+ }
+
+ /**
+ * Sets how many terms the coordinating node will request from each shard.
+ *
+ * @param int $shard_size The amount of terms to be returned.
+ *
+ * @return $this
+ */
+ public function setShardSize($shard_size)
+ {
+ return $this->setParam('shard_size', $shard_size);
+ }
+
+ /**
+ * Instruct Elasticsearch to use direct field data or ordinals of the field values to execute this aggregation.
+ * The execution hint will be ignored if it is not applicable.
+ *
+ * @param string $hint map or ordinals
+ *
+ * @return $this
+ */
+ public function setExecutionHint($hint)
+ {
+ return $this->setParam('execution_hint', $hint);
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Avg.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Avg.php
index 0d601910..abc2f7a1 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Avg.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Avg.php
@@ -1,14 +1,11 @@
<?php
-
namespace Elastica\Aggregation;
-
/**
- * Class Avg
- * @package Elastica\Aggregation
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-metrics-avg-aggregation.html
+ * Class Avg.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-avg-aggregation.html
*/
class Avg extends AbstractSimpleAggregation
{
-
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Cardinality.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Cardinality.php
index 061ddafa..72b2e3aa 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Cardinality.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Cardinality.php
@@ -1,14 +1,38 @@
<?php
-
namespace Elastica\Aggregation;
-
/**
- * Class Cardinality
- * @package Elastica\Aggregation
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-cardinality-aggregation.html
+ * Class Cardinality.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-cardinality-aggregation.html
*/
class Cardinality extends AbstractSimpleAggregation
{
+ /**
+ * @param int $precisionThreshold
+ *
+ * @return $this
+ */
+ public function setPrecisionThreshold($precisionThreshold)
+ {
+ if (!is_int($precisionThreshold)) {
+ throw new \InvalidArgumentException('precision_threshold only supports integer values');
+ }
+
+ return $this->setParam('precision_threshold', $precisionThreshold);
+ }
+
+ /**
+ * @param bool $rehash
+ *
+ * @return $this
+ */
+ public function setRehash($rehash)
+ {
+ if (!is_bool($rehash)) {
+ throw new \InvalidArgumentException('rehash only supports boolean values');
+ }
-}
+ return $this->setParam('rehash', $rehash);
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/DateHistogram.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/DateHistogram.php
index 889fa429..8636f34c 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/DateHistogram.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/DateHistogram.php
@@ -1,82 +1,130 @@
<?php
-
namespace Elastica\Aggregation;
/**
- * Class DateHistogram
- * @package Elastica\Aggregation
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-bucket-datehistogram-aggregation.html
+ * Class DateHistogram.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-datehistogram-aggregation.html
*/
class DateHistogram extends Histogram
{
/**
- * Set pre-rounding based on interval
+ * Set pre-rounding based on interval.
+ *
+ * @deprecated Option "pre_zone" is deprecated as of ES 1.5. Use "time_zone" instead
+ *
* @param string $preZone
- * @return DateHistogram
+ *
+ * @return $this
*/
public function setPreZone($preZone)
{
- return $this->setParam("pre_zone", $preZone);
+ return $this->setParam('pre_zone', $preZone);
}
/**
- * Set post-rounding based on interval
+ * Set post-rounding based on interval.
+ *
+ * @deprecated Option "post_zone" is deprecated as of ES 1.5. Use "time_zone" instead
+ *
* @param string $postZone
- * @return DateHistogram
+ *
+ * @return $this
*/
public function setPostZone($postZone)
{
- return $this->setParam("post_zone", $postZone);
+ return $this->setParam('post_zone', $postZone);
+ }
+
+ /**
+ * Set time_zone option.
+ *
+ * @param string
+ *
+ * @return $this
+ */
+ public function setTimezone($timezone)
+ {
+ return $this->setParam('time_zone', $timezone);
}
/**
- * Set pre-zone adjustment for larger time intervals (day and above)
+ * Set pre-zone adjustment for larger time intervals (day and above).
+ *
+ * @deprecated Option "pre_zone_adjust_large_interval" is deprecated as of ES 1.5
+ *
* @param string $adjust
- * @return DateHistogram
+ *
+ * @return $this
*/
public function setPreZoneAdjustLargeInterval($adjust)
{
- return $this->setParam("pre_zone_adjust_large_interval", $adjust);
+ return $this->setParam('pre_zone_adjust_large_interval', $adjust);
}
/**
- * Adjust for granularity of date data
+ * Adjust for granularity of date data.
+ *
* @param int $factor set to 1000 if date is stored in seconds rather than milliseconds
- * @return DateHistogram
+ *
+ * @return $this
*/
public function setFactor($factor)
{
- return $this->setParam("factor", $factor);
+ return $this->setParam('factor', $factor);
}
/**
- * Set the offset for pre-rounding
+ * Set the offset for pre-rounding.
+ *
+ * @deprecated Option "pre_offset" is deprecated as of ES 1.5. Use "offset" instead
+ *
* @param string $offset "1d", for example
- * @return DateHistogram
+ *
+ * @return $this
*/
public function setPreOffset($offset)
{
- return $this->setParam("pre_offset", $offset);
+ return $this->setParam('pre_offset', $offset);
}
/**
- * Set the offset for post-rounding
+ * Set the offset for post-rounding.
+ *
+ * @deprecated Option "post_offset" is deprecated as of ES 1.5. Use "offset" instead
+ *
* @param string $offset "1d", for example
- * @return DateHistogram
+ *
+ * @return $this
*/
public function setPostOffset($offset)
{
- return $this->setParam("post_offset", $offset);
+ return $this->setParam('post_offset', $offset);
+ }
+
+ /**
+ * Set offset option.
+ *
+ * @param string
+ *
+ * @return $this
+ */
+ public function setOffset($offset)
+ {
+ return $this->setParam('offset', $offset);
}
/**
- * Set the format for returned bucket key_as_string values
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-bucket-daterange-aggregation.html#date-format-pattern
+ * Set the format for returned bucket key_as_string values.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/master/search-aggregations-bucket-daterange-aggregation.html#date-format-pattern
+ *
* @param string $format see link for formatting options
- * @return DateHistogram
+ *
+ * @return $this
*/
public function setFormat($format)
{
- return $this->setParam("format", $format);
+ return $this->setParam('format', $format);
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/DateRange.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/DateRange.php
index 37aca87b..deb5881d 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/DateRange.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/DateRange.php
@@ -1,21 +1,22 @@
<?php
-
namespace Elastica\Aggregation;
/**
- * Class DateRange
- * @package Elastica\Aggregation
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-bucket-daterange-aggregation.html
+ * Class DateRange.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-daterange-aggregation.html
*/
class DateRange extends Range
{
/**
- * Set the formatting for the returned date values
+ * Set the formatting for the returned date values.
+ *
* @param string $format see documentation for formatting options
- * @return Range
+ *
+ * @return $this
*/
public function setFormat($format)
{
return $this->setParam('format', $format);
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/ExtendedStats.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/ExtendedStats.php
index 4aef8a32..2b108bd1 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/ExtendedStats.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/ExtendedStats.php
@@ -1,13 +1,11 @@
<?php
-
namespace Elastica\Aggregation;
/**
- * Class ExtendedStats
- * @package Elastica\Aggregation
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-metrics-extendedstats-aggregation.html
+ * Class ExtendedStats.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-extendedstats-aggregation.html
*/
class ExtendedStats extends AbstractSimpleAggregation
{
-
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Filter.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Filter.php
index c2326ffe..fc83419e 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Filter.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Filter.php
@@ -1,25 +1,38 @@
<?php
-
namespace Elastica\Aggregation;
-
use Elastica\Filter\AbstractFilter;
/**
- * Class Filter
- * @package Elastica\Aggregation
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-bucket-filter-aggregation.html
+ * Class Filter.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filter-aggregation.html
*/
class Filter extends AbstractAggregation
{
/**
- * Set the filter for this aggregation
+ * @param string $name
+ * @param AbstractFilter $filter
+ */
+ public function __construct($name, AbstractFilter $filter = null)
+ {
+ parent::__construct($name);
+
+ if ($filter !== null) {
+ $this->setFilter($filter);
+ }
+ }
+
+ /**
+ * Set the filter for this aggregation.
+ *
* @param AbstractFilter $filter
- * @return Filter
+ *
+ * @return $this
*/
public function setFilter(AbstractFilter $filter)
{
- return $this->setParam("filter", $filter->toArray());
+ return $this->setParam('filter', $filter->toArray());
}
/**
@@ -28,14 +41,13 @@ class Filter extends AbstractAggregation
public function toArray()
{
$array = array(
- "filter" => $this->getParam("filter")
+ 'filter' => $this->getParam('filter'),
);
- if($this->_aggs)
- {
+ if ($this->_aggs) {
$array['aggs'] = $this->_aggs;
}
return $array;
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Filters.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Filters.php
new file mode 100644
index 00000000..e0fbf060
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Filters.php
@@ -0,0 +1,59 @@
+<?php
+namespace Elastica\Aggregation;
+
+use Elastica\Filter\AbstractFilter;
+
+/**
+ * Class Filters.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filters-aggregation.html
+ */
+class Filters extends AbstractAggregation
+{
+ /**
+ * Add a filter.
+ *
+ * If a name is given, it will be added as a key, otherwise considered as an anonymous filter
+ *
+ * @param AbstractFilter $filter
+ * @param string $name
+ *
+ * @return $this
+ */
+ public function addFilter(AbstractFilter $filter, $name = '')
+ {
+ if (empty($name)) {
+ $filterArray[] = $filter->toArray();
+ } else {
+ $filterArray[$name] = $filter->toArray();
+ }
+
+ return $this->addParam('filters', $filterArray);
+ }
+
+ /**
+ * @return array
+ */
+ public function toArray()
+ {
+ $array = array();
+ $filters = $this->getParam('filters');
+
+ foreach ($filters as $filter) {
+ // Detect between anonymous filters and named ones
+ $key = key($filter);
+
+ if (is_string($key)) {
+ $array['filters']['filters'][$key] = current($filter);
+ } else {
+ $array['filters']['filters'][] = current($filter);
+ }
+ }
+
+ if ($this->_aggs) {
+ $array['aggs'] = $this->_aggs;
+ }
+
+ return $array;
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/GeoDistance.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/GeoDistance.php
index 76c871ea..c50018a0 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/GeoDistance.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/GeoDistance.php
@@ -1,23 +1,22 @@
<?php
-
namespace Elastica\Aggregation;
use Elastica\Exception\InvalidException;
/**
- * Class GeoDistance
- * @package Elastica\Aggregation
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-bucket-geodistance-aggregation.html
+ * Class GeoDistance.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geodistance-aggregation.html
*/
class GeoDistance extends AbstractAggregation
{
- const DISTANCE_TYPE_SLOPPY_ARC = "sloppy_arc";
- const DISTANCE_TYPE_ARC = "arc";
- const DISTANCE_TYPE_PLANE = "plane";
+ const DISTANCE_TYPE_SLOPPY_ARC = 'sloppy_arc';
+ const DISTANCE_TYPE_ARC = 'arc';
+ const DISTANCE_TYPE_PLANE = 'plane';
/**
- * @param string $name the name if this aggregation
- * @param string $field the field on which to perform this aggregation
+ * @param string $name the name if this aggregation
+ * @param string $field the field on which to perform this aggregation
* @param string|array $origin the point from which distances will be calculated
*/
public function __construct($name, $field, $origin)
@@ -27,9 +26,11 @@ class GeoDistance extends AbstractAggregation
}
/**
- * Set the field for this aggregation
+ * Set the field for this aggregation.
+ *
* @param string $field the name of the document field on which to perform this aggregation
- * @return GeoDistance
+ *
+ * @return $this
*/
public function setField($field)
{
@@ -37,54 +38,67 @@ class GeoDistance extends AbstractAggregation
}
/**
- * Set the origin point from which distances will be calculated
+ * Set the origin point from which distances will be calculated.
+ *
* @param string|array $origin valid formats are array("lat" => 52.3760, "lon" => 4.894), "52.3760, 4.894", and array(4.894, 52.3760)
- * @return GeoDistance
+ *
+ * @return $this
*/
public function setOrigin($origin)
{
- return $this->setParam("origin", $origin);
+ return $this->setParam('origin', $origin);
}
/**
- * Add a distance range to this aggregation
+ * Add a distance range to this aggregation.
+ *
* @param int $fromValue a distance
- * @param int $toValue a distance
- * @return GeoDistance
+ * @param int $toValue a distance
+ *
* @throws \Elastica\Exception\InvalidException
+ *
+ * @return $this
*/
public function addRange($fromValue = null, $toValue = null)
{
if (is_null($fromValue) && is_null($toValue)) {
- throw new InvalidException("Either fromValue or toValue must be set. Both cannot be null.");
+ throw new InvalidException('Either fromValue or toValue must be set. Both cannot be null.');
}
+
$range = array();
+
if (!is_null($fromValue)) {
$range['from'] = $fromValue;
}
+
if (!is_null($toValue)) {
$range['to'] = $toValue;
}
- return $this->addParam("ranges", $range);
+
+ return $this->addParam('ranges', $range);
}
/**
- * Set the unit of distance measure for this aggregation
+ * Set the unit of distance measure for this aggregation.
+ *
* @param string $unit defaults to km
- * @return GeoDistance
+ *
+ * @return $this
*/
public function setUnit($unit)
{
- return $this->setParam("unit", $unit);
+ return $this->setParam('unit', $unit);
}
/**
- * Set the method by which distances will be calculated
+ * Set the method by which distances will be calculated.
+ *
* @param string $distanceType see DISTANCE_TYPE_* constants for options. Defaults to sloppy_arc.
- * @return GeoDistance
+ *
+ * @return $this
*/
public function setDistanceType($distanceType)
{
- return $this->setParam("distance_type", $distanceType);
+ return $this->setParam('distance_type', $distanceType);
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/GeohashGrid.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/GeohashGrid.php
index 840198c3..e7a40471 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/GeohashGrid.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/GeohashGrid.php
@@ -1,16 +1,15 @@
<?php
-
namespace Elastica\Aggregation;
/**
- * Class GeohashGrid
- * @package Elastica\Aggregation
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-bucket-geohashgrid-aggregation.html
+ * Class GeohashGrid.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geohashgrid-aggregation.html
*/
class GeohashGrid extends AbstractAggregation
{
/**
- * @param string $name the name of this aggregation
+ * @param string $name the name of this aggregation
* @param string $field the field on which to perform this aggregation
*/
public function __construct($name, $field)
@@ -20,9 +19,11 @@ class GeohashGrid extends AbstractAggregation
}
/**
- * Set the field for this aggregation
+ * Set the field for this aggregation.
+ *
* @param string $field the name of the document field on which to perform this aggregation
- * @return GeohashGrid
+ *
+ * @return $this
*/
public function setField($field)
{
@@ -30,32 +31,38 @@ class GeohashGrid extends AbstractAggregation
}
/**
- * Set the precision for this aggregation
+ * Set the precision for this aggregation.
+ *
* @param int $precision an integer between 1 and 12, inclusive. Defaults to 5.
- * @return GeohashGrid
+ *
+ * @return $this
*/
public function setPrecision($precision)
{
- return $this->setParam("precision", $precision);
+ return $this->setParam('precision', $precision);
}
/**
- * Set the maximum number of buckets to return
+ * Set the maximum number of buckets to return.
+ *
* @param int $size defaults to 10,000
- * @return GeohashGrid
+ *
+ * @return $this
*/
public function setSize($size)
{
- return $this->setParam("size", $size);
+ return $this->setParam('size', $size);
}
/**
- * Set the number of results returned from each shard
+ * Set the number of results returned from each shard.
+ *
* @param int $shardSize
- * @return GeohashGrid
+ *
+ * @return $this
*/
public function setShardSize($shardSize)
{
- return $this->setParam("shard_size", $shardSize);
+ return $this->setParam('shard_size', $shardSize);
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/GlobalAggregation.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/GlobalAggregation.php
index 72b56880..523844d2 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/GlobalAggregation.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/GlobalAggregation.php
@@ -1,13 +1,11 @@
<?php
-
namespace Elastica\Aggregation;
/**
- * Class GlobalAggregation
- * @package Elastica\Aggregation
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-bucket-global-aggregation.html
+ * Class GlobalAggregation.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-global-aggregation.html
*/
class GlobalAggregation extends AbstractAggregation
{
-
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Histogram.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Histogram.php
index 26fa7c44..79a8e517 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Histogram.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Histogram.php
@@ -1,18 +1,17 @@
<?php
-
namespace Elastica\Aggregation;
/**
- * Class Histogram
- * @package Elastica\Aggregation
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-bucket-histogram-aggregation.html
+ * Class Histogram.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-histogram-aggregation.html
*/
class Histogram extends AbstractSimpleAggregation
{
/**
- * @param string $name the name of this aggregation
- * @param string $field the name of the field on which to perform the aggregation
- * @param int $interval the interval by which documents will be bucketed
+ * @param string $name the name of this aggregation
+ * @param string $field the name of the field on which to perform the aggregation
+ * @param int $interval the interval by which documents will be bucketed
*/
public function __construct($name, $field, $interval)
{
@@ -21,35 +20,40 @@ class Histogram extends AbstractSimpleAggregation
$this->setInterval($interval);
}
-
/**
- * Set the interval by which documents will be bucketed
+ * Set the interval by which documents will be bucketed.
+ *
* @param int $interval
- * @return Histogram
+ *
+ * @return $this
*/
public function setInterval($interval)
{
- return $this->setParam("interval", $interval);
+ return $this->setParam('interval', $interval);
}
/**
- * Set the bucket sort order
- * @param string $order "_count", "_term", or the name of a sub-aggregation or sub-aggregation response field
+ * Set the bucket sort order.
+ *
+ * @param string $order "_count", "_term", or the name of a sub-aggregation or sub-aggregation response field
* @param string $direction "asc" or "desc"
- * @return Histogram
+ *
+ * @return $this
*/
public function setOrder($order, $direction)
{
- return $this->setParam("order", array($order => $direction));
+ return $this->setParam('order', array($order => $direction));
}
/**
- * Set the minimum number of documents which must fall into a bucket in order for the bucket to be returned
+ * Set the minimum number of documents which must fall into a bucket in order for the bucket to be returned.
+ *
* @param int $count set to 0 to include empty buckets
- * @return Histogram
+ *
+ * @return $this
*/
public function setMinimumDocumentCount($count)
{
- return $this->setParam("min_doc_count", $count);
+ return $this->setParam('min_doc_count', $count);
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/IpRange.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/IpRange.php
index 18e60bfb..7a4ef7c8 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/IpRange.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/IpRange.php
@@ -1,19 +1,17 @@
<?php
-
namespace Elastica\Aggregation;
-
use Elastica\Exception\InvalidException;
/**
- * Class IpRange
- * @package Elastica\Aggregation
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-bucket-iprange-aggregation.html
+ * Class IpRange.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-iprange-aggregation.html
*/
class IpRange extends AbstractAggregation
{
/**
- * @param string $name the name of this aggregation
+ * @param string $name the name of this aggregation
* @param string $field the field on which to perform this aggregation
*/
public function __construct($name, $field)
@@ -23,9 +21,11 @@ class IpRange extends AbstractAggregation
}
/**
- * Set the field for this aggregation
+ * Set the field for this aggregation.
+ *
* @param string $field the name of the document field on which to perform this aggregation
- * @return IpRange
+ *
+ * @return $this
*/
public function setField($field)
{
@@ -33,16 +33,19 @@ class IpRange extends AbstractAggregation
}
/**
- * Add an ip range to this aggregation
+ * Add an ip range to this aggregation.
+ *
* @param string $fromValue a valid ipv4 address. Low end of this range, exclusive (greater than)
- * @param string $toValue a valid ipv4 address. High end of this range, exclusive (less than)
- * @return IpRange
+ * @param string $toValue a valid ipv4 address. High end of this range, exclusive (less than)
+ *
* @throws \Elastica\Exception\InvalidException
+ *
+ * @return $this
*/
public function addRange($fromValue = null, $toValue = null)
{
if (is_null($fromValue) && is_null($toValue)) {
- throw new InvalidException("Either fromValue or toValue must be set. Both cannot be null.");
+ throw new InvalidException('Either fromValue or toValue must be set. Both cannot be null.');
}
$range = array();
if (!is_null($fromValue)) {
@@ -51,16 +54,19 @@ class IpRange extends AbstractAggregation
if (!is_null($toValue)) {
$range['to'] = $toValue;
}
+
return $this->addParam('ranges', $range);
}
/**
- * Add an ip range in the form of a CIDR mask
+ * Add an ip range in the form of a CIDR mask.
+ *
* @param string $mask a valid CIDR mask
- * @return IpRange
+ *
+ * @return $this
*/
public function addMaskRange($mask)
{
- return $this->addParam("ranges", array("mask" => $mask));
+ return $this->addParam('ranges', array('mask' => $mask));
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Max.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Max.php
index 25031b04..fc0294ca 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Max.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Max.php
@@ -1,13 +1,11 @@
<?php
-
namespace Elastica\Aggregation;
/**
- * Class Max
- * @package Elastica\Aggregation
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-metrics-max-aggregation.html
+ * Class Max.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-max-aggregation.html
*/
class Max extends AbstractSimpleAggregation
{
-
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Min.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Min.php
index 60aabb56..d5c5c31b 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Min.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Min.php
@@ -1,13 +1,11 @@
<?php
-
namespace Elastica\Aggregation;
/**
- * Class Min
- * @package Elastica\Aggregation
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-metrics-min-aggregation.html
+ * Class Min.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-min-aggregation.html
*/
class Min extends AbstractSimpleAggregation
{
-
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Missing.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Missing.php
index b882aba0..11a6bdf9 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Missing.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Missing.php
@@ -1,16 +1,15 @@
<?php
-
namespace Elastica\Aggregation;
/**
- * Class Missing
- * @package Elastica\Aggregation
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-bucket-missing-aggregation.html
+ * Class Missing.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-missing-aggregation.html
*/
class Missing extends AbstractAggregation
{
/**
- * @param string $name the name of this aggregation
+ * @param string $name the name of this aggregation
* @param string $field the field on which to perform this aggregation
*/
public function __construct($name, $field)
@@ -20,12 +19,14 @@ class Missing extends AbstractAggregation
}
/**
- * Set the field for this aggregation
+ * Set the field for this aggregation.
+ *
* @param string $field the name of the document field on which to perform this aggregation
- * @return Missing
+ *
+ * @return $this
*/
public function setField($field)
{
return $this->setParam('field', $field);
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Nested.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Nested.php
index afbb8373..76407bc8 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Nested.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Nested.php
@@ -1,11 +1,10 @@
<?php
-
namespace Elastica\Aggregation;
/**
- * Class Nested
- * @package Elastica\Aggregation
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-bucket-nested-aggregation.html
+ * Class Nested.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-nested-aggregation.html
*/
class Nested extends AbstractAggregation
{
@@ -20,12 +19,14 @@ class Nested extends AbstractAggregation
}
/**
- * Set the nested path for this aggregation
+ * Set the nested path for this aggregation.
+ *
* @param string $path
- * @return Nested
+ *
+ * @return $this
*/
public function setPath($path)
{
- return $this->setParam("path", $path);
+ return $this->setParam('path', $path);
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Percentiles.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Percentiles.php
new file mode 100644
index 00000000..22079634
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Percentiles.php
@@ -0,0 +1,59 @@
+<?php
+namespace Elastica\Aggregation;
+
+/**
+ * Class Percentiles.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-percentile-aggregation.html
+ */
+class Percentiles extends AbstractSimpleAggregation
+{
+ /**
+ * @param string $name the name of this aggregation
+ * @param string $field the field on which to perform this aggregation
+ */
+ public function __construct($name, $field = null)
+ {
+ parent::__construct($name);
+
+ if (!is_null($field)) {
+ $this->setField($field);
+ }
+ }
+
+ /**
+ * Set compression parameter.
+ *
+ * @param float $value
+ *
+ * @return $this
+ */
+ public function setCompression($value)
+ {
+ return $this->setParam('compression', (float) $value);
+ }
+
+ /**
+ * Set which percents must be returned.
+ *
+ * @param float[] $percents
+ *
+ * @return $this
+ */
+ public function setPercents(array $percents)
+ {
+ return $this->setParam('percents', $percents);
+ }
+
+ /**
+ * Add yet another percent to result.
+ *
+ * @param float $percent
+ *
+ * @return $this
+ */
+ public function addPercent($percent)
+ {
+ return $this->addParam('percents', (float) $percent);
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Range.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Range.php
index ab70c5e4..becafb28 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Range.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Range.php
@@ -1,45 +1,58 @@
<?php
namespace Elastica\Aggregation;
-
use Elastica\Exception\InvalidException;
/**
- * Class Range
- * @package Elastica\Aggregation
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-bucket-range-aggregation.html
+ * Class Range.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-range-aggregation.html
*/
class Range extends AbstractSimpleAggregation
{
/**
- * Add a range to this aggregation
- * @param int|float $fromValue low end of this range, exclusive (greater than)
- * @param int|float $toValue high end of this range, exclusive (less than)
- * @return Range
+ * Add a range to this aggregation.
+ *
+ * @param int|float $fromValue low end of this range, exclusive (greater than or equal to)
+ * @param int|float $toValue high end of this range, exclusive (less than)
+ * @param string $key customized key value
+ *
* @throws \Elastica\Exception\InvalidException
+ *
+ * @return $this
*/
- public function addRange($fromValue = null, $toValue = null)
+ public function addRange($fromValue = null, $toValue = null, $key = null)
{
if (is_null($fromValue) && is_null($toValue)) {
- throw new InvalidException("Either fromValue or toValue must be set. Both cannot be null.");
+ throw new InvalidException('Either fromValue or toValue must be set. Both cannot be null.');
}
+
$range = array();
+
if (!is_null($fromValue)) {
$range['from'] = $fromValue;
}
+
if (!is_null($toValue)) {
$range['to'] = $toValue;
}
+
+ if (!is_null($key)) {
+ $range['key'] = $key;
+ }
+
return $this->addParam('ranges', $range);
}
/**
- * If set to true, a unique string key will be associated with each bucket, and ranges will be returned as an associative array
+ * If set to true, a unique string key will be associated with each bucket, and ranges will be returned as an associative array.
+ *
* @param bool $keyed
- * @return Range
+ *
+ * @return $this
*/
public function setKeyedResponse($keyed = true)
{
- return $this->setParam('keyed', (bool)$keyed);
+ return $this->setParam('keyed', (bool) $keyed);
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/ReverseNested.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/ReverseNested.php
index d4056f13..5216ae85 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/ReverseNested.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/ReverseNested.php
@@ -1,12 +1,10 @@
<?php
-
namespace Elastica\Aggregation;
/**
- * Reversed Nested Aggregation
+ * Reversed Nested Aggregation.
*
- * @package Elastica\Aggregation
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-bucket-reverse-nested-aggregation.html
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-reverse-nested-aggregation.html
*/
class ReverseNested extends AbstractAggregation
{
@@ -24,14 +22,15 @@ class ReverseNested extends AbstractAggregation
}
/**
- * Set the nested path for this aggregation
+ * Set the nested path for this aggregation.
*
* @param string $path
- * @return ReverseNested
+ *
+ * @return $this
*/
public function setPath($path)
{
- return $this->setParam("path", $path);
+ return $this->setParam('path', $path);
}
/**
@@ -43,7 +42,7 @@ class ReverseNested extends AbstractAggregation
// ensure we have an object for the reverse_nested key.
// if we don't have a path, then this would otherwise get encoded as an empty array, which is invalid.
- $array['reverse_nested'] = (object)$array['reverse_nested'];
+ $array['reverse_nested'] = (object) $array['reverse_nested'];
return $array;
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/ScriptedMetric.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/ScriptedMetric.php
new file mode 100644
index 00000000..3e51f056
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/ScriptedMetric.php
@@ -0,0 +1,82 @@
+<?php
+namespace Elastica\Aggregation;
+
+/**
+ * Class ScriptedMetric.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-scripted-metric-aggregation.html
+ */
+class ScriptedMetric extends AbstractAggregation
+{
+ /**
+ * @param string $name the name if this aggregation
+ * @param string|null $initScript Executed prior to any collection of documents
+ * @param string|null $mapScript Executed once per document collected
+ * @param string|null $combineScript Executed once on each shard after document collection is complete
+ * @param string|null $reduceScript Executed once on the coordinating node after all shards have returned their results
+ */
+ public function __construct($name, $initScript = null, $mapScript = null, $combineScript = null, $reduceScript = null)
+ {
+ parent::__construct($name);
+ if ($initScript) {
+ $this->setInitScript($initScript);
+ }
+ if ($mapScript) {
+ $this->setMapScript($mapScript);
+ }
+ if ($combineScript) {
+ $this->setCombineScript($combineScript);
+ }
+ if ($reduceScript) {
+ $this->setReduceScript($reduceScript);
+ }
+ }
+
+ /**
+ * Set the field for this aggregation.
+ *
+ * @param string $script the name of the document field on which to perform this aggregation
+ *
+ * @return $this
+ */
+ public function setCombineScript($script)
+ {
+ return $this->setParam('combine_script', $script);
+ }
+
+ /**
+ * Set the field for this aggregation.
+ *
+ * @param string $script the name of the document field on which to perform this aggregation
+ *
+ * @return $this
+ */
+ public function setInitScript($script)
+ {
+ return $this->setParam('init_script', $script);
+ }
+
+ /**
+ * Set the field for this aggregation.
+ *
+ * @param string $script the name of the document field on which to perform this aggregation
+ *
+ * @return $this
+ */
+ public function setMapScript($script)
+ {
+ return $this->setParam('map_script', $script);
+ }
+
+ /**
+ * Set the field for this aggregation.
+ *
+ * @param string $script the name of the document field on which to perform this aggregation
+ *
+ * @return $this
+ */
+ public function setReduceScript($script)
+ {
+ return $this->setParam('reduce_script', $script);
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/SignificantTerms.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/SignificantTerms.php
new file mode 100644
index 00000000..fa394791
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/SignificantTerms.php
@@ -0,0 +1,27 @@
+<?php
+namespace Elastica\Aggregation;
+
+use Elastica\Filter\AbstractFilter;
+
+/**
+ * Class SignificantTerms.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-significantterms-aggregation.html
+ */
+class SignificantTerms extends AbstractTermsAggregation
+{
+ /**
+ * The default source of statistical information for background term frequencies is the entire index and this scope can
+ * be narrowed through the use of a background_filter to focus in on significant terms within a narrower context.
+ *
+ * @param AbstractFilter $filter
+ *
+ * @return $this
+ *
+ * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-significantterms-aggregation.html#_custom_background_context
+ */
+ public function setBackgroundFilter(AbstractFilter $filter)
+ {
+ return $this->setParam('background_filter', $filter->toArray());
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Stats.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Stats.php
index 18c903e9..f512628c 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Stats.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Stats.php
@@ -1,13 +1,11 @@
<?php
-
namespace Elastica\Aggregation;
/**
- * Class Stats
- * @package Elastica\Aggregation
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-metrics-stats-aggregation.html
+ * Class Stats.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-stats-aggregation.html
*/
class Stats extends AbstractSimpleAggregation
{
-
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Sum.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Sum.php
index 4d1ef4de..5172a684 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Sum.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Sum.php
@@ -1,13 +1,11 @@
<?php
-
namespace Elastica\Aggregation;
/**
- * Class Sum
- * @package Elastica\Aggregation
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-metrics-sum-aggregation.html
+ * Class Sum.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-sum-aggregation.html
*/
class Sum extends AbstractSimpleAggregation
{
-
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Terms.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Terms.php
index 9ede855c..8d0d6bef 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Terms.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Terms.php
@@ -1,97 +1,23 @@
<?php
-
namespace Elastica\Aggregation;
/**
- * Class Terms
- * @package Elastica\Aggregation
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-bucket-terms-aggregation.html
+ * Class Terms.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html
*/
-class Terms extends AbstractSimpleAggregation
+class Terms extends AbstractTermsAggregation
{
/**
- * Set the bucket sort order
- * @param string $order "_count", "_term", or the name of a sub-aggregation or sub-aggregation response field
+ * Set the bucket sort order.
+ *
+ * @param string $order "_count", "_term", or the name of a sub-aggregation or sub-aggregation response field
* @param string $direction "asc" or "desc"
- * @return Terms
+ *
+ * @return $this
*/
public function setOrder($order, $direction)
{
- return $this->setParam("order", array($order => $direction));
- }
-
- /**
- * Set the minimum number of documents in which a term must appear in order to be returned in a bucket
- * @param int $count
- * @return Terms
- */
- public function setMinimumDocumentCount($count)
- {
- return $this->setParam("min_doc_count", $count);
- }
-
- /**
- * Filter documents to include based on a regular expression
- * @param string $pattern a regular expression
- * @param string $flags Java Pattern flags
- * @return Terms
- */
- public function setInclude($pattern, $flags = null)
- {
- if (is_null($flags)) {
- return $this->setParam("include", $pattern);
- }
- return $this->setParam("include", array(
- "pattern" => $pattern,
- "flags" => $flags
- ));
- }
-
- /**
- * Filter documents to exclude based on a regular expression
- * @param string $pattern a regular expression
- * @param string $flags Java Pattern flags
- * @return Terms
- */
- public function setExclude($pattern, $flags = null)
- {
- if (is_null($flags)) {
- return $this->setParam("exclude", $pattern);
- }
- return $this->setParam("exclude", array(
- "pattern" => $pattern,
- "flags" => $flags
- ));
- }
-
- /**
- * Sets the amount of terms to be returned.
- * @param int $size The amount of terms to be returned.
- * @return \Elastica\Aggregation\Terms
- */
- public function setSize($size)
- {
- return $this->setParam('size', $size);
- }
-
- /**
- * Sets how many terms the coordinating node will request from each shard.
- * @param int $shard_size The amount of terms to be returned.
- * @return \Elastica\Aggregation\Terms
- */
- public function setShardSize($shard_size)
- {
- return $this->setParam('shard_size', $shard_size);
- }
-
- /**
- * Instruct Elasticsearch to use direct field data or ordinals of the field values to execute this aggregation.
- * The execution hint will be ignored if it is not applicable.
- * @param string $hint map or ordinals
- * @return Terms
- */
- public function setExecutionHint($hint)
- {
- return $this->setParam("execution_hint", $hint);
+ return $this->setParam('order', array($order => $direction));
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/TopHits.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/TopHits.php
new file mode 100644
index 00000000..91a48a48
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/TopHits.php
@@ -0,0 +1,156 @@
+<?php
+namespace Elastica\Aggregation;
+
+use Elastica\Script;
+use Elastica\ScriptFields;
+
+/**
+ * Class TopHits.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-top-hits-aggregation.html
+ */
+class TopHits extends AbstractAggregation
+{
+ /**
+ * @return array
+ */
+ public function toArray()
+ {
+ $array = parent::toArray();
+
+ // if there are no params, it's ok, but ES will throw exception if json
+ // will be like {"top_hits":[]} instead of {"top_hits":{}}
+ if (empty($array['top_hits'])) {
+ $array['top_hits'] = new \stdClass();
+ }
+
+ return $array;
+ }
+
+ /**
+ * The maximum number of top matching hits to return per bucket. By default the top three matching hits are returned.
+ *
+ * @param int $size
+ *
+ * @return $this
+ */
+ public function setSize($size)
+ {
+ return $this->setParam('size', (int) $size);
+ }
+
+ /**
+ * The offset from the first result you want to fetch.
+ *
+ * @param int $from
+ *
+ * @return $this
+ */
+ public function setFrom($from)
+ {
+ return $this->setParam('from', (int) $from);
+ }
+
+ /**
+ * How the top matching hits should be sorted. By default the hits are sorted by the score of the main query.
+ *
+ * @param array $sortArgs
+ *
+ * @return $this
+ */
+ public function setSort(array $sortArgs)
+ {
+ return $this->setParam('sort', $sortArgs);
+ }
+
+ /**
+ * Allows to control how the _source field is returned with every hit.
+ *
+ * @param array $fields
+ *
+ * @return $this
+ */
+ public function setSource(array $fields)
+ {
+ return $this->setParam('_source', $fields);
+ }
+
+ /**
+ * Returns a version for each search hit.
+ *
+ * @param bool $version
+ *
+ * @return $this
+ */
+ public function setVersion($version)
+ {
+ return $this->setParam('version', (bool) $version);
+ }
+
+ /**
+ * Enables explanation for each hit on how its score was computed.
+ *
+ * @param bool $explain
+ *
+ * @return $this
+ */
+ public function setExplain($explain)
+ {
+ return $this->setParam('explain', (bool) $explain);
+ }
+
+ /**
+ * Set script fields.
+ *
+ * @param array|\Elastica\ScriptFields $scriptFields
+ *
+ * @return $this
+ */
+ public function setScriptFields($scriptFields)
+ {
+ if (is_array($scriptFields)) {
+ $scriptFields = new ScriptFields($scriptFields);
+ }
+
+ return $this->setParam('script_fields', $scriptFields->toArray());
+ }
+
+ /**
+ * Adds a Script to the aggregation.
+ *
+ * @param string $name
+ * @param \Elastica\Script $script
+ *
+ * @return $this
+ */
+ public function addScriptField($name, Script $script)
+ {
+ $this->_params['script_fields'][$name] = $script->toArray();
+
+ return $this;
+ }
+
+ /**
+ * Sets highlight arguments for the results.
+ *
+ * @param array $highlightArgs
+ *
+ * @return $this
+ */
+ public function setHighlight(array $highlightArgs)
+ {
+ return $this->setParam('highlight', $highlightArgs);
+ }
+
+ /**
+ * Allows to return the field data representation of a field for each hit.
+ *
+ * @param array $fields
+ *
+ * @return $this
+ */
+ public function setFieldDataFields(array $fields)
+ {
+ return $this->setParam('fielddata_fields', $fields);
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/ValueCount.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/ValueCount.php
index 36fb2a2c..8706a1be 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/ValueCount.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/ValueCount.php
@@ -1,16 +1,15 @@
<?php
-
namespace Elastica\Aggregation;
/**
- * Class ValueCount
- * @package Elastica\Aggregation
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-aggregations-metrics-valuecount-aggregation.html
+ * Class ValueCount.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-valuecount-aggregation.html
*/
class ValueCount extends AbstractAggregation
{
/**
- * @param string $name the name of this aggregation
+ * @param string $name the name of this aggregation
* @param string $field the field on which to perform this aggregation
*/
public function __construct($name, $field)
@@ -20,12 +19,14 @@ class ValueCount extends AbstractAggregation
}
/**
- * Set the field for this aggregation
+ * Set the field for this aggregation.
+ *
* @param string $field the name of the document field on which to perform this aggregation
- * @return ValueCount
+ *
+ * @return $this
*/
public function setField($field)
{
return $this->setParam('field', $field);
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Bulk.php b/vendor/ruflin/elastica/lib/Elastica/Bulk.php
index 439fa566..e7693dce 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Bulk.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Bulk.php
@@ -1,20 +1,13 @@
<?php
-
namespace Elastica;
-use Elastica\Document;
-use Elastica\Exception\Bulk\ResponseException as BulkResponseException;
-use Elastica\Exception\Bulk\UdpException;
-use Elastica\Exception\InvalidException;
-use Elastica\Request;
-use Elastica\Response;
-use Elastica\Client;
-use Elastica\Index;
-use Elastica\Type;
use Elastica\Bulk\Action;
use Elastica\Bulk\Action\AbstractDocument as AbstractDocumentAction;
-use Elastica\Bulk\ResponseSet;
use Elastica\Bulk\Response as BulkResponse;
+use Elastica\Bulk\ResponseSet;
+use Elastica\Exception\Bulk\ResponseException as BulkResponseException;
+use Elastica\Exception\Bulk\UdpException;
+use Elastica\Exception\InvalidException;
class Bulk
{
@@ -58,7 +51,8 @@ class Bulk
/**
* @param string|\Elastica\Index $index
- * @return \Elastica\Bulk
+ *
+ * @return $this
*/
public function setIndex($index)
{
@@ -89,7 +83,8 @@ class Bulk
/**
* @param string|\Elastica\Type $type
- * @return \Elastica\Bulk
+ *
+ * @return $this
*/
public function setType($type)
{
@@ -126,28 +121,32 @@ class Bulk
{
$path = '';
if ($this->hasIndex()) {
- $path .= $this->getIndex() . '/';
+ $path .= $this->getIndex().'/';
if ($this->hasType()) {
- $path .= $this->getType() . '/';
+ $path .= $this->getType().'/';
}
}
$path .= '_bulk';
+
return $path;
}
/**
* @param \Elastica\Bulk\Action $action
- * @return \Elastica\Bulk
+ *
+ * @return $this
*/
public function addAction(Action $action)
{
$this->_actions[] = $action;
+
return $this;
}
/**
* @param \Elastica\Bulk\Action[] $actions
- * @return \Elastica\Bulk
+ *
+ * @return $this
*/
public function addActions(array $actions)
{
@@ -168,8 +167,9 @@ class Bulk
/**
* @param \Elastica\Document $document
- * @param string $opType
- * @return \Elastica\Bulk
+ * @param string $opType
+ *
+ * @return $this
*/
public function addDocument(Document $document, $opType = null)
{
@@ -180,8 +180,9 @@ class Bulk
/**
* @param \Elastica\Document[] $documents
- * @param string $opType
- * @return \Elastica\Bulk
+ * @param string $opType
+ *
+ * @return $this
*/
public function addDocuments(array $documents, $opType = null)
{
@@ -194,8 +195,9 @@ class Bulk
/**
* @param \Elastica\Script $data
- * @param string $opType
- * @return \Elastica\Bulk
+ * @param string $opType
+ *
+ * @return $this
*/
public function addScript(Script $script, $opType = null)
{
@@ -206,8 +208,9 @@ class Bulk
/**
* @param \Elastica\Document[] $scripts
- * @param string $opType
- * @return \Elastica\Bulk
+ * @param string $opType
+ *
+ * @return $this
*/
public function addScripts(array $scripts, $opType = null)
{
@@ -220,23 +223,23 @@ class Bulk
/**
* @param \Elastica\Script|\Elastica\Document\array $data
- * @param string $opType
- * @return \Elastica\Bulk
+ * @param string $opType
+ *
+ * @return $this
*/
public function addData($data, $opType = null)
{
- if(!is_array($data)){
+ if (!is_array($data)) {
$data = array($data);
}
- foreach ($data as $actionData){
-
- if ($actionData instanceOf Script) {
+ foreach ($data as $actionData) {
+ if ($actionData instanceof Script) {
$this->addScript($actionData, $opType);
- }else if ($actionData instanceof Document) {
+ } elseif ($actionData instanceof Document) {
$this->addDocument($actionData, $opType);
- }else{
- throw new \InvalidArgumentException("Data should be a Document, a Script or an array containing Documents and/or Scripts");
+ } else {
+ throw new \InvalidArgumentException('Data should be a Document, a Script or an array containing Documents and/or Scripts');
}
}
@@ -245,8 +248,10 @@ class Bulk
/**
* @param array $data
- * @return \Elastica\Bulk
+ *
* @throws \Elastica\Exception\InvalidException
+ *
+ * @return $this
*/
public function addRawData(array $data)
{
@@ -282,20 +287,30 @@ class Bulk
/**
* Set a url parameter on the request bulk request.
- * @var string $name name of the parameter
- * @var string $value value of the parameter
+ *
+ * @param string $name name of the parameter
+ * @param string $value value of the parameter
+ *
+ * @return $this
*/
- public function setRequestParam($name, $value) {
- $this->_requestParams[ $name ] = $value;
+ public function setRequestParam($name, $value)
+ {
+ $this->_requestParams[$name] = $value;
+
+ return $this;
}
/**
* Set the amount of time that the request will wait the shards to come on line.
* Requires Elasticsearch version >= 0.90.8.
- * @var string $time timeout in Elasticsearch time format
+ *
+ * @param string $time timeout in Elasticsearch time format
+ *
+ * @return $this
*/
- public function setShardTimeout($time) {
- $this->setRequestParam( 'timeout', $time );
+ public function setShardTimeout($time)
+ {
+ return $this->setRequestParam('timeout', $time);
}
/**
@@ -313,8 +328,9 @@ class Bulk
{
$data = '';
foreach ($this->getActions() as $action) {
- $data.= $action->toString();
+ $data .= $action->toString();
}
+
return $data;
}
@@ -329,6 +345,7 @@ class Bulk
$data[] = $row;
}
}
+
return $data;
}
@@ -347,8 +364,10 @@ class Bulk
/**
* @param \Elastica\Response $response
- * @throws Exception\Bulk\ResponseException
- * @throws Exception\InvalidException
+ *
+ * @throws \Elastica\Exception\Bulk\ResponseException
+ * @throws \Elastica\Exception\InvalidException
+ *
* @return \Elastica\Bulk\ResponseSet
*/
protected function _processResponse(Response $response)
@@ -361,9 +380,8 @@ class Bulk
if (isset($responseData['items']) && is_array($responseData['items'])) {
foreach ($responseData['items'] as $key => $item) {
-
if (!isset($actions[$key])) {
- throw new InvalidException('No response found for action #' . $key);
+ throw new InvalidException('No response found for action #'.$key);
}
$action = $actions[$key];
@@ -400,7 +418,8 @@ class Bulk
/**
* @param string $host
- * @param int $port
+ * @param int $port
+ *
* @throws \Elastica\Exception\Bulk\UdpException
*/
public function sendUdp($host = null, $port = null)
diff --git a/vendor/ruflin/elastica/lib/Elastica/Bulk/Action.php b/vendor/ruflin/elastica/lib/Elastica/Bulk/Action.php
index 7922ec13..25d02adc 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Bulk/Action.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Bulk/Action.php
@@ -1,16 +1,15 @@
<?php
-
namespace Elastica\Bulk;
use Elastica\Bulk;
-use Elastica\JSON;
use Elastica\Index;
+use Elastica\JSON;
use Elastica\Type;
class Action
{
const OP_TYPE_CREATE = 'create';
- const OP_TYPE_INDEX = 'index';
+ const OP_TYPE_INDEX = 'index';
const OP_TYPE_DELETE = 'delete';
const OP_TYPE_UPDATE = 'update';
@@ -21,7 +20,7 @@ class Action
self::OP_TYPE_CREATE,
self::OP_TYPE_INDEX,
self::OP_TYPE_DELETE,
- self::OP_TYPE_UPDATE
+ self::OP_TYPE_UPDATE,
);
/**
@@ -41,8 +40,8 @@ class Action
/**
* @param string $opType
- * @param array $metadata
- * @param array $source
+ * @param array $metadata
+ * @param array $source
*/
public function __construct($opType = self::OP_TYPE_INDEX, array $metadata = array(), array $source = array())
{
@@ -53,7 +52,8 @@ class Action
/**
* @param string $type
- * @return \Elastica\Bulk\Action
+ *
+ * @return $this
*/
public function setOpType($type)
{
@@ -72,7 +72,8 @@ class Action
/**
* @param array $metadata
- * @return \Elastica\Bulk\Action
+ *
+ * @return $this
*/
public function setMetadata(array $metadata)
{
@@ -99,7 +100,8 @@ class Action
/**
* @param array $source
- * @return \Elastica\Bulk\Action
+ *
+ * @return $this
*/
public function setSource($source)
{
@@ -126,7 +128,8 @@ class Action
/**
* @param string|\Elastica\Index $index
- * @return \Elastica\Bulk\Action
+ *
+ * @return $this
*/
public function setIndex($index)
{
@@ -140,7 +143,8 @@ class Action
/**
* @param string|\Elastica\Type $type
- * @return \Elastica\Bulk\Action
+ *
+ * @return $this
*/
public function setType($type)
{
@@ -155,7 +159,8 @@ class Action
/**
* @param string $id
- * @return \Elastica\Bulk\Action
+ *
+ * @return $this
*/
public function setId($id)
{
@@ -166,7 +171,8 @@ class Action
/**
* @param string $routing
- * @return \Elastica\Bulk\Action
+ *
+ * @return $this
*/
public function setRouting($routing)
{
@@ -184,6 +190,7 @@ class Action
if ($this->hasSource()) {
$data[] = $this->getSource();
}
+
return $data;
}
@@ -192,24 +199,26 @@ class Action
*/
public function toString()
{
- $string = JSON::stringify($this->getActionMetadata(), JSON_FORCE_OBJECT) . Bulk::DELIMITER;
+ $string = JSON::stringify($this->getActionMetadata(), JSON_FORCE_OBJECT).Bulk::DELIMITER;
if ($this->hasSource()) {
$source = $this->getSource();
if (is_string($source)) {
- $string.= $source;
+ $string .= $source;
} elseif (is_array($source) && array_key_exists('doc', $source) && is_string($source['doc'])) {
$docAsUpsert = (isset($source['doc_as_upsert'])) ? ', "doc_as_upsert": '.$source['doc_as_upsert'] : '';
- $string.= '{"doc": '.$source['doc'].$docAsUpsert.'}';
+ $string .= '{"doc": '.$source['doc'].$docAsUpsert.'}';
} else {
- $string.= JSON::stringify($source, 'JSON_ELASTICSEARCH');
+ $string .= JSON::stringify($source, 'JSON_ELASTICSEARCH');
}
- $string.= Bulk::DELIMITER;
+ $string .= Bulk::DELIMITER;
}
+
return $string;
}
/**
* @param string $opType
+ *
* @return bool
*/
public static function isValidOpType($opType)
diff --git a/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/AbstractDocument.php b/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/AbstractDocument.php
index 545e695c..3127ff9c 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/AbstractDocument.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/AbstractDocument.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Bulk\Action;
use Elastica\AbstractUpdateAction;
@@ -24,7 +23,8 @@ abstract class AbstractDocument extends Action
/**
* @param \Elastica\Document $document
- * @return \Elastica\Bulk\Action\AbstractDocument
+ *
+ * @return $this
*/
public function setDocument(Document $document)
{
@@ -39,12 +39,13 @@ abstract class AbstractDocument extends Action
/**
* @param \Elastica\Script $script
- * @return \Elastica\Bulk\Action\AbstractDocument
+ *
+ * @return $this
*/
public function setScript(Script $script)
{
if (!($this instanceof UpdateDocument)) {
- throw new \BadMethodCallException("setScript() can only be used for UpdateDocument");
+ throw new \BadMethodCallException('setScript() can only be used for UpdateDocument');
}
$this->_data = $script;
@@ -57,21 +58,19 @@ abstract class AbstractDocument extends Action
/**
* @param \Elastica\Script|\Elastica\Document $data
+ *
* @throws \InvalidArgumentException
- * @return \Elastica\Bulk\Action\AbstractDocument
+ *
+ * @return $this
*/
public function setData($data)
{
if ($data instanceof Script) {
-
$this->setScript($data);
-
- }else if ($data instanceof Document) {
-
+ } elseif ($data instanceof Document) {
$this->setDocument($data);
-
- }else{
- throw new \InvalidArgumentException("Data should be a Document or a Script.");
+ } else {
+ throw new \InvalidArgumentException('Data should be a Document or a Script.');
}
return $this;
@@ -79,7 +78,8 @@ abstract class AbstractDocument extends Action
/**
* Note: This is for backwards compatibility.
- * @return \Elastica\Document
+ *
+ * @return \Elastica\Document|null
*/
public function getDocument()
{
@@ -87,12 +87,13 @@ abstract class AbstractDocument extends Action
return $this->_data;
}
- return null;
+ return;
}
/**
* Note: This is for backwards compatibility.
- * @return \Elastica\Script
+ *
+ * @return \Elastica\Script|null
*/
public function getScript()
{
@@ -100,7 +101,7 @@ abstract class AbstractDocument extends Action
return $this->_data;
}
- return null;
+ return;
}
/**
@@ -113,22 +114,24 @@ abstract class AbstractDocument extends Action
/**
* @param \Elastica\AbstractUpdateAction $source
+ *
* @return array
*/
abstract protected function _getMetadata(AbstractUpdateAction $source);
/**
* @param \Elastica\Document|\Elastica\Script $data
- * @param string $opType
- * @return \Elastica\Bulk\Action\AbstractDocument
+ * @param string $opType
+ *
+ * @return static
*/
public static function create($data, $opType = null)
{
- //Check type
- if (!($data instanceof Document) && !($data instanceof Script)) {
- throw new \InvalidArgumentException("The data needs to be a Document or a Script.");
- }
-
+ //Check type
+ if (!($data instanceof Document) && !($data instanceof Script)) {
+ throw new \InvalidArgumentException('The data needs to be a Document or a Script.');
+ }
+
if (null === $opType && $data->hasOpType()) {
$opType = $data->getOpType();
}
@@ -137,8 +140,8 @@ abstract class AbstractDocument extends Action
if ($data instanceof Script) {
if ($opType === null) {
$opType = self::OP_TYPE_UPDATE;
- } else if ($opType != self::OP_TYPE_UPDATE) {
- throw new \InvalidArgumentException("Scripts can only be used with the update operation type.");
+ } elseif ($opType != self::OP_TYPE_UPDATE) {
+ throw new \InvalidArgumentException('Scripts can only be used with the update operation type.');
}
}
@@ -157,6 +160,7 @@ abstract class AbstractDocument extends Action
$action = new IndexDocument($data);
break;
}
+
return $action;
}
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/CreateDocument.php b/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/CreateDocument.php
index ae868b49..82581856 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/CreateDocument.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/CreateDocument.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Bulk\Action;
class CreateDocument extends IndexDocument
diff --git a/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/DeleteDocument.php b/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/DeleteDocument.php
index 572f80b6..5a243870 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/DeleteDocument.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/DeleteDocument.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Bulk\Action;
use Elastica\AbstractUpdateAction;
@@ -13,6 +12,7 @@ class DeleteDocument extends AbstractDocument
/**
* @param \Elastica\AbstractUpdateAction $action
+ *
* @return array
*/
protected function _getMetadata(AbstractUpdateAction $action)
@@ -24,7 +24,7 @@ class DeleteDocument extends AbstractDocument
'version',
'version_type',
'routing',
- 'parent'
+ 'parent',
);
$metadata = $action->getOptions($params, true);
diff --git a/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/IndexDocument.php b/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/IndexDocument.php
index d405563e..0cf30e61 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/IndexDocument.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/IndexDocument.php
@@ -1,9 +1,7 @@
<?php
-
namespace Elastica\Bulk\Action;
use Elastica\AbstractUpdateAction;
-use Elastica\Bulk\Action;
use Elastica\Document;
class IndexDocument extends AbstractDocument
@@ -15,7 +13,8 @@ class IndexDocument extends AbstractDocument
/**
* @param \Elastica\Document $document
- * @return \Elastica\Bulk\Action\IndexDocument
+ *
+ * @return $this
*/
public function setDocument(Document $document)
{
@@ -28,6 +27,7 @@ class IndexDocument extends AbstractDocument
/**
* @param \Elastica\AbstractUpdateAction $source
+ *
* @return array
*/
protected function _getMetadata(AbstractUpdateAction $action)
@@ -45,6 +45,7 @@ class IndexDocument extends AbstractDocument
'timestamp',
'retry_on_conflict',
);
+
$metadata = $action->getOptions($params, true);
return $metadata;
diff --git a/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/UpdateDocument.php b/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/UpdateDocument.php
index 4c1dbaa4..2b133acb 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/UpdateDocument.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/UpdateDocument.php
@@ -1,14 +1,9 @@
<?php
-
namespace Elastica\Bulk\Action;
use Elastica\Document;
use Elastica\Script;
-/**
- * @package Elastica\Bulk\Action
- * @link http://www.elasticsearch.org/guide/reference/api/bulk/
- */
class UpdateDocument extends IndexDocument
{
/**
@@ -18,8 +13,10 @@ class UpdateDocument extends IndexDocument
/**
* Set the document for this bulk update action.
+ *
* @param \Elastica\Document $document
- * @return \Elastica\Bulk\Action\UpdateDocument
+ *
+ * @return $this
*/
public function setDocument(Document $document)
{
@@ -28,10 +25,8 @@ class UpdateDocument extends IndexDocument
$source = array('doc' => $document->getData());
if ($document->getDocAsUpsert()) {
- $source['doc_as_upsert'] = true;
-
- }else if ($document->hasUpsert()) {
-
+ $source['doc_as_upsert'] = true;
+ } elseif ($document->hasUpsert()) {
$upsert = $document->getUpsert()->getData();
if (!empty($upsert)) {
@@ -46,7 +41,8 @@ class UpdateDocument extends IndexDocument
/**
* @param \Elastica\Script $script
- * @return \Elastica\Bulk\Action\AbstractDocument
+ *
+ * @return $this
*/
public function setScript(Script $script)
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Bulk/Response.php b/vendor/ruflin/elastica/lib/Elastica/Bulk/Response.php
index 5abd1850..855a72c5 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Bulk/Response.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Bulk/Response.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Bulk;
use Elastica\Response as BaseResponse;
@@ -17,9 +16,9 @@ class Response extends BaseResponse
protected $_opType;
/**
- * @param array|string $responseData
+ * @param array|string $responseData
* @param \Elastica\Bulk\Action $action
- * @param string $opType
+ * @param string $opType
*/
public function __construct($responseData, Action $action, $opType)
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Bulk/ResponseSet.php b/vendor/ruflin/elastica/lib/Elastica/Bulk/ResponseSet.php
index 9fd835e4..1837203f 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Bulk/ResponseSet.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Bulk/ResponseSet.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Bulk;
use Elastica\Response as BaseResponse;
@@ -17,7 +16,7 @@ class ResponseSet extends BaseResponse implements \Iterator, \Countable
protected $_position = 0;
/**
- * @param \Elastica\Response $response
+ * @param \Elastica\Response $response
* @param \Elastica\Bulk\Response[] $bulkResponses
*/
public function __construct(BaseResponse $response, array $bulkResponses)
@@ -36,7 +35,7 @@ class ResponseSet extends BaseResponse implements \Iterator, \Countable
}
/**
- * Returns first found error
+ * Returns first found error.
*
* @return string
*/
diff --git a/vendor/ruflin/elastica/lib/Elastica/Client.php b/vendor/ruflin/elastica/lib/Elastica/Client.php
index a5821180..b30bdb43 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Client.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Client.php
@@ -1,27 +1,21 @@
<?php
-
namespace Elastica;
-use Elastica\Bulk;
use Elastica\Bulk\Action;
-use Elastica\Exception\ResponseException;
-use Elastica\Exception\ClientException;
use Elastica\Exception\ConnectionException;
use Elastica\Exception\InvalidException;
use Elastica\Exception\RuntimeException;
use Psr\Log\LoggerInterface;
/**
- * Client to connect the the elasticsearch server
+ * Client to connect the the elasticsearch server.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
*/
class Client
{
/**
- * Config with defaults
+ * Config with defaults.
*
* log: Set to true, to enable logging, set a string to log to a specific file
* retryOnConflict: Use in \Elastica\Client::updateDocument
@@ -29,26 +23,21 @@ class Client
* @var array
*/
protected $_config = array(
- 'host' => null,
- 'port' => null,
- 'path' => null,
- 'url' => null,
- 'proxy' => null,
- 'transport' => null,
- 'persistent' => true,
- 'timeout' => null,
- 'connections' => array(), // host, port, path, timeout, transport, persistent, timeout, config -> (curl, headers, url)
- 'roundRobin' => false,
- 'log' => false,
+ 'host' => null,
+ 'port' => null,
+ 'path' => null,
+ 'url' => null,
+ 'proxy' => null,
+ 'transport' => null,
+ 'persistent' => true,
+ 'timeout' => null,
+ 'connections' => array(), // host, port, path, timeout, transport, persistent, timeout, config -> (curl, headers, url)
+ 'roundRobin' => false,
+ 'log' => false,
'retryOnConflict' => 0,
);
/**
- * @var \Elastica\Connection[] List of connections
- */
- protected $_connections = array();
-
- /**
* @var callback
*/
protected $_callback = null;
@@ -67,9 +56,13 @@ class Client
* @var LoggerInterface
*/
protected $_logger = null;
+ /**
+ * @var Connection\ConnectionPool
+ */
+ protected $_connectionPool = null;
/**
- * Creates a new Elastica client
+ * Creates a new Elastica client.
*
* @param array $config OPTIONAL Additional config options
* @param callback $callback OPTIONAL Callback function which can be used to be notified about errors (for example connection down)
@@ -82,32 +75,45 @@ class Client
}
/**
- * Inits the client connections
+ * Inits the client connections.
*/
protected function _initConnections()
{
- $connections = $this->getConfig('connections');
+ $connections = array();
- foreach ($connections as $connection) {
- $this->_connections[] = Connection::create($this->_prepareConnectionParams($connection));
+ foreach ($this->getConfig('connections') as $connection) {
+ $connections[] = Connection::create($this->_prepareConnectionParams($connection));
}
if (isset($this->_config['servers'])) {
foreach ($this->getConfig('servers') as $server) {
- $this->_connections[] = Connection::create($this->_prepareConnectionParams($server));
+ $connections[] = Connection::create($this->_prepareConnectionParams($server));
}
}
// If no connections set, create default connection
- if (empty($this->_connections)) {
- $this->_connections[] = Connection::create($this->_prepareConnectionParams($this->getConfig()));
+ if (empty($connections)) {
+ $connections[] = Connection::create($this->_prepareConnectionParams($this->getConfig()));
}
+
+ if (!isset($this->_config['connectionStrategy'])) {
+ if ($this->getConfig('roundRobin') === true) {
+ $this->setConfigValue('connectionStrategy', 'RoundRobin');
+ } else {
+ $this->setConfigValue('connectionStrategy', 'Simple');
+ }
+ }
+
+ $strategy = Connection\Strategy\StrategyFactory::create($this->getConfig('connectionStrategy'));
+
+ $this->_connectionPool = new Connection\ConnectionPool($connections, $strategy, $this->_callback);
}
/**
* Creates a Connection params array from a Client or server config array.
*
* @param array $config
+ *
* @return array
*/
protected function _prepareConnectionParams(array $config)
@@ -126,10 +132,11 @@ class Client
}
/**
- * Sets specific config values (updates and keeps default values)
+ * Sets specific config values (updates and keeps default values).
+ *
+ * @param array $config Params
*
- * @param array $config Params
- * @return \Elastica\Client
+ * @return $this
*/
public function setConfig(array $config)
{
@@ -142,11 +149,13 @@ class Client
/**
* Returns a specific config key or the whole
- * config array if not set
+ * config array if not set.
+ *
+ * @param string $key Config key
*
- * @param string $key Config key
* @throws \Elastica\Exception\InvalidException
- * @return array|string Config value
+ *
+ * @return array|string Config value
*/
public function getConfig($key = '')
{
@@ -155,18 +164,19 @@ class Client
}
if (!array_key_exists($key, $this->_config)) {
- throw new InvalidException('Config key is not set: ' . $key);
+ throw new InvalidException('Config key is not set: '.$key);
}
return $this->_config[$key];
}
/**
- * Sets / overwrites a specific config value
+ * Sets / overwrites a specific config value.
+ *
+ * @param string $key Key to set
+ * @param mixed $value Value
*
- * @param string $key Key to set
- * @param mixed $value Value
- * @return \Elastica\Client Client object
+ * @return $this
*/
public function setConfigValue($key, $value)
{
@@ -174,8 +184,9 @@ class Client
}
/**
- * @param array|string $keys config key or path of config keys
- * @param mixed $default default value will be returned if key was not found
+ * @param array|string $keys config key or path of config keys
+ * @param mixed $default default value will be returned if key was not found
+ *
* @return mixed
*/
public function getConfigValue($keys, $default = null)
@@ -188,13 +199,15 @@ class Client
return $default;
}
}
+
return $value;
}
/**
- * Returns the index for the given connection
+ * Returns the index for the given connection.
+ *
+ * @param string $name Index name to create connection to
*
- * @param string $name Index name to create connection to
* @return \Elastica\Index Index for the given name
*/
public function getIndex($name)
@@ -203,11 +216,14 @@ class Client
}
/**
- * Adds a HTTP Header
+ * Adds a HTTP Header.
+ *
+ * @param string $header The HTTP Header
+ * @param string $headerValue The HTTP Header Value
*
- * @param string $header The HTTP Header
- * @param string $headerValue The HTTP Header Value
* @throws \Elastica\Exception\InvalidException If $header or $headerValue is not a string
+ *
+ * @return $this
*/
public function addHeader($header, $headerValue)
{
@@ -216,13 +232,18 @@ class Client
} else {
throw new InvalidException('Header must be a string');
}
+
+ return $this;
}
/**
- * Remove a HTTP Header
+ * Remove a HTTP Header.
*
- * @param string $header The HTTP Header to remove
- * @throws \Elastica\Exception\InvalidException IF $header is not a string
+ * @param string $header The HTTP Header to remove
+ *
+ * @throws \Elastica\Exception\InvalidException If $header is not a string
+ *
+ * @return $this
*/
public function removeHeader($header)
{
@@ -233,21 +254,27 @@ class Client
} else {
throw new InvalidException('Header must be a string');
}
+
+ return $this;
}
/**
- * Uses _bulk to send documents to the server
+ * Uses _bulk to send documents to the server.
*
* Array of \Elastica\Document as input. Index and type has to be
* set inside the document, because for bulk settings documents,
* documents can belong to any type and index
*
- * @param array|\Elastica\Document[] $docs Array of Elastica\Document
- * @return \Elastica\Bulk\ResponseSet Response object
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
+ *
+ * @param array|\Elastica\Document[] $docs Array of Elastica\Document
+ *
* @throws \Elastica\Exception\InvalidException If docs is empty
- * @link http://www.elasticsearch.org/guide/reference/api/bulk.html
+ *
+ * @return \Elastica\Bulk\ResponseSet Response object
*/
- public function updateDocuments(array $docs) {
+ public function updateDocuments(array $docs)
+ {
if (empty($docs)) {
throw new InvalidException('Array has to consist of at least one element');
}
@@ -260,16 +287,19 @@ class Client
}
/**
- * Uses _bulk to send documents to the server
+ * Uses _bulk to send documents to the server.
*
* Array of \Elastica\Document as input. Index and type has to be
* set inside the document, because for bulk settings documents,
* documents can belong to any type and index
*
- * @param array|\Elastica\Document[] $docs Array of Elastica\Document
- * @return \Elastica\Bulk\ResponseSet Response object
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
+ *
+ * @param array|\Elastica\Document[] $docs Array of Elastica\Document
+ *
* @throws \Elastica\Exception\InvalidException If docs is empty
- * @link http://www.elasticsearch.org/guide/reference/api/bulk.html
+ *
+ * @return \Elastica\Bulk\ResponseSet Response object
*/
public function addDocuments(array $docs)
{
@@ -285,25 +315,25 @@ class Client
}
/**
- * Update document, using update script. Requires elasticsearch >= 0.19.0
+ * Update document, using update script. Requires elasticsearch >= 0.19.0.
+ *
+ * @param int $id document id
+ * @param array|\Elastica\Script|\Elastica\Document $data raw data for request body
+ * @param string $index index to update
+ * @param string $type type of index to update
+ * @param array $options array of query params to use for query. For possible options check es api
*
- * @param int $id document id
- * @param array|\Elastica\Script|\Elastica\Document $data raw data for request body
- * @param string $index index to update
- * @param string $type type of index to update
- * @param array $options array of query params to use for query. For possible options check es api
* @return \Elastica\Response
- * @link http://www.elasticsearch.org/guide/reference/api/update.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html
*/
public function updateDocument($id, $data, $index, $type, array $options = array())
{
- $path = $index . '/' . $type . '/' . $id . '/_update';
+ $path = $index.'/'.$type.'/'.$id.'/_update';
if ($data instanceof Script) {
$requestData = $data->toArray();
-
} elseif ($data instanceof Document) {
-
$requestData = array('doc' => $data->getData());
if ($data->getDocAsUpsert()) {
@@ -339,14 +369,13 @@ class Client
//If an upsert document exists
if ($data instanceof Script || $data instanceof Document) {
-
if ($data->hasUpsert()) {
$requestData['upsert'] = $data->getUpsert()->getData();
}
}
if (!isset($options['retry_on_conflict'])) {
- $retryOnConflict = $this->getConfig("retryOnConflict");
+ $retryOnConflict = $this->getConfig('retryOnConflict');
$options['retry_on_conflict'] = $retryOnConflict;
}
@@ -371,7 +400,7 @@ class Client
/**
* @param \Elastica\Response $response
* @param \Elastica\Document $document
- * @param string $fields Array of field names to be populated or '_source' if whole document data should be updated
+ * @param string $fields Array of field names to be populated or '_source' if whole document data should be updated
*/
protected function _populateDocumentFieldsFromResponse(Response $response, Document $document, $fields)
{
@@ -395,11 +424,13 @@ class Client
}
/**
- * Bulk deletes documents
+ * Bulk deletes documents.
*
* @param array|\Elastica\Document[] $docs
- * @return \Elastica\Bulk\ResponseSet
+ *
* @throws \Elastica\Exception\InvalidException
+ *
+ * @return \Elastica\Bulk\ResponseSet
*/
public function deleteDocuments(array $docs)
{
@@ -414,7 +445,7 @@ class Client
}
/**
- * Returns the status object for all indices
+ * Returns the status object for all indices.
*
* @return \Elastica\Status Status object
*/
@@ -424,7 +455,7 @@ class Client
}
/**
- * Returns the current cluster
+ * Returns the current cluster.
*
* @return \Elastica\Cluster Cluster object
*/
@@ -434,54 +465,35 @@ class Client
}
/**
- * @param \Elastica\Connection $connection
- * @return \Elastica\Client
+ * @param \Elastica\Connection $connection
+ *
+ * @return $this
*/
public function addConnection(Connection $connection)
{
- $this->_connections[] = $connection;
+ $this->_connectionPool->addConnection($connection);
return $this;
}
/**
* Determines whether a valid connection is available for use.
- *
+ *
* @return bool
*/
public function hasConnection()
{
- foreach ($this->_connections as $connection)
- {
- if ($connection->isEnabled())
- {
- return true;
- }
- }
-
- return false;
+ return $this->_connectionPool->hasConnection();
}
/**
* @throws \Elastica\Exception\ClientException
+ *
* @return \Elastica\Connection
*/
public function getConnection()
{
- $enabledConnection = null;
-
- foreach ($this->_connections as $connection) {
- if ($connection->isEnabled()) {
- $enabledConnection = $connection;
- break;
- }
- }
-
- if (empty($enabledConnection)) {
- throw new ClientException('No enabled connection');
- }
-
- return $enabledConnection;
+ return $this->_connectionPool->getConnection();
}
/**
@@ -489,30 +501,42 @@ class Client
*/
public function getConnections()
{
- return $this->_connections;
+ return $this->_connectionPool->getConnections();
+ }
+
+ /**
+ * @return \Elastica\Connection\Strategy\StrategyInterface
+ */
+ public function getConnectionStrategy()
+ {
+ return $this->_connectionPool->getStrategy();
}
/**
- * @param \Elastica\Connection[] $connections
- * @return \Elastica\Client
+ * @param array|\Elastica\Connection[] $connections
+ *
+ * @return $this
*/
public function setConnections(array $connections)
{
- $this->_connections = $connections;
+ $this->_connectionPool->setConnections($connections);
return $this;
}
/**
- * Deletes documents with the given ids, index, type from the index
+ * Deletes documents with the given ids, index, type from the index.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
+ *
+ * @param array $ids Document ids
+ * @param string|\Elastica\Index $index Index name
+ * @param string|\Elastica\Type $type Type of documents
+ * @param string|false $routing Optional routing key for all ids
*
- * @param array $ids Document ids
- * @param string|\Elastica\Index $index Index name
- * @param string|\Elastica\Type $type Type of documents
- * @param string|false $routing Optional routing key for all ids
* @throws \Elastica\Exception\InvalidException
- * @return \Elastica\Bulk\ResponseSet Response object
- * @link http://www.elasticsearch.org/guide/reference/api/bulk.html
+ *
+ * @return \Elastica\Bulk\ResponseSet Response object
*/
public function deleteIds(array $ids, $index, $type, $routing = false)
{
@@ -539,7 +563,7 @@ class Client
}
/**
- * Bulk operation
+ * Bulk operation.
*
* Every entry in the params array has to exactly on array
* of the bulk operation. An example param array would be:
@@ -550,11 +574,14 @@ class Client
* array('delete' => array('_index' => 'test', '_type' => 'user', '_id' => '2'))
* );
*
- * @param array $params Parameter array
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
+ *
+ * @param array $params Parameter array
+ *
* @throws \Elastica\Exception\ResponseException
* @throws \Elastica\Exception\InvalidException
- * @return \Elastica\Bulk\ResponseSet Response object
- * @link http://www.elasticsearch.org/guide/reference/api/bulk.html
+ *
+ * @return \Elastica\Bulk\ResponseSet Response object
*/
public function bulk(array $params)
{
@@ -570,15 +597,17 @@ class Client
}
/**
- * Makes calls to the elasticsearch server based on this index
+ * Makes calls to the elasticsearch server based on this index.
*
* It's possible to make any REST query directly over this method
*
- * @param string $path Path to call
- * @param string $method Rest method to use (GET, POST, DELETE, PUT)
- * @param array $data OPTIONAL Arguments as array
- * @param array $query OPTIONAL Query params
+ * @param string $path Path to call
+ * @param string $method Rest method to use (GET, POST, DELETE, PUT)
+ * @param array $data OPTIONAL Arguments as array
+ * @param array $query OPTIONAL Query params
+ *
* @throws Exception\ConnectionException|\Exception
+ *
* @return \Elastica\Response Response object
*/
public function request($path, $method = Request::GET, $data = array(), array $query = array())
@@ -595,30 +624,26 @@ class Client
$this->_lastResponse = $response;
return $response;
-
} catch (ConnectionException $e) {
- $connection->setEnabled(false);
-
- // Calls callback with connection as param to make it possible to persist invalid connections
- if ($this->_callback) {
- call_user_func($this->_callback, $connection, $e, $this);
- }
+ $this->_connectionPool->onFail($connection, $e, $this);
// In case there is no valid connection left, throw exception which caused the disabling of the connection.
- if (!$this->hasConnection())
- {
+ if (!$this->hasConnection()) {
throw $e;
}
+
return $this->request($path, $method, $data, $query);
}
}
/**
- * Optimizes all search indices
+ * Optimizes all search indices.
+ *
+ * @param array $args OPTIONAL Optional arguments
*
- * @param array $args OPTIONAL Optional arguments
* @return \Elastica\Response Response object
- * @link http://www.elasticsearch.org/guide/reference/api/admin-indices-optimize.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-optimize.html
*/
public function optimizeAll($args = array())
{
@@ -626,10 +651,11 @@ class Client
}
/**
- * Refreshes all search indices
+ * Refreshes all search indices.
*
* @return \Elastica\Response Response object
- * @link http://www.elasticsearch.org/guide/reference/api/admin-indices-refresh.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-refresh.html
*/
public function refreshAll()
{
@@ -637,9 +663,10 @@ class Client
}
/**
- * logging
+ * logging.
*
* @param string|\Elastica\Request $context
+ *
* @throws Exception\RuntimeException
*/
protected function _log($context)
@@ -677,9 +704,10 @@ class Client
}
/**
- * set Logger
+ * set Logger.
*
* @param LoggerInterface $logger
+ *
* @return $this
*/
public function setLogger(LoggerInterface $logger)
diff --git a/vendor/ruflin/elastica/lib/Elastica/Cluster.php b/vendor/ruflin/elastica/lib/Elastica/Cluster.php
index ac5acf76..990aeeb2 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Cluster.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Cluster.php
@@ -1,22 +1,21 @@
<?php
-
namespace Elastica;
+
use Elastica\Cluster\Health;
use Elastica\Cluster\Settings;
use Elastica\Exception\NotImplementedException;
/**
- * Cluster informations for elasticsearch
+ * Cluster informations for elasticsearch.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/api/
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster.html
*/
class Cluster
{
/**
- * Client
+ * Client.
*
* @var \Elastica\Client Client object
*/
@@ -37,7 +36,7 @@ class Cluster
protected $_data;
/**
- * Creates a cluster object
+ * Creates a cluster object.
*
* @param \Elastica\Client $client Connection client object
*/
@@ -48,7 +47,7 @@ class Cluster
}
/**
- * Refreshes all cluster information (state)
+ * Refreshes all cluster information (state).
*/
public function refresh()
{
@@ -58,7 +57,7 @@ class Cluster
}
/**
- * Returns the response object
+ * Returns the response object.
*
* @return \Elastica\Response Response object
*/
@@ -68,7 +67,7 @@ class Cluster
}
/**
- * Return list of index names
+ * Return list of index names.
*
* @return array List of index names
*/
@@ -85,10 +84,11 @@ class Cluster
}
/**
- * Returns the full state of the cluster
+ * Returns the full state of the cluster.
*
* @return array State array
- * @link http://www.elasticsearch.org/guide/reference/api/admin-cluster-state.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-state.html
*/
public function getState()
{
@@ -96,34 +96,40 @@ class Cluster
}
/**
- * Returns a list of existing node names
+ * Returns a list of existing node names.
*
* @return array List of node names
*/
public function getNodeNames()
{
$data = $this->getState();
+ $nodeNames = array();
+ foreach ($data['nodes'] as $node) {
+ $nodeNames[] = $node['name'];
+ }
- return array_keys($data['routing_nodes']['nodes']);
+ return $nodeNames;
}
/**
- * Returns all nodes of the cluster
+ * Returns all nodes of the cluster.
*
* @return \Elastica\Node[]
*/
public function getNodes()
{
$nodes = array();
- foreach ($this->getNodeNames() as $name) {
- $nodes[] = new Node($name, $this->getClient());
+ $data = $this->getState();
+
+ foreach ($data['nodes'] as $id => $name) {
+ $nodes[] = new Node($id, $this->getClient());
}
return $nodes;
}
/**
- * Returns the client object
+ * Returns the client object.
*
* @return \Elastica\Client Client object
*/
@@ -133,11 +139,13 @@ class Cluster
}
/**
- * Returns the cluster information (not implemented yet)
+ * Returns the cluster information (not implemented yet).
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-info.html
+ *
+ * @param array $args Additional arguments
*
- * @param array $args Additional arguments
* @throws \Elastica\Exception\NotImplementedException
- * @link http://www.elasticsearch.org/guide/reference/api/admin-cluster-nodes-info.html
*/
public function getInfo(array $args)
{
@@ -145,10 +153,11 @@ class Cluster
}
/**
- * Return Cluster health
+ * Return Cluster health.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html
*
* @return \Elastica\Cluster\Health
- * @link http://www.elasticsearch.org/guide/reference/api/admin-cluster-health.html
*/
public function getHealth()
{
@@ -156,7 +165,7 @@ class Cluster
}
/**
- * Return Cluster settings
+ * Return Cluster settings.
*
* @return \Elastica\Cluster\Settings
*/
@@ -166,15 +175,17 @@ class Cluster
}
/**
- * Shuts down the complete cluster
+ * Shuts down the complete cluster.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-shutdown.html
+ *
+ * @param string $delay OPTIONAL Seconds to shutdown cluster after (default = 1s)
*
- * @param string $delay OPTIONAL Seconds to shutdown cluster after (default = 1s)
* @return \Elastica\Response
- * @link http://www.elasticsearch.org/guide/reference/api/admin-cluster-nodes-shutdown.html
*/
public function shutdown($delay = '1s')
{
- $path = '_shutdown?delay=' . $delay;
+ $path = '_shutdown?delay='.$delay;
return $this->_client->request($path, Request::POST);
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Cluster/Health.php b/vendor/ruflin/elastica/lib/Elastica/Cluster/Health.php
index 18c77cfc..d5d25ff1 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Cluster/Health.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Cluster/Health.php
@@ -1,6 +1,6 @@
<?php
-
namespace Elastica\Cluster;
+
use Elastica\Client;
use Elastica\Cluster\Health\Index;
use Elastica\Request;
@@ -8,23 +8,19 @@ use Elastica\Request;
/**
* Elastic cluster health.
*
- * @package Elastica
* @author Ray Ward <ray.ward@bigcommerce.com>
- * @link http://www.elasticsearch.org/guide/reference/api/admin-cluster-health.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html
*/
class Health
{
/**
- * Elastica client.
- *
- * @var \Elastica\Client Client object
+ * @var \Elastica\Client Client object.
*/
protected $_client = null;
/**
- * The cluster health data.
- *
- * @var array
+ * @var array The cluster health data.
*/
protected $_data = null;
@@ -63,7 +59,7 @@ class Health
/**
* Refreshes the health data for the cluster.
*
- * @return \Elastica\Cluster\Health
+ * @return $this
*/
public function refresh()
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Cluster/Health/Index.php b/vendor/ruflin/elastica/lib/Elastica/Cluster/Health/Index.php
index c39e94c3..ef55bd00 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Cluster/Health/Index.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Cluster/Health/Index.php
@@ -1,27 +1,22 @@
<?php
-
namespace Elastica\Cluster\Health;
/**
* Wraps status information for an index.
*
- * @package Elastica
* @author Ray Ward <ray.ward@bigcommerce.com>
- * @link http://www.elasticsearch.org/guide/reference/api/admin-cluster-health.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html
*/
class Index
{
/**
- * The name of the index.
- *
- * @var string
+ * @var string The name of the index.
*/
protected $_name;
/**
- * The index health data.
- *
- * @var array
+ * @var array The index health data.
*/
protected $_data;
diff --git a/vendor/ruflin/elastica/lib/Elastica/Cluster/Health/Shard.php b/vendor/ruflin/elastica/lib/Elastica/Cluster/Health/Shard.php
index a5da08ae..e1d2c8dc 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Cluster/Health/Shard.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Cluster/Health/Shard.php
@@ -1,27 +1,22 @@
<?php
-
namespace Elastica\Cluster\Health;
/**
* Wraps status information for a shard.
*
- * @package Elastica
* @author Ray Ward <ray.ward@bigcommerce.com>
- * @link http://www.elasticsearch.org/guide/reference/api/admin-cluster-health.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html
*/
class Shard
{
/**
- * The shard index/number.
- *
- * @var int
+ * @var int The shard index/number.
*/
protected $_shardNumber;
/**
- * The shard health data.
- *
- * @var array
+ * @var array The shard health data.
*/
protected $_data;
diff --git a/vendor/ruflin/elastica/lib/Elastica/Cluster/Settings.php b/vendor/ruflin/elastica/lib/Elastica/Cluster/Settings.php
index 8166dda3..c597417f 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Cluster/Settings.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Cluster/Settings.php
@@ -1,29 +1,25 @@
<?php
-
namespace Elastica\Cluster;
use Elastica\Client;
use Elastica\Request;
/**
- * Cluster settings
+ * Cluster settings.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/api/admin-cluster-update-settings.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-update-settings.html
*/
class Settings
{
/**
- * Client
- *
* @var \Elastica\Client Client object
*/
protected $_client = null;
/**
- * Creates a cluster object
+ * Creates a cluster object.
*
* @param \Elastica\Client $client Connection client object
*/
@@ -33,7 +29,7 @@ class Settings
}
/**
- * Returns settings data
+ * Returns settings data.
*
* @return array Settings data (persistent and transient)
*/
@@ -43,11 +39,12 @@ class Settings
}
/**
- * Returns the current persistent settings of the cluster
+ * Returns the current persistent settings of the cluster.
*
* If param is set, only specified setting is return.
*
- * @param string $setting OPTIONAL Setting name to return
+ * @param string $setting OPTIONAL Setting name to return
+ *
* @return array|string|null Settings data
*/
public function getPersistent($setting = '')
@@ -59,7 +56,7 @@ class Settings
if (isset($settings[$setting])) {
return $settings[$setting];
} else {
- return null;
+ return;
}
}
@@ -67,11 +64,12 @@ class Settings
}
/**
- * Returns the current transient settings of the cluster
+ * Returns the current transient settings of the cluster.
*
* If param is set, only specified setting is return.
*
- * @param string $setting OPTIONAL Setting name to return
+ * @param string $setting OPTIONAL Setting name to return
+ *
* @return array|string|null Settings data
*/
public function getTransient($setting = '')
@@ -90,12 +88,14 @@ class Settings
if (isset($settings[$key])) {
$settings = $settings[$key];
} else {
- return null;
+ return;
}
}
+
return $settings;
}
- return null;
+
+ return;
}
}
@@ -103,10 +103,11 @@ class Settings
}
/**
- * Sets persistent setting
+ * Sets persistent setting.
+ *
+ * @param string $key
+ * @param string $value
*
- * @param string $key
- * @param string $value
* @return \Elastica\Response
*/
public function setPersistent($key, $value)
@@ -114,17 +115,18 @@ class Settings
return $this->set(
array(
'persistent' => array(
- $key => $value
- )
+ $key => $value,
+ ),
)
);
}
/**
- * Sets transient settings
+ * Sets transient settings.
+ *
+ * @param string $key
+ * @param string $value
*
- * @param string $key
- * @param string $value
* @return \Elastica\Response
*/
public function setTransient($key, $value)
@@ -132,19 +134,20 @@ class Settings
return $this->set(
array(
'transient' => array(
- $key => $value
- )
+ $key => $value,
+ ),
)
);
}
/**
- * Sets the cluster to read only
+ * Sets the cluster to read only.
*
* Second param can be used to set it persistent
*
- * @param bool $readOnly
- * @param bool $persistent
+ * @param bool $readOnly
+ * @param bool $persistent
+ *
* @return \Elastica\Response $response
*/
public function setReadOnly($readOnly = true, $persistent = false)
@@ -161,9 +164,10 @@ class Settings
}
/**
- * Set settings for cluster
+ * Set settings for cluster.
+ *
+ * @param array $settings Raw settings (including persistent or transient)
*
- * @param array $settings Raw settings (including persistent or transient)
* @return \Elastica\Response
*/
public function set(array $settings)
@@ -172,7 +176,7 @@ class Settings
}
/**
- * Get the client
+ * Get the client.
*
* @return \Elastica\Client
*/
@@ -182,10 +186,11 @@ class Settings
}
/**
- * Sends settings request
+ * Sends settings request.
+ *
+ * @param array $data OPTIONAL Data array
+ * @param string $method OPTIONAL Transfer method (default = \Elastica\Request::GET)
*
- * @param array $data OPTIONAL Data array
- * @param string $method OPTIONAL Transfer method (default = \Elastica\Request::GET)
* @return \Elastica\Response Response object
*/
public function request(array $data = array(), $method = Request::GET)
diff --git a/vendor/ruflin/elastica/lib/Elastica/Connection.php b/vendor/ruflin/elastica/lib/Elastica/Connection.php
index b9d910c9..0084b6ee 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Connection.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Connection.php
@@ -1,30 +1,28 @@
<?php
-
namespace Elastica;
+
use Elastica\Exception\InvalidException;
use Elastica\Transport\AbstractTransport;
/**
- * Elastica connection instance to an elasticasearch node
+ * Elastica connection instance to an elasticasearch node.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
*/
class Connection extends Param
{
/**
- * Default elastic search port
+ * Default elastic search port.
*/
const DEFAULT_PORT = 9200;
/**
- * Default host
+ * Default host.
*/
const DEFAULT_HOST = 'localhost';
/**
- * Default transport
+ * Default transport.
*
* @var string
*/
@@ -37,7 +35,14 @@ class Connection extends Param
const TIMEOUT = 300;
/**
- * Creates a new connection object. A connection is enabled by default
+ * Number of seconds after a connection timeout occurs for every request during the connection phase.
+ *
+ * @see Connection::setConnectTimeout();
+ */
+ const CONNECT_TIMEOUT = 0;
+
+ /**
+ * Creates a new connection object. A connection is enabled by default.
*
* @param array $params OPTIONAL Connection params: host, port, transport, timeout. All are optional
*/
@@ -57,12 +62,13 @@ class Connection extends Param
*/
public function getPort()
{
- return $this->hasParam('port')?$this->getParam('port'):self::DEFAULT_PORT;
+ return $this->hasParam('port') ? $this->getParam('port') : self::DEFAULT_PORT;
}
/**
- * @param int $port
- * @return \Elastica\Connection
+ * @param int $port
+ *
+ * @return $this
*/
public function setPort($port)
{
@@ -74,12 +80,13 @@ class Connection extends Param
*/
public function getHost()
{
- return $this->hasParam('host')?$this->getParam('host'):self::DEFAULT_HOST;
+ return $this->hasParam('host') ? $this->getParam('host') : self::DEFAULT_HOST;
}
/**
- * @param string $host
- * @return \Elastica\Connection
+ * @param string $host
+ *
+ * @return $this
*/
public function setHost($host)
{
@@ -91,7 +98,7 @@ class Connection extends Param
*/
public function getProxy()
{
- return $this->hasParam('proxy')?$this->getParam('proxy'):null;
+ return $this->hasParam('proxy') ? $this->getParam('proxy') : null;
}
/**
@@ -99,8 +106,10 @@ class Connection extends Param
* empty string to disable proxy and proxy string to set actual http proxy.
*
* @see http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPROXY
- * @param string|null $proxy
- * @return \Elastica\Connection
+ *
+ * @param string|null $proxy
+ *
+ * @return $this
*/
public function setProxy($proxy)
{
@@ -112,12 +121,13 @@ class Connection extends Param
*/
public function getTransport()
{
- return $this->hasParam('transport')?$this->getParam('transport'):self::DEFAULT_TRANSPORT;
+ return $this->hasParam('transport') ? $this->getParam('transport') : self::DEFAULT_TRANSPORT;
}
/**
- * @param string|array $transport
- * @return \Elastica\Connection
+ * @param string|array $transport
+ *
+ * @return $this
*/
public function setTransport($transport)
{
@@ -129,12 +139,13 @@ class Connection extends Param
*/
public function getPath()
{
- return $this->hasParam('path')?$this->getParam('path'):'';
+ return $this->hasParam('path') ? $this->getParam('path') : '';
}
/**
- * @param string $path
- * @return \Elastica\Connection
+ * @param string $path
+ *
+ * @return $this
*/
public function setPath($path)
{
@@ -142,8 +153,9 @@ class Connection extends Param
}
/**
- * @param int $timeout Timeout in seconds
- * @return \Elastica\Connection
+ * @param int $timeout Timeout in seconds
+ *
+ * @return $this
*/
public function setTimeout($timeout)
{
@@ -155,14 +167,40 @@ class Connection extends Param
*/
public function getTimeout()
{
- return (int) $this->hasParam('timeout')?$this->getParam('timeout'):self::TIMEOUT;
+ return (int) $this->hasParam('timeout') ? $this->getParam('timeout') : self::TIMEOUT;
}
/**
- * Enables a connection
+ * Number of seconds after a connection timeout occurs for every request during the connection phase.
+ * Use a small value if you need a fast fail in case of dead, unresponsive or unreachable servers (~5 sec).
+ *
+ * Set to zero to switch to the default built-in connection timeout (300 seconds in curl).
+ *
+ * @see http://curl.haxx.se/libcurl/c/CURLOPT_CONNECTTIMEOUT.html
*
- * @param bool $enabled OPTIONAL (default = true)
- * @return \Elastica\Connection
+ * @param int $timeout Connect timeout in seconds
+ *
+ * @return $this
+ */
+ public function setConnectTimeout($timeout)
+ {
+ return $this->setParam('connectTimeout', $timeout);
+ }
+
+ /**
+ * @return int Connection timeout in seconds
+ */
+ public function getConnectTimeout()
+ {
+ return (int) $this->hasParam('connectTimeout') ? $this->getParam('connectTimeout') : self::CONNECT_TIMEOUT;
+ }
+
+ /**
+ * Enables a connection.
+ *
+ * @param bool $enabled OPTIONAL (default = true)
+ *
+ * @return $this
*/
public function setEnabled($enabled = true)
{
@@ -178,10 +216,11 @@ class Connection extends Param
}
/**
- * Returns an instance of the transport type
+ * Returns an instance of the transport type.
+ *
+ * @throws \Elastica\Exception\InvalidException If invalid transport type
*
* @return \Elastica\Transport\AbstractTransport Transport object
- * @throws \Elastica\Exception\InvalidException If invalid transport type
*/
public function getTransportObject()
{
@@ -195,12 +234,13 @@ class Connection extends Param
*/
public function isPersistent()
{
- return (bool) $this->hasParam('persistent')?$this->getParam('persistent'):true;
+ return (bool) $this->hasParam('persistent') ? $this->getParam('persistent') : true;
}
/**
- * @param array $config
- * @return \Elastica\Connection
+ * @param array $config
+ *
+ * @return $this
*/
public function setConfig(array $config)
{
@@ -208,9 +248,10 @@ class Connection extends Param
}
/**
- * @param string $key
- * @param mixed $value
- * @return \Elastica\Connection
+ * @param string $key
+ * @param mixed $value
+ *
+ * @return $this
*/
public function addConfig($key, $value)
{
@@ -220,7 +261,8 @@ class Connection extends Param
}
/**
- * @param string $key
+ * @param string $key
+ *
* @return bool
*/
public function hasConfig($key)
@@ -232,11 +274,13 @@ class Connection extends Param
/**
* Returns a specific config key or the whole
- * config array if not set
+ * config array if not set.
+ *
+ * @param string $key Config key
*
- * @param string $key Config key
* @throws \Elastica\Exception\InvalidException
- * @return array|string Config value
+ *
+ * @return array|string Config value
*/
public function getConfig($key = '')
{
@@ -246,25 +290,27 @@ class Connection extends Param
}
if (!array_key_exists($key, $config)) {
- throw new InvalidException('Config key is not set: ' . $key);
+ throw new InvalidException('Config key is not set: '.$key);
}
return $config[$key];
}
/**
- * @param \Elastica\Connection|array $params Params to create a connection
+ * @param \Elastica\Connection|array $params Params to create a connection
+ *
* @throws Exception\InvalidException
- * @return \Elastica\Connection
+ *
+ * @return self
*/
public static function create($params = array())
{
$connection = null;
- if ($params instanceof Connection) {
+ if ($params instanceof self) {
$connection = $params;
} elseif (is_array($params)) {
- $connection = new Connection($params);
+ $connection = new self($params);
} else {
throw new InvalidException('Invalid data type');
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Connection/ConnectionPool.php b/vendor/ruflin/elastica/lib/Elastica/Connection/ConnectionPool.php
new file mode 100644
index 00000000..b5fa681d
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Connection/ConnectionPool.php
@@ -0,0 +1,122 @@
+<?php
+namespace Elastica\Connection;
+
+use Elastica\Client;
+use Elastica\Connection;
+use Elastica\Connection\Strategy\StrategyInterface;
+use Exception;
+
+/**
+ * Description of ConnectionPool.
+ *
+ * @author chabior
+ */
+class ConnectionPool
+{
+ /**
+ * @var array|\Elastica\Connection[] Connections array
+ */
+ protected $_connections;
+
+ /**
+ * @var \Elastica\Connection\Strategy\StrategyInterface Strategy for connection
+ */
+ protected $_strategy;
+
+ /**
+ * @var callback Function called on connection fail
+ */
+ protected $_callback;
+
+ /**
+ * @param array $connections
+ * @param \Elastica\Connection\Strategy\StrategyInterface $strategy
+ * @param callback $callback
+ */
+ public function __construct(array $connections, StrategyInterface $strategy, $callback = null)
+ {
+ $this->_connections = $connections;
+
+ $this->_strategy = $strategy;
+
+ $this->_callback = $callback;
+ }
+
+ /**
+ * @param \Elastica\Connection $connection
+ *
+ * @return $this
+ */
+ public function addConnection(Connection $connection)
+ {
+ $this->_connections[] = $connection;
+
+ return $this;
+ }
+
+ /**
+ * @param array|\Elastica\Connection[] $connections
+ *
+ * @return $this
+ */
+ public function setConnections(array $connections)
+ {
+ $this->_connections = $connections;
+
+ return $this;
+ }
+
+ /**
+ * @return bool
+ */
+ public function hasConnection()
+ {
+ foreach ($this->_connections as $connection) {
+ if ($connection->isEnabled()) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * @return array
+ */
+ public function getConnections()
+ {
+ return $this->_connections;
+ }
+
+ /**
+ * @throws \Elastica\Exception\ClientException
+ *
+ * @return \Elastica\Connection
+ */
+ public function getConnection()
+ {
+ return $this->_strategy->getConnection($this->getConnections());
+ }
+
+ /**
+ * @param \Elastica\Connection $connection
+ * @param \Exception $e
+ * @param Client $client
+ */
+ public function onFail(Connection $connection, Exception $e, Client $client)
+ {
+ $connection->setEnabled(false);
+
+ if ($this->_callback) {
+ call_user_func($this->_callback, $connection, $e, $client);
+ }
+ }
+
+ /**
+ * @return \Elastica\Connection\Strategy\StrategyInterface
+ */
+ public function getStrategy()
+ {
+ return $this->_strategy;
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Connection/Strategy/CallbackStrategy.php b/vendor/ruflin/elastica/lib/Elastica/Connection/Strategy/CallbackStrategy.php
new file mode 100644
index 00000000..ccaeb6dd
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Connection/Strategy/CallbackStrategy.php
@@ -0,0 +1,51 @@
+<?php
+namespace Elastica\Connection\Strategy;
+
+use Elastica\Exception\InvalidException;
+
+/**
+ * Description of CallbackStrategy.
+ *
+ * @author chabior
+ */
+class CallbackStrategy implements StrategyInterface
+{
+ /**
+ * @var callable
+ */
+ protected $_callback;
+
+ /**
+ * @param callable $callback
+ *
+ * @throws \Elastica\Exception\InvalidException
+ */
+ public function __construct($callback)
+ {
+ if (!self::isValid($callback)) {
+ throw new InvalidException(sprintf('Callback should be a callable, %s given!', gettype($callback)));
+ }
+
+ $this->_callback = $callback;
+ }
+
+ /**
+ * @param array|\Elastica\Connection[] $connections
+ *
+ * @return \Elastica\Connection
+ */
+ public function getConnection($connections)
+ {
+ return call_user_func_array($this->_callback, array($connections));
+ }
+
+ /**
+ * @param callable $callback
+ *
+ * @return bool
+ */
+ public static function isValid($callback)
+ {
+ return is_callable($callback);
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Connection/Strategy/RoundRobin.php b/vendor/ruflin/elastica/lib/Elastica/Connection/Strategy/RoundRobin.php
new file mode 100644
index 00000000..92cd570e
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Connection/Strategy/RoundRobin.php
@@ -0,0 +1,24 @@
+<?php
+namespace Elastica\Connection\Strategy;
+
+/**
+ * Description of RoundRobin.
+ *
+ * @author chabior
+ */
+class RoundRobin extends Simple
+{
+ /**
+ * @param array|\Elastica\Connection[] $connections
+ *
+ * @throws \Elastica\Exception\ClientException
+ *
+ * @return \Elastica\Connection
+ */
+ public function getConnection($connections)
+ {
+ shuffle($connections);
+
+ return parent::getConnection($connections);
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Connection/Strategy/Simple.php b/vendor/ruflin/elastica/lib/Elastica/Connection/Strategy/Simple.php
new file mode 100644
index 00000000..7c42dd3b
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Connection/Strategy/Simple.php
@@ -0,0 +1,30 @@
+<?php
+namespace Elastica\Connection\Strategy;
+
+use Elastica\Exception\ClientException;
+
+/**
+ * Description of SimpleStrategy.
+ *
+ * @author chabior
+ */
+class Simple implements StrategyInterface
+{
+ /**
+ * @param array|\Elastica\Connection[] $connections
+ *
+ * @throws \Elastica\Exception\ClientException
+ *
+ * @return \Elastica\Connection
+ */
+ public function getConnection($connections)
+ {
+ foreach ($connections as $connection) {
+ if ($connection->isEnabled()) {
+ return $connection;
+ }
+ }
+
+ throw new ClientException('No enabled connection');
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Connection/Strategy/StrategyFactory.php b/vendor/ruflin/elastica/lib/Elastica/Connection/Strategy/StrategyFactory.php
new file mode 100644
index 00000000..7590ab11
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Connection/Strategy/StrategyFactory.php
@@ -0,0 +1,45 @@
+<?php
+namespace Elastica\Connection\Strategy;
+
+use Elastica\Exception\InvalidException;
+
+/**
+ * Description of StrategyFactory.
+ *
+ * @author chabior
+ */
+class StrategyFactory
+{
+ /**
+ * @param mixed|callable|string|StrategyInterface $strategyName
+ *
+ * @throws \Elastica\Exception\InvalidException
+ *
+ * @return \Elastica\Connection\Strategy\StrategyInterface
+ */
+ public static function create($strategyName)
+ {
+ if ($strategyName instanceof StrategyInterface) {
+ return $strategyName;
+ }
+
+ if (CallbackStrategy::isValid($strategyName)) {
+ return new CallbackStrategy($strategyName);
+ }
+
+ if (is_string($strategyName)) {
+ $requiredInterface = '\\Elastica\\Connection\\Strategy\\StrategyInterface';
+ $predefinedStrategy = '\\Elastica\\Connection\\Strategy\\'.$strategyName;
+
+ if (class_exists($predefinedStrategy) && class_implements($predefinedStrategy, $requiredInterface)) {
+ return new $predefinedStrategy();
+ }
+
+ if (class_exists($strategyName) && class_implements($strategyName, $requiredInterface)) {
+ return new $strategyName();
+ }
+ }
+
+ throw new InvalidException('Can\'t create strategy instance by given argument');
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Connection/Strategy/StrategyInterface.php b/vendor/ruflin/elastica/lib/Elastica/Connection/Strategy/StrategyInterface.php
new file mode 100644
index 00000000..29bf7701
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Connection/Strategy/StrategyInterface.php
@@ -0,0 +1,17 @@
+<?php
+namespace Elastica\Connection\Strategy;
+
+/**
+ * Description of AbstractStrategy.
+ *
+ * @author chabior
+ */
+interface StrategyInterface
+{
+ /**
+ * @param array|\Elastica\Connection[] $connections
+ *
+ * @return \Elastica\Connection
+ */
+ public function getConnection($connections);
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Document.php b/vendor/ruflin/elastica/lib/Elastica/Document.php
index 3f6b88de..e82afae9 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Document.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Document.php
@@ -1,17 +1,13 @@
<?php
-
namespace Elastica;
-use Elastica\Exception\InvalidException;
use Elastica\Bulk\Action;
-use Elastica\Filter\Bool;
+use Elastica\Exception\InvalidException;
use Elastica\Exception\NotImplementedException;
/**
- * Single document stored in elastic search
+ * Single document stored in elastic search.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
*/
class Document extends AbstractUpdateAction
@@ -19,7 +15,7 @@ class Document extends AbstractUpdateAction
const OP_TYPE_CREATE = Action::OP_TYPE_CREATE;
/**
- * Document data
+ * Document data.
*
* @var array Document data
*/
@@ -28,22 +24,22 @@ class Document extends AbstractUpdateAction
/**
* Whether to use this document to upsert if the document does not exist.
*
- * @var boolean
+ * @var bool
*/
protected $_docAsUpsert = false;
/**
- * @var boolean
+ * @var bool
*/
protected $_autoPopulate = false;
/**
- * Creates a new document
+ * Creates a new document.
*
- * @param int|string $id OPTIONAL $id Id is create if empty
- * @param array|string $data OPTIONAL Data array
- * @param string $type OPTIONAL Type name
- * @param string $index OPTIONAL Index name
+ * @param int|string $id OPTIONAL $id Id is create if empty
+ * @param array|string $data OPTIONAL Data array
+ * @param string $type OPTIONAL Type name
+ * @param string $index OPTIONAL Index name
*/
public function __construct($id = '', $data = array(), $type = '', $index = '')
{
@@ -55,6 +51,7 @@ class Document extends AbstractUpdateAction
/**
* @param string $key
+ *
* @return mixed
*/
public function __get($key)
@@ -64,7 +61,7 @@ class Document extends AbstractUpdateAction
/**
* @param string $key
- * @param mixed $value
+ * @param mixed $value
*/
public function __set($key, $value)
{
@@ -73,6 +70,7 @@ class Document extends AbstractUpdateAction
/**
* @param string $key
+ *
* @return bool
*/
public function __isset($key)
@@ -90,22 +88,27 @@ class Document extends AbstractUpdateAction
/**
* @param string $key
- * @return mixed
+ *
* @throws \Elastica\Exception\InvalidException
+ *
+ * @return mixed
*/
public function get($key)
{
if (!$this->has($key)) {
throw new InvalidException("Field {$key} does not exist");
}
+
return $this->_data[$key];
}
/**
* @param string $key
- * @param mixed $value
+ * @param mixed $value
+ *
* @throws \Elastica\Exception\InvalidException
- * @return \Elastica\Document
+ *
+ * @return $this
*/
public function set($key, $value)
{
@@ -119,6 +122,7 @@ class Document extends AbstractUpdateAction
/**
* @param string $key
+ *
* @return bool
*/
public function has($key)
@@ -128,8 +132,10 @@ class Document extends AbstractUpdateAction
/**
* @param string $key
+ *
* @throws \Elastica\Exception\InvalidException
- * @return \Elastica\Document
+ *
+ * @return $this
*/
public function remove($key)
{
@@ -142,12 +148,14 @@ class Document extends AbstractUpdateAction
}
/**
- * Adds the given key/value pair to the document
+ * Adds the given key/value pair to the document.
*
* @deprecated
- * @param string $key Document entry key
- * @param mixed $value Document entry value
- * @return \Elastica\Document
+ *
+ * @param string $key Document entry key
+ * @param mixed $value Document entry value
+ *
+ * @return $this
*/
public function add($key, $value)
{
@@ -155,7 +163,7 @@ class Document extends AbstractUpdateAction
}
/**
- * Adds a file to the index
+ * Adds a file to the index.
*
* To use this feature you have to call the following command in the
* elasticsearch directory:
@@ -165,17 +173,18 @@ class Document extends AbstractUpdateAction
* This installs the tika file analysis plugin. More infos about supported formats
* can be found here: {@link http://tika.apache.org/0.7/formats.html}
*
- * @param string $key Key to add the file to
- * @param string $filepath Path to add the file
- * @param string $mimeType OPTIONAL Header mime type
- * @return \Elastica\Document
+ * @param string $key Key to add the file to
+ * @param string $filepath Path to add the file
+ * @param string $mimeType OPTIONAL Header mime type
+ *
+ * @return $this
*/
public function addFile($key, $filepath, $mimeType = '')
{
$value = base64_encode(file_get_contents($filepath));
if (!empty($mimeType)) {
- $value = array('_content_type' => $mimeType, '_name' => $filepath, 'content' => $value,);
+ $value = array('_content_type' => $mimeType, '_name' => $filepath, '_content' => $value);
}
$this->set($key, $value);
@@ -184,11 +193,12 @@ class Document extends AbstractUpdateAction
}
/**
- * Add file content
+ * Add file content.
+ *
+ * @param string $key Document key
+ * @param string $content Raw file content
*
- * @param string $key Document key
- * @param string $content Raw file content
- * @return \Elastica\Document
+ * @return $this
*/
public function addFileContent($key, $content)
{
@@ -196,19 +206,21 @@ class Document extends AbstractUpdateAction
}
/**
- * Adds a geopoint to the document
+ * Adds a geopoint to the document.
*
* Geohashes are not yet supported
*
* @param string $key Field key
* @param float $latitude Latitude value
* @param float $longitude Longitude value
- * @link http://www.elasticsearch.org/guide/reference/mapping/geo-point-type.html
- * @return \Elastica\Document
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-geo-point-type.html
+ *
+ * @return $this
*/
public function addGeoPoint($key, $latitude, $longitude)
{
- $value = array('lat' => $latitude, 'lon' => $longitude,);
+ $value = array('lat' => $latitude, 'lon' => $longitude);
$this->set($key, $value);
@@ -216,10 +228,11 @@ class Document extends AbstractUpdateAction
}
/**
- * Overwrites the current document data with the given data
+ * Overwrites the current document data with the given data.
*
- * @param array|string $data Data array
- * @return \Elastica\Document
+ * @param array|string $data Data array
+ *
+ * @return $this
*/
public function setData($data)
{
@@ -229,7 +242,7 @@ class Document extends AbstractUpdateAction
}
/**
- * Returns the document data
+ * Returns the document data.
*
* @return array|string Document data
*/
@@ -239,36 +252,41 @@ class Document extends AbstractUpdateAction
}
/**
+ * @deprecated
+ *
* @param \Elastica\Script $data
+ *
* @throws NotImplementedException
- * @deprecated
*/
public function setScript($data)
{
- throw new NotImplementedException("setScript() is no longer available as of 0.90.2. See http://elastica.io/migration/0.90.2/upsert.html to migrate");
+ throw new NotImplementedException('setScript() is no longer available as of 0.90.2. See http://elastica.io/migration/0.90.2/upsert.html to migrate');
}
/**
* @throws NotImplementedException
+ *
* @deprecated
*/
public function getScript()
{
- throw new NotImplementedException("getScript() is no longer available as of 0.90.2. See http://elastica.io/migration/0.90.2/upsert.html to migrate");
+ throw new NotImplementedException('getScript() is no longer available as of 0.90.2. See http://elastica.io/migration/0.90.2/upsert.html to migrate');
}
/**
* @throws NotImplementedException
+ *
* @deprecated
*/
public function hasScript()
{
- throw new NotImplementedException("hasScript() is no longer available as of 0.90.2. See http://elastica.io/migration/0.90.2/upsert.html to migrate");
+ throw new NotImplementedException('hasScript() is no longer available as of 0.90.2. See http://elastica.io/migration/0.90.2/upsert.html to migrate');
}
/**
* @param bool $value
- * @return \Elastica\Document
+ *
+ * @return $this
*/
public function setDocAsUpsert($value)
{
@@ -278,7 +296,7 @@ class Document extends AbstractUpdateAction
}
/**
- * @return boolean
+ * @return bool
*/
public function getDocAsUpsert()
{
@@ -287,6 +305,7 @@ class Document extends AbstractUpdateAction
/**
* @param bool $autoPopulate
+ *
* @return $this
*/
public function setAutoPopulate($autoPopulate = true)
@@ -305,7 +324,8 @@ class Document extends AbstractUpdateAction
}
/**
- * Returns the document as an array
+ * Returns the document as an array.
+ *
* @return array
*/
public function toArray()
@@ -317,9 +337,11 @@ class Document extends AbstractUpdateAction
}
/**
- * @param array|\Elastica\Document $data
+ * @param array|\Elastica\Document $data
+ *
* @throws \Elastica\Exception\InvalidException
- * @return \Elastica\Document
+ *
+ * @return self
*/
public static function create($data)
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/Bulk/Response/ActionException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/Bulk/Response/ActionException.php
index 6500e040..5db0e49f 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Exception/Bulk/Response/ActionException.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/Bulk/Response/ActionException.php
@@ -1,10 +1,8 @@
<?php
-
namespace Elastica\Exception\Bulk\Response;
-use Elastica\Exception\BulkException;
-use Elastica\Bulk\Action;
use Elastica\Bulk\Response;
+use Elastica\Exception\BulkException;
class ActionException extends BulkException
{
@@ -41,6 +39,7 @@ class ActionException extends BulkException
/**
* @param \Elastica\Bulk\Response $response
+ *
* @return string
*/
public function getErrorMessage(Response $response)
@@ -51,13 +50,13 @@ class ActionException extends BulkException
$path = '';
if (isset($data['_index'])) {
- $path.= '/' . $data['_index'];
+ $path .= '/'.$data['_index'];
}
if (isset($data['_type'])) {
- $path.= '/' . $data['_type'];
+ $path .= '/'.$data['_type'];
}
if (isset($data['_id'])) {
- $path.= '/' . $data['_id'];
+ $path .= '/'.$data['_id'];
}
$message = "$opType: $path caused $error";
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/Bulk/ResponseException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/Bulk/ResponseException.php
index 9df1b3e8..54b5702b 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Exception/Bulk/ResponseException.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/Bulk/ResponseException.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Exception\Bulk;
use Elastica\Bulk\ResponseSet;
@@ -7,16 +6,11 @@ use Elastica\Exception\Bulk\Response\ActionException;
use Elastica\Exception\BulkException;
/**
- * Bulk Response exception
- *
- * @category Xodoa
- * @package Elastica
+ * Bulk Response exception.
*/
class ResponseException extends BulkException
{
/**
- * Response
- *
* @var \Elastica\Bulk\ResponseSet ResponseSet object
*/
protected $_responseSet;
@@ -27,7 +21,7 @@ class ResponseException extends BulkException
protected $_actionExceptions = array();
/**
- * Construct Exception
+ * Construct Exception.
*
* @param \Elastica\Bulk\ResponseSet $responseSet
*/
@@ -35,8 +29,8 @@ class ResponseException extends BulkException
{
$this->_init($responseSet);
- $message = 'Error in one or more bulk request actions:' . PHP_EOL . PHP_EOL;
- $message.= $this->getActionExceptionsAsString();
+ $message = 'Error in one or more bulk request actions:'.PHP_EOL.PHP_EOL;
+ $message .= $this->getActionExceptionsAsString();
parent::__construct($message);
}
@@ -56,7 +50,7 @@ class ResponseException extends BulkException
}
/**
- * Returns bulk response set object
+ * Returns bulk response set object.
*
* @return \Elastica\Bulk\ResponseSet
*/
@@ -66,7 +60,7 @@ class ResponseException extends BulkException
}
/**
- * Returns array of failed actions
+ * Returns array of failed actions.
*
* @return array Array of failed actions
*/
@@ -96,8 +90,9 @@ class ResponseException extends BulkException
{
$message = '';
foreach ($this->getActionExceptions() as $actionException) {
- $message.= $actionException->getMessage() . PHP_EOL;
+ $message .= $actionException->getMessage().PHP_EOL;
}
+
return $message;
}
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/Bulk/UdpException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/Bulk/UdpException.php
index 0b2d4d2e..e332b92f 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Exception/Bulk/UdpException.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/Bulk/UdpException.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Exception\Bulk;
use Elastica\Exception\BulkException;
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/BulkException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/BulkException.php
index 6d384556..121cf557 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Exception/BulkException.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/BulkException.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Exception;
class BulkException extends \RuntimeException implements ExceptionInterface
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/ClientException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/ClientException.php
index 00efd67d..66af363d 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Exception/ClientException.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/ClientException.php
@@ -1,12 +1,9 @@
<?php
-
namespace Elastica\Exception;
/**
- * Client exception
+ * Client exception.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
*/
class ClientException extends \RuntimeException implements ExceptionInterface
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/Connection/GuzzleException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/Connection/GuzzleException.php
index 645c0eff..614ad139 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Exception/Connection/GuzzleException.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/Connection/GuzzleException.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Exception\Connection;
use Elastica\Exception\ConnectionException;
@@ -8,9 +7,8 @@ use Elastica\Response;
use GuzzleHttp\Exception\TransferException;
/**
- * Transport exception
+ * Transport exception.
*
- * @package Elastica
* @author Milan Magudia <milan@magudia.com>
*/
class GuzzleException extends ConnectionException
@@ -22,8 +20,8 @@ class GuzzleException extends ConnectionException
/**
* @param \GuzzleHttp\Exception\TransferException $guzzleException
- * @param \Elastica\Request $request
- * @param \Elastica\Response $response
+ * @param \Elastica\Request $request
+ * @param \Elastica\Response $response
*/
public function __construct(TransferException $guzzleException, Request $request = null, Response $response = null)
{
@@ -34,6 +32,7 @@ class GuzzleException extends ConnectionException
/**
* @param \GuzzleHttp\Exception\TransferException $guzzleException
+ *
* @return string
*/
public function getErrorMessage(TransferException $guzzleException)
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/Connection/HttpException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/Connection/HttpException.php
index 2a36fe48..28e78e77 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Exception/Connection/HttpException.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/Connection/HttpException.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Exception\Connection;
use Elastica\Exception\ConnectionException;
@@ -7,25 +6,23 @@ use Elastica\Request;
use Elastica\Response;
/**
- * Connection exception
+ * Connection exception.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
*/
class HttpException extends ConnectionException
{
/**
- * Error code / message
+ * Error code / message.
*
* @var string Error code / message
*/
protected $_error = 0;
/**
- * Construct Exception
+ * Construct Exception.
*
- * @param string $error Error
+ * @param string $error Error
* @param \Elastica\Request $request
* @param \Elastica\Response $response
*/
@@ -39,22 +36,23 @@ class HttpException extends ConnectionException
/**
* Returns the error message corresponding to the error code
- * cUrl error code reference can be found here {@link http://curl.haxx.se/libcurl/c/libcurl-errors.html}
+ * cUrl error code reference can be found here {@link http://curl.haxx.se/libcurl/c/libcurl-errors.html}.
+ *
+ * @param string $error Error code
*
- * @param string $error Error code
* @return string Error message
*/
public function getErrorMessage($error)
{
switch ($error) {
case CURLE_UNSUPPORTED_PROTOCOL:
- $error = "Unsupported protocol";
+ $error = 'Unsupported protocol';
break;
case CURLE_FAILED_INIT:
- $error = "Internal cUrl error?";
+ $error = 'Internal cUrl error?';
break;
case CURLE_URL_MALFORMAT:
- $error = "Malformed URL";
+ $error = 'Malformed URL';
break;
case CURLE_COULDNT_RESOLVE_PROXY:
$error = "Couldn't resolve proxy";
@@ -66,10 +64,10 @@ class HttpException extends ConnectionException
$error = "Couldn't connect to host, Elasticsearch down?";
break;
case 28:
- $error = "Operation timed out";
+ $error = 'Operation timed out';
break;
default:
- $error = "Unknown error:" . $error;
+ $error = 'Unknown error:'.$error;
break;
}
@@ -77,7 +75,7 @@ class HttpException extends ConnectionException
}
/**
- * Return Error code / message
+ * Return Error code / message.
*
* @return string Error code / message
*/
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/Connection/MemcacheException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/Connection/MemcacheException.php
new file mode 100644
index 00000000..24181379
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/Connection/MemcacheException.php
@@ -0,0 +1,13 @@
+<?php
+namespace Elastica\Exception\Connection;
+
+use Elastica\Exception\ConnectionException;
+
+/**
+ * Transport exception.
+ *
+ * @author Igor Denisenko <im.denisenko@yahoo.com>
+ */
+class MemcacheException extends ConnectionException
+{
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/Connection/ThriftException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/Connection/ThriftException.php
index 0ca331c7..499cbd7d 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Exception/Connection/ThriftException.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/Connection/ThriftException.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Exception\Connection;
use Elastica\Exception\ConnectionException;
@@ -8,10 +7,8 @@ use Elastica\Response;
use Thrift\Exception\TException;
/**
- * Transport exception
+ * Transport exception.
*
- * @category Xodoa
- * @package Elastica
* @author Mikhail Shamin <munk13@gmail.com>
*/
class ThriftException extends ConnectionException
@@ -23,8 +20,8 @@ class ThriftException extends ConnectionException
/**
* @param \Thrift\Exception\TException $thriftException
- * @param \Elastica\Request $request
- * @param \Elastica\Response $response
+ * @param \Elastica\Request $request
+ * @param \Elastica\Response $response
*/
public function __construct(TException $thriftException, Request $request = null, Response $response = null)
{
@@ -35,6 +32,7 @@ class ThriftException extends ConnectionException
/**
* @param \Thrift\Exception\TException $thriftException
+ *
* @return string
*/
public function getErrorMessage(TException $thriftException)
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/ConnectionException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/ConnectionException.php
index 35d60472..b2376d2f 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Exception/ConnectionException.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/ConnectionException.php
@@ -1,37 +1,30 @@
<?php
-
namespace Elastica\Exception;
use Elastica\Request;
use Elastica\Response;
/**
- * Connection exception
+ * Connection exception.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
*/
class ConnectionException extends \RuntimeException implements ExceptionInterface
{
/**
- * Request
- *
* @var \Elastica\Request Request object
*/
protected $_request;
/**
- * Response
- *
* @var \Elastica\Response Response object
*/
protected $_response;
/**
- * Construct Exception
+ * Construct Exception.
*
- * @param string $message Message
+ * @param string $message Message
* @param \Elastica\Request $request
* @param \Elastica\Response $response
*/
@@ -44,7 +37,7 @@ class ConnectionException extends \RuntimeException implements ExceptionInterfac
}
/**
- * Returns request object
+ * Returns request object.
*
* @return \Elastica\Request Request object
*/
@@ -54,7 +47,7 @@ class ConnectionException extends \RuntimeException implements ExceptionInterfac
}
/**
- * Returns response object
+ * Returns response object.
*
* @return \Elastica\Response Response object
*/
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/ElasticsearchException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/ElasticsearchException.php
index 0f7509f9..59cca0c6 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Exception/ElasticsearchException.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/ElasticsearchException.php
@@ -1,37 +1,29 @@
<?php
-
namespace Elastica\Exception;
/**
- * Elasticsearch exception
+ * Elasticsearch exception.
*
- * @category Xodoa
- * @package Elastica
* @author Ian Babrou <ibobrik@gmail.com>
*/
-class ElasticsearchException extends \Exception
+class ElasticsearchException extends \Exception implements ExceptionInterface
{
-
const REMOTE_TRANSPORT_EXCEPTION = 'RemoteTransportException';
/**
- * Elasticsearch exception name
- *
- * @var string|null
+ * @var string|null Elasticsearch exception name
*/
private $_exception;
/**
- * Whether exception was local to server node or remote
- *
- * @var bool
+ * @var bool Whether exception was local to server node or remote
*/
private $_isRemote = false;
/**
- * Constructs elasticsearch exception
+ * Constructs elasticsearch exception.
*
- * @param int $code Error code
+ * @param int $code Error code
* @param string $error Error message from elasticsearch
*/
public function __construct($code, $error)
@@ -41,7 +33,7 @@ class ElasticsearchException extends \Exception
}
/**
- * Parse error message from elasticsearch
+ * Parse error message from elasticsearch.
*
* @param string $error Error message
*/
@@ -62,9 +54,10 @@ class ElasticsearchException extends \Exception
}
/**
- * Extract exception name from error response
+ * Extract exception name from error response.
*
* @param string $error
+ *
* @return null|string
*/
protected function _extractException($error)
@@ -72,12 +65,12 @@ class ElasticsearchException extends \Exception
if (preg_match('/^(\w+)\[.*\]/', $error, $matches)) {
return $matches[1];
} else {
- return null;
+ return;
}
}
/**
- * Returns elasticsearch exception name
+ * Returns elasticsearch exception name.
*
* @return string|null
*/
@@ -87,7 +80,7 @@ class ElasticsearchException extends \Exception
}
/**
- * Returns whether exception was local to server node or remote
+ * Returns whether exception was local to server node or remote.
*
* @return bool
*/
@@ -95,5 +88,4 @@ class ElasticsearchException extends \Exception
{
return $this->_isRemote;
}
-
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/ExceptionInterface.php b/vendor/ruflin/elastica/lib/Elastica/Exception/ExceptionInterface.php
index 746c9c81..02f43092 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Exception/ExceptionInterface.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/ExceptionInterface.php
@@ -1,12 +1,9 @@
<?php
-
namespace Elastica\Exception;
/**
- * General Elastica exception interface
+ * General Elastica exception interface.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
*/
interface ExceptionInterface
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/InvalidException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/InvalidException.php
index ff4a4cd3..996a9389 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Exception/InvalidException.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/InvalidException.php
@@ -1,12 +1,9 @@
<?php
-
namespace Elastica\Exception;
/**
- * Invalid exception
+ * Invalid exception.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
*/
class InvalidException extends \InvalidArgumentException implements ExceptionInterface
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/JSONParseException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/JSONParseException.php
index 3cf39911..010adf45 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Exception/JSONParseException.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/JSONParseException.php
@@ -1,11 +1,8 @@
<?php
-
namespace Elastica\Exception;
/**
- * JSON Parse exception
- *
- * @package Elastica
+ * JSON Parse exception.
*/
class JSONParseException extends \RuntimeException implements ExceptionInterface
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/NotFoundException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/NotFoundException.php
index 539b01c2..a2897fd7 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Exception/NotFoundException.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/NotFoundException.php
@@ -1,12 +1,9 @@
<?php
-
namespace Elastica\Exception;
/**
- * Not found exception
+ * Not found exception.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
*/
class NotFoundException extends \RuntimeException implements ExceptionInterface
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/NotImplementedException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/NotImplementedException.php
index 49d3918b..591417b6 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Exception/NotImplementedException.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/NotImplementedException.php
@@ -1,14 +1,11 @@
<?php
-
namespace Elastica\Exception;
/**
- * Not implemented exception
+ * Not implemented exception.
*
* Is thrown if a function or feature is not implemented yet
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
*/
class NotImplementedException extends \BadMethodCallException implements ExceptionInterface
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/PartialShardFailureException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/PartialShardFailureException.php
index f853bf96..bb3fa44a 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Exception/PartialShardFailureException.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/PartialShardFailureException.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Exception;
use Elastica\JSON;
@@ -7,19 +6,16 @@ use Elastica\Request;
use Elastica\Response;
/**
- * Partial shard failure exception
+ * Partial shard failure exception.
*
- * @category Xodoa
- * @package Elastica
* @author Ian Babrou <ibobrik@gmail.com>
*/
class PartialShardFailureException extends ResponseException
{
-
/**
- * Construct Exception
+ * Construct Exception.
*
- * @param \Elastica\Request $request
+ * @param \Elastica\Request $request
* @param \Elastica\Response $response
*/
public function __construct(Request $request, Response $response)
@@ -29,5 +25,4 @@ class PartialShardFailureException extends ResponseException
$shardsStatistics = $response->getShardsStatistics();
$this->message = JSON::stringify($shardsStatistics['failed']);
}
-
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/QueryBuilderException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/QueryBuilderException.php
new file mode 100644
index 00000000..ae03c831
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/QueryBuilderException.php
@@ -0,0 +1,11 @@
+<?php
+namespace Elastica\Exception;
+
+/**
+ * QueryBuilder exception.
+ *
+ * @author Manuel Andreo Garcia <andreo.garcia@googlemail.com>
+ */
+class QueryBuilderException extends \RuntimeException implements ExceptionInterface
+{
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/ResponseException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/ResponseException.php
index 63244487..57502307 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Exception/ResponseException.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/ResponseException.php
@@ -1,37 +1,30 @@
<?php
-
namespace Elastica\Exception;
use Elastica\Request;
use Elastica\Response;
/**
- * Response exception
+ * Response exception.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
*/
class ResponseException extends \RuntimeException implements ExceptionInterface
{
/**
- * Request
- *
* @var \Elastica\Request Request object
*/
protected $_request = null;
/**
- * Response
- *
* @var \Elastica\Response Response object
*/
protected $_response = null;
/**
- * Construct Exception
+ * Construct Exception.
*
- * @param \Elastica\Request $request
+ * @param \Elastica\Request $request
* @param \Elastica\Response $response
*/
public function __construct(Request $request, Response $response)
@@ -42,7 +35,7 @@ class ResponseException extends \RuntimeException implements ExceptionInterface
}
/**
- * Returns request object
+ * Returns request object.
*
* @return \Elastica\Request Request object
*/
@@ -52,7 +45,7 @@ class ResponseException extends \RuntimeException implements ExceptionInterface
}
/**
- * Returns response object
+ * Returns response object.
*
* @return \Elastica\Response Response object
*/
@@ -62,14 +55,15 @@ class ResponseException extends \RuntimeException implements ExceptionInterface
}
/**
- * Returns elasticsearch exception
+ * Returns elasticsearch exception.
*
* @return ElasticsearchException
*/
- public function getElasticsearchException() {
+ public function getElasticsearchException()
+ {
$response = $this->getResponse();
$transfer = $response->getTransferInfo();
- $code = array_key_exists('http_code', $transfer) ? $transfer['http_code'] : 0;
+ $code = array_key_exists('http_code', $transfer) ? $transfer['http_code'] : 0;
return new ElasticsearchException($code, $response->getError());
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/RuntimeException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/RuntimeException.php
index 5ee420e1..af18faff 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Exception/RuntimeException.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Exception/RuntimeException.php
@@ -1,12 +1,9 @@
<?php
-
namespace Elastica\Exception;
/**
- * Client exception
+ * Client exception.
*
- * @category Xodoa
- * @package Elastica
* @author Mikhail Shamin <munk13@gmail.com>
*/
class RuntimeException extends \RuntimeException implements ExceptionInterface
diff --git a/vendor/ruflin/elastica/lib/Elastica/Facet/AbstractFacet.php b/vendor/ruflin/elastica/lib/Elastica/Facet/AbstractFacet.php
index 25cee812..743cefe1 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Facet/AbstractFacet.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Facet/AbstractFacet.php
@@ -1,30 +1,27 @@
<?php
-
namespace Elastica\Facet;
-use Elastica\Param;
-use Elastica\Filter\AbstractFilter;
use Elastica\Exception\InvalidException;
+use Elastica\Filter\AbstractFilter;
+use Elastica\Param;
/**
- * Abstract facet object. Should be extended by all facet types
+ * Abstract facet object. Should be extended by all facet types.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
* @author Jasper van Wanrooy <jasper@vanwanrooy.net>
+ *
+ * @deprecated Facets are deprecated and will be removed in a future release. You are encouraged to migrate to aggregations instead.
*/
abstract class AbstractFacet extends Param
{
/**
- * Holds the name of the facet.
- * @var string
+ * @var string Holds the name of the facet.
*/
protected $_name = '';
/**
- * Holds all facet parameters.
- * @var array
+ * @var array Holds all facet parameters.
*/
protected $_facet = array();
@@ -42,9 +39,11 @@ abstract class AbstractFacet extends Param
* Sets the name of the facet. It is automatically set by
* the constructor.
*
- * @param string $name The name of the facet.
- * @throws \Elastica\Exception\InvalidException
- * @return \Elastica\Facet\AbstractFacet
+ * @param string $name The name of the facet.
+ *
+ * @throws \Elastica\Exception\InvalidException If name is empty
+ *
+ * @return $this
*/
public function setName($name)
{
@@ -69,8 +68,9 @@ abstract class AbstractFacet extends Param
/**
* Sets a filter for this facet.
*
- * @param \Elastica\Filter\AbstractFilter $filter A filter to apply on the facet.
- * @return \Elastica\Facet\AbstractFacet
+ * @param \Elastica\Filter\AbstractFilter $filter A filter to apply on the facet.
+ *
+ * @return $this
*/
public function setFilter(AbstractFilter $filter)
{
@@ -82,8 +82,9 @@ abstract class AbstractFacet extends Param
* current search query. When not set, it defaults to the
* Elasticsearch default value.
*
- * @param bool $global Flag to either run the facet globally.
- * @return \Elastica\Facet\AbstractFacet
+ * @param bool $global Flag to either run the facet globally.
+ *
+ * @return $this
*/
public function setGlobal($global = true)
{
@@ -91,10 +92,11 @@ abstract class AbstractFacet extends Param
}
/**
- * Sets the path to the nested document
+ * Sets the path to the nested document.
*
- * @param string $nestedPath Nested path
- * @return \Elastica\Facet\AbstractFacet
+ * @param string $nestedPath Nested path
+ *
+ * @return $this
*/
public function setNested($nestedPath)
{
@@ -102,10 +104,11 @@ abstract class AbstractFacet extends Param
}
/**
- * Sets the scope
+ * Sets the scope.
+ *
+ * @param string $scope Scope
*
- * @param string $scope Scope
- * @return \Elastica\Facet\AbstractFacet
+ * @return $this
*/
public function setScope($scope)
{
@@ -128,9 +131,10 @@ abstract class AbstractFacet extends Param
* Sets a param for the facet. Each facet implementation needs to take
* care of handling their own params.
*
- * @param string $key The key of the param to set.
- * @param mixed $value The value of the param.
- * @return \Elastica\Facet\AbstractFacet
+ * @param string $key The key of the param to set.
+ * @param mixed $value The value of the param.
+ *
+ * @return $this
*/
protected function _setFacetParam($key, $value)
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Facet/DateHistogram.php b/vendor/ruflin/elastica/lib/Elastica/Facet/DateHistogram.php
index 803f54a3..c47eddab 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Facet/DateHistogram.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Facet/DateHistogram.php
@@ -1,23 +1,23 @@
<?php
-
namespace Elastica\Facet;
/**
* Implements the Date Histogram facet.
*
- * @category Xodoa
- * @package Elastica
* @author Raul Martinez Jr <juneym@gmail.com>
- * @link http://www.elasticsearch.org/guide/reference/api/search/facets/date-histogram-facet.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-facets-date-histogram-facet.html
* @link https://github.com/elasticsearch/elasticsearch/issues/591
+ * @deprecated Facets are deprecated and will be removed in a future release. You are encouraged to migrate to aggregations instead.
*/
class DateHistogram extends Histogram
{
/**
- * Set the time_zone parameter
+ * Set the time_zone parameter.
+ *
+ * @param string $tzOffset
*
- * @param string $tzOffset
- * @return \Elastica\Facet\DateHistogram
+ * @return $this
*/
public function setTimezone($tzOffset)
{
@@ -25,16 +25,30 @@ class DateHistogram extends Histogram
}
/**
+ * Set the factor parameter.
+ *
+ * @param int $factor
+ *
+ * @return $this
+ */
+ public function setFactor($factor)
+ {
+ return $this->setParam('factor', $factor);
+ }
+
+ /**
* Creates the full facet definition, which includes the basic
* facet definition of the parent.
*
* @see \Elastica\Facet\AbstractFacet::toArray()
+ *
* @throws \Elastica\Exception\InvalidException When the right fields haven't been set.
+ *
* @return array
*/
public function toArray()
{
- /**
+ /*
* Set the range in the abstract as param.
*/
$this->_setFacetParam('date_histogram', $this->_params);
diff --git a/vendor/ruflin/elastica/lib/Elastica/Facet/Filter.php b/vendor/ruflin/elastica/lib/Elastica/Facet/Filter.php
index ed6f28b7..26f032b4 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Facet/Filter.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Facet/Filter.php
@@ -1,24 +1,24 @@
<?php
-
namespace Elastica\Facet;
use Elastica\Filter\AbstractFilter;
/**
- * Filter facet
+ * Filter facet.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/api/search/facets/filter-facet.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-facets-filter-facet.html
+ * @deprecated Facets are deprecated and will be removed in a future release. You are encouraged to migrate to aggregations instead.
*/
class Filter extends AbstractFacet
{
/**
* Set the filter for the facet.
*
- * @param \Elastica\Filter\AbstractFilter $filter
- * @return \Elastica\Facet\Filter
+ * @param \Elastica\Filter\AbstractFilter $filter
+ *
+ * @return $this
*/
public function setFilter(AbstractFilter $filter)
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Facet/GeoCluster.php b/vendor/ruflin/elastica/lib/Elastica/Facet/GeoCluster.php
index a6f5e9ed..71fa5094 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Facet/GeoCluster.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Facet/GeoCluster.php
@@ -1,41 +1,49 @@
<?php
-
namespace Elastica\Facet;
/**
* Implements the Geo Cluster facet.
*
- * @category Xodoa
- * @package Elastica
* @author Konstantin Nikiforov <konstantin.nikiforov@gmail.com>
+ *
* @link https://github.com/zenobase/geocluster-facet
+ * @deprecated Facets are deprecated and will be removed in a future release. You are encouraged to migrate to aggregations instead.
*/
-class GeoCluster extends AbstractFacet {
-
+class GeoCluster extends AbstractFacet
+{
/**
* @param string $fieldName
+ *
* @return $this
*/
- public function setField($fieldName) {
+ public function setField($fieldName)
+ {
$this->setParam('field', $fieldName);
+
return $this;
}
/**
- * @param double $factor
+ * @param float $factor
+ *
* @return $this
*/
- public function setFactor($factor){
+ public function setFactor($factor)
+ {
$this->setParam('factor', $factor);
+
return $this;
}
/**
- * @param boolean $showIds
+ * @param bool $showIds
+ *
* @return $this
*/
- public function setShowIds($showIds) {
+ public function setShowIds($showIds)
+ {
$this->setParam('showIds', $showIds);
+
return $this;
}
@@ -44,11 +52,15 @@ class GeoCluster extends AbstractFacet {
* facet definition of the parent.
*
* @see \Elastica\Facet\AbstractFacet::toArray()
+ *
* @throws \Elastica\Exception\InvalidException When the right fields haven't been set.
+ *
* @return array
*/
- public function toArray(){
- $this->_setFacetParam ('geo_cluster', $this->_params);
+ public function toArray()
+ {
+ $this->_setFacetParam('geo_cluster', $this->_params);
+
return parent::toArray();
}
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Facet/GeoDistance.php b/vendor/ruflin/elastica/lib/Elastica/Facet/GeoDistance.php
index 35537986..664d33a6 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Facet/GeoDistance.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Facet/GeoDistance.php
@@ -1,14 +1,13 @@
<?php
-
namespace Elastica\Facet;
/**
* Implements the Geo Distance facet.
*
- * @category Xodoa
- * @package Elastica
* @author Gerard A. Matthew <gerard.matthew@gmail.com>
- * @link http://www.elasticsearch.org/guide/reference/api/search/facets/geo-distance-facet.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-facets-geo-distance-facet.html
+ * @deprecated Facets are deprecated and will be removed in a future release. You are encouraged to migrate to aggregations instead.
*/
class GeoDistance extends AbstractFacet
{
@@ -20,10 +19,11 @@ class GeoDistance extends AbstractFacet
* array('from' => 20, 'to' => 70),
* array('from' => 70, 'to' => 120),
* array('from' => 150)
- * )
+ * ).
+ *
+ * @param array $ranges Numerical array with range definitions.
*
- * @param array $ranges Numerical array with range definitions.
- * @return \Elastica\Facet\GeoDistance
+ * @return $this
*/
public function setRanges(array $ranges)
{
@@ -33,16 +33,17 @@ class GeoDistance extends AbstractFacet
/**
* Set the relative GeoPoint for the facet.
*
- * @param string $typeField index type and field e.g foo.bar
- * @param float $latitude
- * @param float $longitude
- * @return \Elastica\Facet\GeoDistance
+ * @param string $typeField index type and field e.g foo.bar
+ * @param float $latitude
+ * @param float $longitude
+ *
+ * @return $this
*/
public function setGeoPoint($typeField, $latitude, $longitude)
{
return $this->setParam($typeField, array(
- "lat" => $latitude,
- "lon" => $longitude,
+ 'lat' => $latitude,
+ 'lon' => $longitude,
));
}
@@ -51,15 +52,17 @@ class GeoDistance extends AbstractFacet
* facet definition of the parent.
*
* @see \Elastica\Facet\AbstractFacet::toArray()
+ *
* @throws \Elastica\Exception\InvalidException When the right fields haven't been set.
+ *
* @return array
*/
public function toArray()
{
- /**
+ /*
* Set the geo_distance in the abstract as param.
*/
- $this->_setFacetParam ('geo_distance', $this->_params);
+ $this->_setFacetParam('geo_distance', $this->_params);
return parent::toArray();
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Facet/Histogram.php b/vendor/ruflin/elastica/lib/Elastica/Facet/Histogram.php
index 68be6757..1b76ea89 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Facet/Histogram.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Facet/Histogram.php
@@ -1,22 +1,22 @@
<?php
-
namespace Elastica\Facet;
/**
* Implements the Histogram facet.
*
- * @category Xodoa
- * @package Elastica
* @author Raul Martinez Jr <juneym@gmail.com>
- * @link http://www.elasticsearch.org/guide/reference/api/search/facets/histogram-facet.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-facets-histogram-facet.html
+ * @deprecated Facets are deprecated and will be removed in a future release. You are encouraged to migrate to aggregations instead.
*/
class Histogram extends AbstractFacet
{
/**
- * Sets the field for histogram
+ * Sets the field for histogram.
+ *
+ * @param string $field The name of the field for the histogram
*
- * @param string $field The name of the field for the histogram
- * @return \Elastica\Facet\Histogram
+ * @return $this
*/
public function setField($field)
{
@@ -24,10 +24,11 @@ class Histogram extends AbstractFacet
}
/**
- * Set the value for interval
+ * Set the value for interval.
*
- * @param string $interval
- * @return \Elastica\Facet\Histogram
+ * @param string $interval
+ *
+ * @return $this
*/
public function setInterval($interval)
{
@@ -35,11 +36,12 @@ class Histogram extends AbstractFacet
}
/**
- * Set the fields for key_field and value_field
+ * Set the fields for key_field and value_field.
+ *
+ * @param string $keyField Key field
+ * @param string $valueField Value field
*
- * @param string $keyField Key field
- * @param string $valueField Value field
- * @return \Elastica\Facet\Histogram
+ * @return $this
*/
public function setKeyValueFields($keyField, $valueField)
{
@@ -49,9 +51,10 @@ class Histogram extends AbstractFacet
/**
* Sets the key and value for this facet by script.
*
- * @param string $keyScript Script to check whether it falls into the range.
- * @param string $valueScript Script to use for statistical calculations.
- * @return \Elastica\Facet\Histogram
+ * @param string $keyScript Script to check whether it falls into the range.
+ * @param string $valueScript Script to use for statistical calculations.
+ *
+ * @return $this
*/
public function setKeyValueScripts($keyScript, $valueScript)
{
@@ -60,10 +63,11 @@ class Histogram extends AbstractFacet
}
/**
- * Set the "params" essential to the a script
+ * Set the "params" essential to the a script.
+ *
+ * @param array $params Associative array (key/value pair)
*
- * @param array $params Associative array (key/value pair)
- * @return \Elastica\Facet\Histogram
+ * @return $this
*/
public function setScriptParams(array $params)
{
@@ -75,12 +79,14 @@ class Histogram extends AbstractFacet
* facet definition of the parent.
*
* @see \Elastica\Facet\AbstractFacet::toArray()
+ *
* @throws \Elastica\Exception\InvalidException When the right fields haven't been set.
+ *
* @return array
*/
public function toArray()
{
- /**
+ /*
* Set the range in the abstract as param.
*/
$this->_setFacetParam('histogram', $this->_params);
diff --git a/vendor/ruflin/elastica/lib/Elastica/Facet/Query.php b/vendor/ruflin/elastica/lib/Elastica/Facet/Query.php
index d43a2375..522090d5 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Facet/Query.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Facet/Query.php
@@ -1,24 +1,24 @@
<?php
-
namespace Elastica\Facet;
use Elastica\Query\AbstractQuery;
/**
- * Query facet
+ * Query facet.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/api/search/facets/query-facet.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-facets-query-facet.html
+ * @deprecated Facets are deprecated and will be removed in a future release. You are encouraged to migrate to aggregations instead.
*/
class Query extends AbstractFacet
{
/**
* Set the query for the facet.
*
- * @param \Elastica\Query\AbstractQuery $query
- * @return \Elastica\Facet\Query
+ * @param \Elastica\Query\AbstractQuery $query
+ *
+ * @return $this
*/
public function setQuery(AbstractQuery $query)
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Facet/Range.php b/vendor/ruflin/elastica/lib/Elastica/Facet/Range.php
index 194f611a..f81caf3d 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Facet/Range.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Facet/Range.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Facet;
use Elastica\Exception\InvalidException;
@@ -7,18 +6,19 @@ use Elastica\Exception\InvalidException;
/**
* Implements the range facet.
*
- * @category Xodoa
- * @package Elastica
* @author Jasper van Wanrooy <jasper@vanwanrooy.net>
- * @link http://www.elasticsearch.org/guide/reference/api/search/facets/range-facet.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-facets-range-facet.html
+ * @deprecated Facets are deprecated and will be removed in a future release. You are encouraged to migrate to aggregations instead.
*/
class Range extends AbstractFacet
{
/**
* Sets the field for the range.
*
- * @param string $field The name of the field for range.
- * @return \Elastica\Facet\Range
+ * @param string $field The name of the field for range.
+ *
+ * @return $this
*/
public function setField($field)
{
@@ -28,9 +28,10 @@ class Range extends AbstractFacet
/**
* Sets the fields by their separate key and value fields.
*
- * @param string $keyField The key_field param for the range.
- * @param string $valueField The key_value param for the range.
- * @return \Elastica\Facet\Range
+ * @param string $keyField The key_field param for the range.
+ * @param string $valueField The key_value param for the range.
+ *
+ * @return $this
*/
public function setKeyValueFields($keyField, $valueField)
{
@@ -44,7 +45,7 @@ class Range extends AbstractFacet
* @param string $keyScript Script to check whether it falls into the range.
* @param string $valueScript Script to use for statistical calculations.
*
- * @return \Elastica\Facet\Range
+ * @return $this
*/
public function setKeyValueScripts($keyScript, $valueScript)
{
@@ -59,10 +60,11 @@ class Range extends AbstractFacet
* array('from' => 20, 'to' 70),
* array('from' => 70, 'to' => 120),
* array('from' => 150)
- * )
+ * ).
*
- * @param array $ranges Numerical array with range definitions.
- * @return \Elastica\Facet\Range
+ * @param array $ranges Numerical array with range definitions.
+ *
+ * @return $this
*/
public function setRanges(array $ranges)
{
@@ -72,9 +74,10 @@ class Range extends AbstractFacet
/**
* Adds a range to the range facet.
*
- * @param mixed $from The from for the range.
- * @param mixed $to The to for the range.
- * @return \Elastica\Facet\Range
+ * @param mixed $from The from for the range.
+ * @param mixed $to The to for the range.
+ *
+ * @return $this
*/
public function addRange($from = null, $to = null)
{
@@ -99,12 +102,14 @@ class Range extends AbstractFacet
* facet definition of the parent.
*
* @see \Elastica\Facet\AbstractFacet::toArray()
+ *
* @throws \Elastica\Exception\InvalidException When the right fields haven't been set.
+ *
* @return array
*/
public function toArray()
{
- /**
+ /*
* Check the facet for validity.
* There are three ways to set the key and value field for the range:
* - a single field for both key and value; or
@@ -128,7 +133,7 @@ class Range extends AbstractFacet
throw new InvalidException('Either field, key_field and key_value or key_script and value_script should be set.');
}
- /**
+ /*
* Set the range in the abstract as param.
*/
$this->_setFacetParam('range', $this->_params);
diff --git a/vendor/ruflin/elastica/lib/Elastica/Facet/Statistical.php b/vendor/ruflin/elastica/lib/Elastica/Facet/Statistical.php
index 71507b8f..bb4eef8b 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Facet/Statistical.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Facet/Statistical.php
@@ -1,22 +1,22 @@
<?php
-
namespace Elastica\Facet;
/**
* Implements the statistical facet.
*
- * @category Xodoa
- * @package Elastica
* @author Robert Katzki <robert@katzki.de>
- * @link http://www.elasticsearch.org/guide/reference/api/search/facets/statistical-facet.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-facets-statistical-facet.html
+ * @deprecated Facets are deprecated and will be removed in a future release. You are encouraged to migrate to aggregations instead.
*/
class Statistical extends AbstractFacet
{
/**
* Sets the field for the statistical query.
*
- * @param string $field The field name for the statistical query.
- * @return \Elastica\Facet\Statistical
+ * @param string $field The field name for the statistical query.
+ *
+ * @return $this
*/
public function setField($field)
{
@@ -26,8 +26,9 @@ class Statistical extends AbstractFacet
/**
* Sets multiple fields for the statistical query.
*
- * @param array $fields Numerical array with the fields for the statistical query.
- * @return \Elastica\Facet\Statistical
+ * @param array $fields Numerical array with the fields for the statistical query.
+ *
+ * @return $this
*/
public function setFields(array $fields)
{
@@ -35,10 +36,11 @@ class Statistical extends AbstractFacet
}
/**
- * Sets a script to calculate statistical information
+ * Sets a script to calculate statistical information.
+ *
+ * @param string $script The script to do calculations on the statistical values
*
- * @param string $script The script to do calculations on the statistical values
- * @return \Elastica\Facet\Statistical
+ * @return $this
*/
public function setScript($script)
{
@@ -50,6 +52,7 @@ class Statistical extends AbstractFacet
* facet definition of the parent.
*
* @see \Elastica\Facet\AbstractFacet::toArray()
+ *
* @return array
*/
public function toArray()
diff --git a/vendor/ruflin/elastica/lib/Elastica/Facet/Terms.php b/vendor/ruflin/elastica/lib/Elastica/Facet/Terms.php
index c1dab800..6af8867b 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Facet/Terms.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Facet/Terms.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Facet;
use Elastica\Exception\InvalidException;
@@ -8,11 +7,11 @@ use Elastica\Script;
/**
* Implements the terms facet.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
* @author Jasper van Wanrooy <jasper@vanwanrooy.net>
- * @link http://www.elasticsearch.org/guide/reference/api/search/facets/terms-facet.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-facets-terms-facet.html
+ * @deprecated Facets are deprecated and will be removed in a future release. You are encouraged to migrate to aggregations instead.
*/
class Terms extends AbstractFacet
{
@@ -27,8 +26,9 @@ class Terms extends AbstractFacet
/**
* Sets the field for the terms.
*
- * @param string $field The field name for the terms.
- * @return \Elastica\Facet\Terms
+ * @param string $field The field name for the terms.
+ *
+ * @return $this
*/
public function setField($field)
{
@@ -38,8 +38,9 @@ class Terms extends AbstractFacet
/**
* Sets the script for the term.
*
- * @param string $script The script for the term.
- * @return \Elastica\Facet\Terms
+ * @param string $script The script for the term.
+ *
+ * @return $this
*/
public function setScript($script)
{
@@ -54,8 +55,9 @@ class Terms extends AbstractFacet
/**
* Sets multiple fields for the terms.
*
- * @param array $fields Numerical array with the fields for the terms.
- * @return \Elastica\Facet\Terms
+ * @param array $fields Numerical array with the fields for the terms.
+ *
+ * @return $this
*/
public function setFields(array $fields)
{
@@ -66,8 +68,9 @@ class Terms extends AbstractFacet
* Sets the flag to return all available terms. When they
* don't have a hit, they have a count of zero.
*
- * @param bool $allTerms Flag to fetch all terms.
- * @return \Elastica\Facet\Terms
+ * @param bool $allTerms Flag to fetch all terms.
+ *
+ * @return $this
*/
public function setAllTerms($allTerms)
{
@@ -78,14 +81,16 @@ class Terms extends AbstractFacet
* Sets the ordering type for this facet. Elasticsearch
* internal default is count.
*
- * @param string $type The order type to set use for sorting of the terms.
+ * @param string $type The order type to set use for sorting of the terms.
+ *
* @throws \Elastica\Exception\InvalidException When an invalid order type was set.
- * @return \Elastica\Facet\Terms
+ *
+ * @return $this
*/
public function setOrder($type)
{
if (!in_array($type, $this->_orderTypes)) {
- throw new InvalidException('Invalid order type: ' . $type);
+ throw new InvalidException('Invalid order type: '.$type);
}
return $this->setParam('order', $type);
@@ -94,8 +99,9 @@ class Terms extends AbstractFacet
/**
* Set an array with terms which are omitted in the search.
*
- * @param array $exclude Numerical array which includes all terms which needs to be ignored.
- * @return \Elastica\Facet\Terms
+ * @param array $exclude Numerical array which includes all terms which needs to be ignored.
+ *
+ * @return $this
*/
public function setExclude(array $exclude)
{
@@ -105,8 +111,9 @@ class Terms extends AbstractFacet
/**
* Sets the amount of terms to be returned.
*
- * @param int $size The amount of terms to be returned.
- * @return \Elastica\Facet\Terms
+ * @param int $size The amount of terms to be returned.
+ *
+ * @return $this
*/
public function setSize($size)
{
@@ -118,6 +125,7 @@ class Terms extends AbstractFacet
* facet definition of the parent.
*
* @see \Elastica\Facet\AbstractFacet::toArray()
+ *
* @return array
*/
public function toArray()
diff --git a/vendor/ruflin/elastica/lib/Elastica/Facet/TermsStats.php b/vendor/ruflin/elastica/lib/Elastica/Facet/TermsStats.php
index 61c6b39e..22d284c5 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Facet/TermsStats.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Facet/TermsStats.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Facet;
use Elastica\Exception\InvalidException;
@@ -7,14 +6,13 @@ use Elastica\Exception\InvalidException;
/**
* Implements the statistical facet on a per term basis.
*
- * @category Xodoa
- * @package Elastica
* @author Tom Michaelis <tom.michaelis@gmail.com>
- * @link http://www.elasticsearch.org/guide/reference/api/search/facets/terms-stats-facet.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-facets-terms-stats-facet.html
+ * @deprecated Facets are deprecated and will be removed in a future release. You are encouraged to migrate to aggregations instead.
*/
class TermsStats extends AbstractFacet
{
-
/**
* Holds the types of ordering which are allowed
* by Elasticsearch.
@@ -23,63 +21,69 @@ class TermsStats extends AbstractFacet
*/
protected $_orderTypes = array('term', 'reverse_term', 'count', 'reverse_count',
'total', 'reverse_total', 'min', 'reverse_min', 'max', 'reverse_max', 'mean',
- 'reverse_mean');
+ 'reverse_mean', );
/**
* Sets the key field for the query.
*
- * @param string $keyField The key field name for the query.
- * @return \Elastica\Facet\TermsStats
+ * @param string $keyField The key field name for the query.
+ *
+ * @return $this
*/
- public function setKeyField( $keyField )
+ public function setKeyField($keyField)
{
- return $this->setParam( 'key_field', $keyField );
+ return $this->setParam('key_field', $keyField);
}
/**
- * Sets a script to calculate statistical information on a per term basis
+ * Sets a script to calculate statistical information on a per term basis.
+ *
+ * @param string $valueScript The script to do calculations on the statistical values
*
- * @param string $valueScript The script to do calculations on the statistical values
- * @return \Elastica\Facet\TermsStats
+ * @return $this
*/
- public function setValueScript( $valueScript )
+ public function setValueScript($valueScript)
{
- return $this->setParam( 'value_script', $valueScript );
+ return $this->setParam('value_script', $valueScript);
}
/**
* Sets the ordering type for this facet. Elasticsearch
* internal default is count.
*
- * @param string $type The order type to set use for sorting of the terms.
+ * @param string $type The order type to set use for sorting of the terms.
+ *
* @throws \Elastica\Exception\InvalidException When an invalid order type was set.
- * @return \Elastica\Facet\TermsStats
+ *
+ * @return $this
*/
public function setOrder($type)
{
if (!in_array($type, $this->_orderTypes)) {
- throw new InvalidException('Invalid order type: ' . $type);
+ throw new InvalidException('Invalid order type: '.$type);
}
return $this->setParam('order', $type);
}
/**
- * Sets a field to compute basic statistical results on
+ * Sets a field to compute basic statistical results on.
+ *
+ * @param string $valueField The field to compute statistical values for
*
- * @param string $valueField The field to compute statistical values for
- * @return \Elastica\Facet\TermsStats
+ * @return $this
*/
- public function setValueField( $valueField )
+ public function setValueField($valueField)
{
- return $this->setParam( 'value_field', $valueField );
+ return $this->setParam('value_field', $valueField);
}
/**
* Sets the amount of terms to be returned.
*
- * @param int $size The amount of terms to be returned.
- * @return \Elastica\Facet\Terms
+ * @param int $size The amount of terms to be returned.
+ *
+ * @return $this
*/
public function setSize($size)
{
@@ -91,13 +95,13 @@ class TermsStats extends AbstractFacet
* facet definition of the parent.
*
* @see \Elastica\Facet\AbstractFacet::toArray()
+ *
* @return array
*/
public function toArray()
{
- $this->_setFacetParam( 'terms_stats', $this->_params );
+ $this->_setFacetParam('terms_stats', $this->_params);
return parent::toArray();
}
-
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractFilter.php b/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractFilter.php
index 665f155f..7c7dc4f7 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractFilter.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractFilter.php
@@ -1,25 +1,24 @@
<?php
-
namespace Elastica\Filter;
use Elastica\Exception\InvalidException;
use Elastica\Param;
/**
- * Abstract filter object. Should be extended by all filter types
+ * Abstract filter object. Should be extended by all filter types.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-filters.html
*/
abstract class AbstractFilter extends Param
{
/**
- * Sets the filter cache
+ * Sets the filter cache.
+ *
+ * @param bool $cached Cached
*
- * @param boolean $cached Cached
- * @return \Elastica\Filter\AbstractFilter
+ * @return $this
*/
public function setCached($cached = true)
{
@@ -27,11 +26,13 @@ abstract class AbstractFilter extends Param
}
/**
- * Sets the filter cache key
+ * Sets the filter cache key.
*
- * @param string $cacheKey Cache key
- * @throws \Elastica\Exception\InvalidException
- * @return \Elastica\Filter\AbstractFilter
+ * @param string $cacheKey Cache key
+ *
+ * @throws \Elastica\Exception\InvalidException If given key is empty
+ *
+ * @return $this
*/
public function setCacheKey($cacheKey)
{
@@ -45,10 +46,11 @@ abstract class AbstractFilter extends Param
}
/**
- * Sets the filter name
+ * Sets the filter name.
+ *
+ * @param string $name Name
*
- * @param string $name Name
- * @return \Elastica\Filter\AbstractFilter
+ * @return $this
*/
public function setName($name)
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractGeoDistance.php b/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractGeoDistance.php
index 997ceab7..b208afb4 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractGeoDistance.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractGeoDistance.php
@@ -1,25 +1,22 @@
<?php
-
namespace Elastica\Filter;
use Elastica\Exception\InvalidException;
/**
- * Geo distance filter
+ * Geo distance filter.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/geo-distance-filter.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-filter.html
*/
abstract class AbstractGeoDistance extends AbstractFilter
{
-
const LOCATION_TYPE_GEOHASH = 'geohash';
const LOCATION_TYPE_LATLON = 'latlon';
/**
- * Location type
+ * Location type.
*
* Decides if this filter uses latitude/longitude or geohash for the location.
* Values are "latlon" or "geohash".
@@ -29,38 +26,39 @@ abstract class AbstractGeoDistance extends AbstractFilter
protected $_locationType = null;
/**
- * Key
+ * Key.
*
* @var string
*/
protected $_key = null;
/**
- * Latitude
+ * Latitude.
*
* @var float
*/
protected $_latitude = null;
/**
- * Longitude
+ * Longitude.
*
* @var float
*/
protected $_longitude = null;
/**
- * Geohash
+ * Geohash.
*
* @var string
*/
protected $_geohash = null;
/**
- * Create GeoDistance object
+ * Create GeoDistance object.
+ *
+ * @param string $key Key
+ * @param array|string $location Location as array or geohash: array('lat' => 48.86, 'lon' => 2.35) OR 'drm3btev3e86'
*
- * @param string $key Key
- * @param array|string $location Location as array or geohash: array('lat' => 48.86, 'lon' => 2.35) OR 'drm3btev3e86'
* @internal param string $distance Distance
*/
public function __construct($key, $location)
@@ -71,8 +69,9 @@ abstract class AbstractGeoDistance extends AbstractFilter
}
/**
- * @param string $key
- * @return \Elastica\Filter\AbstractGeoDistance current filter
+ * @param string $key
+ *
+ * @return $this
*/
public function setKey($key)
{
@@ -82,9 +81,11 @@ abstract class AbstractGeoDistance extends AbstractFilter
}
/**
- * @param array|string $location
- * @return \Elastica\Filter\AbstractGeoDistance
+ * @param array|string $location
+ *
* @throws \Elastica\Exception\InvalidException
+ *
+ * @return $this
*/
public function setLocation($location)
{
@@ -113,8 +114,9 @@ abstract class AbstractGeoDistance extends AbstractFilter
}
/**
- * @param float $latitude
- * @return \Elastica\Filter\AbstractGeoDistance current filter
+ * @param float $latitude
+ *
+ * @return $this
*/
public function setLatitude($latitude)
{
@@ -125,8 +127,9 @@ abstract class AbstractGeoDistance extends AbstractFilter
}
/**
- * @param float $longitude
- * @return \Elastica\Filter\AbstractGeoDistance current filter
+ * @param float $longitude
+ *
+ * @return $this
*/
public function setLongitude($longitude)
{
@@ -137,8 +140,9 @@ abstract class AbstractGeoDistance extends AbstractFilter
}
/**
- * @param string $geohash
- * @return \Elastica\Filter\AbstractGeoDistance current filter
+ * @param string $geohash
+ *
+ * @return $this
*/
public function setGeohash($geohash)
{
@@ -149,8 +153,9 @@ abstract class AbstractGeoDistance extends AbstractFilter
}
/**
- * @return array|string
* @throws \Elastica\Exception\InvalidException
+ *
+ * @return array|string
*/
protected function _getLocationData()
{
@@ -179,7 +184,10 @@ abstract class AbstractGeoDistance extends AbstractFilter
/**
* @see \Elastica\Param::toArray()
+ *
* @throws \Elastica\Exception\InvalidException
+ *
+ * @return array
*/
public function toArray()
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractGeoShape.php b/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractGeoShape.php
index 3585293b..4f5c0f93 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractGeoShape.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractGeoShape.php
@@ -1,32 +1,30 @@
<?php
-
namespace Elastica\Filter;
/**
- * geo_shape filter
+ * geo_shape filter.
*
* Filter pre-indexed shape definitions
*
- * @category Xodoa
- * @package Elastica
* @author Bennie Krijger <benniekrijger@gmail.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/geo-shape-filter/
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-shape-filter.html
*/
abstract class AbstractGeoShape extends AbstractFilter
{
- const RELATION_INTERSECT = 'intersects';
- const RELATION_DISJOINT = 'disjoint';
- const RELATION_CONTAINS = 'within';
+ const RELATION_INTERSECT = 'intersects';
+ const RELATION_DISJOINT = 'disjoint';
+ const RELATION_CONTAINS = 'within';
/**
- * @var string $_path
+ * @var string
*
* elasticsearch path of the pre-indexed shape
*/
protected $_path;
/**
- * @var string $_relation
+ * @var string
*
* the relation of the 2 shaped: intersects, disjoint, within
*/
@@ -34,10 +32,14 @@ abstract class AbstractGeoShape extends AbstractFilter
/**
* @param string $relation
+ *
+ * @return $this
*/
public function setRelation($relation)
{
$this->_relation = $relation;
+
+ return $this;
}
/**
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractMulti.php b/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractMulti.php
index 53ef74cf..06f6daea 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractMulti.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractMulti.php
@@ -1,27 +1,36 @@
<?php
-
namespace Elastica\Filter;
/**
- * Multi Abstract filter object. Should be extended by filter types composed of an array of sub filters
+ * Multi Abstract filter object. Should be extended by filter types composed of an array of sub filters.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
*/
abstract class AbstractMulti extends AbstractFilter
{
/**
- * Filters
+ * Filters.
+ *
* @var array
*/
protected $_filters = array();
/**
- * Add filter
+ * @param \Elastica\Filter\AbstractFilter $filters
+ */
+ public function __construct(array $filters = array())
+ {
+ if (!empty($filters)) {
+ $this->setFilters($filters);
+ }
+ }
+
+ /**
+ * Add filter.
+ *
+ * @param \Elastica\Filter\AbstractFilter $filter
*
- * @param \Elastica\Filter\AbstractFilter $filter
- * @return \Elastica\Filter\AbstractMulti
+ * @return $this
*/
public function addFilter(AbstractFilter $filter)
{
@@ -31,10 +40,11 @@ abstract class AbstractMulti extends AbstractFilter
}
/**
- * Set filters
+ * Set filters.
*
- * @param array $filters
- * @return \Elastica\Filter\AbstractMulti
+ * @param array $filters
+ *
+ * @return $this
*/
public function setFilters(array $filters)
{
@@ -57,6 +67,8 @@ abstract class AbstractMulti extends AbstractFilter
/**
* @see \Elastica\Param::toArray()
+ *
+ * @return array
*/
public function toArray()
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Bool.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Bool.php
index aff708f8..0d30f83f 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/Bool.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Bool.php
@@ -1,146 +1,15 @@
<?php
-
namespace Elastica\Filter;
-use Elastica\Exception\InvalidException;
-
/**
- * Bool Filter
+ * Bool Filter.
+ *
+ * This class is for backward compatibility reason for all php < 7 versions. For PHP 7 and above use BoolFilter as Bool is reserved.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/bool-query.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-filter.html
*/
-class Bool extends AbstractFilter
+class Bool extends BoolFilter
{
- /**
- * @var float
- */
- protected $_boost = 1.0;
-
- /**
- * Must
- *
- * @var array
- */
- protected $_must = array();
-
- /**
- * Should
- *
- * @var array
- */
- protected $_should = array();
-
- /**
- * Must not
- *
- * @var array
- */
- protected $_mustNot = array();
-
- /**
- * Adds should filter
- *
- * @param array|\Elastica\Filter\AbstractFilter $args Filter data
- * @return \Elastica\Filter\Bool Current object
- */
- public function addShould($args)
- {
- return $this->_addFilter('should', $args);
- }
-
- /**
- * Adds must filter
- *
- * @param array|\Elastica\Filter\AbstractFilter $args Filter data
- * @return \Elastica\Filter\Bool Current object
- */
- public function addMust($args)
- {
- return $this->_addFilter('must', $args);
- }
-
- /**
- * Adds mustNot filter
- *
- * @param array|\Elastica\Filter\AbstractFilter $args Filter data
- * @return \Elastica\Filter\Bool Current object
- */
- public function addMustNot($args)
- {
- return $this->_addFilter('mustNot', $args);
- }
-
- /**
- * Adds general filter based on type
- *
- * @param string $type Filter type
- * @param array|\Elastica\Filter\AbstractFilter $args Filter data
- * @throws \Elastica\Exception\InvalidException
- * @return \Elastica\Filter\Bool Current object
- */
- protected function _addFilter($type, $args)
- {
- if ($args instanceof AbstractFilter) {
- $args = $args->toArray();
- }
- else if (!is_array($args)) {
- throw new InvalidException('Invalid parameter. Has to be array or instance of Elastica\Filter');
- }
- else{
- $parsedArgs = array();
- foreach($args as $filter){
- if($filter instanceof AbstractFilter){
- $parsedArgs[] = $filter->toArray();
- }
- }
- $args = $parsedArgs;
- }
-
- $varName = '_' . $type;
- $this->{$varName}[] = $args;
-
- return $this;
- }
-
- /**
- * Converts bool filter to array
- *
- * @see \Elastica\Filter\AbstractFilter::toArray()
- * @return array Filter array
- */
- public function toArray()
- {
- $args = array();
-
- if (!empty($this->_must)) {
- $args['bool']['must'] = $this->_must;
- }
-
- if (!empty($this->_should)) {
- $args['bool']['should'] = $this->_should;
- }
-
- if (!empty($this->_mustNot)) {
- $args['bool']['must_not'] = $this->_mustNot;
- }
-
- return $args;
- }
-
- /**
- * Sets the boost value for this filter
- *
- * @param float $boost Boost
- * @return \Elastica\Filter\Bool Current object
- */
- public function setBoost($boost)
- {
- $this->_boost = $boost;
-
- return $this;
- }
-
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/BoolAnd.php b/vendor/ruflin/elastica/lib/Elastica/Filter/BoolAnd.php
index 2fd19f8e..8a08ea9c 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/BoolAnd.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/BoolAnd.php
@@ -1,14 +1,12 @@
<?php
-
namespace Elastica\Filter;
/**
- * And Filter
+ * And Filter.
*
- * @category Xodoa
- * @package Elastica
* @author Lee Parker, Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/and-filter.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-and-filter.html
*/
class BoolAnd extends AbstractMulti
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/BoolFilter.php b/vendor/ruflin/elastica/lib/Elastica/Filter/BoolFilter.php
new file mode 100644
index 00000000..5a488b77
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/BoolFilter.php
@@ -0,0 +1,133 @@
+<?php
+namespace Elastica\Filter;
+
+use Elastica\Exception\InvalidException;
+
+/**
+ * Bool Filter.
+ *
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-filter.html
+ */
+class BoolFilter extends AbstractFilter
+{
+ /**
+ * Must.
+ *
+ * @var array
+ */
+ protected $_must = array();
+
+ /**
+ * Should.
+ *
+ * @var array
+ */
+ protected $_should = array();
+
+ /**
+ * Must not.
+ *
+ * @var array
+ */
+ protected $_mustNot = array();
+
+ /**
+ * Adds should filter.
+ *
+ * @param array|\Elastica\Filter\AbstractFilter $args Filter data
+ *
+ * @return $this
+ */
+ public function addShould($args)
+ {
+ return $this->_addFilter('should', $args);
+ }
+
+ /**
+ * Adds must filter.
+ *
+ * @param array|\Elastica\Filter\AbstractFilter $args Filter data
+ *
+ * @return $this
+ */
+ public function addMust($args)
+ {
+ return $this->_addFilter('must', $args);
+ }
+
+ /**
+ * Adds mustNot filter.
+ *
+ * @param array|\Elastica\Filter\AbstractFilter $args Filter data
+ *
+ * @return $this
+ */
+ public function addMustNot($args)
+ {
+ return $this->_addFilter('mustNot', $args);
+ }
+
+ /**
+ * Adds general filter based on type.
+ *
+ * @param string $type Filter type
+ * @param array|\Elastica\Filter\AbstractFilter $args Filter data
+ *
+ * @throws \Elastica\Exception\InvalidException
+ *
+ * @return $this
+ */
+ protected function _addFilter($type, $args)
+ {
+ if ($args instanceof AbstractFilter) {
+ $args = $args->toArray();
+ } elseif (!is_array($args)) {
+ throw new InvalidException('Invalid parameter. Has to be array or instance of Elastica\Filter');
+ } else {
+ $parsedArgs = array();
+ foreach ($args as $filter) {
+ if ($filter instanceof AbstractFilter) {
+ $parsedArgs[] = $filter->toArray();
+ }
+ }
+ $args = $parsedArgs;
+ }
+
+ $varName = '_'.$type;
+ $this->{$varName}[] = $args;
+
+ return $this;
+ }
+
+ /**
+ * Converts bool filter to array.
+ *
+ * @see \Elastica\Filter\AbstractFilter::toArray()
+ *
+ * @return array Filter array
+ */
+ public function toArray()
+ {
+ $args = array();
+
+ if (!empty($this->_must)) {
+ $args['bool']['must'] = $this->_must;
+ }
+
+ if (!empty($this->_should)) {
+ $args['bool']['should'] = $this->_should;
+ }
+
+ if (!empty($this->_mustNot)) {
+ $args['bool']['must_not'] = $this->_mustNot;
+ }
+
+ if (isset($args['bool'])) {
+ $args['bool'] = array_merge($args['bool'], $this->getParams());
+ }
+
+ return $args;
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/BoolNot.php b/vendor/ruflin/elastica/lib/Elastica/Filter/BoolNot.php
index 1778997b..81db7f65 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/BoolNot.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/BoolNot.php
@@ -1,19 +1,17 @@
<?php
-
namespace Elastica\Filter;
/**
- * Not Filter
+ * Not Filter.
*
- * @category Xodoa
- * @package Elastica
* @author Lee Parker, Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/not-filter.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-not-filter.html
*/
class BoolNot extends AbstractFilter
{
/**
- * Creates Not filter query
+ * Creates Not filter query.
*
* @param \Elastica\Filter\AbstractFilter $filter Filter object
*/
@@ -23,10 +21,11 @@ class BoolNot extends AbstractFilter
}
/**
- * Set filter
+ * Set filter.
+ *
+ * @param \Elastica\Filter\AbstractFilter $filter
*
- * @param \Elastica\Filter\AbstractFilter $filter
- * @return \Elastica\Filter\BoolNot
+ * @return $this
*/
public function setFilter(AbstractFilter $filter)
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/BoolOr.php b/vendor/ruflin/elastica/lib/Elastica/Filter/BoolOr.php
index 6f63fc30..9091e496 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/BoolOr.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/BoolOr.php
@@ -1,14 +1,12 @@
<?php
-
namespace Elastica\Filter;
/**
- * Or Filter
+ * Or Filter.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/or-filter.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-or-filter.html
*/
class BoolOr extends AbstractMulti
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Exists.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Exists.php
index 6fe43e3d..d6dc9962 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/Exists.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Exists.php
@@ -1,19 +1,17 @@
<?php
-
namespace Elastica\Filter;
/**
- * Exists query
+ * Exists query.
*
- * @category Xodoa
- * @package Elastica
* @author Oleg Cherniy <oleg.cherniy@gmail.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/exists-filter.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-exists-filter.html
*/
class Exists extends AbstractFilter
{
/**
- * Construct exists filter
+ * Construct exists filter.
*
* @param string $field
*/
@@ -23,10 +21,11 @@ class Exists extends AbstractFilter
}
/**
- * Set field
+ * Set field.
+ *
+ * @param string $field
*
- * @param string $field
- * @return \Elastica\Filter\Exists
+ * @return $this
*/
public function setField($field)
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/GeoBoundingBox.php b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoBoundingBox.php
index 1462e9af..f67febe3 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/GeoBoundingBox.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoBoundingBox.php
@@ -1,21 +1,19 @@
<?php
-
namespace Elastica\Filter;
use Elastica\Exception\InvalidException;
/**
- * Geo bounding box filter
+ * Geo bounding box filter.
*
- * @category Xodoa
- * @package Elastica
* @author Fabian Vogler <fabian@equivalence.ch>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/geo-bounding-box-filter.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-bounding-box-filter.html
*/
class GeoBoundingBox extends AbstractFilter
{
/**
- * Construct BoundingBoxFilter
+ * Construct BoundingBoxFilter.
*
* @param string $key Key
* @param array $coordinates Array with top left coordinate as first and bottom right coordinate as second element
@@ -26,12 +24,14 @@ class GeoBoundingBox extends AbstractFilter
}
/**
- * Add coordinates
+ * Add coordinates.
+ *
+ * @param string $key Key
+ * @param array $coordinates Array with top left coordinate as first and bottom right coordinate as second element
+ *
+ * @throws \Elastica\Exception\InvalidException If $coordinates doesn't have two elements
*
- * @param string $key Key
- * @param array $coordinates Array with top left coordinate as first and bottom right coordinate as second element
- * @throws \Elastica\Exception\InvalidException If $coordinates doesn't have two elements
- * @return \Elastica\Filter\GeoBoundingBox Current object
+ * @return $this
*/
public function addCoordinates($key, array $coordinates)
{
@@ -41,7 +41,7 @@ class GeoBoundingBox extends AbstractFilter
$this->setParam($key, array(
'top_left' => $coordinates[0],
- 'bottom_right' => $coordinates[1]
+ 'bottom_right' => $coordinates[1],
));
return $this;
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/GeoDistance.php b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoDistance.php
index 8e875365..f4cb51d9 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/GeoDistance.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoDistance.php
@@ -1,30 +1,30 @@
<?php
-
namespace Elastica\Filter;
/**
- * Geo distance filter
+ * Geo distance filter.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/geo-distance-filter.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-filter.html
*/
class GeoDistance extends AbstractGeoDistance
{
const DISTANCE_TYPE_ARC = 'arc';
const DISTANCE_TYPE_PLANE = 'plane';
+ const DISTANCE_TYPE_SLOPPY_ARC = 'sloppy_arc';
const OPTIMIZE_BBOX_MEMORY = 'memory';
const OPTIMIZE_BBOX_INDEXED = 'indexed';
const OPTIMIZE_BBOX_NONE = 'none';
/**
- * Create GeoDistance object
+ * Create GeoDistance object.
+ *
+ * @param string $key Key
+ * @param array|string $location Location as array or geohash: array('lat' => 48.86, 'lon' => 2.35) OR 'drm3btev3e86'
+ * @param string $distance Distance
*
- * @param string $key Key
- * @param array|string $location Location as array or geohash: array('lat' => 48.86, 'lon' => 2.35) OR 'drm3btev3e86'
- * @param string $distance Distance
* @throws \Elastica\Exception\InvalidException
*/
public function __construct($key, $location, $distance)
@@ -35,8 +35,9 @@ class GeoDistance extends AbstractGeoDistance
}
/**
- * @param string $distance
- * @return \Elastica\Filter\GeoDistance current filter
+ * @param string $distance
+ *
+ * @return $this
*/
public function setDistance($distance)
{
@@ -46,10 +47,11 @@ class GeoDistance extends AbstractGeoDistance
}
/**
- * See DISTANCE_TYPE_* constants
+ * See DISTANCE_TYPE_* constants.
+ *
+ * @param string $distanceType
*
- * @param string $distanceType
- * @return \Elastica\Filter\GeoDistance current filter
+ * @return $this
*/
public function setDistanceType($distanceType)
{
@@ -59,10 +61,11 @@ class GeoDistance extends AbstractGeoDistance
}
/**
- * See OPTIMIZE_BBOX_* constants
+ * See OPTIMIZE_BBOX_* constants.
+ *
+ * @param string $optimizeBbox
*
- * @param string $optimizeBbox
- * @return \Elastica\Filter\GeoDistance current filter
+ * @return $this
*/
public function setOptimizeBbox($optimizeBbox)
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/GeoDistanceRange.php b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoDistanceRange.php
index 230e5ebf..f5cbbeb7 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/GeoDistanceRange.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoDistanceRange.php
@@ -1,16 +1,14 @@
<?php
-
namespace Elastica\Filter;
use Elastica\Exception\InvalidException;
/**
- * Geo distance filter
+ * Geo distance filter.
*
- * @category Xodoa
- * @package Elastica
* @author munkie
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/geo-distance-range-filter.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-range-filter.html
*/
class GeoDistanceRange extends AbstractGeoDistance
{
@@ -33,6 +31,7 @@ class GeoDistanceRange extends AbstractGeoDistance
* @param string $key
* @param array|string $location
* @param array $ranges
+ *
* @internal param string $distance
*/
public function __construct($key, $location, array $ranges = array())
@@ -45,8 +44,9 @@ class GeoDistanceRange extends AbstractGeoDistance
}
/**
- * @param array $ranges
- * @return \Elastica\Filter\GeoDistanceRange
+ * @param array $ranges
+ *
+ * @return $this
*/
public function setRanges(array $ranges)
{
@@ -60,10 +60,12 @@ class GeoDistanceRange extends AbstractGeoDistance
}
/**
- * @param string $key
- * @param mixed $value
- * @return \Elastica\Filter\GeoDistanceRange
+ * @param string $key
+ * @param mixed $value
+ *
* @throws \Elastica\Exception\InvalidException
+ *
+ * @return $this
*/
public function setRange($key, $value)
{
@@ -80,7 +82,7 @@ class GeoDistanceRange extends AbstractGeoDistance
$value = (boolean) $value;
break;
default:
- throw new InvalidException('Invalid range parameter given: ' . $key);
+ throw new InvalidException('Invalid range parameter given: '.$key);
}
$this->_ranges[$key] = $value;
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/GeoPolygon.php b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoPolygon.php
index fa12c035..86ca2b80 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/GeoPolygon.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoPolygon.php
@@ -1,35 +1,31 @@
<?php
-
namespace Elastica\Filter;
-use Elastica\Filter\AbstractFilter;
-
/**
- * Geo polygon filter
+ * Geo polygon filter.
*
- * @category Xodoa
- * @package Elastica
* @author Michael Maclean <mgdm@php.net>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/geo-polygon-filter.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-polygon-filter.html
*/
class GeoPolygon extends AbstractFilter
{
/**
- * Key
+ * Key.
*
* @var string Key
*/
protected $_key = '';
/**
- * Points making up polygon
+ * Points making up polygon.
*
* @var array Points making up polygon
*/
protected $_points = array();
/**
- * Construct polygon filter
+ * Construct polygon filter.
*
* @param string $key Key
* @param array $points Points making up polygon
@@ -41,9 +37,10 @@ class GeoPolygon extends AbstractFilter
}
/**
- * Converts filter to array
+ * Converts filter to array.
*
* @see \Elastica\Filter\AbstractFilter::toArray()
+ *
* @return array
*/
public function toArray()
@@ -51,9 +48,9 @@ class GeoPolygon extends AbstractFilter
return array(
'geo_polygon' => array(
$this->_key => array(
- 'points' => $this->_points
+ 'points' => $this->_points,
),
- )
+ ),
);
}
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapePreIndexed.php b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapePreIndexed.php
index 7e89f8a8..d07cffff 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapePreIndexed.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapePreIndexed.php
@@ -1,49 +1,47 @@
<?php
-
namespace Elastica\Filter;
/**
- * geo_shape filter for pre-indexed shapes
+ * geo_shape filter for pre-indexed shapes.
*
* Filter pre-indexed shape definitions
*
- * @category Xodoa
- * @package Elastica
* @author Bennie Krijger <benniekrijger@gmail.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/geo-shape-filter/
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-shape-filter.html
*/
class GeoShapePreIndexed extends AbstractGeoShape
{
/**
- * elasticsearch id of the pre-indexed shape
+ * elasticsearch id of the pre-indexed shape.
*
* @var string
*/
protected $_indexedId;
/**
- * elasticsearch type of the pre-indexed shape
+ * elasticsearch type of the pre-indexed shape.
*
* @var string
*/
protected $_indexedType;
/**
- * elasticsearch index of the pre-indexed shape
+ * elasticsearch index of the pre-indexed shape.
*
* @var string
*/
protected $_indexedIndex;
/**
- * elasticsearch path/field name of the pre-indexed shape
+ * elasticsearch path/field name of the pre-indexed shape.
*
* @var string
*/
protected $_indexedPath;
/**
- * Construct geo_shape filter with a pre-indexed shape
+ * Construct geo_shape filter with a pre-indexed shape.
*
* @param string $path The path/field of the shape searched
* @param string $indexedId Id of the pre-indexed shape
@@ -61,9 +59,10 @@ class GeoShapePreIndexed extends AbstractGeoShape
}
/**
- * Converts filter to array
+ * Converts filter to array.
*
* @see \Elastica\Filter\AbstractFilter::toArray()
+ *
* @return array
*/
public function toArray()
@@ -75,11 +74,11 @@ class GeoShapePreIndexed extends AbstractGeoShape
'id' => $this->_indexedId,
'type' => $this->_indexedType,
'index' => $this->_indexedIndex,
- 'path' => $this->_indexedPath
+ 'path' => $this->_indexedPath,
),
- 'relation' => $this->_relation
- )
- )
+ 'relation' => $this->_relation,
+ ),
+ ),
);
}
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapeProvided.php b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapeProvided.php
index 5a88c05f..0f25beeb 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapeProvided.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapeProvided.php
@@ -1,42 +1,40 @@
<?php
-
namespace Elastica\Filter;
/**
- * geo_shape filter or provided shapes
+ * geo_shape filter or provided shapes.
*
* Filter provided shape definitions
*
- * @category Xodoa
- * @package Elastica
* @author BennieKrijger <benniekrijger@gmail.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/geo-shape-filter/
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-shape-filter.html
*/
class GeoShapeProvided extends AbstractGeoShape
{
- const TYPE_ENVELOPE = 'envelope';
- const TYPE_MULTIPOINT = 'multipoint';
- const TYPE_POINT = 'point';
- const TYPE_MULTIPOLYGON = 'multipolygon';
- const TYPE_LINESTRING = 'linestring';
- const TYPE_POLYGON = 'polygon';
+ const TYPE_ENVELOPE = 'envelope';
+ const TYPE_MULTIPOINT = 'multipoint';
+ const TYPE_POINT = 'point';
+ const TYPE_MULTIPOLYGON = 'multipolygon';
+ const TYPE_LINESTRING = 'linestring';
+ const TYPE_POLYGON = 'polygon';
/**
- * Type of the geo_shape
+ * Type of the geo_shape.
*
* @var string
*/
protected $_shapeType;
/**
- * Coordinates making up geo_shape
+ * Coordinates making up geo_shape.
*
* @var array Coordinates making up geo_shape
*/
protected $_coordinates;
/**
- * Construct geo_shape filter
+ * Construct geo_shape filter.
*
* @param string $path The path/field of the shape searched
* @param array $coordinates Points making up the shape
@@ -52,9 +50,10 @@ class GeoShapeProvided extends AbstractGeoShape
}
/**
- * Converts filter to array
+ * Converts filter to array.
*
* @see \Elastica\Filter\AbstractFilter::toArray()
+ *
* @return array
*/
public function toArray()
@@ -64,11 +63,11 @@ class GeoShapeProvided extends AbstractGeoShape
$this->_path => array(
'shape' => array(
'type' => $this->_shapeType,
- 'coordinates' => $this->_coordinates
+ 'coordinates' => $this->_coordinates,
),
- 'relation' => $this->_relation
+ 'relation' => $this->_relation,
),
- )
+ ),
);
}
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/GeohashCell.php b/vendor/ruflin/elastica/lib/Elastica/Filter/GeohashCell.php
index d14b25fe..dd147152 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/GeohashCell.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/GeohashCell.php
@@ -1,20 +1,18 @@
<?php
-
namespace Elastica\Filter;
-
/**
- * Class GeohashCell
- * @package Elastica
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/geohash-cell-filter/
+ * Class GeohashCell.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geohash-cell-filter.html
*/
class GeohashCell extends AbstractGeoDistance
{
/**
- * @param string $key The field on which to filter
- * @param array|string $location Location as coordinates array or geohash string ['lat' => 40.3, 'lon' => 45.2]
- * @param $precision Integer length of geohash prefix or distance (3, or "50m")
- * @param bool $neighbors If true, filters cells next to the given cell.
+ * @param string $key The field on which to filter
+ * @param array|string $location Location as coordinates array or geohash string ['lat' => 40.3, 'lon' => 45.2]
+ * @param string|int $precision Integer length of geohash prefix or distance (3, or "50m")
+ * @param bool $neighbors If true, filters cells next to the given cell.
*/
public function __construct($key, $location, $precision = -1, $neighbors = false)
{
@@ -24,9 +22,11 @@ class GeohashCell extends AbstractGeoDistance
}
/**
- * Set the precision for this filter
+ * Set the precision for this filter.
+ *
* @param string|int $precision Integer length of geohash prefix or distance (3, or "50m")
- * @return \Elastica\Filter\GeohashCell
+ *
+ * @return $this
*/
public function setPrecision($precision)
{
@@ -34,12 +34,14 @@ class GeohashCell extends AbstractGeoDistance
}
/**
- * Set the neighbors option for this filter
+ * Set the neighbors option for this filter.
+ *
* @param bool $neighbors If true, filters cells next to the given cell.
- * @return \Elastica\Filter\GeohashCell
+ *
+ * @return $this
*/
public function setNeighbors($neighbors)
{
- return $this->setParam('neighbors', (bool)$neighbors);
+ return $this->setParam('neighbors', (bool) $neighbors);
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/HasChild.php b/vendor/ruflin/elastica/lib/Elastica/Filter/HasChild.php
index e8c6ab96..2c4cc0d6 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/HasChild.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/HasChild.php
@@ -1,22 +1,20 @@
<?php
-
namespace Elastica\Filter;
/**
- * Returns parent documents having child docs matching the query
+ * Returns parent documents having child docs matching the query.
*
- * @category Xodoa
- * @package Elastica
* @author Fabian Vogler <fabian@equivalence.ch>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/has-child-filter.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-has-child-filter.html
*/
class HasChild extends AbstractFilter
{
/**
- * Construct HasChild filter
+ * Construct HasChild filter.
*
* @param string|\Elastica\Query|\Elastica\Filter\AbstractFilter $query Query string or a Elastica\Query object or a filter
- * @param string $type Parent document type
+ * @param string|\Elastica\Type $type Child document type
*/
public function __construct($query, $type = null)
{
@@ -29,10 +27,11 @@ class HasChild extends AbstractFilter
}
/**
- * Sets query object
+ * Sets query object.
*
- * @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query
- * @return \Elastica\Filter\HasChild Current object
+ * @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query
+ *
+ * @return $this
*/
public function setQuery($query)
{
@@ -43,36 +42,54 @@ class HasChild extends AbstractFilter
}
/**
- * Sets the filter object
+ * Sets the filter object.
*
* @param \Elastica\Filter\AbstractFilter $filter
- * @return \Elastica\Filter\HasChild Current object
+ *
+ * @return $this
*/
public function setFilter($filter)
{
- $data = $filter->toArray();
- return $this->setParam('filter', $data);
+ return $this->setParam('filter', $filter->toArray());
}
/**
- * Set type of the parent document
+ * Set type of the child document.
*
- * @param string $type Parent document type
- * @return \Elastica\Filter\HasChild Current object
+ * @param string|\Elastica\Type $type Child document type
+ *
+ * @return $this
*/
public function setType($type)
{
- return $this->setParam('type', $type);
+ if ($type instanceof \Elastica\Type) {
+ $type = $type->getName();
+ }
+
+ return $this->setParam('type', (string) $type);
}
/**
- * Sets the scope
+ * Set minimum number of children are required to match for the parent doc to be considered a match.
+ *
+ * @param int $count
+ *
+ * @return $this
+ */
+ public function setMinimumChildrenCount($count)
+ {
+ return $this->setParam('min_children', (int) $count);
+ }
+
+ /**
+ * Set maximum number of children are required to match for the parent doc to be considered a match.
+ *
+ * @param int $count
*
- * @param string $scope Scope
- * @return \Elastica\Filter\HasChild Current object
+ * @return $this
*/
- public function setScope($scope)
+ public function setMaximumChildrenCount($count)
{
- return $this->setParam('_scope', $scope);
+ return $this->setParam('max_children', (int) $count);
}
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/HasParent.php b/vendor/ruflin/elastica/lib/Elastica/Filter/HasParent.php
index de49e470..73a2dc5a 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/HasParent.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/HasParent.php
@@ -1,21 +1,18 @@
<?php
-
namespace Elastica\Filter;
/**
- * Returns child documents having parent docs matching the query
+ * Returns child documents having parent docs matching the query.
*
- * @category Xodoa
- * @package Elastica
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/has-parent-filter.html
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-has-parent-filter.html
*/
class HasParent extends AbstractFilter
{
/**
- * Construct HasParent filter
+ * Construct HasParent filter.
*
* @param string|\Elastica\Query|\Elastica\Filter\AbstractFilter $query Query string or a Query object or a filter
- * @param string $type Parent document type
+ * @param string|\Elastica\Type $type Parent document type
*/
public function __construct($query, $type)
{
@@ -28,10 +25,11 @@ class HasParent extends AbstractFilter
}
/**
- * Sets query object
+ * Sets query object.
+ *
+ * @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query
*
- * @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query
- * @return \Elastica\Filter\HasParent Current object
+ * @return $this
*/
public function setQuery($query)
{
@@ -42,36 +40,30 @@ class HasParent extends AbstractFilter
}
/**
- * Sets query object
+ * Sets filter object.
+ *
+ * @param \Elastica\Filter\AbstractFilter $filter
*
- * @param \Elastica\Filter\AbstractFilter $filter
- * @return \Elastica\Filter\HasParent Current object
+ * @return $this
*/
public function setFilter($filter)
{
- $data = $filter->toArray();
- return $this->setParam('filter', $data);
+ return $this->setParam('filter', $filter->toArray());
}
/**
- * Set type of the parent document
+ * Set type of the parent document.
*
- * @param string $type Parent document type
- * @return \Elastica\Filter\HasParent Current object
+ * @param string|\Elastica\Type $type Parent document type
+ *
+ * @return $this
*/
public function setType($type)
{
- return $this->setParam('type', $type);
- }
+ if ($type instanceof \Elastica\Type) {
+ $type = $type->getName();
+ }
- /**
- * Sets the scope
- *
- * @param string $scope Scope
- * @return \Elastica\Filter\HasParent Current object
- */
- public function setScope($scope)
- {
- return $this->setParam('_scope', $scope);
+ return $this->setParam('type', (string) $type);
}
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Ids.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Ids.php
index fd1d9770..bfb8cc48 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/Ids.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Ids.php
@@ -1,24 +1,22 @@
<?php
-
namespace Elastica\Filter;
use Elastica\Type as ElasticaType;
/**
- * Ids Filter
+ * Ids Filter.
*
- * @category Xodoa
- * @package Elastica
* @author Lee Parker, Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/ids-filter.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-ids-filter.html
*/
class Ids extends AbstractFilter
{
/**
- * Creates filter object
+ * Creates filter object.
*
* @param string|\Elastica\Type $type Type to filter on
- * @param array $ids List of ids
+ * @param array $ids List of ids
*/
public function __construct($type = null, array $ids = array())
{
@@ -27,10 +25,11 @@ class Ids extends AbstractFilter
}
/**
- * Adds one more filter to the and filter
+ * Adds one more filter to the and filter.
+ *
+ * @param string $id Adds id to filter
*
- * @param string $id Adds id to filter
- * @return \Elastica\Filter\Ids Current object
+ * @return $this
*/
public function addId($id)
{
@@ -38,10 +37,11 @@ class Ids extends AbstractFilter
}
/**
- * Adds one more type to query
+ * Adds one more type to query.
*
- * @param string|\Elastica\Type $type Type name or object
- * @return \Elastica\Filter\Ids Current object
+ * @param string|\Elastica\Type $type Type name or object
+ *
+ * @return $this
*/
public function addType($type)
{
@@ -57,10 +57,11 @@ class Ids extends AbstractFilter
}
/**
- * Set type
+ * Set type.
+ *
+ * @param string|\Elastica\Type $type Type name or object
*
- * @param string|\Elastica\Type $type Type name or object
- * @return \Elastica\Filter\Ids Current object
+ * @return $this
*/
public function setType($type)
{
@@ -76,10 +77,11 @@ class Ids extends AbstractFilter
}
/**
- * Sets the ids to filter
+ * Sets the ids to filter.
+ *
+ * @param array|string $ids List of ids
*
- * @param array|string $ids List of ids
- * @return \Elastica\Filter\Ids Current object
+ * @return $this
*/
public function setIds($ids)
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Indices.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Indices.php
index 66ca5965..ffaf5975 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/Indices.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Indices.php
@@ -1,18 +1,18 @@
<?php
-
namespace Elastica\Filter;
+use Elastica\Index as ElasticaIndex;
/**
- * Class Indices
- * @package Elastica\Filter
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/0.90/query-dsl-indices-filter.html
+ * Class Indices.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-indices-filter.html
*/
class Indices extends AbstractFilter
{
/**
- * @param AbstractFilter $filter filter which will be applied to docs in the specified indices
- * @param string[] $indices
+ * @param AbstractFilter $filter filter which will be applied to docs in the specified indices
+ * @param mixed[] $indices
*/
public function __construct(AbstractFilter $filter, array $indices)
{
@@ -20,19 +20,44 @@ class Indices extends AbstractFilter
}
/**
- * Set the names of the indices on which this filter should be applied
- * @param string[] $indices
- * @return Indices
+ * Set the indices on which this filter should be applied.
+ *
+ * @param mixed[] $indices
+ *
+ * @return $this
*/
public function setIndices(array $indices)
{
- return $this->setParam('indices', $indices);
+ $this->setParam('indices', array());
+ foreach ($indices as $index) {
+ $this->addIndex($index);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Adds one more index on which this filter should be applied.
+ *
+ * @param string|\Elastica\Index $index
+ *
+ * @return $this
+ */
+ public function addIndex($index)
+ {
+ if ($index instanceof ElasticaIndex) {
+ $index = $index->getName();
+ }
+
+ return $this->addParam('indices', (string) $index);
}
/**
- * Set the filter to be applied to docs in the specified indices
+ * Set the filter to be applied to docs in the specified indices.
+ *
* @param AbstractFilter $filter
- * @return Indices
+ *
+ * @return $this
*/
public function setFilter(AbstractFilter $filter)
{
@@ -40,12 +65,14 @@ class Indices extends AbstractFilter
}
/**
- * Set the filter to be applied to docs in indices which do not match those specified in the "indices" parameter
+ * Set the filter to be applied to docs in indices which do not match those specified in the "indices" parameter.
+ *
* @param AbstractFilter $filter
- * @return Indices
+ *
+ * @return $this
*/
public function setNoMatchFilter(AbstractFilter $filter)
{
return $this->setParam('no_match_filter', $filter->toArray());
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Limit.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Limit.php
index e02853ae..bf3f8e13 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/Limit.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Limit.php
@@ -1,22 +1,19 @@
<?php
-
namespace Elastica\Filter;
/**
- * Limit Filter
+ * Limit Filter.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/limit-filter.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-limit-filter.html
*/
class Limit extends AbstractFilter
{
/**
- * Construct limit filter
+ * Construct limit filter.
*
- * @param int $limit Limit
- * @return \Elastica\Filter\Limit
+ * @param int $limit Limit
*/
public function __construct($limit)
{
@@ -24,10 +21,11 @@ class Limit extends AbstractFilter
}
/**
- * Set the limit
+ * Set the limit.
+ *
+ * @param int $limit Limit
*
- * @param int $limit Limit
- * @return \Elastica\Filter\Limit
+ * @return $this
*/
public function setLimit($limit)
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/MatchAll.php b/vendor/ruflin/elastica/lib/Elastica/Filter/MatchAll.php
index a69b65a2..607c5fd1 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/MatchAll.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/MatchAll.php
@@ -1,19 +1,17 @@
<?php
-
namespace Elastica\Filter;
/**
- * Match all filter
+ * Match all filter.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/match-all-filter.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-all-filter.html
*/
class MatchAll extends AbstractFilter
{
/**
- * Creates match all filter
+ * Creates match all filter.
*/
public function __construct()
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Missing.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Missing.php
index df8466a8..9b157b2c 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/Missing.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Missing.php
@@ -1,19 +1,17 @@
<?php
-
namespace Elastica\Filter;
/**
- * Missing Filter
+ * Missing Filter.
*
- * @category Xodoa
- * @package Elastica
* @author Maciej Wiercinski <maciej@wiercinski.net>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/missing-filter.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-missing-filter.html
*/
class Missing extends AbstractFilter
{
/**
- * Construct missing filter
+ * Construct missing filter.
*
* @param string $field OPTIONAL
*/
@@ -25,13 +23,38 @@ class Missing extends AbstractFilter
}
/**
- * Set field
+ * Set field.
+ *
+ * @param string $field
*
- * @param string $field
- * @return \Elastica\Filter\Missing
+ * @return $this
*/
public function setField($field)
{
return $this->setParam('field', (string) $field);
}
+
+ /**
+ * Set "existence" parameter.
+ *
+ * @param bool $existence
+ *
+ * @return $this
+ */
+ public function setExistence($existence)
+ {
+ return $this->setParam('existence', (bool) $existence);
+ }
+
+ /**
+ * Set "null_value" parameter.
+ *
+ * @param bool $nullValue
+ *
+ * @return $this
+ */
+ public function setNullValue($nullValue)
+ {
+ return $this->setParam('null_value', (bool) $nullValue);
+ }
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Nested.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Nested.php
index 16293519..ad21bc7e 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/Nested.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Nested.php
@@ -1,24 +1,23 @@
<?php
-
namespace Elastica\Filter;
use Elastica\Query\AbstractQuery;
/**
- * Nested filter
+ * Nested filter.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/nested-filter.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-nested-filter.html
*/
class Nested extends AbstractFilter
{
/**
- * Adds field to mlt filter
+ * Adds field to mlt filter.
+ *
+ * @param string $path Nested object path
*
- * @param string $path Nested object path
- * @return \Elastica\Filter\Nested
+ * @return $this
*/
public function setPath($path)
{
@@ -26,10 +25,11 @@ class Nested extends AbstractFilter
}
/**
- * Sets nested query
+ * Sets nested query.
*
- * @param \Elastica\Query\AbstractQuery $query
- * @return \Elastica\Filter\Nested
+ * @param \Elastica\Query\AbstractQuery $query
+ *
+ * @return $this
*/
public function setQuery(AbstractQuery $query)
{
@@ -37,10 +37,11 @@ class Nested extends AbstractFilter
}
/**
- * Sets nested filter
+ * Sets nested filter.
+ *
+ * @param \Elastica\Filter\AbstractFilter $filter
*
- * @param \Elastica\Filter\AbstractFilter $filter
- * @return \Elastica\Filter\Nested
+ * @return $this
*/
public function setFilter(AbstractFilter $filter)
{
@@ -48,13 +49,14 @@ class Nested extends AbstractFilter
}
/**
- * Set score mode
+ * Set join option.
+ *
+ * @param bool $join
*
- * @param string $scoreMode Options: avg, total, max and none.
- * @return \Elastica\Filter\Nested
+ * @return $this
*/
- public function setScoreMode($scoreMode)
+ public function setJoin($join)
{
- return $this->setParam('score_mode', $scoreMode);
+ return $this->setParam('join', (bool) $join);
}
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/NumericRange.php b/vendor/ruflin/elastica/lib/Elastica/Filter/NumericRange.php
index 5a6e2551..08342616 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/NumericRange.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/NumericRange.php
@@ -1,14 +1,12 @@
<?php
-
namespace Elastica\Filter;
/**
- * Numeric Range Filter
+ * Numeric Range Filter.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/numeric-range-filter.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-filter.html
*/
class NumericRange extends Range
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Prefix.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Prefix.php
index 2caf13cb..e845fd73 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/Prefix.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Prefix.php
@@ -1,14 +1,12 @@
<?php
-
namespace Elastica\Filter;
/**
- * Prefix filter
+ * Prefix filter.
*
- * @category Xodoa
- * @package Elastica
* @author Jasper van Wanrooy <jasper@vanwanrooy.net>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/prefix-filter.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-prefix-filter.html
*/
class Prefix extends AbstractFilter
{
@@ -27,7 +25,7 @@ class Prefix extends AbstractFilter
protected $_prefix = '';
/**
- * Creates prefix filter
+ * Creates prefix filter.
*
* @param string $field Field name
* @param string $prefix Prefix string
@@ -41,8 +39,9 @@ class Prefix extends AbstractFilter
/**
* Sets the name of the prefix field.
*
- * @param string $field Field name
- * @return \Elastica\Filter\Prefix
+ * @param string $field Field name
+ *
+ * @return $this
*/
public function setField($field)
{
@@ -54,8 +53,9 @@ class Prefix extends AbstractFilter
/**
* Sets the prefix string.
*
- * @param string $prefix Prefix string
- * @return \Elastica\Filter\Prefix
+ * @param string $prefix Prefix string
+ *
+ * @return $this
*/
public function setPrefix($prefix)
{
@@ -65,9 +65,10 @@ class Prefix extends AbstractFilter
}
/**
- * Converts object to an array
+ * Converts object to an array.
*
* @see \Elastica\Filter\AbstractFilter::toArray()
+ *
* @return array data array
*/
public function toArray()
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Query.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Query.php
index 3f1ba2d2..acb6a124 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/Query.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Query.php
@@ -1,28 +1,27 @@
<?php
-
namespace Elastica\Filter;
use Elastica\Exception\InvalidException;
use Elastica\Query\AbstractQuery;
/**
- * Query filter
+ * Query filter.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/query-filter.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-filter.html
*/
class Query extends AbstractFilter
{
/**
- * Query
+ * Query.
+ *
* @var array
*/
protected $_query;
/**
- * Construct query filter
+ * Construct query filter.
*
* @param array|\Elastica\Query\AbstractQuery $query
*/
@@ -34,15 +33,17 @@ class Query extends AbstractFilter
}
/**
- * Set query
+ * Set query.
+ *
+ * @param array|\Elastica\Query\AbstractQuery $query
+ *
+ * @throws \Elastica\Exception\InvalidException If parameter is invalid
*
- * @param array|\Elastica\Query\AbstractQuery $query
- * @return \Elastica\Filter\Query Query object
- * @throws \Elastica\Exception\InvalidException Invalid param
+ * @return $this
*/
public function setQuery($query)
{
- if (!$query instanceof AbstractQuery && ! is_array($query)) {
+ if (!$query instanceof AbstractQuery && !is_array($query)) {
throw new InvalidException('expected an array or instance of Elastica\Query\AbstractQuery');
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Range.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Range.php
index b142e674..1e7bf132 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/Range.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Range.php
@@ -1,31 +1,29 @@
<?php
-
namespace Elastica\Filter;
/**
- * Range Filter
+ * Range Filter.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/range-filter.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-filter.html
*/
class Range extends AbstractFilter
{
/**
- * Fields
+ * Fields.
*
* @var array Fields
*/
protected $_fields = array();
/**
- * Construct range filter
+ * Construct range filter.
*
- * @param string|bool $fieldName Field name
- * @param array $args Field arguments
+ * @param string $fieldName Field name
+ * @param array $args Field arguments
*/
- public function __construct($fieldName = false, array $args = array())
+ public function __construct($fieldName = '', array $args = array())
{
if ($fieldName) {
$this->addField($fieldName, $args);
@@ -33,11 +31,12 @@ class Range extends AbstractFilter
}
/**
- * Ads a field with arguments to the range query
+ * Ads a field with arguments to the range query.
+ *
+ * @param string $fieldName Field name
+ * @param array $args Field arguments
*
- * @param string $fieldName Field name
- * @param array $args Field arguments
- * @return \Elastica\Filter\Range
+ * @return $this
*/
public function addField($fieldName, array $args)
{
@@ -47,14 +46,27 @@ class Range extends AbstractFilter
}
/**
- * Converts object to array
+ * Set execution mode.
+ *
+ * @param string $execution Options: "index" or "fielddata"
+ *
+ * @return $this
+ */
+ public function setExecution($execution)
+ {
+ return $this->setParam('execution', (string) $execution);
+ }
+
+ /**
+ * Converts object to array.
*
* @see \Elastica\Filter\AbstractFilter::toArray()
+ *
* @return array Filter array
*/
public function toArray()
{
- $this->setParams($this->_fields);
+ $this->setParams(array_merge($this->getParams(), $this->_fields));
return parent::toArray();
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Regexp.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Regexp.php
index 33c47cfd..612dc434 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/Regexp.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Regexp.php
@@ -1,14 +1,12 @@
<?php
-
namespace Elastica\Filter;
/**
- * Regexp filter
+ * Regexp filter.
*
- * @category Xodoa
- * @package Elastica
* @author Timothy Lamb <trash80@gmail.com>
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-regexp-filter.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-regexp-filter.html
*/
class Regexp extends AbstractFilter
{
@@ -27,23 +25,34 @@ class Regexp extends AbstractFilter
protected $_regexp = '';
/**
- * Create Regexp object
+ * Holds the regexp options.
+ *
+ * @var array
+ */
+ protected $_options = array();
+
+ /**
+ * Create Regexp object.
+ *
+ * @param string $field Field name
+ * @param string $regexp Regular expression
+ * @param array $options Regular expression options
*
- * @param string $field Field name
- * @param string $regexp Regular expression
* @throws \Elastica\Exception\InvalidException
*/
- public function __construct($field = '', $regexp = '')
+ public function __construct($field = '', $regexp = '', $options = array())
{
$this->setField($field);
$this->setRegexp($regexp);
+ $this->setOptions($options);
}
/**
* Sets the name of the regexp field.
*
- * @param string $field Field name
- * @return \Elastica\Filter\Regexp
+ * @param string $field Field name
+ *
+ * @return $this
*/
public function setField($field)
{
@@ -55,8 +64,9 @@ class Regexp extends AbstractFilter
/**
* Sets the regular expression query string.
*
- * @param string $regexp Regular expression
- * @return \Elastica\Filter\Regexp
+ * @param string $regexp Regular expression
+ *
+ * @return $this
*/
public function setRegexp($regexp)
{
@@ -66,14 +76,36 @@ class Regexp extends AbstractFilter
}
/**
- * Converts object to an array
+ * Sets the regular expression query options.
+ *
+ * @param array $options Regular expression options
+ *
+ * @return $this
+ */
+ public function setOptions($options)
+ {
+ $this->_options = $options;
+
+ return $this;
+ }
+
+ /**
+ * Converts object to an array.
*
* @see \Elastica\Filter\AbstractFilter::toArray()
+ *
* @return array data array
*/
public function toArray()
{
- $this->setParam($this->_field, $this->_regexp);
+ if (count($this->_options) > 0) {
+ $options = array('value' => $this->_regexp);
+ $options = array_merge($options, $this->_options);
+
+ $this->setParam($this->_field, $options);
+ } else {
+ $this->setParam($this->_field, $this->_regexp);
+ }
return parent::toArray();
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Script.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Script.php
index 9b34b1ec..2c8d34bf 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/Script.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Script.php
@@ -1,29 +1,26 @@
<?php
-
namespace Elastica\Filter;
use Elastica;
-use Elastica\Query\AbstractQuery;
/**
- * Script filter
+ * Script filter.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/script-filter.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-script-filter.html
*/
class Script extends AbstractFilter
{
/**
- * Query object
+ * Query object.
*
* @var array|\Elastica\Query\AbstractQuery
*/
protected $_query = null;
/**
- * Construct script filter
+ * Construct script filter.
*
* @param array|string|\Elastica\Script $script OPTIONAL Script
*/
@@ -35,10 +32,11 @@ class Script extends AbstractFilter
}
/**
- * Sets script object
+ * Sets script object.
+ *
+ * @param \Elastica\Script|string|array $script
*
- * @param \Elastica\Script|string|array $script
- * @return \Elastica\Filter\Script
+ * @return $this
*/
public function setScript($script)
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Term.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Term.php
index b4773030..2a387318 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/Term.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Term.php
@@ -1,19 +1,17 @@
<?php
-
namespace Elastica\Filter;
/**
- * Term query
+ * Term query.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/term-filter.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-filter.html
*/
class Term extends AbstractFilter
{
/**
- * Construct term filter
+ * Construct term filter.
*
* @param array $term Term array
*/
@@ -23,10 +21,11 @@ class Term extends AbstractFilter
}
/**
- * Sets/overwrites key and term directly
+ * Sets/overwrites key and term directly.
*
- * @param array $term Key value pair
- * @return \Elastica\Filter\Term Filter object
+ * @param array $term Key value pair
+ *
+ * @return $this
*/
public function setRawTerm(array $term)
{
@@ -34,11 +33,12 @@ class Term extends AbstractFilter
}
/**
- * Adds a term to the term query
+ * Adds a term to the term query.
+ *
+ * @param string $key Key to query
+ * @param string|array $value Values(s) for the query. Boost can be set with array
*
- * @param string $key Key to query
- * @param string|array $value Values(s) for the query. Boost can be set with array
- * @return \Elastica\Filter\Term Filter object
+ * @return $this
*/
public function setTerm($key, $value)
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Terms.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Terms.php
index 2f7c88e3..c099ab3d 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/Terms.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Terms.php
@@ -1,42 +1,40 @@
<?php
-
namespace Elastica\Filter;
use Elastica\Exception\InvalidException;
/**
- * Terms filter
+ * Terms filter.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/terms-filter.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-filter.html
*/
class Terms extends AbstractFilter
{
/**
- * Terms
+ * Terms.
*
* @var array Terms
*/
protected $_terms = array();
/**
- * Params
+ * Params.
*
* @var array Params
*/
protected $_params = array();
/**
- * Terms key
+ * Terms key.
*
* @var string Terms key
*/
protected $_key = '';
/**
- * Creates terms filter
+ * Creates terms filter.
*
* @param string $key Terms key
* @param array $terms Terms values
@@ -47,11 +45,12 @@ class Terms extends AbstractFilter
}
/**
- * Sets key and terms for the filter
+ * Sets key and terms for the filter.
*
- * @param string $key Terms key
- * @param array $terms Terms for the query.
- * @return \Elastica\Filter\Terms
+ * @param string $key Terms key
+ * @param array $terms Terms for the query.
+ *
+ * @return $this
*/
public function setTerms($key, array $terms)
{
@@ -62,13 +61,15 @@ class Terms extends AbstractFilter
}
/**
- * Set the lookup parameters for this filter
- * @param string $key terms key
- * @param string|\Elastica\Type $type document type from which to fetch the terms values
- * @param string $id id of the document from which to fetch the terms values
- * @param string $path the field from which to fetch the values for the filter
+ * Set the lookup parameters for this filter.
+ *
+ * @param string $key terms key
+ * @param string|\Elastica\Type $type document type from which to fetch the terms values
+ * @param string $id id of the document from which to fetch the terms values
+ * @param string $path the field from which to fetch the values for the filter
* @param string|array|\Elastica\Index $options An array of options or the index from which to fetch the terms values. Defaults to the current index.
- * @return \Elastica\Filter\Terms Filter object
+ *
+ * @return $this
*/
public function setLookup($key, $type, $id, $path, $options = array())
{
@@ -79,32 +80,34 @@ class Terms extends AbstractFilter
$this->_terms = array(
'type' => $type,
'id' => $id,
- 'path' => $path
+ 'path' => $path,
);
-
+
$index = $options;
- if(is_array($options)) {
- if(isset($options['index'])) {
+ if (is_array($options)) {
+ if (isset($options['index'])) {
$index = $options['index'];
unset($options['index']);
}
$this->_terms = array_merge($options, $this->_terms);
}
-
+
if (!is_null($index)) {
if ($index instanceof \Elastica\Index) {
$index = $index->getName();
}
$this->_terms['index'] = $index;
}
+
return $this;
}
/**
- * Adds an additional term to the query
+ * Adds an additional term to the query.
+ *
+ * @param string $term Filter term
*
- * @param string $term Filter term
- * @return \Elastica\Filter\Terms Filter object
+ * @return $this
*/
public function addTerm($term)
{
@@ -114,11 +117,13 @@ class Terms extends AbstractFilter
}
/**
- * Converts object to an array
+ * Converts object to an array.
*
* @see \Elastica\Filter\AbstractFilter::toArray()
+ *
* @throws \Elastica\Exception\InvalidException
- * @return array data array
+ *
+ * @return array
*/
public function toArray()
{
@@ -129,4 +134,16 @@ class Terms extends AbstractFilter
return array('terms' => $this->_params);
}
+
+ /**
+ * Set execution mode.
+ *
+ * @param string $execution Options: "bool", "and", "or", "plain" or "fielddata"
+ *
+ * @return $this
+ */
+ public function setExecution($execution)
+ {
+ return $this->setParam('execution', (string) $execution);
+ }
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Type.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Type.php
index 8fb58c7d..f9c17813 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Filter/Type.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Type.php
@@ -1,42 +1,40 @@
<?php
-
namespace Elastica\Filter;
/**
- * Type Filter
+ * Type Filter.
*
- * @category Xodoa
- * @package Elastica
* @author James Wilson <jwilson556@gmail.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/type-filter.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-type-filter.html
*/
class Type extends AbstractFilter
{
/**
- * Type name
+ * Type name.
*
* @var string
*/
protected $_type = null;
/**
- * Construct Type Filter
+ * Construct Type Filter.
*
- * @param string $typeName Type name
- * @return \Elastica\Filter\Type
+ * @param string $type Type name
*/
- public function __construct($typeName = null)
+ public function __construct($type = null)
{
- if ($typeName) {
- $this->setType($typeName);
+ if ($type) {
+ $this->setType($type);
}
}
/**
- * Ads a field with arguments to the range query
+ * Ads a field with arguments to the range query.
*
- * @param string $typeName Type name
- * @return \Elastica\Filter\Type current object
+ * @param string $typeName Type name
+ *
+ * @return $this
*/
public function setType($typeName)
{
@@ -46,15 +44,16 @@ class Type extends AbstractFilter
}
/**
- * Convert object to array
+ * Convert object to array.
*
* @see \Elastica\Filter\AbstractFilter::toArray()
+ *
* @return array Filter array
*/
public function toArray()
{
return array(
- 'type' => array('value' => $this->_type)
+ 'type' => array('value' => $this->_type),
);
}
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Index.php b/vendor/ruflin/elastica/lib/Elastica/Index.php
index 5e1e7138..3b8d431b 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Index.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Index.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica;
use Elastica\Exception\InvalidException;
@@ -9,53 +8,53 @@ use Elastica\Index\Stats as IndexStats;
use Elastica\Index\Status as IndexStatus;
/**
- * Elastica index object
+ * Elastica index object.
*
* Handles reads, deletes and configurations of an index
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
*/
class Index implements SearchableInterface
{
/**
- * Index name
+ * Index name.
*
* @var string Index name
*/
protected $_name = '';
/**
- * Client object
+ * Client object.
*
* @var \Elastica\Client Client object
*/
protected $_client = null;
/**
- * Creates a new index object
+ * Creates a new index object.
*
* All the communication to and from an index goes of this object
*
- * @param \Elastica\Client $client Client object
- * @param string $name Index name
+ * @param \Elastica\Client $client Client object
+ * @param string $name Index name
+ *
* @throws \Elastica\Exception\InvalidException
*/
public function __construct(Client $client, $name)
{
$this->_client = $client;
- if (!is_string($name)) {
- throw new InvalidException('Index name should be of type string');
+ if (!is_scalar($name)) {
+ throw new InvalidException('Index name should be a scalar type');
}
- $this->_name = $name;
+ $this->_name = (string) $name;
}
/**
- * Returns a type object for the current index with the given name
+ * Returns a type object for the current index with the given name.
+ *
+ * @param string $type Type name
*
- * @param string $type Type name
* @return \Elastica\Type Type object
*/
public function getType($type)
@@ -64,7 +63,7 @@ class Index implements SearchableInterface
}
/**
- * Returns the current status of the index
+ * Returns the current status of the index.
*
* @return \Elastica\Index\Status Index status
*/
@@ -74,7 +73,7 @@ class Index implements SearchableInterface
}
/**
- * Return Index Stats
+ * Return Index Stats.
*
* @return \Elastica\Index\Stats
*/
@@ -94,10 +93,10 @@ class Index implements SearchableInterface
$response = $this->request($path, Request::GET);
$data = $response->getData();
-
+
// Get first entry as if index is an Alias, the name of the mapping is the real name and not alias name
$mapping = array_shift($data);
-
+
if (isset($mapping['mappings'])) {
return $mapping['mappings'];
}
@@ -106,7 +105,7 @@ class Index implements SearchableInterface
}
/**
- * Returns the index settings object
+ * Returns the index settings object.
*
* @return \Elastica\Index\Settings Settings object
*/
@@ -116,11 +115,13 @@ class Index implements SearchableInterface
}
/**
- * Uses _bulk to send documents to the server
+ * Uses _bulk to send documents to the server.
+ *
+ * @param array|\Elastica\Document[] $docs Array of Elastica\Document
*
- * @param array|\Elastica\Document[] $docs Array of Elastica\Document
* @return \Elastica\Bulk\ResponseSet
- * @link http://www.elasticsearch.org/guide/reference/api/bulk.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
*/
public function updateDocuments(array $docs)
{
@@ -132,11 +133,13 @@ class Index implements SearchableInterface
}
/**
- * Uses _bulk to send documents to the server
+ * Uses _bulk to send documents to the server.
+ *
+ * @param array|\Elastica\Document[] $docs Array of Elastica\Document
*
- * @param array|\Elastica\Document[] $docs Array of Elastica\Document
* @return \Elastica\Bulk\ResponseSet
- * @link http://www.elasticsearch.org/guide/reference/api/bulk.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
*/
public function addDocuments(array $docs)
{
@@ -148,7 +151,30 @@ class Index implements SearchableInterface
}
/**
- * Deletes the index
+ * Deletes entries in the db based on a query.
+ *
+ * @param \Elastica\Query|string $query Query object
+ * @param array $options Optional params
+ *
+ * @return \Elastica\Response
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html
+ */
+ public function deleteByQuery($query, array $options = array())
+ {
+ if (is_string($query)) {
+ // query_string queries are not supported for delete by query operations
+ $options['q'] = $query;
+
+ return $this->request('_query', Request::DELETE, array(), $options);
+ }
+ $query = Query::create($query);
+
+ return $this->request('_query', Request::DELETE, array('query' => $query->getQuery()), $options);
+ }
+
+ /**
+ * Deletes the index.
*
* @return \Elastica\Response Response object
*/
@@ -160,11 +186,13 @@ class Index implements SearchableInterface
}
/**
- * Uses _bulk to delete documents from the server
+ * Uses _bulk to delete documents from the server.
+ *
+ * @param array|\Elastica\Document[] $docs Array of Elastica\Document
*
- * @param array|\Elastica\Document[] $docs Array of Elastica\Document
* @return \Elastica\Bulk\ResponseSet
- * @link http://www.elasticsearch.org/guide/reference/api/bulk.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
*/
public function deleteDocuments(array $docs)
{
@@ -176,24 +204,27 @@ class Index implements SearchableInterface
}
/**
- * Optimizes search index
+ * Optimizes search index.
*
* Detailed arguments can be found here in the link
*
- * @param array $args OPTIONAL Additional arguments
+ * @param array $args OPTIONAL Additional arguments
+ *
* @return array Server response
- * @link http://www.elasticsearch.org/guide/reference/api/admin-indices-optimize.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-optimize.html
*/
public function optimize($args = array())
{
- $this->request('_optimize', Request::POST, array(), $args);
+ return $this->request('_optimize', Request::POST, array(), $args);
}
/**
- * Refreshes the index
+ * Refreshes the index.
*
* @return \Elastica\Response Response object
- * @link http://www.elasticsearch.org/guide/reference/api/admin-indices-refresh.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-refresh.html
*/
public function refresh()
{
@@ -201,16 +232,19 @@ class Index implements SearchableInterface
}
/**
- * Creates a new index with the given arguments
+ * Creates a new index with the given arguments.
*
- * @param array $args OPTIONAL Arguments to use
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html
+ *
+ * @param array $args OPTIONAL Arguments to use
* @param bool|array $options OPTIONAL
* bool=> Deletes index first if already exists (default = false).
* array => Associative array of options (option=>value)
+ *
* @throws \Elastica\Exception\InvalidException
* @throws \Elastica\Exception\ResponseException
- * @return array Server response
- * @link http://www.elasticsearch.org/guide/reference/api/admin-indices-create-index.html
+ *
+ * @return array Server response
*/
public function create(array $args = array(), $options = null)
{
@@ -240,7 +274,7 @@ class Index implements SearchableInterface
$query = array('routing' => $value);
break;
default:
- throw new InvalidException('Invalid option ' . $key);
+ throw new InvalidException('Invalid option '.$key);
break;
}
}
@@ -251,7 +285,7 @@ class Index implements SearchableInterface
}
/**
- * Checks if the given index is already created
+ * Checks if the given index is already created.
*
* @return bool True if index exists
*/
@@ -260,12 +294,13 @@ class Index implements SearchableInterface
$response = $this->getClient()->request($this->getName(), Request::HEAD);
$info = $response->getTransferInfo();
- return (bool)($info['http_code'] == 200);
+ return (bool) ($info['http_code'] == 200);
}
/**
- * @param string $query
- * @param int|array $options
+ * @param string|array|\Elastica\Query $query
+ * @param int|array $options
+ *
* @return \Elastica\Search
*/
public function createSearch($query = '', $options = null)
@@ -278,11 +313,13 @@ class Index implements SearchableInterface
}
/**
- * Searches in this index
+ * Searches in this index.
+ *
+ * @param string|array|\Elastica\Query $query Array with all query data inside or a Elastica\Query object
+ * @param int|array $options OPTIONAL Limit or associative array of options (option=>value)
+ *
+ * @return \Elastica\ResultSet ResultSet with all results inside
*
- * @param string|array|\Elastica\Query $query Array with all query data inside or a Elastica\Query object
- * @param int|array $options OPTIONAL Limit or associative array of options (option=>value)
- * @return \Elastica\ResultSet ResultSet with all results inside
* @see \Elastica\SearchableInterface::search
*/
public function search($query = '', $options = null)
@@ -293,10 +330,12 @@ class Index implements SearchableInterface
}
/**
- * Counts results of query
+ * Counts results of query.
+ *
+ * @param string|array|\Elastica\Query $query Array with all query data inside or a Elastica\Query object
+ *
+ * @return int number of documents matching the query
*
- * @param string|array|\Elastica\Query $query Array with all query data inside or a Elastica\Query object
- * @return int number of documents matching the query
* @see \Elastica\SearchableInterface::count
*/
public function count($query = '')
@@ -307,21 +346,23 @@ class Index implements SearchableInterface
}
/**
- * Opens an index
+ * Opens an index.
*
* @return \Elastica\Response Response object
- * @link http://www.elasticsearch.org/guide/reference/api/admin-indices-open-close.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-open-close.html
*/
public function open()
{
- $this->request('_open', Request::POST);
+ return $this->request('_open', Request::POST);
}
/**
- * Closes the index
+ * Closes the index.
*
* @return \Elastica\Response Response object
- * @link http://www.elasticsearch.org/guide/reference/api/admin-indices-open-close.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-open-close.html
*/
public function close()
{
@@ -329,7 +370,7 @@ class Index implements SearchableInterface
}
/**
- * Returns the index name
+ * Returns the index name.
*
* @return string Index name
*/
@@ -339,7 +380,7 @@ class Index implements SearchableInterface
}
/**
- * Returns index client
+ * Returns index client.
*
* @return \Elastica\Client Index client object
*/
@@ -349,12 +390,14 @@ class Index implements SearchableInterface
}
/**
- * Adds an alias to the current index
+ * Adds an alias to the current index.
+ *
+ * @param string $name Alias name
+ * @param bool $replace OPTIONAL If set, an existing alias will be replaced
*
- * @param string $name Alias name
- * @param bool $replace OPTIONAL If set, an existing alias will be replaced
* @return \Elastica\Response Response
- * @link http://www.elasticsearch.org/guide/reference/api/admin-indices-aliases.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html
*/
public function addAlias($name, $replace = false)
{
@@ -375,11 +418,13 @@ class Index implements SearchableInterface
}
/**
- * Removes an alias pointing to the current index
+ * Removes an alias pointing to the current index.
+ *
+ * @param string $name Alias name
*
- * @param string $name Alias name
* @return \Elastica\Response Response
- * @link http://www.elasticsearch.org/guide/reference/api/admin-indices-aliases.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html
*/
public function removeAlias($name)
{
@@ -391,10 +436,11 @@ class Index implements SearchableInterface
}
/**
- * Clears the cache of an index
+ * Clears the cache of an index.
*
* @return \Elastica\Response Response object
- * @link http://www.elasticsearch.org/guide/reference/api/admin-indices-clearcache.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-clearcache.html
*/
public function clearCache()
{
@@ -404,24 +450,27 @@ class Index implements SearchableInterface
}
/**
- * Flushes the index to storage
+ * Flushes the index to storage.
*
* @return \Elastica\Response Response object
- * @link http://www.elasticsearch.org/guide/reference/api/admin-indices-flush.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-flush.html
*/
public function flush($refresh = false)
{
$path = '_flush';
+
return $this->request($path, Request::POST, array(), array('refresh' => $refresh));
}
/**
- * Can be used to change settings during runtime. One example is to use
- * if for bulk updating {@link http://www.elasticsearch.org/blog/2011/03/23/update-settings.html}
+ * Can be used to change settings during runtime. One example is to use it for bulk updating.
+ *
+ * @param array $data Data array
*
- * @param array $data Data array
* @return \Elastica\Response Response object
- * @link http://www.elasticsearch.org/guide/reference/api/admin-indices-update-settings.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html
*/
public function setSettings(array $data)
{
@@ -429,34 +478,38 @@ class Index implements SearchableInterface
}
/**
- * Makes calls to the elasticsearch server based on this index
+ * Makes calls to the elasticsearch server based on this index.
+ *
+ * @param string $path Path to call
+ * @param string $method Rest method to use (GET, POST, DELETE, PUT)
+ * @param array $data OPTIONAL Arguments as array
+ * @param array $query OPTIONAL Query params
*
- * @param string $path Path to call
- * @param string $method Rest method to use (GET, POST, DELETE, PUT)
- * @param array $data OPTIONAL Arguments as array
- * @param array $query OPTIONAL Query params
* @return \Elastica\Response Response object
*/
public function request($path, $method, $data = array(), array $query = array())
{
- $path = $this->getName() . '/' . $path;
+ $path = $this->getName().'/'.$path;
return $this->getClient()->request($path, $method, $data, $query);
}
/**
- * Analyzes a string
+ * Analyzes a string.
*
* Detailed arguments can be found here in the link
*
- * @param string $text String to be analyzed
- * @param array $args OPTIONAL Additional arguments
+ * @param string $text String to be analyzed
+ * @param array $args OPTIONAL Additional arguments
+ *
* @return array Server response
- * @link http://www.elasticsearch.org/guide/reference/api/admin-indices-analyze.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-analyze.html
*/
public function analyze($text, $args = array())
{
$data = $this->request('_analyze', Request::POST, $text, $args)->getData();
+
return $data['tokens'];
}
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Index/Settings.php b/vendor/ruflin/elastica/lib/Elastica/Index/Settings.php
index 2f2b90c6..f97e360a 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Index/Settings.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Index/Settings.php
@@ -1,41 +1,41 @@
<?php
-
namespace Elastica\Index;
+use Elastica\Exception\NotFoundException;
+use Elastica\Exception\ResponseException;
use Elastica\Index as BaseIndex;
use Elastica\Request;
/**
- * Elastica index settings object
+ * Elastica index settings object.
*
- * All settings listed in the update settings API (http://www.elasticsearch.org/guide/reference/api/admin-indices-update-settings.html)
- * can be changed on a running indices. To make changes like the merge policy (http://www.elasticsearch.org/guide/reference/index-modules/merge.html)
+ * All settings listed in the update settings API (http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html)
+ * can be changed on a running indices. To make changes like the merge policy (http://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-merge.html)
* the index has to be closed first and reopened after the call
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/api/admin-indices-update-settings.html
- * @link http://www.elasticsearch.org/guide/reference/index-modules/merge.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-merge.html
*/
class Settings
{
/**
- * Response
+ * Response.
*
* @var \Elastica\Response Response object
*/
protected $_response = null;
/**
- * Stats info
+ * Stats info.
*
* @var array Stats info
*/
protected $_data = array();
/**
- * Index
+ * Index.
*
* @var \Elastica\Index Index object
*/
@@ -44,7 +44,7 @@ class Settings
const DEFAULT_REFRESH_INTERVAL = '1s';
/**
- * Construct
+ * Construct.
*
* @param \Elastica\Index $index Index object
*/
@@ -54,53 +54,64 @@ class Settings
}
/**
- * Returns the current settings of the index
+ * Returns the current settings of the index.
*
* If param is set, only specified setting is return.
* 'index.' is added in front of $setting.
*
- * @param string $setting OPTIONAL Setting name to return
+ * @param string $setting OPTIONAL Setting name to return
+ *
* @return array|string|null Settings data
- * @link http://www.elasticsearch.org/guide/reference/api/admin-indices-update-settings.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html
*/
public function get($setting = '')
{
$requestData = $this->request()->getData();
$data = reset($requestData);
+
+ if (empty($data['settings']) || empty($data['settings']['index'])) {
+ // should not append, the request should throw a ResponseException
+ throw new NotFoundException('Index '.$this->getIndex()->getName().' not found');
+ }
$settings = $data['settings']['index'];
- if (!empty($setting)) {
- if (isset($settings[$setting])) {
- return $settings[$setting];
- } else {
- if (strpos($setting, '.') !== false) {
- // translate old dot-notation settings to nested arrays
- $keys = explode('.', $setting);
- foreach ($keys as $key) {
- if (isset($settings[$key])) {
- $settings = $settings[$key];
- } else {
- return null;
- }
+ if (!$setting) {
+ // return all array
+ return $settings;
+ }
+
+ if (isset($settings[$setting])) {
+ return $settings[$setting];
+ } else {
+ if (strpos($setting, '.') !== false) {
+ // translate old dot-notation settings to nested arrays
+ $keys = explode('.', $setting);
+ foreach ($keys as $key) {
+ if (isset($settings[$key])) {
+ $settings = $settings[$key];
+ } else {
+ return;
}
- return $settings;
}
- return null;
+
+ return $settings;
}
- }
- return $settings;
+ return;
+ }
}
/**
- * Sets the number of replicas
+ * Sets the number of replicas.
+ *
+ * @param int $replicas Number of replicas
*
- * @param int $replicas Number of replicas
* @return \Elastica\Response Response object
*/
public function setNumberOfReplicas($replicas)
{
- $replicas = (int)$replicas;
+ $replicas = (int) $replicas;
$data = array('number_of_replicas' => $replicas);
@@ -108,14 +119,25 @@ class Settings
}
/**
- * Sets the index to read only
+ * Sets the index to read only.
+ *
+ * @param bool $readOnly (default = true)
*
- * @param bool $readOnly (default = true)
* @return \Elastica\Response
*/
public function setReadOnly($readOnly = true)
{
- return $this->set(array('blocks.read_only' => $readOnly));
+ return $this->set(array('blocks.write' => $readOnly));
+ }
+
+ /**
+ * getReadOnly.
+ *
+ * @return bool
+ */
+ public function getReadOnly()
+ {
+ return $this->get('blocks.write') === 'true'; // ES returns a string for this setting
}
/**
@@ -123,11 +145,12 @@ class Settings
*/
public function getBlocksRead()
{
- return (bool)$this->get('blocks.read');
+ return (bool) $this->get('blocks.read');
}
/**
- * @param bool $state OPTIONAL (default = true)
+ * @param bool $state OPTIONAL (default = true)
+ *
* @return \Elastica\Response
*/
public function setBlocksRead($state = true)
@@ -142,18 +165,19 @@ class Settings
*/
public function getBlocksWrite()
{
- return (bool)$this->get('blocks.write');
+ return (bool) $this->get('blocks.write');
}
/**
- * @param bool $state OPTIONAL (default = true)
+ * @param bool $state OPTIONAL (default = true)
+ *
* @return \Elastica\Response
*/
public function setBlocksWrite($state = true)
{
$state = $state ? 1 : 0;
- return $this->set(array('blocks.write' => (int)$state));
+ return $this->set(array('blocks.write' => $state));
}
/**
@@ -161,27 +185,41 @@ class Settings
*/
public function getBlocksMetadata()
{
- return (bool)$this->get('blocks.metadata');
+ // TODO will have to be replace by block.metadata.write once https://github.com/elasticsearch/elasticsearch/pull/9203 has been fixed
+ // the try/catch will have to be remove too
+ try {
+ return (bool) $this->get('blocks.metadata');
+ } catch (ResponseException $e) {
+ if (strpos($e->getMessage(), 'ClusterBlockException') !== false) {
+ // hacky way to test if the metadata is blocked since bug 9203 is not fixed
+ return true;
+ } else {
+ throw $e;
+ }
+ }
}
/**
- * @param bool $state OPTIONAL (default = true)
+ * @param bool $state OPTIONAL (default = true)
+ *
* @return \Elastica\Response
*/
public function setBlocksMetadata($state = true)
{
+ // TODO will have to be replace by block.metadata.write once https://github.com/elasticsearch/elasticsearch/pull/9203 has been fixed
$state = $state ? 1 : 0;
- return $this->set(array('blocks.metadata' => (int)$state));
+ return $this->set(array('blocks.metadata' => $state));
}
/**
- * Sets the index refresh interval
+ * Sets the index refresh interval.
*
* Value can be for example 3s for 3 seconds or
* 5m for 5 minutes. -1 refreshing is disabled.
*
- * @param int $interval Number of seconds
+ * @param int $interval Number of milliseconds
+ *
* @return \Elastica\Response Response object
*/
public function setRefreshInterval($interval)
@@ -190,7 +228,7 @@ class Settings
}
/**
- * Returns the refresh interval
+ * Returns the refresh interval.
*
* If no interval is set, the default interval is returned
*
@@ -208,22 +246,23 @@ class Settings
}
/**
- * Return merge policy
+ * Return merge policy.
*
* @return string Merge policy type
*/
public function getMergePolicyType()
{
-
return $this->get('merge.policy.type');
}
/**
- * Sets merge policy
+ * Sets merge policy.
+ *
+ * @param string $type Merge policy type
*
- * @param string $type Merge policy type
* @return \Elastica\Response Response object
- * @link http://www.elasticsearch.org/guide/reference/index-modules/merge.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-merge.html
*/
public function setMergePolicyType($type)
{
@@ -235,30 +274,34 @@ class Settings
}
/**
- * Sets the specific merge policies
+ * Sets the specific merge policies.
*
* To have this changes made the index has to be closed and reopened
*
- * @param string $key Merge policy key (for ex. expunge_deletes_allowed)
- * @param string $value
+ * @param string $key Merge policy key (for ex. expunge_deletes_allowed)
+ * @param string $value
+ *
* @return \Elastica\Response
- * @link http://www.elasticsearch.org/guide/reference/index-modules/merge.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-merge.html
*/
public function setMergePolicy($key, $value)
{
$this->getIndex()->close();
- $response = $this->set(array('merge.policy.' . $key => $value));
+ $response = $this->set(array('merge.policy.'.$key => $value));
$this->getIndex()->open();
return $response;
}
/**
- * Returns the specific merge policy value
+ * Returns the specific merge policy value.
+ *
+ * @param string $key Merge policy key (for ex. expunge_deletes_allowed)
*
- * @param string $key Merge policy key (for ex. expunge_deletes_allowed)
* @return string Refresh interval
- * @link http://www.elasticsearch.org/guide/reference/index-modules/merge.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-merge.html
*/
public function getMergePolicy($key)
{
@@ -266,13 +309,15 @@ class Settings
if (isset($settings['merge']['policy'][$key])) {
return $settings['merge']['policy'][$key];
}
- return null;
+
+ return;
}
/**
- * Can be used to set/update settings
+ * Can be used to set/update settings.
+ *
+ * @param array $data Arguments
*
- * @param array $data Arguments
* @return \Elastica\Response Response object
*/
public function set(array $data)
@@ -281,7 +326,7 @@ class Settings
}
/**
- * Returns the index object
+ * Returns the index object.
*
* @return \Elastica\Index Index object
*/
@@ -291,7 +336,7 @@ class Settings
}
/**
- * Updates the given settings for the index
+ * Updates the given settings for the index.
*
* With elasticsearch 0.16 the following settings are supported
* - index.term_index_interval
@@ -303,15 +348,18 @@ class Settings
* - index.merge.policy
* - index.auto_expand_replicas
*
- * @param array $data OPTIONAL Data array
- * @param string $method OPTIONAL Transfer method (default = \Elastica\Request::GET)
+ * @param array $data OPTIONAL Data array
+ * @param string $method OPTIONAL Transfer method (default = \Elastica\Request::GET)
+ *
* @return \Elastica\Response Response object
*/
public function request(array $data = array(), $method = Request::GET)
{
$path = '_settings';
- $data = array('index' => $data);
+ if (!empty($data)) {
+ $data = array('index' => $data);
+ }
return $this->getIndex()->request($path, $method, $data);
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Index/Stats.php b/vendor/ruflin/elastica/lib/Elastica/Index/Stats.php
index 9312e273..d86903dc 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Index/Stats.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Index/Stats.php
@@ -1,42 +1,41 @@
<?php
-
namespace Elastica\Index;
+
use Elastica\Index as BaseIndex;
use Elastica\Request;
/**
- * Elastica index stats object
+ * Elastica index stats object.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/api/admin-indices-stats.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-stats.html
*/
class Stats
{
/**
- * Response
+ * Response.
*
* @var \Elastica\Response Response object
*/
protected $_response = null;
/**
- * Stats info
+ * Stats info.
*
* @var array Stats info
*/
protected $_data = array();
/**
- * Index
+ * Index.
*
* @var \Elastica\Index Index object
*/
protected $_index = null;
/**
- * Construct
+ * Construct.
*
* @param \Elastica\Index $index Index object
*/
@@ -47,7 +46,7 @@ class Stats
}
/**
- * Returns the raw stats info
+ * Returns the raw stats info.
*
* @return array Stats info
*/
@@ -70,7 +69,7 @@ class Stats
if (isset($data[$arg])) {
$data = $data[$arg];
} else {
- return null;
+ return;
}
}
@@ -78,7 +77,7 @@ class Stats
}
/**
- * Returns the index object
+ * Returns the index object.
*
* @return \Elastica\Index Index object
*/
@@ -88,7 +87,7 @@ class Stats
}
/**
- * Returns response object
+ * Returns response object.
*
* @return \Elastica\Response Response object
*/
@@ -98,7 +97,7 @@ class Stats
}
/**
- * Reloads all status data of this object
+ * Reloads all status data of this object.
*/
public function refresh()
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Index/Status.php b/vendor/ruflin/elastica/lib/Elastica/Index/Status.php
index 6a343025..0b9dff48 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Index/Status.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Index/Status.php
@@ -1,43 +1,41 @@
<?php
-
namespace Elastica\Index;
-use Elastica\Cluster;
+
use Elastica\Index as BaseIndex;
use Elastica\Request;
/**
- * Elastica index status object
+ * Elastica index status object.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/api/admin-indices-status.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-status.html
*/
class Status
{
/**
- * Response
+ * Response.
*
* @var \Elastica\Response Response object
*/
protected $_response = null;
/**
- * Stats info
+ * Stats info.
*
* @var array Stats info
*/
protected $_data = array();
/**
- * Index
+ * Index.
*
* @var \Elastica\Index Index object
*/
protected $_index = null;
/**
- * Construct
+ * Construct.
*
* @param \Elastica\Index $index Index object
*/
@@ -48,7 +46,7 @@ class Status
}
/**
- * Returns all status info
+ * Returns all status info.
*
* @return array Status info
*/
@@ -72,7 +70,7 @@ class Status
if (isset($data[$arg])) {
$data = $data[$arg];
} else {
- return null;
+ return;
}
}
@@ -80,31 +78,39 @@ class Status
}
/**
- * Returns all index aliases
+ * Returns all index aliases.
*
* @return array Aliases
*/
public function getAliases()
{
$responseData = $this->getIndex()->request('_aliases', \Elastica\Request::GET)->getData();
- return array_keys($responseData[$this->getIndex()->getName()]['aliases']);
+
+ $data = $responseData[$this->getIndex()->getName()];
+ if (!empty($data['aliases'])) {
+ return array_keys($data['aliases']);
+ }
+
+ return array();
}
/**
- * Returns all index settings
+ * Returns all index settings.
*
* @return array Index settings
*/
public function getSettings()
{
$responseData = $this->getIndex()->request('_settings', \Elastica\Request::GET)->getData();
+
return $responseData[$this->getIndex()->getName()]['settings'];
}
/**
- * Checks if the index has the given alias
+ * Checks if the index has the given alias.
+ *
+ * @param string $name Alias name
*
- * @param string $name Alias name
* @return bool
*/
public function hasAlias($name)
@@ -113,7 +119,7 @@ class Status
}
/**
- * Returns the index object
+ * Returns the index object.
*
* @return \Elastica\Index Index object
*/
@@ -123,7 +129,7 @@ class Status
}
/**
- * Returns response object
+ * Returns response object.
*
* @return \Elastica\Response Response object
*/
@@ -133,7 +139,7 @@ class Status
}
/**
- * Reloads all status data of this object
+ * Reloads all status data of this object.
*/
public function refresh()
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/JSON.php b/vendor/ruflin/elastica/lib/Elastica/JSON.php
index 07869821..921bc484 100644
--- a/vendor/ruflin/elastica/lib/Elastica/JSON.php
+++ b/vendor/ruflin/elastica/lib/Elastica/JSON.php
@@ -1,23 +1,22 @@
<?php
-
namespace Elastica;
use Elastica\Exception\JSONParseException;
/**
- * Elastica JSON tools
- *
- * @package Elastica
+ * Elastica JSON tools.
*/
class JSON
{
/**
- * Parse JSON string to an array
+ * Parse JSON string to an array.
*
- * @param string $json JSON string to parse
- * @return array PHP array representation of JSON string
* @link http://php.net/manual/en/function.json-decode.php
- * @link http://www.php.net/manual/en/function.json-last-error.php
+ * @link http://php.net/manual/en/function.json-last-error.php
+ *
+ * @param string $json JSON string to parse
+ *
+ * @return array PHP array representation of JSON string
*/
public static function parse(/* inherit from json_decode */)
{
@@ -43,11 +42,13 @@ class JSON
}
/**
- * Convert input to JSON string with standard options
+ * Convert input to JSON string with standard options.
+ *
+ * @link http://php.net/manual/en/function.json-encode.php
*
* @param mixed check args for PHP function json_encode
+ *
* @return string Valid JSON representation of $input
- * @link http://php.net/manual/en/function.json-encode.php
*/
public static function stringify(/* inherit from json_encode */)
{
@@ -57,8 +58,7 @@ class JSON
// allow special options value for Elasticsearch compatibility
if (sizeof($args) > 1 && $args[1] === 'JSON_ELASTICSEARCH') {
// Use built in JSON constants if available (php >= 5.4)
- $args[1] = (defined('JSON_UNESCAPED_SLASHES') ? JSON_UNESCAPED_SLASHES : 64)
- | (defined('JSON_UNESCAPED_UNICODE') ? JSON_UNESCAPED_UNICODE : 256);
+ $args[1] = defined('JSON_UNESCAPED_UNICODE') ? JSON_UNESCAPED_UNICODE : 256;
}
// run encode and output
diff --git a/vendor/ruflin/elastica/lib/Elastica/Log.php b/vendor/ruflin/elastica/lib/Elastica/Log.php
index b246a7b1..c2f0c18a 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Log.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Log.php
@@ -1,35 +1,31 @@
<?php
-
namespace Elastica;
-use Elastica\JSON;
use Psr\Log\AbstractLogger;
/**
- * Elastica log object
+ * Elastica log object.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
*/
class Log extends AbstractLogger
{
/**
- * Log path or true if enabled
+ * Log path or true if enabled.
*
* @var string|bool
*/
protected $_log = true;
/**
- * Last logged message
+ * Last logged message.
*
* @var string Last logged message
*/
protected $_lastMessage = '';
/**
- * Inits log object
+ * Inits log object.
*
* @param string|bool String to set a specific file for logging
*/
@@ -39,11 +35,12 @@ class Log extends AbstractLogger
}
/**
- * Log a message
+ * Log a message.
*
- * @param mixed $level
+ * @param mixed $level
* @param string $message
- * @param array $context
+ * @param array $context
+ *
* @return null|void
*/
public function log($level, $message, array $context = array())
@@ -52,18 +49,18 @@ class Log extends AbstractLogger
$this->_lastMessage = JSON::stringify($context);
if (!empty($this->_log) && is_string($this->_log)) {
- error_log($this->_lastMessage . PHP_EOL, 3, $this->_log);
+ error_log($this->_lastMessage.PHP_EOL, 3, $this->_log);
} else {
error_log($this->_lastMessage);
}
-
}
/**
- * Enable/disable log or set log path
+ * Enable/disable log or set log path.
+ *
+ * @param bool|string $log Enables log or sets log path
*
- * @param bool|string $log Enables log or sets log path
- * @return \Elastica\Log
+ * @return $this
*/
public function setLog($log)
{
@@ -73,7 +70,7 @@ class Log extends AbstractLogger
}
/**
- * Return last logged message
+ * Return last logged message.
*
* @return string Last logged message
*/
diff --git a/vendor/ruflin/elastica/lib/Elastica/Multi/ResultSet.php b/vendor/ruflin/elastica/lib/Elastica/Multi/ResultSet.php
index a0df5785..4d4186af 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Multi/ResultSet.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Multi/ResultSet.php
@@ -1,44 +1,42 @@
<?php
-
namespace Elastica\Multi;
+
use Elastica\Exception\InvalidException;
use Elastica\Response;
-use Elastica\Search as BaseSearch;
use Elastica\ResultSet as BaseResultSet;
+use Elastica\Search as BaseSearch;
/**
* Elastica multi search result set
- * List of result sets for each search request
+ * List of result sets for each search request.
*
- * @category Xodoa
- * @package Elastica
* @author munkie
*/
class ResultSet implements \Iterator, \ArrayAccess, \Countable
{
/**
- * Result Sets
+ * Result Sets.
*
* @var array|\Elastica\ResultSet[] Result Sets
*/
protected $_resultSets = array();
/**
- * Current position
+ * Current position.
*
* @var int Current position
*/
protected $_position = 0;
/**
- * Response
+ * Response.
*
* @var \Elastica\Response Response object
*/
protected $_response;
/**
- * Constructs ResultSet object
+ * Constructs ResultSet object.
*
* @param \Elastica\Response $response
* @param array|\Elastica\Search[] $searches
@@ -50,8 +48,9 @@ class ResultSet implements \Iterator, \ArrayAccess, \Countable
}
/**
- * @param \Elastica\Response $response
- * @param array|\Elastica\Search[] $searches
+ * @param \Elastica\Response $response
+ * @param array|\Elastica\Search[] $searches
+ *
* @throws \Elastica\Exception\InvalidException
*/
protected function _init(Response $response, array $searches)
@@ -65,9 +64,9 @@ class ResultSet implements \Iterator, \ArrayAccess, \Countable
$currentSearch = each($searches);
if ($currentSearch === false) {
- throw new InvalidException('No result found for search #' . $key);
+ throw new InvalidException('No result found for search #'.$key);
} elseif (!$currentSearch['value'] instanceof BaseSearch) {
- throw new InvalidException('Invalid object for search #' . $key . ' provided. Should be Elastica\Search');
+ throw new InvalidException('Invalid object for search #'.$key.' provided. Should be Elastica\Search');
}
$search = $currentSearch['value'];
@@ -88,7 +87,7 @@ class ResultSet implements \Iterator, \ArrayAccess, \Countable
}
/**
- * Returns response object
+ * Returns response object.
*
* @return \Elastica\Response Response object
*/
@@ -98,7 +97,7 @@ class ResultSet implements \Iterator, \ArrayAccess, \Countable
}
/**
- * There is at least one result set with error
+ * There is at least one result set with error.
*
* @return bool
*/
@@ -126,7 +125,6 @@ class ResultSet implements \Iterator, \ArrayAccess, \Countable
}
/**
- * @return void
*/
public function next()
{
@@ -150,7 +148,6 @@ class ResultSet implements \Iterator, \ArrayAccess, \Countable
}
/**
- * @return void
*/
public function rewind()
{
@@ -166,8 +163,9 @@ class ResultSet implements \Iterator, \ArrayAccess, \Countable
}
/**
- * @param string|int $offset
- * @return boolean true on success or false on failure.
+ * @param string|int $offset
+ *
+ * @return bool true on success or false on failure.
*/
public function offsetExists($offset)
{
@@ -176,6 +174,7 @@ class ResultSet implements \Iterator, \ArrayAccess, \Countable
/**
* @param mixed $offset
+ *
* @return mixed Can return all value types.
*/
public function offsetGet($offset)
@@ -186,7 +185,6 @@ class ResultSet implements \Iterator, \ArrayAccess, \Countable
/**
* @param mixed $offset
* @param mixed $value
- * @return void
*/
public function offsetSet($offset, $value)
{
@@ -199,7 +197,6 @@ class ResultSet implements \Iterator, \ArrayAccess, \Countable
/**
* @param mixed $offset
- * @return void
*/
public function offsetUnset($offset)
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Multi/Search.php b/vendor/ruflin/elastica/lib/Elastica/Multi/Search.php
index a9874eb2..294fc0a7 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Multi/Search.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Multi/Search.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Multi;
use Elastica\Client;
@@ -8,12 +7,11 @@ use Elastica\Request;
use Elastica\Search as BaseSearch;
/**
- * Elastica multi search
+ * Elastica multi search.
*
- * @category Xodoa
- * @package Elastica
* @author munkie
- * @link http://www.elasticsearch.org/guide/reference/api/multi-search.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html
*/
class Search
{
@@ -33,7 +31,7 @@ class Search
protected $_client;
/**
- * Constructs search object
+ * Constructs search object.
*
* @param \Elastica\Client $client Client object
*/
@@ -51,8 +49,9 @@ class Search
}
/**
- * @param \Elastica\Client $client
- * @return \Elastica\Multi\Search
+ * @param \Elastica\Client $client
+ *
+ * @return $this
*/
public function setClient(Client $client)
{
@@ -62,7 +61,7 @@ class Search
}
/**
- * @return \Elastica\Multi\Search
+ * @return $this
*/
public function clearSearches()
{
@@ -71,25 +70,27 @@ class Search
return $this;
}
- /**
- * @param \Elastica\Search $search
- * @param string $key Optional key
- * @return \Elastica\Multi\Search
- */
+ /**
+ * @param \Elastica\Search $search
+ * @param string $key Optional key
+ *
+ * @return $this
+ */
public function addSearch(BaseSearch $search, $key = null)
{
if ($key) {
- $this->_searches[$key] = $search;
+ $this->_searches[$key] = $search;
} else {
- $this->_searches[] = $search;
+ $this->_searches[] = $search;
}
return $this;
}
/**
- * @param array|\Elastica\Search[] $searches
- * @return \Elastica\Multi\Search
+ * @param array|\Elastica\Search[] $searches
+ *
+ * @return $this
*/
public function addSearches(array $searches)
{
@@ -101,8 +102,9 @@ class Search
}
/**
- * @param array|\Elastica\Search[] $searches
- * @return \Elastica\Multi\Search
+ * @param array|\Elastica\Search[] $searches
+ *
+ * @return $this
*/
public function setSearches(array $searches)
{
@@ -121,8 +123,9 @@ class Search
}
/**
- * @param string $searchType
- * @return \Elastica\Multi\Search
+ * @param string $searchType
+ *
+ * @return $this
*/
public function setSearchType($searchType)
{
@@ -155,30 +158,32 @@ class Search
{
$data = '';
foreach ($this->getSearches() as $search) {
- $data.= $this->_getSearchData($search);
+ $data .= $this->_getSearchData($search);
}
return $data;
}
/**
- * @param \Elastica\Search $search
+ * @param \Elastica\Search $search
+ *
* @return string
*/
protected function _getSearchData(BaseSearch $search)
{
$header = $this->_getSearchDataHeader($search);
- $header = (empty($header)) ? new \stdClass : $header;
+ $header = (empty($header)) ? new \stdClass() : $header;
$query = $search->getQuery();
- $data = JSON::stringify($header) . "\n";
- $data.= JSON::stringify($query->toArray()) . "\n";
+ $data = JSON::stringify($header)."\n";
+ $data .= JSON::stringify($query->toArray())."\n";
return $data;
}
/**
- * @param \Elastica\Search $search
+ * @param \Elastica\Search $search
+ *
* @return array
*/
protected function _getSearchDataHeader(BaseSearch $search)
diff --git a/vendor/ruflin/elastica/lib/Elastica/Node.php b/vendor/ruflin/elastica/lib/Elastica/Node.php
index a9684ca6..1453418d 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Node.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Node.php
@@ -1,72 +1,97 @@
<?php
-
namespace Elastica;
+
use Elastica\Node\Info;
use Elastica\Node\Stats;
/**
- * Elastica cluster node object
+ * Elastica cluster node object.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/api/admin-indices-status.html
*/
class Node
{
/**
- * Client
+ * Client.
*
* @var \Elastica\Client
*/
protected $_client = null;
/**
- * Node name
+ * @var string Unique node id
+ */
+ protected $_id = '';
+
+ /**
+ * Node name.
*
* @var string Node name
*/
protected $_name = '';
/**
- * Node stats
+ * Node stats.
*
* @var \Elastica\Node\Stats Node Stats
*/
protected $_stats = null;
/**
- * Node info
+ * Node info.
*
* @var \Elastica\Node\Info Node info
*/
protected $_info = null;
/**
- * Create a new node object
+ * Create a new node object.
*
- * @param string $name Node name
+ * @param string $id Node id or name
* @param \Elastica\Client $client Node object
*/
- public function __construct($name, Client $client)
+ public function __construct($id, Client $client)
{
- $this->_name = $name;
$this->_client = $client;
- $this->refresh();
+ $this->setId($id);
+ }
+
+ /**
+ * @return string Unique node id. Can also be name if id not exists.
+ */
+ public function getId()
+ {
+ return $this->_id;
}
/**
- * Get the name of the node
+ * @param string $id Node id
+ *
+ * @return $this Refreshed object
+ */
+ public function setId($id)
+ {
+ $this->_id = $id;
+
+ return $this->refresh();
+ }
+
+ /**
+ * Get the name of the node.
*
* @return string Node name
*/
public function getName()
{
+ if (empty($this->_name)) {
+ $this->_name = $this->getInfo()->getName();
+ }
+
return $this->_name;
}
/**
- * Returns the current client object
+ * Returns the current client object.
*
* @return \Elastica\Client Client
*/
@@ -76,7 +101,9 @@ class Node
}
/**
- * Return stats object of the current node
+ * Return stats object of the current node.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-stats.html
*
* @return \Elastica\Node\Stats Node stats
*/
@@ -90,7 +117,9 @@ class Node
}
/**
- * Return info object of the current node
+ * Return info object of the current node.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-info.html
*
* @return \Elastica\Node\Info Node info object
*/
@@ -104,7 +133,7 @@ class Node
}
/**
- * Refreshes all node information
+ * Refreshes all node information.
*
* This should be called after updating a node to refresh all information
*/
@@ -115,15 +144,17 @@ class Node
}
/**
- * Shuts this node down
+ * Shuts this node down.
+ *
+ * @param string $delay OPTIONAL Delay after which node is shut down (default = 1s)
*
- * @param string $delay OPTIONAL Delay after which node is shut down (default = 1s)
* @return \Elastica\Response
- * @link http://www.elasticsearch.org/guide/reference/api/admin-cluster-nodes-shutdown.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-shutdown.html
*/
public function shutdown($delay = '1s')
{
- $path = '_cluster/nodes/' . $this->getName() . '/_shutdown?delay=' . $delay;
+ $path = '_cluster/nodes/'.$this->getId().'/_shutdown?delay='.$delay;
return $this->_client->request($path, Request::POST);
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Node/Info.php b/vendor/ruflin/elastica/lib/Elastica/Node/Info.php
index 1d04e53d..25734641 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Node/Info.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Node/Info.php
@@ -1,53 +1,51 @@
<?php
-
namespace Elastica\Node;
use Elastica\Node as BaseNode;
use Elastica\Request;
/**
- * Elastica cluster node object
+ * Elastica cluster node object.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/api/admin-indices-status.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-status.html
*/
class Info
{
/**
- * Response
+ * Response.
*
* @var \Elastica\Response Response object
*/
protected $_response = null;
/**
- * Stats data
+ * Stats data.
*
* @var array stats data
*/
protected $_data = array();
/**
- * Node
+ * Node.
*
* @var \Elastica\Node Node object
*/
protected $_node = null;
/**
- * Query parameters
+ * Query parameters.
*
* @var array
*/
protected $_params = array();
/**
- * Create new info object for node
+ * Create new info object for node.
*
* @param \Elastica\Node $node Node object
- * @param array $params List of params to return. Can be: settings, os, process, jvm, thread_pool, network, transport, http
+ * @param array $params List of params to return. Can be: settings, os, process, jvm, thread_pool, network, transport, http
*/
public function __construct(BaseNode $node, array $params = array())
{
@@ -73,7 +71,7 @@ class Info
if (isset($data[$arg])) {
$data = $data[$arg];
} else {
- return null;
+ return;
}
}
@@ -81,7 +79,7 @@ class Info
}
/**
- * Return port of the node
+ * Return port of the node.
*
* @return string Returns Node port
*/
@@ -96,7 +94,7 @@ class Info
}
/**
- * Return IP of the node
+ * Return IP of the node.
*
* @return string Returns Node ip address
*/
@@ -111,37 +109,43 @@ class Info
}
/**
- * Return data regarding plugins installed on this node
+ * Return data regarding plugins installed on this node.
+ *
* @return array plugin data
- * @link http://www.elasticsearch.org/guide/reference/api/admin-cluster-nodes-info/
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-info.html
*/
public function getPlugins()
{
- if(!in_array('plugins', $this->_params)) {
+ if (!in_array('plugins', $this->_params)) {
//Plugin data was not retrieved when refresh() was called last. Get it now.
$this->_params[] = 'plugins';
$this->refresh($this->_params);
}
+
return $this->get('plugins');
}
/**
- * Check if the given plugin is installed on this node
+ * Check if the given plugin is installed on this node.
+ *
* @param string $name plugin name
+ *
* @return bool true if the plugin is installed, false otherwise
*/
public function hasPlugin($name)
{
- foreach($this->getPlugins() as $plugin) {
- if($plugin['name'] == $name) {
+ foreach ($this->getPlugins() as $plugin) {
+ if ($plugin['name'] == $name) {
return true;
}
}
+
return false;
}
/**
- * Return all info data
+ * Return all info data.
*
* @return array Data array
*/
@@ -151,7 +155,7 @@ class Info
}
/**
- * Return node object
+ * Return node object.
*
* @return \Elastica\Node Node object
*/
@@ -161,7 +165,23 @@ class Info
}
/**
- * Returns response object
+ * @return string Unique node id
+ */
+ public function getId()
+ {
+ return $this->_id;
+ }
+
+ /**
+ * @return string Node name
+ */
+ public function getName()
+ {
+ return $this->_data['name'];
+ }
+
+ /**
+ * Returns response object.
*
* @return \Elastica\Response Response object
*/
@@ -171,26 +191,30 @@ class Info
}
/**
- * Reloads all nodes information. Has to be called if informations changed
+ * Reloads all nodes information. Has to be called if informations changed.
+ *
+ * @param array $params Params to return (default none). Possible options: settings, os, process, jvm, thread_pool, network, transport, http, plugin
*
- * @param array $params Params to return (default none). Possible options: settings, os, process, jvm, thread_pool, network, transport, http, plugin
* @return \Elastica\Response Response object
*/
public function refresh(array $params = array())
{
$this->_params = $params;
- $path = '_nodes/' . $this->getNode()->getName();
+ $path = '_nodes/'.$this->getNode()->getId();
if (!empty($params)) {
$path .= '?';
foreach ($params as $param) {
- $path .= $param . '=true&';
+ $path .= $param.'=true&';
}
}
$this->_response = $this->getNode()->getClient()->request($path, Request::GET);
$data = $this->getResponse()->getData();
+
$this->_data = reset($data['nodes']);
+ $this->_id = key($data['nodes']);
+ $this->getNode()->setId($this->getId());
}
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Node/Stats.php b/vendor/ruflin/elastica/lib/Elastica/Node/Stats.php
index d918e686..1af94b07 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Node/Stats.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Node/Stats.php
@@ -1,43 +1,41 @@
<?php
-
namespace Elastica\Node;
use Elastica\Node as BaseNode;
use Elastica\Request;
/**
- * Elastica cluster node object
+ * Elastica cluster node object.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/api/admin-indices-status.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-status.html
*/
class Stats
{
/**
- * Response
+ * Response.
*
* @var \Elastica\Response Response object
*/
protected $_response = null;
/**
- * Stats data
+ * Stats data.
*
* @var array stats data
*/
protected $_data = array();
/**
- * Node
+ * Node.
*
* @var \Elastica\Node Node object
*/
protected $_node = null;
/**
- * Create new stats for node
+ * Create new stats for node.
*
* @param \Elastica\Node $node Elastica node object
*/
@@ -48,7 +46,7 @@ class Stats
}
/**
- * Returns all node stats as array based on the arguments
+ * Returns all node stats as array based on the arguments.
*
* Several arguments can be use
* get('index', 'test', 'example')
@@ -63,7 +61,7 @@ class Stats
if (isset($data[$arg])) {
$data = $data[$arg];
} else {
- return null;
+ return;
}
}
@@ -71,7 +69,7 @@ class Stats
}
/**
- * Returns all stats data
+ * Returns all stats data.
*
* @return array Data array
*/
@@ -81,7 +79,7 @@ class Stats
}
/**
- * Returns node object
+ * Returns node object.
*
* @return \Elastica\Node Node object
*/
@@ -91,7 +89,7 @@ class Stats
}
/**
- * Returns response object
+ * Returns response object.
*
* @return \Elastica\Response Response object
*/
@@ -101,13 +99,13 @@ class Stats
}
/**
- * Reloads all nodes information. Has to be called if informations changed
+ * Reloads all nodes information. Has to be called if informations changed.
*
* @return \Elastica\Response Response object
*/
public function refresh()
{
- $path = '_nodes/' . $this->getNode()->getName() . '/stats';
+ $path = '_nodes/'.$this->getNode()->getName().'/stats';
$this->_response = $this->getNode()->getClient()->request($path, Request::GET);
$data = $this->getResponse()->getData();
$this->_data = reset($data['nodes']);
diff --git a/vendor/ruflin/elastica/lib/Elastica/Param.php b/vendor/ruflin/elastica/lib/Elastica/Param.php
index 38a45d14..484fbbc3 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Param.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Param.php
@@ -1,28 +1,26 @@
<?php
-
namespace Elastica;
+
use Elastica\Exception\InvalidException;
/**
- * Class to handle params
+ * Class to handle params.
*
* This function can be used to handle params for queries, filter, facets
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
*/
class Param
{
/**
- * Params
+ * Params.
*
* @var array
*/
protected $_params = array();
/**
- * Raw Params
+ * Raw Params.
*
* @var array
*/
@@ -31,7 +29,7 @@ class Param
/**
* Converts the params to an array. A default implementation exist to create
* the an array out of the class name (last part of the class name)
- * and the params
+ * and the params.
*
* @return array Filter array
*/
@@ -49,7 +47,7 @@ class Param
/**
* Param's name
* Picks the last part of the class name and makes it snake_case
- * You can override this method if you want to change the name
+ * You can override this method if you want to change the name.
*
* @return string name
*/
@@ -59,11 +57,12 @@ class Param
}
/**
- * Sets params not inside params array
+ * Sets params not inside params array.
+ *
+ * @param string $key
+ * @param mixed $value
*
- * @param string $key
- * @param mixed $value
- * @return \Elastica\Param
+ * @return $this
*/
protected function _setRawParam($key, $value)
{
@@ -73,11 +72,12 @@ class Param
}
/**
- * Sets (overwrites) the value at the given key
+ * Sets (overwrites) the value at the given key.
*
- * @param string $key Key to set
- * @param mixed $value Key Value
- * @return \Elastica\Param
+ * @param string $key Key to set
+ * @param mixed $value Key Value
+ *
+ * @return $this
*/
public function setParam($key, $value)
{
@@ -87,10 +87,11 @@ class Param
}
/**
- * Sets (overwrites) all params of this object
+ * Sets (overwrites) all params of this object.
+ *
+ * @param array $params Parameter list
*
- * @param array $params Parameter list
- * @return \Elastica\Param
+ * @return $this
*/
public function setParams(array $params)
{
@@ -104,46 +105,50 @@ class Param
*
* This function can be used to add an array of params
*
- * @param string $key Param key
- * @param mixed $value Value to set
- * @return \Elastica\Param
+ * @param string $key Param key
+ * @param mixed $value Value to set
+ *
+ * @return $this
*/
public function addParam($key, $value)
{
- if($key != null) {
+ if ($key != null) {
if (!isset($this->_params[$key])) {
$this->_params[$key] = array();
}
$this->_params[$key][] = $value;
} else {
- $this->_params = $value;
+ $this->_params = $value;
}
return $this;
}
/**
- * Returns a specific param
+ * Returns a specific param.
+ *
+ * @param string $key Key to return
*
- * @param string $key Key to return
- * @return mixed Key value
* @throws \Elastica\Exception\InvalidException If requested key is not set
+ *
+ * @return mixed Key value
*/
public function getParam($key)
{
if (!$this->hasParam($key)) {
- throw new InvalidException('Param ' . $key . ' does not exist');
+ throw new InvalidException('Param '.$key.' does not exist');
}
return $this->_params[$key];
}
/**
- * Test if a param is set
+ * Test if a param is set.
+ *
+ * @param string $key Key to test
*
- * @param string $key Key to test
- * @return boolean True if the param is set, false otherwise
+ * @return bool True if the param is set, false otherwise
*/
public function hasParam($key)
{
@@ -151,7 +156,7 @@ class Param
}
/**
- * Returns the params array
+ * Returns the params array.
*
* @return array Params
*/
diff --git a/vendor/ruflin/elastica/lib/Elastica/Percolator.php b/vendor/ruflin/elastica/lib/Elastica/Percolator.php
index 2ec312b9..98d0490a 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Percolator.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Percolator.php
@@ -1,26 +1,44 @@
<?php
-
namespace Elastica;
/**
- * Percolator class
+ * Percolator class.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/api/percolate/
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-percolate.html
*/
class Percolator
{
+ const EXTRA_FILTER = 'filter';
+ const EXTRA_QUERY = 'query';
+ const EXTRA_SIZE = 'size';
+ const EXTRA_TRACK_SCORES = 'track_scores';
+ const EXTRA_SORT = 'sort';
+ const EXTRA_FACETS = 'facets';
+ const EXTRA_AGGS = 'aggs';
+ const EXTRA_HIGHLIGHT = 'highlight';
+
+ private $_extraRequestBodyOptions = array(
+ self::EXTRA_FILTER,
+ self::EXTRA_QUERY,
+ self::EXTRA_SIZE,
+ self::EXTRA_TRACK_SCORES,
+ self::EXTRA_SORT,
+ self::EXTRA_FACETS,
+ self::EXTRA_AGGS,
+ self::EXTRA_HIGHLIGHT,
+ );
+
/**
- * Index object
+ * Index object.
*
* @var \Elastica\Index
*/
protected $_index = null;
/**
- * Construct new percolator
+ * Construct new percolator.
*
* @param \Elastica\Index $index
*/
@@ -32,15 +50,16 @@ class Percolator
/**
* Registers a percolator query, with optional extra fields to include in the registered query.
*
- * @param string $name Query name
- * @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query Query to add
- * @param array $fields Extra fields to include in the registered query
- * and can be used to filter executed queries.
+ * @param string $name Query name
+ * @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query Query to add
+ * @param array $fields Extra fields to include in the registered query
+ * and can be used to filter executed queries.
+ *
* @return \Elastica\Response
*/
public function registerQuery($name, $query, $fields = array())
{
- $path = $this->_index->getName() . '/.percolator/' . $name;
+ $path = $this->_index->getName().'/.percolator/'.$name;
$query = Query::create($query);
$data = array_merge($query->toArray(), $fields);
@@ -49,58 +68,100 @@ class Percolator
}
/**
- * Removes a percolator query
- * @param string $name query name
+ * Removes a percolator query.
+ *
+ * @param string $name query name
+ *
* @return \Elastica\Response
*/
public function unregisterQuery($name)
{
- $path = $this->_index->getName() . '/.percolator/' . $name;
+ $path = $this->_index->getName().'/.percolator/'.$name;
return $this->_index->getClient()->request($path, Request::DELETE);
}
/**
- * Match a document to percolator queries
+ * Match a document to percolator queries.
*
- * @param \Elastica\Document $doc
- * @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query Query to filter the percolator queries which
+ * @param \Elastica\Document $doc
+ * @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query Query to filter the percolator queries which
* are executed.
- * @param string $type
- * @param array $params
+ * @param string $type
+ * @param array $params Supports setting additional request body options to the percolate request.
+ * [ Percolator::EXTRA_FILTER,
+ * Percolator::EXTRA_QUERY,
+ * Percolator::EXTRA_SIZE,
+ * Percolator::EXTRA_TRACK_SCORES,
+ * Percolator::EXTRA_SORT,
+ * Percolator::EXTRA_FACETS,
+ * Percolator::EXTRA_AGGS,
+ * Percolator::EXTRA_HIGHLIGHT ]
+ *
* @return array With matching registered queries.
*/
public function matchDoc(Document $doc, $query = null, $type = 'type', $params = array())
{
- $path = $this->_index->getName() . '/' . $type . '/_percolate';
+ $path = $this->_index->getName().'/'.$type.'/_percolate';
$data = array('doc' => $doc->getData());
+ $this->_applyAdditionalRequestBodyOptions($params, $data);
+
return $this->_percolate($path, $query, $data, $params);
}
/**
- * Percolating an existing document
+ * Percolating an existing document.
*
- * @param string $id
- * @param string $type
- * @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query Query to filter the percolator queries which
+ * @param string $id
+ * @param string $type
+ * @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query Query to filter the percolator queries which
* are executed.
- * @param array $params
+ * @param array $params Supports setting additional request body options to the percolate request.
+ * [ Percolator::EXTRA_FILTER,
+ * Percolator::EXTRA_QUERY,
+ * Percolator::EXTRA_SIZE,
+ * Percolator::EXTRA_TRACK_SCORES,
+ * Percolator::EXTRA_SORT,
+ * Percolator::EXTRA_FACETS,
+ * Percolator::EXTRA_AGGS,
+ * Percolator::EXTRA_HIGHLIGHT ]
+ *
* @return array With matching registered queries.
*/
public function matchExistingDoc($id, $type, $query = null, $params = array())
{
$id = urlencode($id);
- $path = $this->_index->getName() . '/' . $type . '/'. $id . '/_percolate';
+ $path = $this->_index->getName().'/'.$type.'/'.$id.'/_percolate';
+
+ $data = array();
+ $this->_applyAdditionalRequestBodyOptions($params, $data);
- return $this->_percolate($path, $query, array(), $params);
+ return $this->_percolate($path, $query, $data, $params);
+ }
+
+ /**
+ * Process the provided parameters and apply them to the data array.
+ *
+ * @param &$params
+ * @param &$data
+ */
+ protected function _applyAdditionalRequestBodyOptions(&$params, &$data)
+ {
+ foreach ($params as $key => $value) {
+ if (in_array($key, $this->_extraRequestBodyOptions)) {
+ $data[$key] = $params[$key];
+ unset($params[$key]);
+ }
+ }
}
/**
- * @param string $path
- * @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query] $query [description]
- * @param array $data
- * @param array $params
+ * @param string $path
+ * @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query] $query [description]
+ * @param array $data
+ * @param array $params
+ *
* @return array
*/
protected function _percolate($path, $query, $data = array(), $params = array())
@@ -117,11 +178,12 @@ class Percolator
if (isset($data['matches'])) {
return $data['matches'];
}
+
return array();
}
/**
- * Return index object
+ * Return index object.
*
* @return \Elastica\Index
*/
diff --git a/vendor/ruflin/elastica/lib/Elastica/Query.php b/vendor/ruflin/elastica/lib/Elastica/Query.php
index 2f37f2ea..175c8c95 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Query.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Query.php
@@ -1,6 +1,6 @@
<?php
-
namespace Elastica;
+
use Elastica\Aggregation\AbstractAggregation;
use Elastica\Exception\InvalidException;
use Elastica\Exception\NotImplementedException;
@@ -10,36 +10,34 @@ use Elastica\Query\AbstractQuery;
use Elastica\Query\MatchAll;
use Elastica\Query\QueryString;
use Elastica\Suggest\AbstractSuggest;
-use Elastica\Suggest;
/**
- * Elastica query object
+ * Elastica query object.
*
* Creates different types of queries
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/api/search/
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html
*/
class Query extends Param
{
/**
- * Params
+ * Params.
*
* @var array Params
*/
protected $_params = array();
-
+
/**
- * Suggest query or not
- *
- * @var int Suggest
- */
+ * Suggest query or not.
+ *
+ * @var int Suggest
+ */
protected $_suggest = 0;
/**
- * Creates a query object
+ * Creates a query object.
*
* @param array|\Elastica\Query\AbstractQuery $query OPTIONAL Query object (default = null)
*/
@@ -55,24 +53,26 @@ class Query extends Param
}
/**
- * Transforms a string or an array to a query object
+ * Transforms a string or an array to a query object.
*
* If query is empty,
*
- * @param mixed $query
+ * @param mixed $query
+ *
* @throws \Elastica\Exception\NotImplementedException
- * @return \Elastica\Query
+ *
+ * @return self
*/
public static function create($query)
{
switch (true) {
- case $query instanceof Query:
+ case $query instanceof self:
return $query;
case $query instanceof AbstractQuery:
return new self($query);
case $query instanceof AbstractFilter:
$newQuery = new self();
- $newQuery->setFilter($query);
+ $newQuery->setPostFilter($query);
return $newQuery;
case empty($query):
@@ -94,10 +94,11 @@ class Query extends Param
}
/**
- * Sets query as raw array. Will overwrite all already set arguments
+ * Sets query as raw array. Will overwrite all already set arguments.
*
- * @param array $query Query array
- * @return \Elastica\Query Query object
+ * @param array $query Query array
+ *
+ * @return $this
*/
public function setRawQuery(array $query)
{
@@ -107,10 +108,11 @@ class Query extends Param
}
/**
- * Sets the query
+ * Sets the query.
+ *
+ * @param \Elastica\Query\AbstractQuery $query Query object
*
- * @param \Elastica\Query\AbstractQuery $query Query object
- * @return \Elastica\Query Query object
+ * @return $this
*/
public function setQuery(AbstractQuery $query)
{
@@ -118,7 +120,7 @@ class Query extends Param
}
/**
- * Gets the query array
+ * Gets the query array.
*
* @return array
**/
@@ -128,21 +130,28 @@ class Query extends Param
}
/**
- * Set Filter
+ * Set Filter.
+ *
+ * @param \Elastica\Filter\AbstractFilter $filter Filter object
+ *
+ * @return $this
*
- * @param \Elastica\Filter\AbstractFilter $filter Filter object
- * @return \Elastica\Query Current object
+ * @link https://github.com/elasticsearch/elasticsearch/issues/7422
+ * @deprecated
*/
public function setFilter(AbstractFilter $filter)
{
- return $this->setParam('filter', $filter->toArray());
+ trigger_error('Deprecated: Elastica\Query::setFilter() is deprecated. Use Elastica\Query::setPostFilter() instead.', E_USER_DEPRECATED);
+
+ return $this->setPostFilter($filter);
}
/**
- * Sets the start from which the search results should be returned
+ * Sets the start from which the search results should be returned.
+ *
+ * @param int $from
*
- * @param int $from
- * @return \Elastica\Query Query object
+ * @return $this
*/
public function setFrom($from)
{
@@ -151,11 +160,13 @@ class Query extends Param
/**
* Sets sort arguments for the query
- * Replaces existing values
+ * Replaces existing values.
+ *
+ * @param array $sortArgs Sorting arguments
*
- * @param array $sortArgs Sorting arguments
- * @return \Elastica\Query Query object
- * @link http://www.elasticsearch.org/guide/reference/api/search/sort.html
+ * @return $this
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-sort.html
*/
public function setSort(array $sortArgs)
{
@@ -163,11 +174,13 @@ class Query extends Param
}
/**
- * Adds a sort param to the query
+ * Adds a sort param to the query.
+ *
+ * @param mixed $sort Sort parameter
*
- * @param mixed $sort Sort parameter
- * @return \Elastica\Query Query object
- * @link http://www.elasticsearch.org/guide/reference/api/search/sort.html
+ * @return $this
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-sort.html
*/
public function addSort($sort)
{
@@ -175,11 +188,13 @@ class Query extends Param
}
/**
- * Sets highlight arguments for the query
+ * Sets highlight arguments for the query.
+ *
+ * @param array $highlightArgs Set all highlight arguments
*
- * @param array $highlightArgs Set all highlight arguments
- * @return \Elastica\Query Query object
- * @link http://www.elasticsearch.org/guide/reference/api/search/highlighting.html
+ * @return $this
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-highlighting.html
*/
public function setHighlight(array $highlightArgs)
{
@@ -187,11 +202,13 @@ class Query extends Param
}
/**
- * Adds a highlight argument
+ * Adds a highlight argument.
+ *
+ * @param mixed $highlight Add highlight argument
*
- * @param mixed $highlight Add highlight argument
- * @return \Elastica\Query Query object
- * @link http://www.elasticsearch.org/guide/reference/api/search/highlighting.html
+ * @return $this
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-highlighting.html
*/
public function addHighlight($highlight)
{
@@ -199,23 +216,25 @@ class Query extends Param
}
/**
- * Sets maximum number of results for this query
+ * Sets maximum number of results for this query.
+ *
+ * @param int $size OPTIONAL Maximal number of results for query (default = 10)
*
- * @param int $size OPTIONAL Maximal number of results for query (default = 10)
- * @return \Elastica\Query Query object
+ * @return $this
*/
public function setSize($size = 10)
{
return $this->setParam('size', $size);
-
}
/**
- * Alias for setSize
+ * Alias for setSize.
*
* @deprecated Use the setSize() method, this method will be removed in future releases
- * @param int $limit OPTIONAL Maximal number of results for query (default = 10)
- * @return \Elastica\Query Query object
+ *
+ * @param int $limit OPTIONAL Maximal number of results for query (default = 10)
+ *
+ * @return $this
*/
public function setLimit($limit = 10)
{
@@ -223,11 +242,13 @@ class Query extends Param
}
/**
- * Enables explain on the query
+ * Enables explain on the query.
+ *
+ * @param bool $explain OPTIONAL Enabled or disable explain (default = true)
+ *
+ * @return $this
*
- * @param bool $explain OPTIONAL Enabled or disable explain (default = true)
- * @return \Elastica\Query Current object
- * @link http://www.elasticsearch.org/guide/reference/api/search/explain.html
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-explain.html
*/
public function setExplain($explain = true)
{
@@ -235,11 +256,13 @@ class Query extends Param
}
/**
- * Enables version on the query
+ * Enables version on the query.
*
- * @param bool $version OPTIONAL Enabled or disable version (default = true)
- * @return \Elastica\Query Current object
- * @link http://www.elasticsearch.org/guide/reference/api/search/version.html
+ * @param bool $version OPTIONAL Enabled or disable version (default = true)
+ *
+ * @return $this
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-version.html
*/
public function setVersion($version = true)
{
@@ -248,10 +271,14 @@ class Query extends Param
/**
* Sets the fields to be returned by the search
+ * NOTICE php will encode modified(or named keys) array into object format in json format request
+ * so the fields array must a sequence(list) type of array.
+ *
+ * @param array $fields Fields to be returned
*
- * @param array $fields Fields to be returned
- * @return \Elastica\Query Current object
- * @link http://www.elasticsearch.org/guide/reference/api/search/fields.html
+ * @return $this
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-fields.html
*/
public function setFields(array $fields)
{
@@ -259,11 +286,13 @@ class Query extends Param
}
/**
- * Set script fields
+ * Set script fields.
+ *
+ * @param array|\Elastica\ScriptFields $scriptFields Script fields
*
- * @param array|\Elastica\ScriptFields $scriptFields Script fields
- * @return \Elastica\Query Current object
- * @link http://www.elasticsearch.org/guide/reference/api/search/script-fields.html
+ * @return $this
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-script-fields.html
*/
public function setScriptFields($scriptFields)
{
@@ -275,11 +304,12 @@ class Query extends Param
}
/**
- * Adds a Script to the query
+ * Adds a Script to the query.
+ *
+ * @param string $name
+ * @param \Elastica\Script $script Script object
*
- * @param string $name
- * @param \Elastica\Script $script Script object
- * @return \Elastica\Query Query object
+ * @return $this
*/
public function addScriptField($name, Script $script)
{
@@ -289,11 +319,14 @@ class Query extends Param
}
/**
- * Sets all facets for this query object. Replaces existing facets
+ * Sets all facets for this query object. Replaces existing facets.
*
- * @param array $facets List of facet objects
- * @return \Elastica\Query Query object
- * @link http://www.elasticsearch.org/guide/reference/api/search/facets/
+ * @param array $facets List of facet objects
+ *
+ * @return $this
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-facets.html
+ * @deprecated Facets are deprecated and will be removed in a future release. You are encouraged to migrate to aggregations instead.
*/
public function setFacets(array $facets)
{
@@ -306,10 +339,13 @@ class Query extends Param
}
/**
- * Adds a Facet to the query
+ * Adds a Facet to the query.
+ *
+ * @param \Elastica\Facet\AbstractFacet $facet Facet object
+ *
+ * @return $this
*
- * @param \Elastica\Facet\AbstractFacet $facet Facet object
- * @return \Elastica\Query Query object
+ * @deprecated Facets are deprecated and will be removed in a future release. You are encouraged to migrate to aggregations instead.
*/
public function addFacet(AbstractFacet $facet)
{
@@ -319,10 +355,11 @@ class Query extends Param
}
/**
- * Adds an Aggregation to the query
+ * Adds an Aggregation to the query.
*
* @param AbstractAggregation $agg
- * @return \Elastica\Query Query object
+ *
+ * @return $this
*/
public function addAggregation(AbstractAggregation $agg)
{
@@ -330,11 +367,12 @@ class Query extends Param
$this->_params['aggs'] = array();
}
$this->_params['aggs'][$agg->getName()] = $agg->toArray();
+
return $this;
}
/**
- * Converts all query params to an array
+ * Converts all query params to an array.
*
* @return array Query array
*/
@@ -356,11 +394,13 @@ class Query extends Param
}
/**
- * Allows filtering of documents based on a minimum score
+ * Allows filtering of documents based on a minimum score.
+ *
+ * @param int $minScore Minimum score to filter documents by
*
- * @param int $minScore Minimum score to filter documents by
* @throws \Elastica\Exception\InvalidException
- * @return \Elastica\Query Query object
+ *
+ * @return $this
*/
public function setMinScore($minScore)
{
@@ -372,49 +412,77 @@ class Query extends Param
}
/**
- * Add a suggest term
+ * Add a suggest term.
*
- * @param \Elastica\Suggest $suggest suggestion object
+ * @param \Elastica\Suggest $suggest suggestion object
+ *
+ * @return $this
*/
public function setSuggest(Suggest $suggest)
{
- $this->addParam(NULL, $suggest->toArray());
+ $this->setParams(array_merge(
+ $this->getParams(),
+ $suggest->toArray()
+ ));
+
$this->_suggest = 1;
+
+ return $this;
}
/**
- * Add a Rescore
+ * Add a Rescore.
+ *
+ * @param mixed $rescore suggestion object
*
- * @param \Elastica\Rescore\AbstractRescore $suggest suggestion object
+ * @return $this
*/
public function setRescore($rescore)
{
- $this->setParam('rescore', $rescore->toArray());
+ if (is_array($rescore)) {
+ $buffer = array();
+
+ foreach ($rescore as $rescoreQuery) {
+ $buffer [] = $rescoreQuery->toArray();
+ }
+ } else {
+ $buffer = $rescore->toArray();
+ }
+
+ return $this->setParam('rescore', $buffer);
}
/**
- * Sets the _source field to be returned with every hit
+ * Sets the _source field to be returned with every hit.
*
- * @param array $fields Fields to be returned
- * @return \Elastica\Query Current object
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/search-request-source-filtering.html
+ * @param array|bool $params Fields to be returned or false to disable source
+ *
+ * @return $this
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-source-filtering.html
*/
- public function setSource(array $fields)
+ public function setSource($params)
{
- return $this->setParam('_source', $fields);
+ return $this->setParam('_source', $params);
}
/**
- * Sets post_filter argument for the query. The filter is applied after the query has executed
- * @param array $post
- * @return \Elastica\Query Current object
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/_filtering_queries_and_aggregations.html#_post_filter
+ * Sets post_filter argument for the query. The filter is applied after the query has executed.
+ *
+ * @param array|\Elastica\Filter\AbstractFilter $filter
+ *
+ * @return $this
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-post-filter.html
*/
- public function setPostFilter(array $post)
+ public function setPostFilter($filter)
{
- return $this->setParam("post_filter", $post);
+ if ($filter instanceof AbstractFilter) {
+ $filter = $filter->toArray();
+ } else {
+ trigger_error('Deprecated: Elastica\Query::setPostFilter() passing filter as array is deprecated. Pass instance of AbstractFilter instead.', E_USER_DEPRECATED);
+ }
+
+ return $this->setParam('post_filter', $filter);
}
}
-
-
-
diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/AbstractQuery.php b/vendor/ruflin/elastica/lib/Elastica/Query/AbstractQuery.php
index 5b24ace4..fd1c29b0 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Query/AbstractQuery.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Query/AbstractQuery.php
@@ -1,13 +1,11 @@
<?php
-
namespace Elastica\Query;
+
use Elastica\Param;
/**
* Abstract query object. Should be extended by all query types.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
*/
abstract class AbstractQuery extends Param
diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/Bool.php b/vendor/ruflin/elastica/lib/Elastica/Query/Bool.php
index 2b2c1157..c5bccc54 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Query/Bool.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Query/Bool.php
@@ -1,92 +1,15 @@
<?php
-
namespace Elastica\Query;
-use Elastica\Exception\InvalidException;
-use Elastica\Query\AbstractQuery;
/**
- * Bool query
+ * Bool query.
+ *
+ * This class is for backward compatibility reason for all php < 7 versions. For PHP 7 and above use BoolFilter as Bool is reserved.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/bool-query.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html
*/
-class Bool extends AbstractQuery
+class Bool extends BoolQuery
{
- /**
- * Add should part to query
- *
- * @param \Elastica\Query\AbstractQuery|array $args Should query
- * @return \Elastica\Query\Bool Current object
- */
- public function addShould($args)
- {
- return $this->_addQuery('should', $args);
- }
-
- /**
- * Add must part to query
- *
- * @param \Elastica\Query\AbstractQuery|array $args Must query
- * @return \Elastica\Query\Bool Current object
- */
- public function addMust($args)
- {
- return $this->_addQuery('must', $args);
- }
-
- /**
- * Add must not part to query
- *
- * @param \Elastica\Query\AbstractQuery|array $args Must not query
- * @return \Elastica\Query\Bool Current object
- */
- public function addMustNot($args)
- {
- return $this->_addQuery('must_not', $args);
- }
-
- /**
- * Adds a query to the current object
- *
- * @param string $type Query type
- * @param \Elastica\Query\AbstractQuery|array $args Query
- * @return \Elastica\Query\Bool
- * @throws \Elastica\Exception\InvalidException If not valid query
- */
- protected function _addQuery($type, $args)
- {
- if ($args instanceof AbstractQuery) {
- $args = $args->toArray();
- }
-
- if (!is_array($args)) {
- throw new InvalidException('Invalid parameter. Has to be array or instance of Elastica\Query\AbstractQuery');
- }
-
- return $this->addParam($type, $args);
- }
-
- /**
- * Sets boost value of this query
- *
- * @param float $boost Boost value
- * @return \Elastica\Query\Bool Current object
- */
- public function setBoost($boost)
- {
- return $this->setParam('boost', $boost);
- }
-
- /**
- * Set the minimum number of of should match
- *
- * @param int $minimumNumberShouldMatch Should match minimum
- * @return \Elastica\Query\Bool Current object
- */
- public function setMinimumNumberShouldMatch($minimumNumberShouldMatch)
- {
- return $this->setParam('minimum_number_should_match', $minimumNumberShouldMatch);
- }
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/BoolQuery.php b/vendor/ruflin/elastica/lib/Elastica/Query/BoolQuery.php
new file mode 100644
index 00000000..7b8bd4da
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Query/BoolQuery.php
@@ -0,0 +1,111 @@
+<?php
+namespace Elastica\Query;
+
+use Elastica\Exception\InvalidException;
+
+/**
+ * Bool query.
+ *
+ * @author Nicolas Ruflin <spam@ruflin.com>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html
+ */
+class BoolQuery extends AbstractQuery
+{
+ /**
+ * Add should part to query.
+ *
+ * @param \Elastica\Query\AbstractQuery|array $args Should query
+ *
+ * @return $this
+ */
+ public function addShould($args)
+ {
+ return $this->_addQuery('should', $args);
+ }
+
+ /**
+ * Add must part to query.
+ *
+ * @param \Elastica\Query\AbstractQuery|array $args Must query
+ *
+ * @return $this
+ */
+ public function addMust($args)
+ {
+ return $this->_addQuery('must', $args);
+ }
+
+ /**
+ * Add must not part to query.
+ *
+ * @param \Elastica\Query\AbstractQuery|array $args Must not query
+ *
+ * @return $this
+ */
+ public function addMustNot($args)
+ {
+ return $this->_addQuery('must_not', $args);
+ }
+
+ /**
+ * Adds a query to the current object.
+ *
+ * @param string $type Query type
+ * @param \Elastica\Query\AbstractQuery|array $args Query
+ *
+ * @throws \Elastica\Exception\InvalidException If not valid query
+ *
+ * @return $this
+ */
+ protected function _addQuery($type, $args)
+ {
+ if ($args instanceof AbstractQuery) {
+ $args = $args->toArray();
+ }
+
+ if (!is_array($args)) {
+ throw new InvalidException('Invalid parameter. Has to be array or instance of Elastica\Query\AbstractQuery');
+ }
+
+ return $this->addParam($type, $args);
+ }
+
+ /**
+ * Sets boost value of this query.
+ *
+ * @param float $boost Boost value
+ *
+ * @return $this
+ */
+ public function setBoost($boost)
+ {
+ return $this->setParam('boost', $boost);
+ }
+
+ /**
+ * Set the minimum number of of should match.
+ *
+ * @param int $minimumNumberShouldMatch Should match minimum
+ *
+ * @return $this
+ */
+ public function setMinimumNumberShouldMatch($minimumNumberShouldMatch)
+ {
+ return $this->setParam('minimum_number_should_match', $minimumNumberShouldMatch);
+ }
+
+ /**
+ * Converts array to an object in case no queries are added.
+ *
+ * @return array
+ */
+ public function toArray()
+ {
+ if (empty($this->_params)) {
+ $this->_params = new \stdClass();
+ }
+
+ return parent::toArray();
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/Boosting.php b/vendor/ruflin/elastica/lib/Elastica/Query/Boosting.php
index fe429637..95dcde3d 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Query/Boosting.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Query/Boosting.php
@@ -1,21 +1,23 @@
<?php
-
namespace Elastica\Query;
/**
- * Class Boosting
- * @package Elastica\Query
+ * Class Boosting.
+ *
* @author Balazs Nadasdi <yitsushi@gmail.com>
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-boosting-query.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-boosting-query.html
*/
class Boosting extends AbstractQuery
{
const NEGATIVE_BOOST = 0.2;
/**
- * Set the positive query for this Boosting Query
+ * Set the positive query for this Boosting Query.
+ *
* @param AbstractQuery $query
- * @return \Elastica\Query\Boosting
+ *
+ * @return $this
*/
public function setPositiveQuery(AbstractQuery $query)
{
@@ -23,9 +25,11 @@ class Boosting extends AbstractQuery
}
/**
- * Set the negative query for this Boosting Query
+ * Set the negative query for this Boosting Query.
+ *
* @param AbstractQuery $query
- * @return \Elastica\Query\Boosting
+ *
+ * @return $this
*/
public function setNegativeQuery(AbstractQuery $query)
{
@@ -33,12 +37,14 @@ class Boosting extends AbstractQuery
}
/**
- * Set the negative_boost parameter for this Boosting Query
+ * Set the negative_boost parameter for this Boosting Query.
+ *
* @param Float $negativeBoost
- * @return \Elastica\Query\Boosting
+ *
+ * @return $this
*/
public function setNegativeBoost($negativeBoost)
{
- return $this->setParam('negative_boost', (float)$negativeBoost);
+ return $this->setParam('negative_boost', (float) $negativeBoost);
}
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/Builder.php b/vendor/ruflin/elastica/lib/Elastica/Query/Builder.php
index 2a5e8baa..55b6b903 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Query/Builder.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Query/Builder.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Query;
use Elastica\Exception\InvalidException;
@@ -9,10 +8,10 @@ use Elastica\JSON;
/**
* Query Builder.
*
- * @category Xodoa
- * @package Elastica
* @author Chris Gedrim <chris@gedr.im>
- * @link http://www.elasticsearch.org/
+ *
+ * @link http://www.elastic.co/
+ * @deprecated This builder is deprecated and will be removed. Use new Elastica\QueryBuilder instead.
**/
class Builder extends AbstractQuery
{
@@ -28,21 +27,21 @@ class Builder extends AbstractQuery
*
* @param string $string JSON encoded string to use as query.
*
- * @return \Elastica\Query\Builder
+ * @return self
*/
public static function factory($string = null)
{
- return new Builder($string);
+ return new self($string);
}
/**
- * Constructor
+ * Constructor.
*
* @param string $string JSON encoded string to use as query.
*/
public function __construct($string = null)
{
- if (! $string == null) {
+ if (!$string == null) {
$this->_string .= substr($string, 1, -1);
}
}
@@ -63,18 +62,21 @@ class Builder extends AbstractQuery
public function toArray()
{
try {
- return JSON::parse($this->__toString());
+ return JSON::parse($input = $this->__toString());
} catch (JSONParseException $e) {
- throw new InvalidException('The query produced is invalid');
+ throw new InvalidException(sprintf(
+ 'The produced query is not a valid json string : "%s"',
+ $input
+ ));
}
}
/**
* Allow wildcards (*, ?) as the first character in a query.
*
- * @param boolean $bool Defaults to true.
+ * @param bool $bool Defaults to true.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function allowLeadingWildcard($bool = true)
{
@@ -84,9 +86,9 @@ class Builder extends AbstractQuery
/**
* Enable best effort analysis of wildcard terms.
*
- * @param boolean $bool Defaults to true.
+ * @param bool $bool Defaults to true.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function analyzeWildcard($bool = true)
{
@@ -98,7 +100,7 @@ class Builder extends AbstractQuery
*
* @param string $analyzer Analyzer to use.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function analyzer($analyzer)
{
@@ -108,9 +110,9 @@ class Builder extends AbstractQuery
/**
* Autogenerate phrase queries.
*
- * @param boolean $bool Defaults to true.
+ * @param bool $bool Defaults to true.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function autoGeneratePhraseQueries($bool = true)
{
@@ -129,7 +131,7 @@ class Builder extends AbstractQuery
*
* The occurrence types are: must, should, must_not.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function bool()
{
@@ -141,7 +143,7 @@ class Builder extends AbstractQuery
*
* Alias of close() for ease of reading in source.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function boolClose()
{
@@ -153,7 +155,7 @@ class Builder extends AbstractQuery
*
* @param float $boost Defaults to 1.0.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function boost($boost = 1.0)
{
@@ -163,7 +165,7 @@ class Builder extends AbstractQuery
/**
* Close a previously opened brace.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function close()
{
@@ -180,7 +182,7 @@ class Builder extends AbstractQuery
*
* Maps to Lucene ConstantScoreQuery.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function constantScore()
{
@@ -192,7 +194,7 @@ class Builder extends AbstractQuery
*
* Alias of close() for ease of reading in source.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function constantScoreClose()
{
@@ -204,7 +206,7 @@ class Builder extends AbstractQuery
*
* @param string $field Defaults to _all.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function defaultField($field = '_all')
{
@@ -220,7 +222,7 @@ class Builder extends AbstractQuery
*
* @param string $operator Defaults to OR.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function defaultOperator($operator = 'OR')
{
@@ -235,7 +237,7 @@ class Builder extends AbstractQuery
* produced by any subquery, plus a tie breaking increment for any additional
* matching subqueries.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function disMax()
{
@@ -247,7 +249,7 @@ class Builder extends AbstractQuery
*
* Alias of close() for ease of reading in source.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function disMaxClose()
{
@@ -257,9 +259,9 @@ class Builder extends AbstractQuery
/**
* Enable position increments in result queries.
*
- * @param boolean $bool Defaults to true.
+ * @param bool $bool Defaults to true.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function enablePositionIncrements($bool = true)
{
@@ -269,9 +271,9 @@ class Builder extends AbstractQuery
/**
* Enables explanation for each hit on how its score was computed.
*
- * @param boolean $value Turn on / off explain.
+ * @param bool $value Turn on / off explain.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function explain($value = true)
{
@@ -289,7 +291,7 @@ class Builder extends AbstractQuery
* Elasticsearch supports more advanced facet implementations, such as
* statistical or date histogram facets.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function facets()
{
@@ -301,7 +303,7 @@ class Builder extends AbstractQuery
*
* Alias of close() for ease of reading in source.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function facetsClose()
{
@@ -314,12 +316,12 @@ class Builder extends AbstractQuery
* @param string $name Field to add.
* @param mixed $value Value to set.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function field($name, $value)
{
if (is_bool($value)) {
- $value = '"'. var_export($value, true) . '"';
+ $value = '"'.var_export($value, true).'"';
} elseif (is_array($value)) {
$value = '["'.implode('","', $value).'"]';
} else {
@@ -348,7 +350,7 @@ class Builder extends AbstractQuery
* ->rangeClose()
* ->queryClose();
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function fieldClose()
{
@@ -360,7 +362,7 @@ class Builder extends AbstractQuery
*
* @param string $name Field name.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function fieldOpen($name)
{
@@ -375,7 +377,7 @@ class Builder extends AbstractQuery
*
* @param array $fields Array of fields to return.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function fields(array $fields)
{
@@ -393,7 +395,7 @@ class Builder extends AbstractQuery
/**
* Open a 'filter' block.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function filter()
{
@@ -403,7 +405,7 @@ class Builder extends AbstractQuery
/**
* Close a filter block.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function filterClose()
{
@@ -413,7 +415,7 @@ class Builder extends AbstractQuery
/**
* Query.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function filteredQuery()
{
@@ -425,7 +427,7 @@ class Builder extends AbstractQuery
*
* Alias of close() for ease of reading in source.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function filteredQueryClose()
{
@@ -435,9 +437,9 @@ class Builder extends AbstractQuery
/**
* Set the from parameter (offset).
*
- * @param integer $value Result number to start from.
+ * @param int $value Result number to start from.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function from($value = 0)
{
@@ -449,7 +451,7 @@ class Builder extends AbstractQuery
*
* @param float $value Defaults to 0.5.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function fuzzyMinSim($value = 0.5)
{
@@ -459,9 +461,9 @@ class Builder extends AbstractQuery
/**
* Set the prefix length for fuzzy queries.
*
- * @param integer $value Defaults to 0.
+ * @param int $value Defaults to 0.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function fuzzyPrefixLength($value = 0)
{
@@ -475,7 +477,7 @@ class Builder extends AbstractQuery
*
* @param mixed $value Value to be gt.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function gt($value)
{
@@ -489,7 +491,7 @@ class Builder extends AbstractQuery
*
* @param mixed $value Value to be gte to.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function gte($value)
{
@@ -499,9 +501,9 @@ class Builder extends AbstractQuery
/**
* Automatically lower-case terms of wildcard, prefix, fuzzy, and range queries.
*
- * @param boolean $bool Defaults to true.
+ * @param bool $bool Defaults to true.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function lowercaseExpandedTerms($bool = true)
{
@@ -515,7 +517,7 @@ class Builder extends AbstractQuery
*
* @param mixed $value Value to be lt.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function lt($value)
{
@@ -529,7 +531,7 @@ class Builder extends AbstractQuery
*
* @param mixed $value Value to be lte to.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function lte($value)
{
@@ -545,13 +547,13 @@ class Builder extends AbstractQuery
*
* @param float $boost Boost to use.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function matchAll($boost = null)
{
$this->fieldOpen('match_all');
- if ( ! $boost == null && is_numeric($boost)) {
+ if (!$boost == null && is_numeric($boost)) {
$this->field('boost', (float) $boost);
}
@@ -561,9 +563,9 @@ class Builder extends AbstractQuery
/**
* The minimum number of should clauses to match.
*
- * @param integer $minimum Minimum number that should match.
+ * @param int $minimum Minimum number that should match.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function minimumNumberShouldMatch($minimum)
{
@@ -573,7 +575,7 @@ class Builder extends AbstractQuery
/**
* The clause (query) must appear in matching documents.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function must()
{
@@ -585,7 +587,7 @@ class Builder extends AbstractQuery
*
* Alias of close() for ease of reading in source.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function mustClose()
{
@@ -598,7 +600,7 @@ class Builder extends AbstractQuery
* Note that it is not possible to search on documents that only consists of
* a must_not clauses.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function mustNot()
{
@@ -610,7 +612,7 @@ class Builder extends AbstractQuery
*
* Alias of close() for ease of reading in source.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function mustNotClose()
{
@@ -620,7 +622,7 @@ class Builder extends AbstractQuery
/**
* Add an opening brace.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function open()
{
@@ -634,9 +636,9 @@ class Builder extends AbstractQuery
*
* If zero, then exact phrase matches are required.
*
- * @param integer $value Defaults to 0.
+ * @param int $value Defaults to 0.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function phraseSlop($value = 0)
{
@@ -646,7 +648,7 @@ class Builder extends AbstractQuery
/**
* Query.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function prefix()
{
@@ -658,7 +660,7 @@ class Builder extends AbstractQuery
*
* Alias of close() for ease of reading in source.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function prefixClose()
{
@@ -670,7 +672,7 @@ class Builder extends AbstractQuery
*
* @param array $queries Array of queries.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function queries(array $queries)
{
@@ -688,7 +690,7 @@ class Builder extends AbstractQuery
/**
* Open a query block.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function query()
{
@@ -700,7 +702,7 @@ class Builder extends AbstractQuery
*
* Alias of close() for ease of reading in source.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function queryClose()
{
@@ -712,7 +714,7 @@ class Builder extends AbstractQuery
*
* A query that uses a query parser in order to parse its content
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function queryString()
{
@@ -724,7 +726,7 @@ class Builder extends AbstractQuery
*
* Alias of close() for ease of reading in source.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function queryStringClose()
{
@@ -734,7 +736,7 @@ class Builder extends AbstractQuery
/**
* Open a range block.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function range()
{
@@ -746,7 +748,7 @@ class Builder extends AbstractQuery
*
* Alias of close() for ease of reading in source.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function rangeClose()
{
@@ -759,7 +761,7 @@ class Builder extends AbstractQuery
* A boolean query with no must clauses, one or more should clauses must
* match a document.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function should()
{
@@ -771,7 +773,7 @@ class Builder extends AbstractQuery
*
* Alias of close() for ease of reading in source.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function shouldClose()
{
@@ -781,9 +783,9 @@ class Builder extends AbstractQuery
/**
* Set the size parameter (number of records to return).
*
- * @param integer $value Number of records to return.
+ * @param int $value Number of records to return.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function size($value = 10)
{
@@ -793,7 +795,7 @@ class Builder extends AbstractQuery
/**
* Allows to add one or more sort on specific fields.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function sort()
{
@@ -805,7 +807,7 @@ class Builder extends AbstractQuery
*
* Alias of close() for ease of reading in source.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function sortClose()
{
@@ -815,10 +817,10 @@ class Builder extends AbstractQuery
/**
* Add a field to sort on.
*
- * @param string $name Field to sort.
- * @param boolean $reverse Reverse direction.
+ * @param string $name Field to sort.
+ * @param bool $reverse Reverse direction.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function sortField($name, $reverse = false)
{
@@ -831,12 +833,12 @@ class Builder extends AbstractQuery
}
/**
- * Sort on multiple fields
+ * Sort on multiple fields.
*
* @param array $fields Associative array where the keys are field names to sort on, and the
* values are the sort order: "asc" or "desc"
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function sortFields(array $fields)
{
@@ -846,7 +848,7 @@ class Builder extends AbstractQuery
$this->_string .= '{"'.$fieldName.'":"'.$order.'"},';
}
- $this->_string = rtrim($this->_string, ',') . '],';
+ $this->_string = rtrim($this->_string, ',').'],';
return $this;
}
@@ -858,7 +860,7 @@ class Builder extends AbstractQuery
*
* The term query maps to Lucene TermQuery.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function term()
{
@@ -870,7 +872,7 @@ class Builder extends AbstractQuery
*
* Alias of close() for ease of reading in source.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function termClose()
{
@@ -880,7 +882,7 @@ class Builder extends AbstractQuery
/**
* Open a 'text_phrase' block.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function textPhrase()
{
@@ -890,7 +892,7 @@ class Builder extends AbstractQuery
/**
* Close a 'text_phrase' block.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function textPhraseClose()
{
@@ -902,7 +904,7 @@ class Builder extends AbstractQuery
*
* @param float $multiplier Multiplier to use.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function tieBreakerMultiplier($multiplier)
{
@@ -912,7 +914,7 @@ class Builder extends AbstractQuery
/**
* Query.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function wildcard()
{
@@ -924,7 +926,7 @@ class Builder extends AbstractQuery
*
* Alias of close() for ease of reading in source.
*
- * @return \Elastica\Query\Builder
+ * @return $this
*/
public function wildcardClose()
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/Common.php b/vendor/ruflin/elastica/lib/Elastica/Query/Common.php
index 6e112769..9ca58d2e 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Query/Common.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Query/Common.php
@@ -1,12 +1,10 @@
<?php
-
namespace Elastica\Query;
-
/**
- * Class Common
- * @package Elastica
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/common-terms-query/
+ * Class Common.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-common-terms-query.html
*/
class Common extends AbstractQuery
{
@@ -24,9 +22,9 @@ class Common extends AbstractQuery
protected $_queryParams = array();
/**
- * @param string $field the field on which to query
- * @param string $query the query string
- * @param float $cutoffFrequency percentage in decimal form (.001 == 0.1%)
+ * @param string $field the field on which to query
+ * @param string $query the query string
+ * @param float $cutoffFrequency percentage in decimal form (.001 == 0.1%)
*/
public function __construct($field, $query, $cutoffFrequency)
{
@@ -36,20 +34,25 @@ class Common extends AbstractQuery
}
/**
- * Set the field on which to query
+ * Set the field on which to query.
+ *
* @param string $field the field on which to query
- * @return \Elastica\Query\Common
+ *
+ * @return $this
*/
public function setField($field)
{
$this->_field = $field;
+
return $this;
}
/**
- * Set the query string for this query
+ * Set the query string for this query.
+ *
* @param string $query
- * @return \Elastica\Query\Common
+ *
+ * @return $this
*/
public function setQuery($query)
{
@@ -57,19 +60,23 @@ class Common extends AbstractQuery
}
/**
- * Set the frequency below which terms will be put in the low frequency group
+ * Set the frequency below which terms will be put in the low frequency group.
+ *
* @param float $frequency percentage in decimal form (.001 == 0.1%)
- * @return \Elastica\Query\Common
+ *
+ * @return $this
*/
public function setCutoffFrequency($frequency)
{
- return $this->setQueryParam('cutoff_frequency', (float)$frequency);
+ return $this->setQueryParam('cutoff_frequency', (float) $frequency);
}
/**
- * Set the logic operator for low frequency terms
+ * Set the logic operator for low frequency terms.
+ *
* @param string $operator see OPERATOR_* class constants for options
- * @return \Elastica\Query\Common
+ *
+ * @return $this
*/
public function setLowFrequencyOperator($operator)
{
@@ -77,9 +84,11 @@ class Common extends AbstractQuery
}
/**
- * Set the logic operator for high frequency terms
+ * Set the logic operator for high frequency terms.
+ *
* @param string $operator see OPERATOR_* class constants for options
- * @return \Elastica\Query\Common
+ *
+ * @return $this
*/
public function setHighFrequencyOperator($operator)
{
@@ -87,10 +96,13 @@ class Common extends AbstractQuery
}
/**
- * Set the minimum_should_match parameter
+ * Set the minimum_should_match parameter.
+ *
* @param int|string $minimum minimum number of low frequency terms which must be present
- * @return \Elastica\Query\Common
- * @link Possible values for minimum_should_match http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-minimum-should-match.html
+ *
+ * @return $this
+ *
+ * @link Possible values for minimum_should_match http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-minimum-should-match.html
*/
public function setMinimumShouldMatch($minimum)
{
@@ -98,19 +110,23 @@ class Common extends AbstractQuery
}
/**
- * Set the boost for this query
+ * Set the boost for this query.
+ *
* @param float $boost
- * @return \Elastica\Query\Common
+ *
+ * @return $this
*/
public function setBoost($boost)
{
- return $this->setQueryParam('boost', (float)$boost);
+ return $this->setQueryParam('boost', (float) $boost);
}
/**
- * Set the analyzer for this query
+ * Set the analyzer for this query.
+ *
* @param string $analyzer
- * @return \Elastica\Query\Common
+ *
+ * @return $this
*/
public function setAnalyzer($analyzer)
{
@@ -118,24 +134,29 @@ class Common extends AbstractQuery
}
/**
- * Enable / disable computation of score factor based on the fraction of all query terms contained in the document
+ * Enable / disable computation of score factor based on the fraction of all query terms contained in the document.
+ *
* @param bool $disable disable_coord is false by default
- * @return \Elastica\Query\Common
+ *
+ * @return $this
*/
public function setDisableCoord($disable = true)
{
- return $this->setQueryParam('disable_coord', (bool)$disable);
+ return $this->setQueryParam('disable_coord', (bool) $disable);
}
/**
- * Set a parameter in the body of this query
- * @param string $key parameter key
- * @param mixed $value parameter value
- * @return \Elastica\Query\Common
+ * Set a parameter in the body of this query.
+ *
+ * @param string $key parameter key
+ * @param mixed $value parameter value
+ *
+ * @return $this
*/
public function setQueryParam($key, $value)
{
$this->_queryParams[$key] = $value;
+
return $this;
}
@@ -145,6 +166,7 @@ class Common extends AbstractQuery
public function toArray()
{
$this->setParam($this->_field, $this->_queryParams);
+
return parent::toArray();
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/ConstantScore.php b/vendor/ruflin/elastica/lib/Elastica/Query/ConstantScore.php
index 16854600..3578606d 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Query/ConstantScore.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Query/ConstantScore.php
@@ -1,20 +1,19 @@
<?php
-
namespace Elastica\Query;
+
use Elastica\Filter\AbstractFilter;
/**
- * Constant score query
+ * Constant score query.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/constant-score-query.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-constant-score-query.html
*/
class ConstantScore extends AbstractQuery
{
/**
- * Construct constant score query
+ * Construct constant score query.
*
* @param null|\Elastica\Filter\AbstractFilter|array $filter
*/
@@ -26,10 +25,11 @@ class ConstantScore extends AbstractQuery
}
/**
- * Set filter
+ * Set filter.
*
- * @param array|\Elastica\Filter\AbstractFilter $filter
- * @return \Elastica\Query\ConstantScore Query object
+ * @param array|\Elastica\Filter\AbstractFilter $filter
+ *
+ * @return $this
*/
public function setFilter($filter)
{
@@ -41,10 +41,11 @@ class ConstantScore extends AbstractQuery
}
/**
- * Set query
+ * Set query.
*
* @param array|\Elastica\Query\AbstractQuery $query
- * @return \Elastica\Query\ConstantScore Query object
+ *
+ * @return $this
*/
public function setQuery($query)
{
@@ -56,10 +57,11 @@ class ConstantScore extends AbstractQuery
}
/**
- * Set boost
+ * Set boost.
+ *
+ * @param float $boost
*
- * @param float $boost
- * @return \Elastica\Query\ConstantScore
+ * @return $this
*/
public function setBoost($boost)
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/DisMax.php b/vendor/ruflin/elastica/lib/Elastica/Query/DisMax.php
index 4b1d320d..b3c5f252 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Query/DisMax.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Query/DisMax.php
@@ -1,24 +1,25 @@
<?php
-
namespace Elastica\Query;
+
use Elastica\Exception\InvalidException;
/**
- * DisMax query
+ * DisMax query.
*
- * @category Xodoa
- * @package Elastica
* @author Hung Tran <oohnoitz@gmail.com>
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-dis-max-query.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-dis-max-query.html
*/
class DisMax extends AbstractQuery
{
/**
- * Adds a query to the current object
+ * Adds a query to the current object.
+ *
+ * @param \Elastica\Query\AbstractQuery|array $args Query
*
- * @param \Elastica\Query\AbstractQuery|array $args Query
- * @return \Elastica\Query\DisMax
* @throws \Elastica\Exception\InvalidException If not valid query
+ *
+ * @return $this
*/
public function addQuery($args)
{
@@ -34,10 +35,11 @@ class DisMax extends AbstractQuery
}
/**
- * Set boost
+ * Set boost.
+ *
+ * @param float $boost
*
- * @param float $boost
- * @return \Elastica\Query\DisMax
+ * @return $this
*/
public function setBoost($boost)
{
@@ -49,8 +51,9 @@ class DisMax extends AbstractQuery
*
* If not set, defaults to 0.0
*
- * @param float $tieBreaker
- * @return \Elastica\Query\DisMax
+ * @param float $tieBreaker
+ *
+ * @return $this
*/
public function setTieBreaker($tieBreaker = 0.0)
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/Filtered.php b/vendor/ruflin/elastica/lib/Elastica/Query/Filtered.php
index c28d4cdd..ac085037 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Query/Filtered.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Query/Filtered.php
@@ -1,36 +1,36 @@
<?php
-
namespace Elastica\Query;
-use Elastica\Filter\AbstractFilter;
use Elastica\Exception\InvalidException;
+use Elastica\Filter\AbstractFilter;
/**
- * Filtered query. Needs a query and a filter
+ * Filtered query. Needs a query and a filter.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/filtered-query.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-filtered-query.html
*/
class Filtered extends AbstractQuery
{
/**
- * Constructs a filtered query
+ * Constructs a filtered query.
*
* @param \Elastica\Query\AbstractQuery $query OPTIONAL Query object
* @param \Elastica\Filter\AbstractFilter $filter OPTIONAL Filter object
*/
- public function __construct(AbstractQuery $query = null, AbstractFilter $filter = null) {
+ public function __construct(AbstractQuery $query = null, AbstractFilter $filter = null)
+ {
$this->setQuery($query);
$this->setFilter($filter);
}
/**
- * Sets a query
+ * Sets a query.
*
- * @param \Elastica\Query\AbstractQuery $query Query object
- * @return \Elastica\Query\Filtered Current object
+ * @param \Elastica\Query\AbstractQuery $query Query object
+ *
+ * @return $this
*/
public function setQuery(AbstractQuery $query = null)
{
@@ -38,10 +38,11 @@ class Filtered extends AbstractQuery
}
/**
- * Sets the filter
+ * Sets the filter.
+ *
+ * @param \Elastica\Filter\AbstractFilter $filter Filter object
*
- * @param \Elastica\Filter\AbstractFilter $filter Filter object
- * @return \Elastica\Query\Filtered Current object
+ * @return $this
*/
public function setFilter(AbstractFilter $filter = null)
{
@@ -69,9 +70,10 @@ class Filtered extends AbstractQuery
}
/**
- * Converts query to array
+ * Converts query to array.
*
* @return array Query array
+ *
* @see \Elastica\Query\AbstractQuery::toArray()
*/
public function toArray()
@@ -89,7 +91,7 @@ class Filtered extends AbstractQuery
if (empty($filtered)) {
throw new InvalidException('A query and/or filter is required');
}
-
+
return array('filtered' => $filtered);
}
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/FunctionScore.php b/vendor/ruflin/elastica/lib/Elastica/Query/FunctionScore.php
index 8230c86e..b11454fb 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Query/FunctionScore.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Query/FunctionScore.php
@@ -1,13 +1,13 @@
<?php
-
namespace Elastica\Query;
+
use Elastica\Filter\AbstractFilter;
use Elastica\Script;
/**
- * Class FunctionScore
- * @package Elastica\Query
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/function-score-query/
+ * Class FunctionScore.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html
*/
class FunctionScore extends AbstractQuery
{
@@ -32,9 +32,11 @@ class FunctionScore extends AbstractQuery
protected $_functions = array();
/**
- * Set the child query for this function_score query
+ * Set the child query for this function_score query.
+ *
* @param AbstractQuery $query
- * @return \Elastica\Query\FunctionScore
+ *
+ * @return $this
*/
public function setQuery(AbstractQuery $query)
{
@@ -43,7 +45,8 @@ class FunctionScore extends AbstractQuery
/**
* @param AbstractFilter $filter
- * @return \Elastica\Param
+ *
+ * @return $this
*/
public function setFilter(AbstractFilter $filter)
{
@@ -51,113 +54,151 @@ class FunctionScore extends AbstractQuery
}
/**
- * Add a function to the function_score query
- * @param string $functionType valid values are DECAY_* constants and script_score
- * @param array|float $functionParams the body of the function. See documentation for proper syntax.
- * @param AbstractFilter $filter optional filter to apply to the function
- * @return \Elastica\Query\FunctionScore
+ * Add a function to the function_score query.
+ *
+ * @param string $functionType valid values are DECAY_* constants and script_score
+ * @param array|float $functionParams the body of the function. See documentation for proper syntax.
+ * @param AbstractFilter $filter optional filter to apply to the function
+ * @param float $weight function weight
+ *
+ * @return $this
*/
- public function addFunction($functionType, $functionParams, AbstractFilter $filter = NULL)
+ public function addFunction($functionType, $functionParams, AbstractFilter $filter = null, $weight = null)
{
$function = array(
- $functionType => $functionParams
+ $functionType => $functionParams,
);
if (!is_null($filter)) {
$function['filter'] = $filter->toArray();
}
+ if ($weight !== null) {
+ $function['weight'] = $weight;
+ }
+
$this->_functions[] = $function;
+
return $this;
}
/**
- * Add a script_score function to the query
- * @param Script $script a Script object
+ * Add a script_score function to the query.
+ *
+ * @param Script $script a Script object
* @param AbstractFilter $filter an optional filter to apply to the function
- * @return \Elastica\Query\FunctionScore
+ * @param float $weight the weight of the function
+ *
+ * @return $this
*/
- public function addScriptScoreFunction(Script $script, AbstractFilter $filter = NULL)
+ public function addScriptScoreFunction(Script $script, AbstractFilter $filter = null, $weight = null)
{
- return $this->addFunction('script_score', $script->toArray(), $filter);
+ return $this->addFunction('script_score', $script->toArray(), $filter, $weight);
}
/**
- * Add a decay function to the query
- * @param string $function see DECAY_* constants for valid options
- * @param string $field the document field on which to perform the decay function
- * @param string $origin the origin value for this decay function
- * @param string $scale a scale to define the rate of decay for this function
- * @param string $offset If defined, this function will only be computed for documents with a distance from the origin greater than this value
- * @param float $decay optionally defines how documents are scored at the distance given by the $scale parameter
- * @param float $scaleWeight optional factor by which to multiply the score at the value provided by the $scale parameter
- * @param AbstractFilter $filter a filter associated with this function
- * @return \Elastica\Query\FunctionScore
+ * Add a decay function to the query.
+ *
+ * @param string $function see DECAY_* constants for valid options
+ * @param string $field the document field on which to perform the decay function
+ * @param string $origin the origin value for this decay function
+ * @param string $scale a scale to define the rate of decay for this function
+ * @param string $offset If defined, this function will only be computed for documents with a distance from the origin greater than this value
+ * @param float $decay optionally defines how documents are scored at the distance given by the $scale parameter
+ * @param float $scaleWeight optional factor by which to multiply the score at the value provided by the $scale parameter
+ * @param float $weight optional factor by which to multiply the score at the value provided by the $scale parameter
+ * @param AbstractFilter $filter a filter associated with this function
+ *
+ * @return $this
*/
- public function addDecayFunction($function, $field, $origin, $scale, $offset = NULL, $decay = NULL, $scaleWeight = NULL,
- AbstractFilter $filter = NULL)
- {
+ public function addDecayFunction(
+ $function,
+ $field,
+ $origin,
+ $scale,
+ $offset = null,
+ $decay = null,
+ $weight = null,
+ AbstractFilter $filter = null
+ ) {
$functionParams = array(
$field => array(
'origin' => $origin,
- 'scale' => $scale
- )
+ 'scale' => $scale,
+ ),
);
if (!is_null($offset)) {
$functionParams[$field]['offset'] = $offset;
}
if (!is_null($decay)) {
- $functionParams[$field]['decay'] = (float)$decay;
- }
- if (!is_null($scaleWeight)) {
- $functionParams[$field]['scale_weight'] = (float)$scaleWeight;
+ $functionParams[$field]['decay'] = (float) $decay;
}
- return $this->addFunction($function, $functionParams, $filter);
+
+ return $this->addFunction($function, $functionParams, $filter, $weight);
}
/**
- * Add a boost_factor function to the query
- * @param float $boostFactor the boost factor value
+ * Add a boost_factor function to the query.
+ *
+ * @param float $boostFactor the boost factor value
+ * @param AbstractFilter $filter a filter associated with this function
+ *
+ * @deprecated
+ */
+ public function addBoostFactorFunction($boostFactor, AbstractFilter $filter = null)
+ {
+ $this->addWeightFunction($boostFactor, $filter);
+ }
+
+ /**
+ * @param float $weight the weight of the function
* @param AbstractFilter $filter a filter associated with this function
*/
- public function addBoostFactorFunction($boostFactor, AbstractFilter $filter = NULL)
+ public function addWeightFunction($weight, AbstractFilter $filter = null)
{
- $this->addFunction('boost_factor', $boostFactor, $filter);
+ $this->addFunction('weight', $weight, $filter);
}
/**
- * Add a random_score function to the query
- * @param number $seed the seed value
+ * Add a random_score function to the query.
+ *
+ * @param number $seed the seed value
* @param AbstractFilter $filter a filter associated with this function
- * @param float $boost an optional boost value associated with this function
+ * @param float $weight an optional boost value associated with this function
*/
- public function addRandomScoreFunction($seed, AbstractFilter $filter = NULL, $boost = NULL)
+ public function addRandomScoreFunction($seed, AbstractFilter $filter = null, $weight = null)
{
- $this->addFunction('random_score', array('seed' => $seed), $filter, $boost);
+ $this->addFunction('random_score', array('seed' => $seed), $filter, $weight);
}
/**
- * Set an overall boost value for this query
+ * Set an overall boost value for this query.
+ *
* @param float $boost
- * @return \Elastica\Query\FunctionScore
+ *
+ * @return $this
*/
public function setBoost($boost)
{
- return $this->setParam('boost', (float)$boost);
+ return $this->setParam('boost', (float) $boost);
}
/**
- * Restrict the combined boost of the function_score query and its child query
+ * Restrict the combined boost of the function_score query and its child query.
+ *
* @param float $maxBoost
- * @return \Elastica\Query\FunctionScore
+ *
+ * @return $this
*/
public function setMaxBoost($maxBoost)
{
- return $this->setParam('max_boost', (float)$maxBoost);
+ return $this->setParam('max_boost', (float) $maxBoost);
}
/**
- * The boost mode determines how the score of this query is combined with that of the child query
+ * The boost mode determines how the score of this query is combined with that of the child query.
+ *
* @param string $mode see BOOST_MODE_* constants for valid options. Default is multiply.
- * @return \Elastica\Query\FunctionScore
+ *
+ * @return $this
*/
public function setBoostMode($mode)
{
@@ -166,22 +207,27 @@ class FunctionScore extends AbstractQuery
/**
* If set, this query will return results in random order.
+ *
* @param int $seed Set a seed value to return results in the same random order for consistent pagination.
- * @return \Elastica\Query\FunctionScore
+ *
+ * @return $this
*/
- public function setRandomScore($seed = NULL)
+ public function setRandomScore($seed = null)
{
$seedParam = new \stdClass();
if (!is_null($seed)) {
$seedParam->seed = $seed;
}
+
return $this->setParam('random_score', $seedParam);
}
/**
- * Set the score method
+ * Set the score method.
+ *
* @param string $mode see SCORE_MODE_* constants for valid options. Default is multiply.
- * @return \Elastica\Query\FunctionScore
+ *
+ * @return $this
*/
public function setScoreMode($mode)
{
@@ -189,6 +235,18 @@ class FunctionScore extends AbstractQuery
}
/**
+ * Set min_score option.
+ *
+ * @param float $minScore
+ *
+ * @return $this
+ */
+ public function setMinScore($minScore)
+ {
+ return $this->setParam('min_score', (float) $minScore);
+ }
+
+ /**
* @return array
*/
public function toArray()
@@ -196,6 +254,7 @@ class FunctionScore extends AbstractQuery
if (sizeof($this->_functions)) {
$this->setParam('functions', $this->_functions);
}
+
return parent::toArray();
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/Fuzzy.php b/vendor/ruflin/elastica/lib/Elastica/Query/Fuzzy.php
index 73b0f1a1..a3a46693 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Query/Fuzzy.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Query/Fuzzy.php
@@ -1,27 +1,24 @@
<?php
-
namespace Elastica\Query;
use Elastica\Exception\InvalidException;
/**
- * Fuzzy query
+ * Fuzzy query.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/fuzzy-query.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-fuzzy-query.html
*/
class Fuzzy extends AbstractQuery
{
/**
- * Construct a fuzzy query
+ * Construct a fuzzy query.
*
- * @param string $fieldName Field name
- * @param string $value String to search for
- * @return \Elastica\Query\Fuzzy Current object
+ * @param string $fieldName Field name
+ * @param string $value String to search for
*/
- public function __construct ($fieldName = null, $value = null)
+ public function __construct($fieldName = null, $value = null)
{
if ($fieldName and $value) {
$this->setField($fieldName, $value);
@@ -29,13 +26,14 @@ class Fuzzy extends AbstractQuery
}
/**
- * Set field for fuzzy query
+ * Set field for fuzzy query.
*
- * @param string $fieldName Field name
- * @param string $value String to search for
- * @return \Elastica\Query\Fuzzy Current object
+ * @param string $fieldName Field name
+ * @param string $value String to search for
+ *
+ * @return $this
*/
- public function setField ($fieldName, $value)
+ public function setField($fieldName, $value)
{
if (!is_string($value) or !is_string($fieldName)) {
throw new InvalidException('The field and value arguments must be of type string.');
@@ -43,30 +41,34 @@ class Fuzzy extends AbstractQuery
if (count($this->getParams()) > 0 and array_shift(array_keys($this->getParams())) != $fieldName) {
throw new InvalidException('Fuzzy query can only support a single field.');
}
+
return $this->setParam($fieldName, array('value' => $value));
}
/**
- * Set optional parameters on the existing query
+ * Set optional parameters on the existing query.
*
- * @param string $param option name
- * @param mixed $value Value of the parameter
- * @return \Elastica\Query\Fuzzy Current object
+ * @param string $param option name
+ * @param mixed $value Value of the parameter
+ *
+ * @return $this
*/
- public function setFieldOption ($param, $value) {
+ public function setFieldOption($param, $value)
+ {
//Retrieve the single existing field for alteration.
$params = $this->getParams();
if (count($params) < 1) {
- throw new InvalidException('No field has been set');
+ throw new InvalidException('No field has been set');
}
$keyArray = array_keys($params);
$params[$keyArray[0]][$param] = $value;
- return $this->setparam($keyArray[0], $params[$keyArray[0]]);
+ return $this->setParam($keyArray[0], $params[$keyArray[0]]);
}
/**
* Deprecated method of setting a field.
+ *
* @deprecated
*/
public function addField($fieldName, $args)
@@ -79,6 +81,7 @@ class Fuzzy extends AbstractQuery
foreach ($args as $param => $value) {
$this->setFieldOption($param, $value);
}
+
return $this;
}
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/FuzzyLikeThis.php b/vendor/ruflin/elastica/lib/Elastica/Query/FuzzyLikeThis.php
index ffa34a81..2de480a8 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Query/FuzzyLikeThis.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Query/FuzzyLikeThis.php
@@ -1,79 +1,77 @@
<?php
-
namespace Elastica\Query;
/**
- * Fuzzy Like This query
+ * Fuzzy Like This query.
*
- * @category Xodoa
- * @package Elastica
* @author Raul Martinez, Jr <juneym@gmail.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/flt-query.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-flt-query.html
*/
class FuzzyLikeThis extends AbstractQuery
{
/**
- * Field names
+ * Field names.
*
* @var array Field names
*/
protected $_fields = array();
/**
- * Like text
+ * Like text.
*
* @var string Like text
*/
- protected $_likeText = '';
+ protected $_likeText = '';
/**
- * Ignore term frequency
+ * Ignore term frequency.
*
- * @var boolean ignore term frequency
+ * @var bool ignore term frequency
*/
protected $_ignoreTF = false;
/**
- * Max query terms value
+ * Max query terms value.
*
* @var int Max query terms value
*/
protected $_maxQueryTerms = 25;
/**
- * minimum similarity
+ * minimum similarity.
*
* @var int minimum similarity
*/
protected $_minSimilarity = 0.5;
/**
- * Prefix Length
+ * Prefix Length.
*
* @var int Prefix Length
*/
protected $_prefixLength = 0;
/**
- * Boost
+ * Boost.
*
* @var float Boost
*/
protected $_boost = 1.0;
/**
- * Analyzer
+ * Analyzer.
*
* @var sting Analyzer
*/
protected $_analyzer;
-
/**
- * Adds field to flt query
+ * Adds field to flt query.
+ *
+ * @param array $fields Field names
*
- * @param array $fields Field names
- * @return \Elastica\Query\FuzzyLikeThis Current object
+ * @return $this
*/
public function addFields(array $fields)
{
@@ -83,10 +81,11 @@ class FuzzyLikeThis extends AbstractQuery
}
/**
- * Set the "like_text" value
+ * Set the "like_text" value.
*
- * @param string $text
- * @return \Elastica\Query\FuzzyLikeThis This current object
+ * @param string $text
+ *
+ * @return $this
*/
public function setLikeText($text)
{
@@ -97,10 +96,11 @@ class FuzzyLikeThis extends AbstractQuery
}
/**
- * Set the "ignore_tf" value (ignore term frequency)
+ * Set the "ignore_tf" value (ignore term frequency).
+ *
+ * @param bool $ignoreTF
*
- * @param bool $ignoreTF
- * @return \Elastica\Query\FuzzyLikeThis Current object
+ * @return $this
*/
public function setIgnoreTF($ignoreTF)
{
@@ -110,10 +110,11 @@ class FuzzyLikeThis extends AbstractQuery
}
/**
- * Set the minimum similarity
+ * Set the minimum similarity.
*
- * @param int $value
- * @return \Elastica\Query\FuzzyLikeThis This current object
+ * @param int $value
+ *
+ * @return $this
*/
public function setMinSimilarity($value)
{
@@ -124,10 +125,11 @@ class FuzzyLikeThis extends AbstractQuery
}
/**
- * Set boost
+ * Set boost.
+ *
+ * @param float $value Boost value
*
- * @param float $value Boost value
- * @return \Elastica\Query\FuzzyLikeThis Query object
+ * @return $this
*/
public function setBoost($value)
{
@@ -137,10 +139,11 @@ class FuzzyLikeThis extends AbstractQuery
}
/**
- * Set Prefix Length
+ * Set Prefix Length.
*
- * @param int $value Prefix length
- * @return \Elastica\Query\FuzzyLikeThis
+ * @param int $value Prefix length
+ *
+ * @return $this
*/
public function setPrefixLength($value)
{
@@ -150,10 +153,11 @@ class FuzzyLikeThis extends AbstractQuery
}
/**
- * Set max_query_terms
+ * Set max_query_terms.
+ *
+ * @param int $value Max query terms value
*
- * @param int $value Max query terms value
- * @return \Elastica\Query\FuzzyLikeThis
+ * @return $this
*/
public function setMaxQueryTerms($value)
{
@@ -163,10 +167,11 @@ class FuzzyLikeThis extends AbstractQuery
}
/**
- * Set analyzer
+ * Set analyzer.
*
- * @param string $text Analyzer text
- * @return \Elastica\Query\FuzzyLikeThis
+ * @param string $text Analyzer text
+ *
+ * @return $this
*/
public function setAnalyzer($text)
{
@@ -177,9 +182,10 @@ class FuzzyLikeThis extends AbstractQuery
}
/**
- * Converts fuzzy like this query to array
+ * Converts fuzzy like this query to array.
*
* @return array Query array
+ *
* @see \Elastica\Query\AbstractQuery::toArray()
*/
public function toArray()
@@ -192,18 +198,14 @@ class FuzzyLikeThis extends AbstractQuery
$args['boost'] = $this->_boost;
}
- if (!empty($this->_likeText)) {
- $args['like_text'] = $this->_likeText;
- }
-
if (!empty($this->_analyzer)) {
$args['analyzer'] = $this->_analyzer;
}
-
$args['min_similarity'] = ($this->_minSimilarity > 0) ? $this->_minSimilarity : 0;
- $args['prefix_length'] = $this->_prefixLength;
+ $args['like_text'] = $this->_likeText;
+ $args['prefix_length'] = $this->_prefixLength;
$args['ignore_tf'] = $this->_ignoreTF;
$args['max_query_terms'] = $this->_maxQueryTerms;
diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/HasChild.php b/vendor/ruflin/elastica/lib/Elastica/Query/HasChild.php
index e849a9bf..190fa592 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Query/HasChild.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Query/HasChild.php
@@ -1,23 +1,22 @@
<?php
-
namespace Elastica\Query;
+
use Elastica\Query as BaseQuery;
/**
- * Returns parent documents having child docs matching the query
+ * Returns parent documents having child docs matching the query.
*
- * @category Xodoa
- * @package Elastica
* @author Fabian Vogler <fabian@equivalence.ch>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/has-child-query.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-has-child-query.html
*/
class HasChild extends AbstractQuery
{
/**
- * Construct HasChild Query
+ * Construct HasChild Query.
*
* @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query
- * @param string $type Parent document type
+ * @param string $type Parent document type
*/
public function __construct($query, $type = null)
{
@@ -26,10 +25,11 @@ class HasChild extends AbstractQuery
}
/**
- * Sets query object
+ * Sets query object.
*
- * @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query
- * @return \Elastica\Query\HasChild
+ * @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query
+ *
+ * @return $this
*/
public function setQuery($query)
{
@@ -40,10 +40,11 @@ class HasChild extends AbstractQuery
}
/**
- * Set type of the parent document
+ * Set type of the parent document.
+ *
+ * @param string $type Parent document type
*
- * @param string $type Parent document type
- * @return \Elastica\Query\HasChild Current object
+ * @return $this
*/
public function setType($type)
{
@@ -51,10 +52,11 @@ class HasChild extends AbstractQuery
}
/**
- * Sets the scope
+ * Sets the scope.
+ *
+ * @param string $scope Scope
*
- * @param string $scope Scope
- * @return \Elastica\Query\HasChild Current object
+ * @return $this
*/
public function setScope($scope)
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/HasParent.php b/vendor/ruflin/elastica/lib/Elastica/Query/HasParent.php
index 809fb18d..03aae13b 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Query/HasParent.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Query/HasParent.php
@@ -1,22 +1,20 @@
<?php
-
namespace Elastica\Query;
+
use Elastica\Query as BaseQuery;
/**
- * Returns child documents having parent docs matching the query
+ * Returns child documents having parent docs matching the query.
*
- * @category Xodoa
- * @package Elastica
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/has-parent-query.html
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-has-parent-query.html
*/
class HasParent extends AbstractQuery
{
/**
- * Construct HasChild Query
+ * Construct HasChild Query.
*
- * @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query
- * @param string $type Parent document type
+ * @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query
+ * @param string $type Parent document type
*/
public function __construct($query, $type)
{
@@ -25,10 +23,11 @@ class HasParent extends AbstractQuery
}
/**
- * Sets query object
+ * Sets query object.
+ *
+ * @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query
*
- * @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query
- * @return \Elastica\Filter\HasParent
+ * @return $this
*/
public function setQuery($query)
{
@@ -39,10 +38,11 @@ class HasParent extends AbstractQuery
}
/**
- * Set type of the parent document
+ * Set type of the parent document.
*
- * @param string $type Parent document type
- * @return \Elastica\Filter\HasParent Current object
+ * @param string $type Parent document type
+ *
+ * @return $this
*/
public function setType($type)
{
@@ -50,10 +50,11 @@ class HasParent extends AbstractQuery
}
/**
- * Sets the scope
+ * Sets the scope.
+ *
+ * @param string $scope Scope
*
- * @param string $scope Scope
- * @return \Elastica\Filter\HasParent Current object
+ * @return $this
*/
public function setScope($scope)
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/Ids.php b/vendor/ruflin/elastica/lib/Elastica/Query/Ids.php
index f4a6f1aa..5d76efcf 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Query/Ids.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Query/Ids.php
@@ -1,32 +1,31 @@
<?php
-
namespace Elastica\Query;
+
use Elastica\Type;
/**
- * Ids Query
+ * Ids Query.
*
- * @category Xodoa
- * @package Elastica
* @author Lee Parker
* @author Nicolas Ruflin <spam@ruflin.com>
* @author Tim Rupp
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/ids-query.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-ids-query.html
*/
class Ids extends AbstractQuery
{
/**
- * Params
+ * Params.
*
* @var array Params
*/
protected $_params = array();
/**
- * Creates filter object
+ * Creates filter object.
*
* @param string|\Elastica\Type $type Type to filter on
- * @param array $ids List of ids
+ * @param array $ids List of ids
*/
public function __construct($type = null, array $ids = array())
{
@@ -35,10 +34,11 @@ class Ids extends AbstractQuery
}
/**
- * Adds one more filter to the and filter
+ * Adds one more filter to the and filter.
+ *
+ * @param string $id Adds id to filter
*
- * @param string $id Adds id to filter
- * @return \Elastica\Query\Ids Current object
+ * @return $this
*/
public function addId($id)
{
@@ -48,10 +48,11 @@ class Ids extends AbstractQuery
}
/**
- * Adds one more type to query
+ * Adds one more type to query.
*
- * @param string|\Elastica\Type $type Type name or object
- * @return \Elastica\Query\Ids Current object
+ * @param string|\Elastica\Type $type Type name or object
+ *
+ * @return $this
*/
public function addType($type)
{
@@ -68,10 +69,11 @@ class Ids extends AbstractQuery
}
/**
- * Set type
+ * Set type.
+ *
+ * @param string|\Elastica\Type $type Type name or object
*
- * @param string|\Elastica\Type $type Type name or object
- * @return \Elastica\Query\Ids Current object
+ * @return $this
*/
public function setType($type)
{
@@ -88,10 +90,11 @@ class Ids extends AbstractQuery
}
/**
- * Sets the ids to filter
+ * Sets the ids to filter.
*
- * @param array|string $ids List of ids
- * @return \Elastica\Query\Ids Current object
+ * @param array|string $ids List of ids
+ *
+ * @return $this
*/
public function setIds($ids)
{
@@ -105,9 +108,10 @@ class Ids extends AbstractQuery
}
/**
- * Converts filter to array
+ * Converts filter to array.
*
* @see \Elastica\Query\AbstractQuery::toArray()
+ *
* @return array Query array
*/
public function toArray()
diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/Image.php b/vendor/ruflin/elastica/lib/Elastica/Query/Image.php
new file mode 100644
index 00000000..bf7d028b
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Query/Image.php
@@ -0,0 +1,187 @@
+<?php
+namespace Elastica\Query;
+
+/**
+ * Image query.
+ *
+ * @author Jacques Moati <jacques@moati.net>
+ *
+ * @link https://github.com/kzwang/elasticsearch-image
+ *
+ * To use this feature you have to call the following command in the
+ * elasticsearch directory:
+ * <code>
+ * ./bin/plugin --url https://github.com/SibaTokyo/elasticsearch-image/releases/download/1.4.0/elasticsearch-image-1.4.0.zip --install image
+ * </code>
+ * This installs the image plugin. More infos
+ * can be found here: {@link https://github.com/SibaTokyo/elasticsearch-image}
+ */
+class Image extends AbstractQuery
+{
+ public function __construct(array $image = array())
+ {
+ $this->setParams($image);
+ }
+
+ /**
+ * Sets a param for the given field.
+ *
+ * @param string $field
+ * @param string $key
+ * @param string $value
+ *
+ * @return $this
+ */
+ public function setFieldParam($field, $key, $value)
+ {
+ if (!isset($this->_params[$field])) {
+ $this->_params[$field] = array();
+ }
+
+ $this->_params[$field][$key] = $value;
+
+ return $this;
+ }
+
+ /**
+ * Set field boost value.
+ *
+ * If not set, defaults to 1.0.
+ *
+ * @param string $field
+ * @param float $boost
+ *
+ * @return $this
+ */
+ public function setFieldBoost($field, $boost = 1.0)
+ {
+ return $this->setFieldParam($field, 'boost', (float) $boost);
+ }
+
+ /**
+ * Set field feature value.
+ *
+ * If not set, defaults CEDD.
+ *
+ * @param string $field
+ * @param string $feature
+ *
+ * @return $this
+ */
+ public function setFieldFeature($field, $feature = 'CEDD')
+ {
+ return $this->setFieldParam($field, 'feature', $feature);
+ }
+
+ /**
+ * Set field hash value.
+ *
+ * If not set, defaults BIT_SAMPLING.
+ *
+ * @param string $field
+ * @param string $hash
+ *
+ * @return $this
+ */
+ public function setFieldHash($field, $hash = 'BIT_SAMPLING')
+ {
+ return $this->setFieldParam($field, 'hash', $hash);
+ }
+
+ /**
+ * Set field image value.
+ *
+ * @param string $field
+ * @param string $path File will be base64_encode
+ *
+ * @throws \Exception
+ *
+ * @return $this
+ */
+ public function setFieldImage($field, $path)
+ {
+ if (!file_exists($path) || !is_readable($path)) {
+ throw new \Exception(sprintf("File %s can't be open", $path));
+ }
+
+ return $this->setFieldParam($field, 'image', base64_encode(file_get_contents($path)));
+ }
+
+ /**
+ * Set field index value.
+ *
+ * @param string $field
+ * @param string $index
+ *
+ * @return $this
+ */
+ public function setFieldIndex($field, $index)
+ {
+ return $this->setFieldParam($field, 'index', $index);
+ }
+
+ /**
+ * Set field type value.
+ *
+ * @param string $field
+ * @param string $type
+ *
+ * @return $this
+ */
+ public function setFieldType($field, $type)
+ {
+ return $this->setFieldParam($field, 'type', $type);
+ }
+
+ /**
+ * Set field id value.
+ *
+ * @param string $field
+ * @param string $id
+ *
+ * @return $this
+ */
+ public function setFieldId($field, $id)
+ {
+ return $this->setFieldParam($field, 'id', $id);
+ }
+
+ /**
+ * Set field path value.
+ *
+ * @param string $field
+ * @param string $path
+ *
+ * @return $this
+ */
+ public function setFieldPath($field, $path)
+ {
+ return $this->setFieldParam($field, 'path', $path);
+ }
+
+ /**
+ * Define quickly a reference image already in your elasticsearch database.
+ *
+ * If not set, path will be the same as $field.
+ *
+ * @param string $field
+ * @param string $index
+ * @param string $type
+ * @param string $id
+ * @param string $path
+ *
+ * @return $this
+ */
+ public function setImageByReference($field, $index, $type, $id, $path = null)
+ {
+ if (null === $path) {
+ $path = $field;
+ }
+
+ $this->setFieldIndex($field, $index);
+ $this->setFieldType($field, $type);
+ $this->setFieldId($field, $id);
+
+ return $this->setFieldPath($field, $path);
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/Match.php b/vendor/ruflin/elastica/lib/Elastica/Query/Match.php
index ba66ad63..abb40970 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Query/Match.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Query/Match.php
@@ -1,27 +1,37 @@
<?php
-
namespace Elastica\Query;
/**
- * Match query
+ * Match query.
*
- * @category Xodoa
- * @package Elastica
* @author F21
* @author WONG Wing Lun <luiges90@gmail.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/match-query.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html
*/
class Match extends AbstractQuery
{
- const ZERO_TERM_NONE = 'none';
- const ZERO_TERM_ALL = 'all';
+ const ZERO_TERM_NONE = 'none';
+ const ZERO_TERM_ALL = 'all';
+
+ /**
+ * @param string $field
+ * @param mixed $values
+ */
+ public function __construct($field = null, $values = null)
+ {
+ if ($field !== null && $values !== null) {
+ $this->setParam($field, $values);
+ }
+ }
/**
- * Sets a param for the message array
+ * Sets a param for the message array.
+ *
+ * @param string $field
+ * @param mixed $values
*
- * @param string $field
- * @param mixed $values
- * @return \Elastica\Query\Match
+ * @return $this
*/
public function setField($field, $values)
{
@@ -29,12 +39,13 @@ class Match extends AbstractQuery
}
/**
- * Sets a param for the given field
+ * Sets a param for the given field.
*
- * @param string $field
- * @param string $key
- * @param string $value
- * @return \Elastica\Query\Match
+ * @param string $field
+ * @param string $key
+ * @param string $value
+ *
+ * @return $this
*/
public function setFieldParam($field, $key, $value)
{
@@ -48,11 +59,12 @@ class Match extends AbstractQuery
}
/**
- * Sets the query string
+ * Sets the query string.
+ *
+ * @param string $field
+ * @param string $query
*
- * @param string $field
- * @param string $query
- * @return \Elastica\Query\Match
+ * @return $this
*/
public function setFieldQuery($field, $query)
{
@@ -60,11 +72,12 @@ class Match extends AbstractQuery
}
/**
- * Set field type
+ * Set field type.
+ *
+ * @param string $field
+ * @param string $type
*
- * @param string $field
- * @param string $type
- * @return \Elastica\Query\Match
+ * @return $this
*/
public function setFieldType($field, $type)
{
@@ -72,11 +85,12 @@ class Match extends AbstractQuery
}
/**
- * Set field operator
+ * Set field operator.
*
- * @param string $field
- * @param string $operator
- * @return \Elastica\Query\Match
+ * @param string $field
+ * @param string $operator
+ *
+ * @return $this
*/
public function setFieldOperator($field, $operator)
{
@@ -84,11 +98,12 @@ class Match extends AbstractQuery
}
/**
- * Set field analyzer
+ * Set field analyzer.
+ *
+ * @param string $field
+ * @param string $analyzer
*
- * @param string $field
- * @param string $analyzer
- * @return \Elastica\Query\Match
+ * @return $this
*/
public function setFieldAnalyzer($field, $analyzer)
{
@@ -96,13 +111,14 @@ class Match extends AbstractQuery
}
/**
- * Set field boost value
+ * Set field boost value.
*
* If not set, defaults to 1.0.
*
- * @param string $field
- * @param float $boost
- * @return \Elastica\Query\Match
+ * @param string $field
+ * @param float $boost
+ *
+ * @return $this
*/
public function setFieldBoost($field, $boost = 1.0)
{
@@ -110,12 +126,14 @@ class Match extends AbstractQuery
}
/**
- * Set field minimum should match
+ * Set field minimum should match.
*
- * @param string $field
- * @param int|string $minimumShouldMatch
- * @return \Elastica\Query\Match
- * @link Possible values for minimum_should_match http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-minimum-should-match.html
+ * @param string $field
+ * @param int|string $minimumShouldMatch
+ *
+ * @return $this
+ *
+ * @link Possible values for minimum_should_match http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-minimum-should-match.html
*/
public function setFieldMinimumShouldMatch($field, $minimumShouldMatch)
{
@@ -123,11 +141,12 @@ class Match extends AbstractQuery
}
/**
- * Set field fuzziness
+ * Set field fuzziness.
+ *
+ * @param string $field
+ * @param mixed $fuzziness
*
- * @param string $field
- * @param mixed $fuzziness
- * @return \Elastica\Query\Match
+ * @return $this
*/
public function setFieldFuzziness($field, $fuzziness)
{
@@ -135,11 +154,12 @@ class Match extends AbstractQuery
}
/**
- * Set field fuzzy rewrite
+ * Set field fuzzy rewrite.
*
- * @param string $field
- * @param string $fuzzyRewrite
- * @return \Elastica\Query\Match
+ * @param string $field
+ * @param string $fuzzyRewrite
+ *
+ * @return $this
*/
public function setFieldFuzzyRewrite($field, $fuzzyRewrite)
{
@@ -147,11 +167,12 @@ class Match extends AbstractQuery
}
/**
- * Set field prefix length
+ * Set field prefix length.
+ *
+ * @param string $field
+ * @param int $prefixLength
*
- * @param string $field
- * @param int $prefixLength
- * @return \Elastica\Query\Match
+ * @return $this
*/
public function setFieldPrefixLength($field, $prefixLength)
{
@@ -159,11 +180,12 @@ class Match extends AbstractQuery
}
/**
- * Set field max expansions
+ * Set field max expansions.
+ *
+ * @param string $field
+ * @param int $maxExpansions
*
- * @param string $field
- * @param int $maxExpansions
- * @return \Elastica\Query\Match
+ * @return $this
*/
public function setFieldMaxExpansions($field, $maxExpansions)
{
@@ -171,13 +193,14 @@ class Match extends AbstractQuery
}
/**
- * Set zero terms query
+ * Set zero terms query.
*
* If not set, default to 'none'
*
- * @param string $field
- * @param string $zeroTermQuery
- * @return \Elastica\Query\Match
+ * @param string $field
+ * @param string $zeroTermQuery
+ *
+ * @return $this
*/
public function setFieldZeroTermsQuery($field, $zeroTermQuery = 'none')
{
@@ -185,11 +208,12 @@ class Match extends AbstractQuery
}
/**
- * Set cutoff frequency
+ * Set cutoff frequency.
+ *
+ * @param string $field
+ * @param float $cutoffFrequency
*
- * @param string $field
- * @param float $cutoffFrequency
- * @return \Elastica\Query\Match
+ * @return $this
*/
public function setFieldCutoffFrequency($field, $cutoffFrequency)
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/MatchAll.php b/vendor/ruflin/elastica/lib/Elastica/Query/MatchAll.php
index 23b4fdfc..d01aaee8 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Query/MatchAll.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Query/MatchAll.php
@@ -1,19 +1,17 @@
<?php
-
namespace Elastica\Query;
/**
- * Match all query. Returns all results
+ * Match all query. Returns all results.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/match-all-query.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-all-query.html
*/
class MatchAll extends AbstractQuery
{
/**
- * Creates match all query
+ * Creates match all query.
*/
public function __construct()
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/MatchPhrase.php b/vendor/ruflin/elastica/lib/Elastica/Query/MatchPhrase.php
new file mode 100644
index 00000000..54302f90
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Query/MatchPhrase.php
@@ -0,0 +1,13 @@
+<?php
+namespace Elastica\Query;
+
+/**
+ * Match Phrase query.
+ *
+ * @author Jacques Moati <jacques@moati.net>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html#_phrase
+ */
+class MatchPhrase extends Match
+{
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/MatchPhrasePrefix.php b/vendor/ruflin/elastica/lib/Elastica/Query/MatchPhrasePrefix.php
new file mode 100644
index 00000000..61764bda
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Query/MatchPhrasePrefix.php
@@ -0,0 +1,13 @@
+<?php
+namespace Elastica\Query;
+
+/**
+ * Match Phrase Prefix query.
+ *
+ * @author Jacques Moati <jacques@moati.net>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html#_match_phrase_prefix
+ */
+class MatchPhrasePrefix extends Match
+{
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/MoreLikeThis.php b/vendor/ruflin/elastica/lib/Elastica/Query/MoreLikeThis.php
index d9ae4284..cd375db5 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Query/MoreLikeThis.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Query/MoreLikeThis.php
@@ -1,21 +1,20 @@
<?php
-
namespace Elastica\Query;
/**
- * More Like This query
+ * More Like This query.
*
- * @category Xodoa
- * @package Elastica
* @author Raul Martinez, Jr <juneym@gmail.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/mlt-query.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-mlt-query.html
*/
class MoreLikeThis extends AbstractQuery
{
/**
- * Adds field to mlt query
+ * Set fields to which to restrict the mlt query.
+ *
+ * @param array $fields Field names
*
- * @param array $fields Field names
* @return \Elastica\Query\MoreLikeThis Current object
*/
public function setFields(array $fields)
@@ -24,10 +23,23 @@ class MoreLikeThis extends AbstractQuery
}
/**
- * Set the "like_text" value
+ * Set document ids for the mlt query.
+ *
+ * @param array $ids Document ids
+ *
+ * @return \Elastica\Query\MoreLikeThis Current object
+ */
+ public function setIds(array $ids)
+ {
+ return $this->setParam('ids', $ids);
+ }
+
+ /**
+ * Set the "like_text" value.
+ *
+ * @param string $likeText
*
- * @param string $likeText
- * @return \Elastica\Query\MoreLikeThis This current object
+ * @return $this
*/
public function setLikeText($likeText)
{
@@ -37,10 +49,11 @@ class MoreLikeThis extends AbstractQuery
}
/**
- * Set boost
+ * Set boost.
*
- * @param float $boost Boost value
- * @return \Elastica\Query\MoreLikeThis Query object
+ * @param float $boost Boost value
+ *
+ * @return $this
*/
public function setBoost($boost)
{
@@ -48,10 +61,11 @@ class MoreLikeThis extends AbstractQuery
}
/**
- * Set max_query_terms
+ * Set max_query_terms.
+ *
+ * @param int $maxQueryTerms Max query terms value
*
- * @param int $maxQueryTerms Max query terms value
- * @return \Elastica\Query\MoreLikeThis
+ * @return $this
*/
public function setMaxQueryTerms($maxQueryTerms)
{
@@ -59,10 +73,13 @@ class MoreLikeThis extends AbstractQuery
}
/**
- * Set percent terms to match
+ * Set percent terms to match.
+ *
+ * @param float $percentTermsToMatch Percentage
+ *
+ * @return $this
*
- * @param float $percentTermsToMatch Percentage
- * @return \Elastica\Query\MoreLikeThis
+ * @deprecated Option "percent_terms_to_match" deprecated as of ES 1.5. Use "minimum_should_match" instead.
*/
public function setPercentTermsToMatch($percentTermsToMatch)
{
@@ -70,10 +87,11 @@ class MoreLikeThis extends AbstractQuery
}
/**
- * Set min term frequency
+ * Set min term frequency.
*
- * @param int $minTermFreq
- * @return \Elastica\Query\MoreLikeThis
+ * @param int $minTermFreq
+ *
+ * @return $this
*/
public function setMinTermFrequency($minTermFreq)
{
@@ -81,10 +99,11 @@ class MoreLikeThis extends AbstractQuery
}
/**
- * set min document frequency
+ * set min document frequency.
+ *
+ * @param int $minDocFreq
*
- * @param int $minDocFreq
- * @return \Elastica\Query\MoreLikeThis
+ * @return $this
*/
public function setMinDocFrequency($minDocFreq)
{
@@ -92,10 +111,11 @@ class MoreLikeThis extends AbstractQuery
}
/**
- * set max document frequency
+ * set max document frequency.
*
- * @param int $maxDocFreq
- * @return \Elastica\Query\MoreLikeThis
+ * @param int $maxDocFreq
+ *
+ * @return $this
*/
public function setMaxDocFrequency($maxDocFreq)
{
@@ -103,10 +123,11 @@ class MoreLikeThis extends AbstractQuery
}
/**
- * Set min word length
+ * Set min word length.
+ *
+ * @param int $minWordLength
*
- * @param int $minWordLength
- * @return \Elastica\Query\MoreLikeThis
+ * @return $this
*/
public function setMinWordLength($minWordLength)
{
@@ -114,10 +135,11 @@ class MoreLikeThis extends AbstractQuery
}
/**
- * Set max word length
+ * Set max word length.
*
- * @param int $maxWordLength
- * @return \Elastica\Query\MoreLikeThis
+ * @param int $maxWordLength
+ *
+ * @return $this
*/
public function setMaxWordLength($maxWordLength)
{
@@ -125,11 +147,11 @@ class MoreLikeThis extends AbstractQuery
}
/**
- * Set boost terms
+ * Set boost terms.
+ *
+ * @param bool $boostTerms
*
- * @param bool $boostTerms
- * @return \Elastica\Query\MoreLikeThis
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/mlt-query.html
+ * @return $this
*/
public function setBoostTerms($boostTerms)
{
@@ -137,10 +159,11 @@ class MoreLikeThis extends AbstractQuery
}
/**
- * Set analyzer
+ * Set analyzer.
*
- * @param string $analyzer
- * @return \Elastica\Query\MoreLikeThis
+ * @param string $analyzer
+ *
+ * @return $this
*/
public function setAnalyzer($analyzer)
{
@@ -150,13 +173,26 @@ class MoreLikeThis extends AbstractQuery
}
/**
- * Set stop words
+ * Set stop words.
+ *
+ * @param array $stopWords
*
- * @param array $stopWords
- * @return \Elastica\Query\MoreLikeThis
+ * @return $this
*/
public function setStopWords(array $stopWords)
{
return $this->setParam('stop_words', $stopWords);
}
+
+ /**
+ * Set minimum_should_match option.
+ *
+ * @param int|string $minimumShouldMatch
+ *
+ * @return $this
+ */
+ public function setMinimumShouldMatch($minimumShouldMatch)
+ {
+ return $this->setParam('minimum_should_match', $minimumShouldMatch);
+ }
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/MultiMatch.php b/vendor/ruflin/elastica/lib/Elastica/Query/MultiMatch.php
index ac2d01b3..0771f370 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Query/MultiMatch.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Query/MultiMatch.php
@@ -1,36 +1,35 @@
<?php
-
namespace Elastica\Query;
/**
- * Multi Match
+ * Multi Match.
*
- * @category Xodoa
- * @package Elastica
* @author Rodolfo Adhenawer Campagnoli Moraes <adhenawer@gmail.com>
* @author Wong Wing Lun <luiges90@gmail.com>
* @author Tristan Maindron <tmaindron@gmail.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/multi-match-query.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html
*/
class MultiMatch extends AbstractQuery
{
- const TYPE_BEST_FIELDS = 'best_fields';
- const TYPE_MOST_FIELDS = 'most_fields';
- const TYPE_CROSS_FIELDS = 'cross_fields';
- const TYPE_PHRASE = 'phrase';
+ const TYPE_BEST_FIELDS = 'best_fields';
+ const TYPE_MOST_FIELDS = 'most_fields';
+ const TYPE_CROSS_FIELDS = 'cross_fields';
+ const TYPE_PHRASE = 'phrase';
const TYPE_PHRASE_PREFIX = 'phrase_prefix';
- const OPERATOR_OR = 'or';
- const OPERATOR_AND = 'and';
+ const OPERATOR_OR = 'or';
+ const OPERATOR_AND = 'and';
- const ZERO_TERM_NONE = 'none';
- const ZERO_TERM_ALL = 'all';
+ const ZERO_TERM_NONE = 'none';
+ const ZERO_TERM_ALL = 'all';
/**
- * Sets the query
+ * Sets the query.
*
- * @param string $query Query
- * @return \Elastica\Query\MultiMatch Current object
+ * @param string $query Query
+ *
+ * @return $this
*/
public function setQuery($query = '')
{
@@ -40,8 +39,9 @@ class MultiMatch extends AbstractQuery
/**
* Sets Fields to be used in the query.
*
- * @param array $fields Fields
- * @return \Elastica\Query\MultiMatch Current object
+ * @param array $fields Fields
+ *
+ * @return $this
*/
public function setFields($fields = array())
{
@@ -53,8 +53,9 @@ class MultiMatch extends AbstractQuery
*
* If not set, defaults to true.
*
- * @param boolean $useDisMax
- * @return \Elastica\Query\MultiMatch Current object
+ * @param bool $useDisMax
+ *
+ * @return $this
*/
public function setUseDisMax($useDisMax = true)
{
@@ -66,8 +67,9 @@ class MultiMatch extends AbstractQuery
*
* If not set, defaults to 0.0.
*
- * @param float $tieBreaker
- * @return \Elastica\Query\MultiMatch Current object
+ * @param float $tieBreaker
+ *
+ * @return $this
*/
public function setTieBreaker($tieBreaker = 0.0)
{
@@ -75,12 +77,13 @@ class MultiMatch extends AbstractQuery
}
/**
- * Sets operator for Match Query
+ * Sets operator for Match Query.
*
* If not set, defaults to 'or'
*
- * @param string $operator
- * @return \Elastica\Query\MultiMatch Current object
+ * @param string $operator
+ *
+ * @return $this
*/
public function setOperator($operator = 'or')
{
@@ -88,23 +91,25 @@ class MultiMatch extends AbstractQuery
}
/**
- * Set field minimum should match for Match Query
+ * Set field minimum should match for Match Query.
+ *
+ * @param mixed $minimumShouldMatch
*
- * @param int $minimumShouldMatch
- * @return \Elastica\Query\Match
+ * @return $this
*/
public function setMinimumShouldMatch($minimumShouldMatch)
{
- return $this->setParam('minimum_should_match', (int) $minimumShouldMatch);
+ return $this->setParam('minimum_should_match', $minimumShouldMatch);
}
/**
- * Set zero terms query for Match Query
+ * Set zero terms query for Match Query.
*
* If not set, default to 'none'
*
- * @param string $zeroTermQuery
- * @return \Elastica\Query\Match
+ * @param string $zeroTermQuery
+ *
+ * @return $this
*/
public function setZeroTermsQuery($zeroTermQuery = 'none')
{
@@ -112,10 +117,11 @@ class MultiMatch extends AbstractQuery
}
/**
- * Set cutoff frequency for Match Query
+ * Set cutoff frequency for Match Query.
+ *
+ * @param float $cutoffFrequency
*
- * @param float $cutoffFrequency
- * @return \Elastica\Query\Match
+ * @return $this
*/
public function setCutoffFrequency($cutoffFrequency)
{
@@ -123,11 +129,12 @@ class MultiMatch extends AbstractQuery
}
/**
- * Set type
+ * Set type.
*
- * @param string $field
- * @param string $type
- * @return \Elastica\Query\Match
+ * @param string $field
+ * @param string $type
+ *
+ * @return $this
*/
public function setType($type)
{
@@ -135,10 +142,11 @@ class MultiMatch extends AbstractQuery
}
/**
- * Set fuzziness
+ * Set fuzziness.
+ *
+ * @param float $fuzziness
*
- * @param float $fuzziness
- * @return \Elastica\Query\Match
+ * @return $this
*/
public function setFuzziness($fuzziness)
{
@@ -146,10 +154,11 @@ class MultiMatch extends AbstractQuery
}
/**
- * Set prefix length
+ * Set prefix length.
*
- * @param int $prefixLength
- * @return \Elastica\Query\Match
+ * @param int $prefixLength
+ *
+ * @return $this
*/
public function setPrefixLength($prefixLength)
{
@@ -157,10 +166,11 @@ class MultiMatch extends AbstractQuery
}
/**
- * Set max expansions
+ * Set max expansions.
+ *
+ * @param int $maxExpansions
*
- * @param int $maxExpansions
- * @return \Elastica\Query\Match
+ * @return $this
*/
public function setMaxExpansions($maxExpansions)
{
@@ -168,10 +178,11 @@ class MultiMatch extends AbstractQuery
}
/**
- * Set analyzer
+ * Set analyzer.
+ *
+ * @param string $analyzer
*
- * @param string $analyzer
- * @return \Elastica\Query\Match
+ * @return $this
*/
public function setAnalyzer($analyzer)
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/Nested.php b/vendor/ruflin/elastica/lib/Elastica/Query/Nested.php
index 3d2f2f64..b072cfc8 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Query/Nested.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Query/Nested.php
@@ -1,22 +1,21 @@
<?php
-
namespace Elastica\Query;
/**
- * Nested query
+ * Nested query.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/nested-query.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-nested-query.html
*/
class Nested extends AbstractQuery
{
/**
- * Adds field to mlt query
+ * Adds field to mlt query.
+ *
+ * @param string $path Nested object path
*
- * @param string $path Nested object path
- * @return \Elastica\Query\Nested
+ * @return $this
*/
public function setPath($path)
{
@@ -24,10 +23,11 @@ class Nested extends AbstractQuery
}
/**
- * Sets nested query
+ * Sets nested query.
*
- * @param \Elastica\Query\AbstractQuery $query
- * @return \Elastica\Query\Nested
+ * @param \Elastica\Query\AbstractQuery $query
+ *
+ * @return $this
*/
public function setQuery(AbstractQuery $query)
{
@@ -35,10 +35,11 @@ class Nested extends AbstractQuery
}
/**
- * Set score method
+ * Set score method.
+ *
+ * @param string $scoreMode Options: avg, total, max and none.
*
- * @param string $scoreMode Options: avg, total, max and none.
- * @return \Elastica\Query\Nested
+ * @return $this
*/
public function setScoreMode($scoreMode)
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/Prefix.php b/vendor/ruflin/elastica/lib/Elastica/Query/Prefix.php
index 4306fd9c..c2b903ea 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Query/Prefix.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Query/Prefix.php
@@ -1,18 +1,15 @@
<?php
-
namespace Elastica\Query;
/**
- * Prefix query
+ * Prefix query.
*
- * @category Xodoa
- * @package Elastica
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/prefix-query.html
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-prefix-query.html
*/
class Prefix extends AbstractQuery
{
/**
- * Constructs the Prefix query object
+ * Constructs the Prefix query object.
*
* @param array $prefix OPTIONAL Calls setRawPrefix with the given $prefix array
*/
@@ -25,8 +22,9 @@ class Prefix extends AbstractQuery
* setRawPrefix can be used instead of setPrefix if some more special
* values for a prefix have to be set.
*
- * @param array $prefix Prefix array
- * @return \Elastica\Query\Prefix Current object
+ * @param array $prefix Prefix array
+ *
+ * @return $this
*/
public function setRawPrefix(array $prefix)
{
@@ -34,12 +32,13 @@ class Prefix extends AbstractQuery
}
/**
- * Adds a prefix to the prefix query
+ * Adds a prefix to the prefix query.
+ *
+ * @param string $key Key to query
+ * @param string|array $value Values(s) for the query. Boost can be set with array
+ * @param float $boost OPTIONAL Boost value (default = 1.0)
*
- * @param string $key Key to query
- * @param string|array $value Values(s) for the query. Boost can be set with array
- * @param float $boost OPTIONAL Boost value (default = 1.0)
- * @return \Elastica\Query\Prefix Current object
+ * @return $this
*/
public function setPrefix($key, $value, $boost = 1.0)
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/QueryString.php b/vendor/ruflin/elastica/lib/Elastica/Query/QueryString.php
index 7d0b0094..89ea77cd 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Query/QueryString.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Query/QueryString.php
@@ -1,27 +1,26 @@
<?php
-
namespace Elastica\Query;
+
use Elastica\Exception\InvalidException;
/**
- * QueryString query
+ * QueryString query.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>, Jasper van Wanrooy <jasper@vanwanrooy.net>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/query-string-query.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html
*/
class QueryString extends AbstractQuery
{
/**
- * Query string
+ * Query string.
*
* @var string Query string
*/
protected $_queryString = '';
/**
- * Creates query string object. Calls setQuery with argument
+ * Creates query string object. Calls setQuery with argument.
*
* @param string $queryString OPTIONAL Query string for object
*/
@@ -31,11 +30,13 @@ class QueryString extends AbstractQuery
}
/**
- * Sets a new query string for the object
+ * Sets a new query string for the object.
+ *
+ * @param string $query Query string
+ *
+ * @throws \Elastica\Exception\InvalidException If given parameter is not a string
*
- * @param string $query Query string
- * @throws \Elastica\Exception\InvalidException
- * @return \Elastica\Query\QueryString Current object
+ * @return $this
*/
public function setQuery($query = '')
{
@@ -47,12 +48,13 @@ class QueryString extends AbstractQuery
}
/**
- * Sets the default field
+ * Sets the default field.
*
* If no field is set, _all is chosen
*
- * @param string $field Field
- * @return \Elastica\Query\QueryString Current object
+ * @param string $field Field
+ *
+ * @return $this
*/
public function setDefaultField($field)
{
@@ -60,12 +62,13 @@ class QueryString extends AbstractQuery
}
/**
- * Sets the default operator AND or OR
+ * Sets the default operator AND or OR.
*
* If no operator is set, OR is chosen
*
- * @param string $operator Operator
- * @return \Elastica\Query\QueryString Current object
+ * @param string $operator Operator
+ *
+ * @return $this
*/
public function setDefaultOperator($operator)
{
@@ -75,8 +78,9 @@ class QueryString extends AbstractQuery
/**
* Sets the analyzer to analyze the query with.
*
- * @param string $analyzer Analyser to use
- * @return \Elastica\Query\QueryString Current object
+ * @param string $analyzer Analyser to use
+ *
+ * @return $this
*/
public function setAnalyzer($analyzer)
{
@@ -88,8 +92,9 @@ class QueryString extends AbstractQuery
*
* If not set, defaults to true.
*
- * @param bool $allow
- * @return \Elastica\Query\QueryString Current object
+ * @param bool $allow
+ *
+ * @return $this
*/
public function setAllowLeadingWildcard($allow = true)
{
@@ -97,25 +102,13 @@ class QueryString extends AbstractQuery
}
/**
- * Sets the parameter to auto-lowercase terms of some queries.
- *
- * If not set, defaults to true.
- *
- * @param bool $lowercase
- * @return \Elastica\Query\QueryString Current object
- */
- public function setLowercaseExpandedTerms($lowercase = true)
- {
- return $this->setParam('lowercase_expanded_terms', (bool) $lowercase);
- }
-
- /**
* Sets the parameter to enable the position increments in result queries.
*
* If not set, defaults to true.
*
- * @param bool $enabled
- * @return \Elastica\Query\QueryString Current object
+ * @param bool $enabled
+ *
+ * @return $this
*/
public function setEnablePositionIncrements($enabled = true)
{
@@ -127,8 +120,9 @@ class QueryString extends AbstractQuery
*
* If not set, defaults to 0.
*
- * @param int $length
- * @return \Elastica\Query\QueryString Current object
+ * @param int $length
+ *
+ * @return $this
*/
public function setFuzzyPrefixLength($length = 0)
{
@@ -140,8 +134,9 @@ class QueryString extends AbstractQuery
*
* If not set, defaults to 0.5
*
- * @param float $minSim
- * @return \Elastica\Query\QueryString Current object
+ * @param float $minSim
+ *
+ * @return $this
*/
public function setFuzzyMinSim($minSim = 0.5)
{
@@ -154,8 +149,9 @@ class QueryString extends AbstractQuery
* If zero, exact phrases are required.
* If not set, defaults to zero.
*
- * @param int $phraseSlop
- * @return \Elastica\Query\QueryString Current object
+ * @param int $phraseSlop
+ *
+ * @return $this
*/
public function setPhraseSlop($phraseSlop = 0)
{
@@ -167,8 +163,9 @@ class QueryString extends AbstractQuery
*
* If not set, defaults to 1.0.
*
- * @param float $boost
- * @return \Elastica\Query\QueryString Current object
+ * @param float $boost
+ *
+ * @return $this
*/
public function setBoost($boost = 1.0)
{
@@ -180,8 +177,9 @@ class QueryString extends AbstractQuery
*
* If not set, defaults to true
*
- * @param bool $analyze
- * @return \Elastica\Query\QueryString Current object
+ * @param bool $analyze
+ *
+ * @return $this
*/
public function setAnalyzeWildcard($analyze = true)
{
@@ -193,8 +191,9 @@ class QueryString extends AbstractQuery
*
* If not set, defaults to true.
*
- * @param bool $autoGenerate
- * @return \Elastica\Query\QueryString Current object
+ * @param bool $autoGenerate
+ *
+ * @return $this
*/
public function setAutoGeneratePhraseQueries($autoGenerate = true)
{
@@ -202,13 +201,13 @@ class QueryString extends AbstractQuery
}
/**
- * Sets the fields
+ * Sets the fields. If no fields are set, _all is chosen.
+ *
+ * @param array $fields Fields
*
- * If no fields are set, _all is chosen
+ * @throws \Elastica\Exception\InvalidException If given parameter is not an array
*
- * @param array $fields Fields
- * @throws \Elastica\Exception\InvalidException
- * @return \Elastica\Query\QueryString Current object
+ * @return $this
*/
public function setFields(array $fields)
{
@@ -222,8 +221,9 @@ class QueryString extends AbstractQuery
/**
* Whether to use bool or dis_max queries to internally combine results for multi field search.
*
- * @param bool $value Determines whether to use
- * @return \Elastica\Query\QueryString Current object
+ * @param bool $value Determines whether to use
+ *
+ * @return $this
*/
public function setUseDisMax($value = true)
{
@@ -235,8 +235,9 @@ class QueryString extends AbstractQuery
*
* If not set, defaults to 0.
*
- * @param int $tieBreaker
- * @return \Elastica\Query\QueryString Current object
+ * @param int $tieBreaker
+ *
+ * @return $this
*/
public function setTieBreaker($tieBreaker = 0)
{
@@ -244,24 +245,38 @@ class QueryString extends AbstractQuery
}
/**
- * Set a re-write condition. See https://github.com/elasticsearch/elasticsearch/issues/1186 for additional information
+ * Set a re-write condition. See https://github.com/elasticsearch/elasticsearch/issues/1186 for additional information.
*
- * @param string $rewrite
- * @return \Elastica\Query\QueryString Current object
+ * @param string $rewrite
+ *
+ * @return $this
*/
- public function setRewrite($rewrite = "")
+ public function setRewrite($rewrite = '')
{
return $this->setParam('rewrite', $rewrite);
}
/**
- * Converts query to array
+ * Set timezone option.
+ *
+ * @param string $timezone
+ *
+ * @return $this
+ */
+ public function setTimezone($timezone)
+ {
+ return $this->setParam('time_zone', $timezone);
+ }
+
+ /**
+ * Converts query to array.
*
* @see \Elastica\Query\AbstractQuery::toArray()
+ *
* @return array Query array
*/
public function toArray()
{
- return array('query_string' => array_merge(array('query' => $this->_queryString), $this->getParams()),);
+ return array('query_string' => array_merge(array('query' => $this->_queryString), $this->getParams()));
}
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/Range.php b/vendor/ruflin/elastica/lib/Elastica/Query/Range.php
index 54b79027..b2f9175a 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Query/Range.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Query/Range.php
@@ -1,19 +1,17 @@
<?php
-
namespace Elastica\Query;
/**
- * Range query
+ * Range query.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/range-query.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-query.html
*/
class Range extends AbstractQuery
{
/**
- * Constructor
+ * Constructor.
*
* @param string $fieldName Field name
* @param array $args Field arguments
@@ -26,11 +24,12 @@ class Range extends AbstractQuery
}
/**
- * Adds a range field to the query
+ * Adds a range field to the query.
+ *
+ * @param string $fieldName Field name
+ * @param array $args Field arguments
*
- * @param string $fieldName Field name
- * @param array $args Field arguments
- * @return \Elastica\Query\Range Current object
+ * @return $this
*/
public function addField($fieldName, array $args)
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/Regexp.php b/vendor/ruflin/elastica/lib/Elastica/Query/Regexp.php
new file mode 100644
index 00000000..22a48560
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Query/Regexp.php
@@ -0,0 +1,40 @@
+<?php
+namespace Elastica\Query;
+
+/**
+ * Regexp query.
+ *
+ * @author Aurélien Le Grand <gnitg@yahoo.fr>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-regexp-query.html
+ */
+class Regexp extends AbstractQuery
+{
+ /**
+ * Construct regexp query.
+ *
+ * @param string $key OPTIONAL Regexp key
+ * @param string $value OPTIONAL Regexp value
+ * @param float $boost OPTIONAL Boost value (default = 1)
+ */
+ public function __construct($key = '', $value = null, $boost = 1.0)
+ {
+ if (!empty($key)) {
+ $this->setValue($key, $value, $boost);
+ }
+ }
+
+ /**
+ * Sets the query expression for a key with its boost value.
+ *
+ * @param string $key
+ * @param string $value
+ * @param float $boost
+ *
+ * @return $this
+ */
+ public function setValue($key, $value, $boost = 1.0)
+ {
+ return $this->setParam($key, array('value' => $value, 'boost' => $boost));
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/Simple.php b/vendor/ruflin/elastica/lib/Elastica/Query/Simple.php
index 2448ca79..6ba9310d 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Query/Simple.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Query/Simple.php
@@ -1,26 +1,23 @@
<?php
-
namespace Elastica\Query;
/**
* Simple query
* Pure php array query. Can be used to create any not existing type of query.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
*/
class Simple extends AbstractQuery
{
/**
- * Query
+ * Query.
*
* @var array Query
*/
protected $_query = array();
/**
- * Constructs a query based on an array
+ * Constructs a query based on an array.
*
* @param array $query Query array
*/
@@ -30,10 +27,11 @@ class Simple extends AbstractQuery
}
/**
- * Sets new query array
+ * Sets new query array.
+ *
+ * @param array $query Query array
*
- * @param array $query Query array
- * @return \Elastica\Query\Simple Current object
+ * @return $this
*/
public function setQuery(array $query)
{
@@ -43,9 +41,10 @@ class Simple extends AbstractQuery
}
/**
- * Converts query to array
+ * Converts query to array.
*
* @return array Query array
+ *
* @see \Elastica\Query\AbstractQuery::toArray()
*/
public function toArray()
diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/SimpleQueryString.php b/vendor/ruflin/elastica/lib/Elastica/Query/SimpleQueryString.php
index a6c4ba9d..c2302d44 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Query/SimpleQueryString.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Query/SimpleQueryString.php
@@ -1,20 +1,19 @@
<?php
-
namespace Elastica\Query;
/**
- * Class SimpleQueryString
- * @package Elastica\Query
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-simple-query-string-query.html
+ * Class SimpleQueryString.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-simple-query-string-query.html
*/
class SimpleQueryString extends AbstractQuery
{
- const OPERATOR_AND = "and";
- const OPERATOR_OR = "or";
+ const OPERATOR_AND = 'and';
+ const OPERATOR_OR = 'or';
/**
* @param string $query
- * @param array $fields
+ * @param array $fields
*/
public function __construct($query, array $fields = array())
{
@@ -25,41 +24,60 @@ class SimpleQueryString extends AbstractQuery
}
/**
- * Set the querystring for this query
+ * Set the querystring for this query.
+ *
* @param string $query see ES documentation for querystring syntax
- * @return \Elastica\Query\SimpleQueryString
+ *
+ * @return $this
*/
public function setQuery($query)
{
- return $this->setParam("query", $query);
+ return $this->setParam('query', $query);
}
/**
* @param string[] $fields the fields on which to perform this query. Defaults to index.query.default_field.
- * @return \Elastica\Query\SimpleQueryString
+ *
+ * @return $this
*/
public function setFields(array $fields)
{
- return $this->setParam("fields", $fields);
+ return $this->setParam('fields', $fields);
}
/**
- * Set the default operator to use if no explicit operator is defined in the query string
+ * Set the default operator to use if no explicit operator is defined in the query string.
+ *
* @param string $operator see OPERATOR_* constants for options
- * @return \Elastica\Query\SimpleQueryString
+ *
+ * @return $this
*/
public function setDefaultOperator($operator)
{
- return $this->setParam("default_operator", $operator);
+ return $this->setParam('default_operator', $operator);
}
/**
- * Set the analyzer used to analyze each term of the query
+ * Set the analyzer used to analyze each term of the query.
+ *
* @param string $analyzer
- * @return \Elastica\Query\SimpleQueryString
+ *
+ * @return $this
*/
public function setAnalyzer($analyzer)
{
- return $this->setParam("analyzer", $analyzer);
+ return $this->setParam('analyzer', $analyzer);
+ }
+
+ /**
+ * Set minimum_should_match option.
+ *
+ * @param int|string $minimumShouldMatch
+ *
+ * @return $this
+ */
+ public function setMinimumShouldMatch($minimumShouldMatch)
+ {
+ return $this->setParam('minimum_should_match', $minimumShouldMatch);
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/Term.php b/vendor/ruflin/elastica/lib/Elastica/Query/Term.php
index eb20eb86..8cfe0a88 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Query/Term.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Query/Term.php
@@ -1,19 +1,17 @@
<?php
-
namespace Elastica\Query;
/**
- * Term query
+ * Term query.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/term-query.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html
*/
class Term extends AbstractQuery
{
/**
- * Constructs the Term query object
+ * Constructs the Term query object.
*
* @param array $term OPTIONAL Calls setTerm with the given $term array
*/
@@ -26,8 +24,9 @@ class Term extends AbstractQuery
* Set term can be used instead of addTerm if some more special
* values for a term have to be set.
*
- * @param array $term Term array
- * @return \Elastica\Query\Term Current object
+ * @param array $term Term array
+ *
+ * @return $this
*/
public function setRawTerm(array $term)
{
@@ -35,12 +34,13 @@ class Term extends AbstractQuery
}
/**
- * Adds a term to the term query
+ * Adds a term to the term query.
+ *
+ * @param string $key Key to query
+ * @param string|array $value Values(s) for the query. Boost can be set with array
+ * @param float $boost OPTIONAL Boost value (default = 1.0)
*
- * @param string $key Key to query
- * @param string|array $value Values(s) for the query. Boost can be set with array
- * @param float $boost OPTIONAL Boost value (default = 1.0)
- * @return \Elastica\Query\Term Current object
+ * @return $this
*/
public function setTerm($key, $value, $boost = 1.0)
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/Terms.php b/vendor/ruflin/elastica/lib/Elastica/Query/Terms.php
index 41cc9216..54f26461 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Query/Terms.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Query/Terms.php
@@ -1,41 +1,40 @@
<?php
-
namespace Elastica\Query;
+
use Elastica\Exception\InvalidException;
/**
- * Terms query
+ * Terms query.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/terms-query.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-query.html
*/
class Terms extends AbstractQuery
{
/**
- * Terms
+ * Terms.
*
* @var array Terms
*/
protected $_terms = array();
/**
- * Params
+ * Params.
*
* @var array Params
*/
protected $_params = array();
/**
- * Terms key
+ * Terms key.
*
* @var string Terms key
*/
protected $_key = '';
/**
- * Construct terms query
+ * Construct terms query.
*
* @param string $key OPTIONAL Terms key
* @param array $terms OPTIONAL Terms list
@@ -46,11 +45,12 @@ class Terms extends AbstractQuery
}
/**
- * Sets key and terms for the query
+ * Sets key and terms for the query.
+ *
+ * @param string $key Terms key
+ * @param array $terms Terms for the query.
*
- * @param string $key Terms key
- * @param array $terms Terms for the query.
- * @return \Elastica\Query\Terms
+ * @return $this
*/
public function setTerms($key, array $terms)
{
@@ -61,10 +61,11 @@ class Terms extends AbstractQuery
}
/**
- * Adds a single term to the list
+ * Adds a single term to the list.
*
- * @param string $term Term
- * @return \Elastica\Query\Terms
+ * @param string $term Term
+ *
+ * @return $this
*/
public function addTerm($term)
{
@@ -74,10 +75,11 @@ class Terms extends AbstractQuery
}
/**
- * Sets the minimum matching values
+ * Sets the minimum matching values.
+ *
+ * @param int $minimum Minimum value
*
- * @param int $minimum Minimum value
- * @return \Elastica\Query\Terms
+ * @return $this
*/
public function setMinimumMatch($minimum)
{
@@ -85,11 +87,13 @@ class Terms extends AbstractQuery
}
/**
- * Converts the terms object to an array
+ * Converts the terms object to an array.
*
* @see \Elastica\Query\AbstractQuery::toArray()
- * @throws \Elastica\Exception\InvalidException
- * @return array Query array
+ *
+ * @throws \Elastica\Exception\InvalidException If term key is empty
+ *
+ * @return array Query array
*/
public function toArray()
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/TopChildren.php b/vendor/ruflin/elastica/lib/Elastica/Query/TopChildren.php
index baaf7501..6f15c79d 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Query/TopChildren.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Query/TopChildren.php
@@ -1,23 +1,22 @@
<?php
-
namespace Elastica\Query;
+
use Elastica\Query as BaseQuery;
/**
* Runs the child query with an estimated hits size, and out of the hit docs, aggregates it into parent docs.
*
- * @category Xodoa
- * @package Elastica
* @author Wu Yang <darkyoung@gmail.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/top-children-query.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-top-children-query.html
*/
class TopChildren extends AbstractQuery
{
/**
- * Construct topChildren query
+ * Construct topChildren query.
*
* @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query
- * @param string $type Parent document type
+ * @param string $type Parent document type
*/
public function __construct($query, $type = null)
{
@@ -26,10 +25,11 @@ class TopChildren extends AbstractQuery
}
/**
- * Sets query object
+ * Sets query object.
*
- * @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query
- * @return \Elastica\Query\TopChildren
+ * @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query
+ *
+ * @return $this
*/
public function setQuery($query)
{
@@ -40,10 +40,11 @@ class TopChildren extends AbstractQuery
}
/**
- * Set type of the parent document
+ * Set type of the parent document.
+ *
+ * @param string $type Parent document type
*
- * @param string $type Parent document type
- * @return \Elastica\Query\TopChildren Current object
+ * @return $this
*/
public function setType($type)
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/Wildcard.php b/vendor/ruflin/elastica/lib/Elastica/Query/Wildcard.php
index 68aca67e..bfa5e751 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Query/Wildcard.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Query/Wildcard.php
@@ -1,19 +1,17 @@
<?php
-
namespace Elastica\Query;
/**
- * Wildcard query
+ * Wildcard query.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/query-dsl/wildcard-query.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-wildcard-query.html
*/
class Wildcard extends AbstractQuery
{
/**
- * Construct wildcard query
+ * Construct wildcard query.
*
* @param string $key OPTIONAL Wildcard key
* @param string $value OPTIONAL Wildcard value
@@ -27,12 +25,13 @@ class Wildcard extends AbstractQuery
}
/**
- * Sets the query expression for a key with its boost value
+ * Sets the query expression for a key with its boost value.
+ *
+ * @param string $key
+ * @param string $value
+ * @param float $boost
*
- * @param string $key
- * @param string $value
- * @param float $boost
- * @return \Elastica\Query\Wildcard
+ * @return $this
*/
public function setValue($key, $value, $boost = 1.0)
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/QueryBuilder.php b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder.php
new file mode 100644
index 00000000..477c4525
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder.php
@@ -0,0 +1,114 @@
+<?php
+namespace Elastica;
+
+use Elastica\Exception\QueryBuilderException;
+use Elastica\QueryBuilder\DSL;
+use Elastica\QueryBuilder\Facade;
+use Elastica\QueryBuilder\Version;
+use Elastica\QueryBuilder\Version\Version150;
+
+/**
+ * Query Builder.
+ *
+ * @author Manuel Andreo Garcia <andreo.garcia@googlemail.com>
+ */
+class QueryBuilder
+{
+ /**
+ * @var Version
+ */
+ private $_version;
+
+ /**
+ * @var Facade[]
+ */
+ private $_facades = array();
+
+ /**
+ * Constructor.
+ *
+ * @param Version $version
+ */
+ public function __construct(Version $version = null)
+ {
+ $this->_version = $version ?: new Version150();
+
+ $this->addDSL(new DSL\Query());
+ $this->addDSL(new DSL\Filter());
+ $this->addDSL(new DSL\Aggregation());
+ $this->addDSL(new DSL\Suggest());
+ }
+
+ /**
+ * Returns Facade for custom DSL object.
+ *
+ * @param $dsl
+ * @param array $arguments
+ *
+ * @throws QueryBuilderException
+ *
+ * @return Facade
+ */
+ public function __call($dsl, array $arguments)
+ {
+ if (false === isset($this->_facades[$dsl])) {
+ throw new QueryBuilderException('DSL "'.$dsl.'" not supported');
+ }
+
+ return $this->_facades[$dsl];
+ }
+
+ /**
+ * Adds a new DSL object.
+ *
+ * @param DSL $dsl
+ */
+ public function addDSL(DSL $dsl)
+ {
+ $this->_facades[$dsl->getType()] = new Facade($dsl, $this->_version);
+ }
+
+ /*
+ * convenience methods
+ */
+
+ /**
+ * Query DSL.
+ *
+ * @return DSL\Query
+ */
+ public function query()
+ {
+ return $this->_facades[DSL::TYPE_QUERY];
+ }
+
+ /**
+ * Filter DSL.
+ *
+ * @return DSL\Filter
+ */
+ public function filter()
+ {
+ return $this->_facades[DSL::TYPE_FILTER];
+ }
+
+ /**
+ * Aggregation DSL.
+ *
+ * @return DSL\Aggregation
+ */
+ public function aggregation()
+ {
+ return $this->_facades[DSL::TYPE_AGGREGATION];
+ }
+
+ /**
+ * Suggest DSL.
+ *
+ * @return DSL\Suggest
+ */
+ public function suggest()
+ {
+ return $this->_facades[DSL::TYPE_SUGGEST];
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/DSL.php b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/DSL.php
new file mode 100644
index 00000000..976de5f4
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/DSL.php
@@ -0,0 +1,22 @@
+<?php
+namespace Elastica\QueryBuilder;
+
+/**
+ * DSL Interface.
+ *
+ * @author Manuel Andreo Garcia <andreo.garcia@googlemail.com>
+ */
+interface DSL
+{
+ const TYPE_QUERY = 'query';
+ const TYPE_FILTER = 'filter';
+ const TYPE_AGGREGATION = 'aggregation';
+ const TYPE_SUGGEST = 'suggest';
+
+ /**
+ * must return type for QueryBuilder usage.
+ *
+ * @return string
+ */
+ public function getType();
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/DSL/Aggregation.php b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/DSL/Aggregation.php
new file mode 100644
index 00000000..8393b8aa
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/DSL/Aggregation.php
@@ -0,0 +1,470 @@
+<?php
+namespace Elastica\QueryBuilder\DSL;
+
+use Elastica\Aggregation\Avg;
+use Elastica\Aggregation\Cardinality;
+use Elastica\Aggregation\DateHistogram;
+use Elastica\Aggregation\DateRange;
+use Elastica\Aggregation\ExtendedStats;
+use Elastica\Aggregation\Filter as FilterAggregation;
+use Elastica\Aggregation\Filters;
+use Elastica\Aggregation\GeoDistance;
+use Elastica\Aggregation\GeohashGrid;
+use Elastica\Aggregation\GlobalAggregation;
+use Elastica\Aggregation\Histogram;
+use Elastica\Aggregation\IpRange;
+use Elastica\Aggregation\Max;
+use Elastica\Aggregation\Min;
+use Elastica\Aggregation\Missing;
+use Elastica\Aggregation\Nested;
+use Elastica\Aggregation\Percentiles;
+use Elastica\Aggregation\Range;
+use Elastica\Aggregation\ReverseNested;
+use Elastica\Aggregation\ScriptedMetric;
+use Elastica\Aggregation\SignificantTerms;
+use Elastica\Aggregation\Stats;
+use Elastica\Aggregation\Sum;
+use Elastica\Aggregation\Terms;
+use Elastica\Aggregation\TopHits;
+use Elastica\Aggregation\ValueCount;
+use Elastica\Exception\NotImplementedException;
+use Elastica\Filter\AbstractFilter;
+use Elastica\QueryBuilder\DSL;
+
+/**
+ * elasticsearch aggregation DSL.
+ *
+ * @author Manuel Andreo Garcia <andreo.garcia@googlemail.com>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations.html
+ */
+class Aggregation implements DSL
+{
+ /**
+ * must return type for QueryBuilder usage.
+ *
+ * @return string
+ */
+ public function getType()
+ {
+ return DSL::TYPE_AGGREGATION;
+ }
+
+ /**
+ * min aggregation.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-min-aggregation.html
+ *
+ * @param string $name
+ *
+ * @return Min
+ */
+ public function min($name)
+ {
+ return new Min($name);
+ }
+
+ /**
+ * max aggregation.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-max-aggregation.html
+ *
+ * @param string $name
+ *
+ * @return Max
+ */
+ public function max($name)
+ {
+ return new Max($name);
+ }
+
+ /**
+ * sum aggregation.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-sum-aggregation.html
+ *
+ * @param string $name
+ *
+ * @return Sum
+ */
+ public function sum($name)
+ {
+ return new Sum($name);
+ }
+
+ /**
+ * avg aggregation.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-avg-aggregation.html
+ *
+ * @param string $name
+ *
+ * @return Avg
+ */
+ public function avg($name)
+ {
+ return new Avg($name);
+ }
+
+ /**
+ * stats aggregation.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-stats-aggregation.html
+ *
+ * @param string $name
+ *
+ * @return Stats
+ */
+ public function stats($name)
+ {
+ return new Stats($name);
+ }
+
+ /**
+ * extended stats aggregation.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-extendedstats-aggregation.html
+ *
+ * @param string $name
+ *
+ * @return ExtendedStats
+ */
+ public function extended_stats($name)
+ {
+ return new ExtendedStats($name);
+ }
+
+ /**
+ * value count aggregation.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-valuecount-aggregation.html
+ *
+ * @param string $name
+ * @param string $field
+ *
+ * @return ValueCount
+ */
+ public function value_count($name, $field)
+ {
+ return new ValueCount($name, $field);
+ }
+
+ /**
+ * percentiles aggregation.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-percentile-aggregation.html
+ *
+ * @param string $name the name of this aggregation
+ * @param string $field the field on which to perform this aggregation
+ *
+ * @return Percentiles
+ */
+ public function percentiles($name, $field = null)
+ {
+ return new Percentiles($name, $field);
+ }
+
+ /**
+ * percentile ranks aggregation.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-percentile-rank-aggregation.html
+ *
+ * @param string $name
+ */
+ public function percentile_ranks($name)
+ {
+ throw new NotImplementedException();
+ }
+
+ /**
+ * cardinality aggregation.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-cardinality-aggregation.html
+ *
+ * @param string $name
+ *
+ * @return Cardinality
+ */
+ public function cardinality($name)
+ {
+ return new Cardinality($name);
+ }
+
+ /**
+ * geo bounds aggregation.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-geobounds-aggregation.html
+ *
+ * @param string $name
+ */
+ public function geo_bounds($name)
+ {
+ throw new NotImplementedException();
+ }
+
+ /**
+ * top hits aggregation.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-top-hits-aggregation.html
+ *
+ * @param string $name
+ *
+ * @return TopHits
+ */
+ public function top_hits($name)
+ {
+ return new TopHits($name);
+ }
+
+ /**
+ * scripted metric aggregation.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-scripted-metric-aggregation.html
+ *
+ * @param string $name
+ * @param string|null $initScript
+ * @param string|null $mapScript
+ * @param string|null $combineScript
+ * @param string|null $reduceScript
+ *
+ * @return ScriptedMetric
+ */
+ public function scripted_metric($name, $initScript = null, $mapScript = null, $combineScript = null, $reduceScript = null)
+ {
+ return new ScriptedMetric($name, $initScript, $mapScript, $combineScript, $reduceScript);
+ }
+
+ /**
+ * global aggregation.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-global-aggregation.html
+ *
+ * @param string $name
+ *
+ * @return GlobalAggregation
+ */
+ public function global_agg($name)
+ {
+ return new GlobalAggregation($name);
+ }
+
+ /**
+ * filter aggregation.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filter-aggregation.html
+ *
+ * @param string $name
+ * @param AbstractFilter $filter
+ *
+ * @return FilterAggregation
+ */
+ public function filter($name, AbstractFilter $filter = null)
+ {
+ return new FilterAggregation($name, $filter);
+ }
+
+ /**
+ * filters aggregation.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filters-aggregation.html
+ *
+ * @param string $name
+ *
+ * @return Filters
+ */
+ public function filters($name)
+ {
+ return new Filters($name);
+ }
+
+ /**
+ * missing aggregation.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-missing-aggregation.html
+ *
+ * @param string $name
+ * @param string $field
+ *
+ * @return Missing
+ */
+ public function missing($name, $field)
+ {
+ return new Missing($name, $field);
+ }
+
+ /**
+ * nested aggregation.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-nested-aggregation.html
+ *
+ * @param string $name
+ * @param string $path the nested path for this aggregation
+ *
+ * @return Nested
+ */
+ public function nested($name, $path)
+ {
+ return new Nested($name, $path);
+ }
+
+ /**
+ * reverse nested aggregation.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-reverse-nested-aggregation.html
+ *
+ * @param string $name The name of this aggregation
+ * @param string $path Optional path to the nested object for this aggregation. Defaults to the root of the main document.
+ *
+ * @return ReverseNested
+ */
+ public function reverse_nested($name, $path = null)
+ {
+ return new ReverseNested($name);
+ }
+
+ /**
+ * children aggregation.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-children-aggregation.html
+ *
+ * @param string $name
+ */
+ public function children($name)
+ {
+ throw new NotImplementedException();
+ }
+
+ /**
+ * terms aggregation.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html
+ *
+ * @param string $name
+ *
+ * @return Terms
+ */
+ public function terms($name)
+ {
+ return new Terms($name);
+ }
+
+ /**
+ * significant terms aggregation.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-significantterms-aggregation.html
+ *
+ * @param string $name
+ *
+ * @return SignificantTerms
+ */
+ public function significant_terms($name)
+ {
+ return new SignificantTerms($name);
+ }
+
+ /**
+ * range aggregation.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-range-aggregation.html
+ *
+ * @param string $name
+ *
+ * @return Range
+ */
+ public function range($name)
+ {
+ return new Range($name);
+ }
+
+ /**
+ * date range aggregation.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-daterange-aggregation.html
+ *
+ * @param string $name
+ *
+ * @return DateRange
+ */
+ public function date_range($name)
+ {
+ return new DateRange($name);
+ }
+
+ /**
+ * ipv4 range aggregation.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-iprange-aggregation.html
+ *
+ * @param string $name
+ * @param string $field
+ *
+ * @return IpRange
+ */
+ public function ipv4_range($name, $field)
+ {
+ return new IpRange($name, $field);
+ }
+
+ /**
+ * histogram aggregation.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-histogram-aggregation.html
+ *
+ * @param string $name the name of this aggregation
+ * @param string $field the name of the field on which to perform the aggregation
+ * @param int $interval the interval by which documents will be bucketed
+ *
+ * @return Histogram
+ */
+ public function histogram($name, $field, $interval)
+ {
+ return new Histogram($name, $field, $interval);
+ }
+
+ /**
+ * date histogram aggregation.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-datehistogram-aggregation.html
+ *
+ * @param string $name the name of this aggregation
+ * @param string $field the name of the field on which to perform the aggregation
+ * @param int $interval the interval by which documents will be bucketed
+ *
+ * @return DateHistogram
+ */
+ public function date_histogram($name, $field, $interval)
+ {
+ return new DateHistogram($name, $field, $interval);
+ }
+
+ /**
+ * geo distance aggregation.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geodistance-aggregation.html
+ *
+ * @param string $name the name if this aggregation
+ * @param string $field the field on which to perform this aggregation
+ * @param string|array $origin the point from which distances will be calculated
+ *
+ * @return GeoDistance
+ */
+ public function geo_distance($name, $field, $origin)
+ {
+ return new GeoDistance($name, $field, $origin);
+ }
+
+ /**
+ * geohash grid aggregation.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geohashgrid-aggregation.html
+ *
+ * @param string $name the name of this aggregation
+ * @param string $field the field on which to perform this aggregation
+ *
+ * @return GeohashGrid
+ */
+ public function geohash_grid($name, $field)
+ {
+ return new GeohashGrid($name, $field);
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/DSL/Filter.php b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/DSL/Filter.php
new file mode 100644
index 00000000..1c41239f
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/DSL/Filter.php
@@ -0,0 +1,480 @@
+<?php
+namespace Elastica\QueryBuilder\DSL;
+
+use Elastica\Filter\AbstractFilter;
+use Elastica\Filter\BoolAnd;
+use Elastica\Filter\BoolFilter;
+use Elastica\Filter\BoolNot;
+use Elastica\Filter\BoolOr;
+use Elastica\Filter\Exists;
+use Elastica\Filter\GeoBoundingBox;
+use Elastica\Filter\GeoDistance;
+use Elastica\Filter\GeoDistanceRange;
+use Elastica\Filter\GeohashCell;
+use Elastica\Filter\GeoPolygon;
+use Elastica\Filter\GeoShapePreIndexed;
+use Elastica\Filter\GeoShapeProvided;
+use Elastica\Filter\HasChild;
+use Elastica\Filter\HasParent;
+use Elastica\Filter\Ids;
+use Elastica\Filter\Indices;
+use Elastica\Filter\Limit;
+use Elastica\Filter\MatchAll;
+use Elastica\Filter\Missing;
+use Elastica\Filter\Nested;
+use Elastica\Filter\NumericRange;
+use Elastica\Filter\Prefix;
+use Elastica\Filter\Query as QueryFilter;
+use Elastica\Filter\Range;
+use Elastica\Filter\Regexp;
+use Elastica\Filter\Script;
+use Elastica\Filter\Term;
+use Elastica\Filter\Terms;
+use Elastica\Filter\Type;
+use Elastica\Query\AbstractQuery;
+use Elastica\QueryBuilder\DSL;
+
+/**
+ * elasticsearch filter DSL.
+ *
+ * @author Manuel Andreo Garcia <andreo.garcia@googlemail.com>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-filters.html
+ */
+class Filter implements DSL
+{
+ /**
+ * must return type for QueryBuilder usage.
+ *
+ * @return string
+ */
+ public function getType()
+ {
+ return self::TYPE_FILTER;
+ }
+
+ /**
+ * and filter.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-and-filter.html
+ *
+ * @param AbstractFilter[] $filters
+ *
+ * @return BoolAnd
+ */
+ public function bool_and(array $filters = array())
+ {
+ return new BoolAnd($filters);
+ }
+
+ /**
+ * bool filter.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-filter.html
+ *
+ * @return \Elastica\Filter\Bool
+ */
+ public function bool()
+ {
+ return new BoolFilter();
+ }
+
+ /**
+ * exists filter.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-exists-filter.html
+ *
+ * @param string $field
+ *
+ * @return Exists
+ */
+ public function exists($field)
+ {
+ return new Exists($field);
+ }
+
+ /**
+ * geo bounding box filter.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-bounding-box-filter.html
+ *
+ * @param string $key
+ * @param array $coordinates
+ *
+ * @return GeoBoundingBox
+ */
+ public function geo_bounding_box($key, array $coordinates)
+ {
+ return new GeoBoundingBox($key, $coordinates);
+ }
+
+ /**
+ * geo distance filter.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-filter.html
+ *
+ * @param string $key Key
+ * @param array|string $location Location as array or geohash: array('lat' => 48.86, 'lon' => 2.35) OR 'drm3btev3e86'
+ * @param string $distance Distance
+ *
+ * @return GeoDistance
+ */
+ public function geo_distance($key, $location, $distance)
+ {
+ return new GeoDistance($key, $location, $distance);
+ }
+
+ /**
+ * geo distance rangefilter.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-range-filter.html
+ *
+ * @param string $key
+ * @param array|string $location
+ * @param array $ranges
+ *
+ * @return GeoDistanceRange
+ */
+ public function geo_distance_range($key, $location, array $ranges = array())
+ {
+ return new GeoDistanceRange($key, $location, $ranges);
+ }
+
+ /**
+ * geo polygon filter.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-polygon-filter.html
+ *
+ * @param string $key Key
+ * @param array $points Points making up polygon
+ *
+ * @return GeoPolygon
+ */
+ public function geo_polygon($key, array $points)
+ {
+ return new GeoPolygon($key, $points);
+ }
+
+ /**
+ * provided geo shape filter.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-shape-filter.html#_provided_shape_definition
+ *
+ * @param string $path
+ * @param array $coordinates
+ * @param string $shapeType
+ *
+ * @return GeoShapeProvided
+ */
+ public function geo_shape_provided($path, array $coordinates, $shapeType = GeoShapeProvided::TYPE_ENVELOPE)
+ {
+ return new GeoShapeProvided($path, $coordinates, $shapeType);
+ }
+
+ /**
+ * pre indexed geo shape filter.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-shape-filter.html#_pre_indexed_shape
+ *
+ * @param string $path The path/field of the shape searched
+ * @param string $indexedId Id of the pre-indexed shape
+ * @param string $indexedType Type of the pre-indexed shape
+ * @param string $indexedIndex Index of the pre-indexed shape
+ * @param string $indexedPath Path of the pre-indexed shape
+ *
+ * @return GeoShapePreIndexed
+ */
+ public function geo_shape_pre_indexed($path, $indexedId, $indexedType, $indexedIndex, $indexedPath)
+ {
+ return new GeoShapePreIndexed($path, $indexedId, $indexedType, $indexedIndex, $indexedPath);
+ }
+
+ /**
+ * geohash cell filter.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geohash-cell-filter.html
+ *
+ * @param string $key The field on which to filter
+ * @param array|string $location Location as coordinates array or geohash string ['lat' => 40.3, 'lon' => 45.2]
+ * @param int|string $precision length of geohash prefix or distance (3, or "50m")
+ * @param bool $neighbors If true, filters cells next to the given cell.
+ *
+ * @return GeohashCell
+ */
+ public function geohash_cell($key, $location, $precision = -1, $neighbors = false)
+ {
+ return new GeohashCell($key, $location, $precision, $neighbors);
+ }
+
+ /**
+ * has child filter.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-has-child-filter.html
+ *
+ * @param AbstractQuery|AbstractFilter $query
+ * @param string $type
+ *
+ * @return HasChild
+ */
+ public function has_child($query, $type = null)
+ {
+ return new HasChild($query, $type);
+ }
+
+ /**
+ * has parent filter.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-has-parent-filter.html
+ *
+ * @param AbstractQuery|AbstractFilter $query
+ * @param string $type
+ *
+ * @return HasParent
+ */
+ public function has_parent($query, $type)
+ {
+ return new HasParent($query, $type);
+ }
+
+ /**
+ * ids filter.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-ids-filter.html
+ *
+ * @param string|\Elastica\Type $type
+ * @param array $ids
+ *
+ * @return Ids
+ */
+ public function ids($type = null, array $ids = array())
+ {
+ return new Ids($type, $ids);
+ }
+
+ /**
+ * indices filter.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-indices-filter.html
+ *
+ * @param AbstractFilter $filter filter which will be applied to docs in the specified indices
+ * @param string[] $indices
+ *
+ * @return Indices
+ */
+ public function indices(AbstractFilter $filter, array $indices)
+ {
+ return new Indices($filter, $indices);
+ }
+
+ /**
+ * limit filter.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-limit-filter.html
+ *
+ * @param int $limit Limit
+ *
+ * @return Limit
+ */
+ public function limit($limit)
+ {
+ return new Limit($limit);
+ }
+
+ /**
+ * match all filter.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-all-filter.html
+ *
+ * @return MatchAll
+ */
+ public function match_all()
+ {
+ return new MatchAll();
+ }
+
+ /**
+ * missing filter.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-missing-filter.html
+ *
+ * @param string $field
+ *
+ * @return Missing
+ */
+ public function missing($field = '')
+ {
+ return new Missing($field);
+ }
+
+ /**
+ * nested filter.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-nested-filter.html
+ *
+ * @return Nested
+ */
+ public function nested()
+ {
+ return new Nested();
+ }
+
+ /**
+ * not filter.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-not-filter.html
+ *
+ * @param AbstractFilter $filter
+ *
+ * @return BoolNot
+ */
+ public function bool_not(AbstractFilter $filter)
+ {
+ return new BoolNot($filter);
+ }
+
+ /**
+ * numeric range filter.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/0.90/query-dsl-numeric-range-filter.html
+ *
+ * @param string $fieldName Field name
+ * @param array $args Field arguments
+ *
+ * @return NumericRange
+ */
+ public function numeric_range($fieldName = '', array $args = array())
+ {
+ return new NumericRange($fieldName, $args);
+ }
+
+ /**
+ * or filter.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-or-filter.html
+ *
+ * @param AbstractFilter[] $filters
+ *
+ * @return BoolOr
+ */
+ public function bool_or(array $filters = array())
+ {
+ return new BoolOr($filters);
+ }
+
+ /**
+ * prefix filter.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-prefix-filter.html
+ *
+ * @param string $field
+ * @param string $prefix
+ *
+ * @return Prefix
+ */
+ public function prefix($field = '', $prefix = '')
+ {
+ return new Prefix($field, $prefix);
+ }
+
+ /**
+ * query filter.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-filter.html
+ *
+ * @param array|AbstractQuery $query
+ *
+ * @return QueryFilter
+ */
+ public function query($query = null)
+ {
+ return new QueryFilter($query);
+ }
+
+ /**
+ * range filter.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-filter.html
+ *
+ * @param string $fieldName
+ * @param array $args
+ *
+ * @return Range
+ */
+ public function range($fieldName = '', array $args = array())
+ {
+ return new Range($fieldName, $args);
+ }
+
+ /**
+ * regexp filter.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-regexp-filter.html
+ *
+ * @param string $field Field name
+ * @param string $regexp Regular expression
+ * @param array $options Regular expression options
+ *
+ * @return Regexp
+ */
+ public function regexp($field = '', $regexp = '', $options = array())
+ {
+ return new Regexp($field, $regexp, $options);
+ }
+
+ /**
+ * script filter.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-script-filter.html
+ *
+ * @param array|string|\Elastica\Script $script
+ *
+ * @return Script
+ */
+ public function script($script = null)
+ {
+ return new Script($script);
+ }
+
+ /**
+ * term filter.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-filter.html
+ *
+ * @param array $term
+ *
+ * @return Term
+ */
+ public function term(array $term = array())
+ {
+ return new Term($term);
+ }
+
+ /**
+ * terms filter.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-filter.html
+ *
+ * @param string $key
+ * @param array $terms
+ *
+ * @return Terms
+ */
+ public function terms($key = '', array $terms = array())
+ {
+ return new Terms($key, $terms);
+ }
+
+ /**
+ * type filter.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-type-filter.html
+ *
+ * @param string $type
+ *
+ * @return Type
+ */
+ public function type($type = null)
+ {
+ return new Type($type);
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/DSL/Query.php b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/DSL/Query.php
new file mode 100644
index 00000000..7d1aca68
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/DSL/Query.php
@@ -0,0 +1,586 @@
+<?php
+namespace Elastica\QueryBuilder\DSL;
+
+use Elastica\Exception\NotImplementedException;
+use Elastica\Filter\AbstractFilter;
+use Elastica\Query\AbstractQuery;
+use Elastica\Query\BoolQuery;
+use Elastica\Query\Boosting;
+use Elastica\Query\Common;
+use Elastica\Query\ConstantScore;
+use Elastica\Query\DisMax;
+use Elastica\Query\Filtered;
+use Elastica\Query\FunctionScore;
+use Elastica\Query\Fuzzy;
+use Elastica\Query\FuzzyLikeThis;
+use Elastica\Query\HasChild;
+use Elastica\Query\HasParent;
+use Elastica\Query\Ids;
+use Elastica\Query\Match;
+use Elastica\Query\MatchAll;
+use Elastica\Query\MoreLikeThis;
+use Elastica\Query\MultiMatch;
+use Elastica\Query\Nested;
+use Elastica\Query\Prefix;
+use Elastica\Query\QueryString;
+use Elastica\Query\Range;
+use Elastica\Query\Regexp;
+use Elastica\Query\SimpleQueryString;
+use Elastica\Query\Term;
+use Elastica\Query\Terms;
+use Elastica\Query\TopChildren;
+use Elastica\Query\Wildcard;
+use Elastica\QueryBuilder\DSL;
+
+/**
+ * elasticsearch query DSL.
+ *
+ * @author Manuel Andreo Garcia <andreo.garcia@googlemail.com>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-queries.html
+ */
+class Query implements DSL
+{
+ /**
+ * must return type for QueryBuilder usage.
+ *
+ * @return string
+ */
+ public function getType()
+ {
+ return self::TYPE_QUERY;
+ }
+
+ /**
+ * match query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html
+ *
+ * @param string $field
+ * @param mixed $values
+ *
+ * @return Match
+ */
+ public function match($field = null, $values = null)
+ {
+ return new Match($field, $values);
+ }
+
+ /**
+ * multi match query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html
+ *
+ * @return \Elastica\Query\MultiMatch
+ */
+ public function multi_match()
+ {
+ return new MultiMatch();
+ }
+
+ /**
+ * bool query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html
+ *
+ * @return \Elastica\Query\BoolQuery
+ */
+ public function bool()
+ {
+ return new BoolQuery();
+ }
+
+ /**
+ * boosting query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-boosting-query.html
+ *
+ * @return Boosting
+ */
+ public function boosting()
+ {
+ return new Boosting();
+ }
+
+ /**
+ * common terms query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-common-terms-query.html
+ *
+ * @param string $field
+ * @param string $query
+ * @param float $cutoffFrequency percentage in decimal form (.001 == 0.1%)
+ *
+ * @return Common
+ */
+ public function common_terms($field, $query, $cutoffFrequency)
+ {
+ return new Common($field, $query, $cutoffFrequency);
+ }
+
+ /**
+ * custom filters score query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/0.90/query-dsl-custom-filters-score-query.html
+ */
+ public function custom_filters_score()
+ {
+ throw new NotImplementedException();
+ }
+
+ /**
+ * custom score query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/0.90/query-dsl-custom-score-query.html
+ */
+ public function custom_score()
+ {
+ throw new NotImplementedException();
+ }
+
+ /**
+ * custom boost factor query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/0.90/query-dsl-custom-boost-factor-query.html
+ */
+ public function custom_boost_factor()
+ {
+ throw new NotImplementedException();
+ }
+
+ /**
+ * constant score query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-constant-score-query.html
+ *
+ * @param null|\Elastica\Filter\AbstractFilter|array $filter
+ *
+ * @return ConstantScore
+ */
+ public function constant_score($filter = null)
+ {
+ return new ConstantScore($filter);
+ }
+
+ /**
+ * dis max query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-dis-max-query.html
+ *
+ * @return DisMax
+ */
+ public function dis_max()
+ {
+ return new DisMax();
+ }
+
+ /**
+ * field query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/0.90/query-dsl-field-query.html
+ */
+ public function field()
+ {
+ throw new NotImplementedException();
+ }
+
+ /**
+ * filtered query.
+ *
+ * @param AbstractFilter $filter
+ * @param AbstractQuery $query
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-filtered-query.html
+ *
+ * @return Filtered
+ */
+ public function filtered(AbstractQuery $query = null, AbstractFilter $filter = null)
+ {
+ return new Filtered($query, $filter);
+ }
+
+ /**
+ * fuzzy like this query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-flt-query.html
+ *
+ * @return FuzzyLikeThis
+ */
+ public function fuzzy_like_this()
+ {
+ return new FuzzyLikeThis();
+ }
+
+ /**
+ * fuzzy like this field query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-flt-field-query.html
+ */
+ public function fuzzy_like_this_field()
+ {
+ throw new NotImplementedException();
+ }
+
+ /**
+ * function score query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html
+ *
+ * @return FunctionScore
+ */
+ public function function_score()
+ {
+ return new FunctionScore();
+ }
+
+ /**
+ * fuzzy query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-fuzzy-query.html
+ *
+ * @param string $fieldName Field name
+ * @param string $value String to search for
+ *
+ * @return Fuzzy
+ */
+ public function fuzzy($fieldName = null, $value = null)
+ {
+ return new Fuzzy($fieldName, $value);
+ }
+
+ /**
+ * geo shape query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-shape-query.html
+ */
+ public function geo_shape()
+ {
+ throw new NotImplementedException();
+ }
+
+ /**
+ * has child query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-has-child-query.html
+ *
+ * @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query
+ * @param string $type Parent document type
+ *
+ * @return HasChild
+ */
+ public function has_child($query, $type = null)
+ {
+ return new HasChild($query, $type);
+ }
+
+ /**
+ * has parent query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-has-parent-query.html
+ *
+ * @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query
+ * @param string $type Parent document type
+ *
+ * @return HasParent
+ */
+ public function has_parent($query, $type)
+ {
+ return new HasParent($query, $type);
+ }
+
+ /**
+ * ids query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-ids-query.html
+ *
+ * @param array|string|\Elastica\Type $type
+ * @param array $ids
+ *
+ * @return Ids
+ */
+ public function ids($type = null, array $ids = array())
+ {
+ return new Ids($type, $ids);
+ }
+
+ /**
+ * indices query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-indices-query.html
+ */
+ public function indices()
+ {
+ throw new NotImplementedException();
+ }
+
+ /**
+ * match all query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-all-query.html
+ *
+ * @return MatchAll
+ */
+ public function match_all()
+ {
+ return new MatchAll();
+ }
+
+ /**
+ * more like this query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-mlt-query.html
+ *
+ * @return MoreLikeThis
+ */
+ public function more_like_this()
+ {
+ return new MoreLikeThis();
+ }
+
+ /**
+ * more_like_this_field query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/1.4/query-dsl-mlt-field-query.html
+ * @deprecated More Like This Field query is deprecated as of ES 1.4 and will be removed in ES 2.0
+ */
+ public function more_like_this_field()
+ {
+ throw new NotImplementedException();
+ }
+
+ /**
+ * nested query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-nested-query.html
+ *
+ * @return Nested
+ */
+ public function nested()
+ {
+ return new Nested();
+ }
+
+ /**
+ * prefix query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-prefix-query.html
+ *
+ * @param array $prefix Prefix array
+ *
+ * @return Prefix
+ */
+ public function prefix(array $prefix = array())
+ {
+ return new Prefix($prefix);
+ }
+
+ /**
+ * query string query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html
+ *
+ * @param string $queryString OPTIONAL Query string for object
+ *
+ * @return QueryString
+ */
+ public function query_string($queryString = '')
+ {
+ return new QueryString($queryString);
+ }
+
+ /**
+ * simple_query_string query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-simple-query-string-query.html
+ *
+ * @param string $query
+ * @param array $fields
+ *
+ * @return SimpleQueryString
+ */
+ public function simple_query_string($query, array $fields = array())
+ {
+ return new SimpleQueryString($query, $fields);
+ }
+
+ /**
+ * range query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-query.html
+ *
+ * @param string $fieldName
+ * @param array $args
+ *
+ * @return Range
+ */
+ public function range($fieldName = null, array $args = array())
+ {
+ return new Range($fieldName, $args);
+ }
+
+ /**
+ * regexp query.
+ *
+ * @param string $key
+ * @param string $value
+ * @param float $boost
+ *
+ * @return Regexp
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-regexp-query.html
+ */
+ public function regexp($key = '', $value = null, $boost = 1.0)
+ {
+ return new Regexp($key, $value, $boost);
+ }
+
+ /**
+ * span first query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-first-query.html
+ */
+ public function span_first()
+ {
+ throw new NotImplementedException();
+ }
+
+ /**
+ * span multi term query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-multi-term-query.html
+ */
+ public function span_multi_term()
+ {
+ throw new NotImplementedException();
+ }
+
+ /**
+ * span near query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-near-query.html
+ */
+ public function span_near()
+ {
+ throw new NotImplementedException();
+ }
+
+ /**
+ * span not query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-not-query.html
+ */
+ public function span_not()
+ {
+ throw new NotImplementedException();
+ }
+
+ /**
+ * span or query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-or-query.html
+ */
+ public function span_or()
+ {
+ throw new NotImplementedException();
+ }
+
+ /**
+ * span term query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-span-term-query.html
+ */
+ public function span_term()
+ {
+ throw new NotImplementedException();
+ }
+
+ /**
+ * term query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html
+ *
+ * @param array $term
+ *
+ * @return Term
+ */
+ public function term(array $term = array())
+ {
+ return new Term($term);
+ }
+
+ /**
+ * terms query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-query.html
+ *
+ * @param string $key
+ * @param array $terms
+ *
+ * @return Terms
+ */
+ public function terms($key = '', array $terms = array())
+ {
+ return new Terms($key, $terms);
+ }
+
+ /**
+ * top children query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-top-children-query.html
+ *
+ * @param string|AbstractQuery|\Elastica\Query $query
+ * @param string $type
+ *
+ * @return TopChildren
+ */
+ public function top_children($query, $type = null)
+ {
+ return new TopChildren($query, $type);
+ }
+
+ /**
+ * wildcard query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-wildcard-query.html
+ *
+ * @param string $key OPTIONAL Wildcard key
+ * @param string $value OPTIONAL Wildcard value
+ * @param float $boost OPTIONAL Boost value (default = 1)
+ *
+ * @return Wildcard
+ */
+ public function wildcard($key = '', $value = null, $boost = 1.0)
+ {
+ return new Wildcard($key, $value, $boost);
+ }
+
+ /**
+ * text query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/0.90/query-dsl-text-query.html
+ */
+ public function text()
+ {
+ throw new NotImplementedException();
+ }
+
+ /**
+ * minimum should match query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-minimum-should-match.html
+ */
+ public function minimum_should_match()
+ {
+ throw new NotImplementedException();
+ }
+
+ /**
+ * template query.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-template-query.html
+ */
+ public function template()
+ {
+ throw new NotImplementedException();
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/DSL/Suggest.php b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/DSL/Suggest.php
new file mode 100644
index 00000000..9a54ccde
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/DSL/Suggest.php
@@ -0,0 +1,83 @@
+<?php
+namespace Elastica\QueryBuilder\DSL;
+
+use Elastica\Exception\NotImplementedException;
+use Elastica\QueryBuilder\DSL;
+use Elastica\Suggest\Completion;
+use Elastica\Suggest\Phrase;
+use Elastica\Suggest\Term;
+
+/**
+ * elasticsearch suggesters DSL.
+ *
+ * @author Manuel Andreo Garcia <andreo.garcia@googlemail.com>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters.html
+ */
+class Suggest implements DSL
+{
+ /**
+ * must return type for QueryBuilder usage.
+ *
+ * @return string
+ */
+ public function getType()
+ {
+ return self::TYPE_SUGGEST;
+ }
+
+ /**
+ * term suggester.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-term.html
+ *
+ * @param $name
+ * @param $field
+ *
+ * @return Term
+ */
+ public function term($name, $field)
+ {
+ return new Term($name, $field);
+ }
+
+ /**
+ * phrase suggester.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-phrase.html
+ *
+ * @param $name
+ * @param $field
+ *
+ * @return Phrase
+ */
+ public function phrase($name, $field)
+ {
+ return new Phrase($name, $field);
+ }
+
+ /**
+ * completion suggester.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html
+ *
+ * @param string $name
+ * @param string $field
+ *
+ * @return Completion
+ */
+ public function completion($name, $field)
+ {
+ return new Completion($name, $field);
+ }
+
+ /**
+ * context suggester.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/suggester-context.html
+ */
+ public function context()
+ {
+ throw new NotImplementedException();
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Facade.php b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Facade.php
new file mode 100644
index 00000000..b0f6da82
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Facade.php
@@ -0,0 +1,64 @@
+<?php
+namespace Elastica\QueryBuilder;
+
+use Elastica\Exception\QueryBuilderException;
+
+/**
+ * Facade for a specific DSL object.
+ *
+ * @author Manuel Andreo Garcia <andreo.garcia@googlemail.com>
+ **/
+class Facade
+{
+ /**
+ * @var DSL
+ */
+ private $_dsl;
+
+ /**
+ * @var Version
+ */
+ private $_version;
+
+ /**
+ * Constructor.
+ *
+ * @param DSL $dsl
+ * @param Version $version
+ */
+ public function __construct(DSL $dsl, Version $version)
+ {
+ $this->_dsl = $dsl;
+ $this->_version = $version;
+ }
+
+ /**
+ * Executes DSL methods.
+ *
+ * @param string $name
+ * @param array $arguments
+ *
+ * @throws QueryBuilderException
+ *
+ * @return mixed
+ */
+ public function __call($name, array $arguments)
+ {
+ // defined check
+ if (false === method_exists($this->_dsl, $name)) {
+ throw new QueryBuilderException(
+ 'undefined '.$this->_dsl->getType().' "'.$name.'"'
+ );
+ }
+
+ // version support check
+ if (false === $this->_version->supports($name, $this->_dsl->getType())) {
+ $reflection = new \ReflectionClass($this->_version);
+ throw new QueryBuilderException(
+ $this->_dsl->getType().' "'.$name.'" in '.$reflection->getShortName().' not supported'
+ );
+ }
+
+ return call_user_func_array(array($this->_dsl, $name), $arguments);
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version.php b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version.php
new file mode 100644
index 00000000..5230600d
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version.php
@@ -0,0 +1,101 @@
+<?php
+namespace Elastica\QueryBuilder;
+
+/**
+ * Abstract Version class.
+ *
+ * @author Manuel Andreo Garcia <andreo.garcia@googlemail.com>
+ */
+abstract class Version
+{
+ /**
+ * supported query methods.
+ *
+ * @var string[]
+ */
+ protected $queries = array();
+
+ /**
+ * supported filter methods.
+ *
+ * @var string[]
+ */
+ protected $filters = array();
+
+ /**
+ * supported aggregation methods.
+ *
+ * @var string[]
+ */
+ protected $aggregations = array();
+
+ /**
+ * supported $suggester methods.
+ *
+ * @var string[]
+ */
+ protected $suggesters = array();
+
+ /**
+ * returns true if $name is supported, false otherwise.
+ *
+ * @param string $name
+ * @param $type
+ *
+ * @return bool
+ */
+ public function supports($name, $type)
+ {
+ switch ($type) {
+ case DSL::TYPE_QUERY:
+ $supports = in_array($name, $this->queries);
+ break;
+ case DSL::TYPE_FILTER:
+ $supports = in_array($name, $this->filters);
+ break;
+ case DSL::TYPE_AGGREGATION:
+ $supports = in_array($name, $this->aggregations);
+ break;
+ case DSL::TYPE_SUGGEST:
+ $supports = in_array($name, $this->suggesters);
+ break;
+ default:
+ // disables version check in Facade for custom DSL objects
+ $supports = true;
+ }
+
+ return $supports;
+ }
+
+ /**
+ * @return string[]
+ */
+ public function getAggregations()
+ {
+ return $this->aggregations;
+ }
+
+ /**
+ * @return string[]
+ */
+ public function getFilters()
+ {
+ return $this->filters;
+ }
+
+ /**
+ * @return string[]
+ */
+ public function getQueries()
+ {
+ return $this->queries;
+ }
+
+ /**
+ * @return string[]
+ */
+ public function getSuggesters()
+ {
+ return $this->suggesters;
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version/Version090.php b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version/Version090.php
new file mode 100644
index 00000000..193ba852
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version/Version090.php
@@ -0,0 +1,97 @@
+<?php
+namespace Elastica\QueryBuilder\Version;
+
+use Elastica\QueryBuilder\Version;
+
+/**
+ * elasticsearch 0.9 DSL.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/0.90/index.html
+ *
+ * @author Manuel Andreo Garcia <andreo.garcia@googlemail.com>
+ */
+class Version090 extends Version
+{
+ protected $queries = array(
+ 'match',
+ 'multi_match',
+ 'bool',
+ 'boosting',
+ 'common_terms',
+ 'custom_filters_score',
+ 'custom_score',
+ 'custom_boost_factor',
+ 'constant_score',
+ 'dis_max',
+ 'field',
+ 'filtered',
+ 'fuzzy_like_this',
+ 'fuzzy_like_this_field',
+ 'function_score',
+ 'fuzzy',
+ 'geo_shape',
+ 'has_child',
+ 'has_parent',
+ 'ids',
+ 'indices',
+ 'match_all',
+ 'more_like_this',
+ 'more_like_this_field',
+ 'nested',
+ 'prefix',
+ 'query_string',
+ 'simple_query_string',
+ 'range',
+ 'regexp',
+ 'span_first',
+ 'span_multi_term',
+ 'span_near',
+ 'span_not',
+ 'span_or',
+ 'span_term',
+ 'term',
+ 'terms',
+ 'top_children',
+ 'wildcard',
+ 'text',
+ 'minimum_should_match',
+ );
+
+ protected $filters = array(
+ 'bool_and', // original: bool
+ 'bool',
+ 'exists',
+ 'geo_bounding_box',
+ 'geo_distance',
+ 'geo_distance_range',
+ 'geo_polygon',
+ 'geo_shape_provided', // original: geo_shape
+ 'geo_shape_pre_indexed', // original: geo_shape
+ 'geohash_cell',
+ 'has_child',
+ 'has_parent',
+ 'ids',
+ 'indices',
+ 'limit',
+ 'match_all',
+ 'missing',
+ 'nested',
+ 'bool_not', // original: not
+ 'numeric_range',
+ 'bool_or', // original: or
+ 'prefix',
+ 'query',
+ 'range',
+ 'regexp',
+ 'script',
+ 'term',
+ 'terms',
+ 'type',
+ );
+
+ protected $suggesters = array(
+ 'term',
+ 'phrase',
+ 'completion',
+ );
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version/Version100.php b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version/Version100.php
new file mode 100644
index 00000000..66a5c9cd
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version/Version100.php
@@ -0,0 +1,123 @@
+<?php
+namespace Elastica\QueryBuilder\Version;
+
+use Elastica\QueryBuilder\Version;
+
+/**
+ * elasticsearch 1.0 DSL.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/1.x/index.html
+ *
+ * @author Manuel Andreo Garcia <andreo.garcia@googlemail.com>
+ */
+class Version100 extends Version
+{
+ protected $queries = array(
+ 'match',
+ 'multi_match',
+ 'bool',
+ 'boosting',
+ 'common_terms',
+ 'constant_score',
+ 'dis_max',
+ 'filtered',
+ 'fuzzy_like_this',
+ 'fuzzy_like_this_field',
+ 'function_score',
+ 'fuzzy',
+ 'geo_shape',
+ 'has_child',
+ 'has_parent',
+ 'ids',
+ 'indices',
+ 'match_all',
+ 'more_like_this',
+ 'more_like_this_field',
+ 'nested',
+ 'prefix',
+ 'query_string',
+ 'simple_query_string',
+ 'range',
+ 'regexp',
+ 'span_first',
+ 'span_multi_term',
+ 'span_near',
+ 'span_not',
+ 'span_or',
+ 'span_term',
+ 'term',
+ 'terms',
+ 'top_children',
+ 'wildcard',
+ 'minimum_should_match',
+
+ // removed in 1.0.0
+ // 'text'
+ // 'field'
+ // 'custom_filters_score'
+ // 'custom_score'
+ // 'custom_boost_factor'
+ );
+
+ protected $filters = array(
+ 'bool_and', // original: bool
+ 'bool',
+ 'exists',
+ 'geo_bounding_box',
+ 'geo_distance',
+ 'geo_distance_range',
+ 'geo_polygon',
+ 'geo_shape_provided', // original: geo_shape
+ 'geo_shape_pre_indexed', // original: geo_shape
+ 'geohash_cell',
+ 'has_child',
+ 'has_parent',
+ 'ids',
+ 'indices',
+ 'limit',
+ 'match_all',
+ 'missing',
+ 'nested',
+ 'bool_not', // original: not
+ 'bool_or', // original: or
+ 'prefix',
+ 'query',
+ 'range',
+ 'regexp',
+ 'script',
+ 'term',
+ 'terms',
+ 'type',
+
+ // removed in 1.0.0
+ // 'numeric_range'
+ );
+
+ protected $aggregations = array(
+ 'min',
+ 'max',
+ 'sum',
+ 'avg',
+ 'stats',
+ 'extended_stats',
+ 'value_count',
+ 'global_agg', // original: global
+ 'filter',
+ 'missing',
+ 'nested',
+ 'terms',
+ 'range',
+ 'date_range',
+ 'ipv4_range',
+ 'histogram',
+ 'date_histogram',
+ 'geo_distance',
+ 'geohash_grid',
+ );
+
+ protected $suggesters = array(
+ 'term',
+ 'phrase',
+ 'completion',
+ );
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version/Version110.php b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version/Version110.php
new file mode 100644
index 00000000..b6465e76
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version/Version110.php
@@ -0,0 +1,131 @@
+<?php
+namespace Elastica\QueryBuilder\Version;
+
+use Elastica\QueryBuilder\Version;
+
+/**
+ * elasticsearch 1.1 DSL.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/1.x/index.html
+ *
+ * @author Manuel Andreo Garcia <andreo.garcia@googlemail.com>
+ */
+class Version110 extends Version
+{
+ protected $queries = array(
+ 'match',
+ 'multi_match',
+ 'bool',
+ 'boosting',
+ 'common_terms',
+ 'constant_score',
+ 'dis_max',
+ 'filtered',
+ 'fuzzy_like_this',
+ 'fuzzy_like_this_field',
+ 'function_score',
+ 'fuzzy',
+ 'geo_shape',
+ 'has_child',
+ 'has_parent',
+ 'ids',
+ 'indices',
+ 'match_all',
+ 'more_like_this',
+ 'more_like_this_field',
+ 'nested',
+ 'prefix',
+ 'query_string',
+ 'simple_query_string',
+ 'range',
+ 'regexp',
+ 'span_first',
+ 'span_multi_term',
+ 'span_near',
+ 'span_not',
+ 'span_or',
+ 'span_term',
+ 'term',
+ 'terms',
+ 'top_children',
+ 'wildcard',
+ 'minimum_should_match',
+
+ // removed in 1.0.0
+ // 'text'
+ // 'field'
+ // 'custom_filters_score'
+ // 'custom_score'
+ // 'custom_boost_factor'
+
+ // new in 1.1.0
+ 'template',
+ );
+
+ protected $filters = array(
+ 'bool_and', // original: bool
+ 'bool',
+ 'exists',
+ 'geo_bounding_box',
+ 'geo_distance',
+ 'geo_distance_range',
+ 'geo_polygon',
+ 'geo_shape_provided', // original: geo_shape
+ 'geo_shape_pre_indexed', // original: geo_shape
+ 'geohash_cell',
+ 'has_child',
+ 'has_parent',
+ 'ids',
+ 'indices',
+ 'limit',
+ 'match_all',
+ 'missing',
+ 'nested',
+ 'bool_not', // original: not
+ 'bool_or', // original: or
+ 'prefix',
+ 'query',
+ 'range',
+ 'regexp',
+ 'script',
+ 'term',
+ 'terms',
+ 'type',
+
+ // removed in 1.0.0
+ // 'numeric_range'
+ );
+
+ protected $aggregations = array(
+ 'min',
+ 'max',
+ 'sum',
+ 'avg',
+ 'stats',
+ 'extended_stats',
+ 'value_count',
+ 'global_agg', // original: global
+ 'filter',
+ 'missing',
+ 'nested',
+ 'terms',
+ 'range',
+ 'date_range',
+ 'ipv4_range',
+ 'histogram',
+ 'date_histogram',
+ 'geo_distance',
+ 'geohash_grid',
+
+ // new in 1.1.0
+ 'percentiles',
+ 'cardinality',
+ 'significant_terms',
+ );
+
+ protected $suggesters = array(
+ 'term',
+ 'phrase',
+ 'completion',
+ );
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version/Version120.php b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version/Version120.php
new file mode 100644
index 00000000..f74e3bdc
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version/Version120.php
@@ -0,0 +1,137 @@
+<?php
+namespace Elastica\QueryBuilder\Version;
+
+use Elastica\QueryBuilder\Version;
+
+/**
+ * elasticsearch 1.2 DSL.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/1.x/index.html
+ *
+ * @author Manuel Andreo Garcia <andreo.garcia@googlemail.com>
+ */
+class Version120 extends Version
+{
+ protected $queries = array(
+ 'match',
+ 'multi_match',
+ 'bool',
+ 'boosting',
+ 'common_terms',
+ 'constant_score',
+ 'dis_max',
+ 'filtered',
+ 'fuzzy_like_this',
+ 'fuzzy_like_this_field',
+ 'function_score',
+ 'fuzzy',
+ 'geo_shape',
+ 'has_child',
+ 'has_parent',
+ 'ids',
+ 'indices',
+ 'match_all',
+ 'more_like_this',
+ 'more_like_this_field',
+ 'nested',
+ 'prefix',
+ 'query_string',
+ 'simple_query_string',
+ 'range',
+ 'regexp',
+ 'span_first',
+ 'span_multi_term',
+ 'span_near',
+ 'span_not',
+ 'span_or',
+ 'span_term',
+ 'term',
+ 'terms',
+ 'top_children',
+ 'wildcard',
+ 'minimum_should_match',
+
+ // removed in 1.0.0
+ // 'text'
+ // 'field'
+ // 'custom_filters_score'
+ // 'custom_score'
+ // 'custom_boost_factor'
+
+ // new in 1.1.0
+ 'template',
+ );
+
+ protected $filters = array(
+ 'bool_and', // original: bool
+ 'bool',
+ 'exists',
+ 'geo_bounding_box',
+ 'geo_distance',
+ 'geo_distance_range',
+ 'geo_polygon',
+ 'geo_shape_provided', // original: geo_shape
+ 'geo_shape_pre_indexed', // original: geo_shape
+ 'geohash_cell',
+ 'has_child',
+ 'has_parent',
+ 'ids',
+ 'indices',
+ 'limit',
+ 'match_all',
+ 'missing',
+ 'nested',
+ 'bool_not', // original: not
+ 'bool_or', // original: or
+ 'prefix',
+ 'query',
+ 'range',
+ 'regexp',
+ 'script',
+ 'term',
+ 'terms',
+ 'type',
+
+ // removed in 1.0.0
+ // 'numeric_range'
+ );
+
+ protected $aggregations = array(
+ 'min',
+ 'max',
+ 'sum',
+ 'avg',
+ 'stats',
+ 'extended_stats',
+ 'value_count',
+ 'global_agg', // original: global
+ 'filter',
+ 'missing',
+ 'nested',
+ 'terms',
+ 'range',
+ 'date_range',
+ 'ipv4_range',
+ 'histogram',
+ 'date_histogram',
+ 'geo_distance',
+ 'geohash_grid',
+
+ // new in 1.1.0
+ 'percentiles',
+ 'cardinality',
+ 'significant_terms',
+
+ // new in 1.2.0
+ 'reverse_nested',
+ );
+
+ protected $suggesters = array(
+ 'term',
+ 'phrase',
+ 'completion',
+
+ // new in 1.2.0
+ 'context',
+ );
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version/Version130.php b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version/Version130.php
new file mode 100644
index 00000000..ad52e3e7
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version/Version130.php
@@ -0,0 +1,142 @@
+<?php
+namespace Elastica\QueryBuilder\Version;
+
+use Elastica\QueryBuilder\Version;
+
+/**
+ * elasticsearch 1.3 DSL.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/1.3/index.html
+ *
+ * @author Manuel Andreo Garcia <andreo.garcia@googlemail.com>
+ */
+class Version130 extends Version
+{
+ protected $queries = array(
+ 'match',
+ 'multi_match',
+ 'bool',
+ 'boosting',
+ 'common_terms',
+ 'constant_score',
+ 'dis_max',
+ 'filtered',
+ 'fuzzy_like_this',
+ 'fuzzy_like_this_field',
+ 'function_score',
+ 'fuzzy',
+ 'geo_shape',
+ 'has_child',
+ 'has_parent',
+ 'ids',
+ 'indices',
+ 'match_all',
+ 'more_like_this',
+ 'more_like_this_field',
+ 'nested',
+ 'prefix',
+ 'query_string',
+ 'simple_query_string',
+ 'range',
+ 'regexp',
+ 'span_first',
+ 'span_multi_term',
+ 'span_near',
+ 'span_not',
+ 'span_or',
+ 'span_term',
+ 'term',
+ 'terms',
+ 'top_children',
+ 'wildcard',
+ 'minimum_should_match',
+
+ // removed in 1.0.0
+ // 'text'
+ // 'field'
+ // 'custom_filters_score'
+ // 'custom_score'
+ // 'custom_boost_factor'
+
+ // new in 1.1.0
+ 'template',
+ );
+
+ protected $filters = array(
+ 'bool_and', // original: bool
+ 'bool',
+ 'exists',
+ 'geo_bounding_box',
+ 'geo_distance',
+ 'geo_distance_range',
+ 'geo_polygon',
+ 'geo_shape_provided', // original: geo_shape
+ 'geo_shape_pre_indexed', // original: geo_shape
+ 'geohash_cell',
+ 'has_child',
+ 'has_parent',
+ 'ids',
+ 'indices',
+ 'limit',
+ 'match_all',
+ 'missing',
+ 'nested',
+ 'bool_not', // original: not
+ 'bool_or', // original: or
+ 'prefix',
+ 'query',
+ 'range',
+ 'regexp',
+ 'script',
+ 'term',
+ 'terms',
+ 'type',
+
+ // removed in 1.0.0
+ // 'numeric_range'
+ );
+
+ protected $aggregations = array(
+ 'min',
+ 'max',
+ 'sum',
+ 'avg',
+ 'stats',
+ 'extended_stats',
+ 'value_count',
+ 'global_agg', // original: global
+ 'filter',
+ 'missing',
+ 'nested',
+ 'terms',
+ 'range',
+ 'date_range',
+ 'ipv4_range',
+ 'histogram',
+ 'date_histogram',
+ 'geo_distance',
+ 'geohash_grid',
+
+ // new in 1.1.0
+ 'percentiles',
+ 'cardinality',
+ 'significant_terms',
+
+ // new in 1.2.0
+ 'reverse_nested',
+
+ // new in 1.3.0
+ 'percentile_ranks',
+ 'geo_bounds',
+ 'top_hits',
+ );
+
+ protected $suggesters = array(
+ 'term',
+ 'phrase',
+ 'completion',
+
+ // new in 1.2.0
+ 'context',
+ );
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version/Version140.php b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version/Version140.php
new file mode 100644
index 00000000..7b5d73e3
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version/Version140.php
@@ -0,0 +1,145 @@
+<?php
+namespace Elastica\QueryBuilder\Version;
+
+/**
+ * elasticsearch 1.4 DSL.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/1.4/index.html
+ *
+ * @author Manuel Andreo Garcia <andreo.garcia@googlemail.com>
+ */
+class Version140 extends Version130
+{
+ protected $queries = array(
+ 'match',
+ 'multi_match',
+ 'bool',
+ 'boosting',
+ 'common_terms',
+ 'constant_score',
+ 'dis_max',
+ 'filtered',
+ 'fuzzy_like_this',
+ 'fuzzy_like_this_field',
+ 'function_score',
+ 'fuzzy',
+ 'geo_shape',
+ 'has_child',
+ 'has_parent',
+ 'ids',
+ 'indices',
+ 'match_all',
+ 'more_like_this',
+ 'more_like_this_field',
+ 'nested',
+ 'prefix',
+ 'query_string',
+ 'simple_query_string',
+ 'range',
+ 'regexp',
+ 'span_first',
+ 'span_multi_term',
+ 'span_near',
+ 'span_not',
+ 'span_or',
+ 'span_term',
+ 'term',
+ 'terms',
+ 'top_children',
+ 'wildcard',
+ 'minimum_should_match',
+
+ // removed in 1.0.0
+ // 'text'
+ // 'field'
+ // 'custom_filters_score'
+ // 'custom_score'
+ // 'custom_boost_factor'
+
+ // new in 1.1.0
+ 'template',
+ );
+
+ protected $filters = array(
+ 'bool_and', // original: bool
+ 'bool',
+ 'exists',
+ 'geo_bounding_box',
+ 'geo_distance',
+ 'geo_distance_range',
+ 'geo_polygon',
+ 'geo_shape_provided', // original: geo_shape
+ 'geo_shape_pre_indexed', // original: geo_shape
+ 'geohash_cell',
+ 'has_child',
+ 'has_parent',
+ 'ids',
+ 'indices',
+ 'limit',
+ 'match_all',
+ 'missing',
+ 'nested',
+ 'bool_not', // original: not
+ 'bool_or', // original: or
+ 'prefix',
+ 'query',
+ 'range',
+ 'regexp',
+ 'script',
+ 'term',
+ 'terms',
+ 'type',
+
+ // removed in 1.0.0
+ // 'numeric_range'
+ );
+
+ protected $aggregations = array(
+ 'min',
+ 'max',
+ 'sum',
+ 'avg',
+ 'stats',
+ 'extended_stats',
+ 'value_count',
+ 'global_agg', // original: global
+ 'filter',
+ 'missing',
+ 'nested',
+ 'terms',
+ 'range',
+ 'date_range',
+ 'ipv4_range',
+ 'histogram',
+ 'date_histogram',
+ 'geo_distance',
+ 'geohash_grid',
+
+ // new in 1.1.0
+ 'percentiles',
+ 'cardinality',
+ 'significant_terms',
+
+ // new in 1.2.0
+ 'reverse_nested',
+
+ // new in 1.3.0
+ 'percentile_ranks',
+ 'geo_bounds',
+ 'top_hits',
+
+ // new in 1.4.0
+ 'scripted_metric',
+ 'filters',
+ 'children',
+ );
+
+ protected $suggesters = array(
+ 'term',
+ 'phrase',
+ 'completion',
+
+ // new in 1.2.0
+ 'context',
+ );
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version/Version150.php b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version/Version150.php
new file mode 100644
index 00000000..fcb5e087
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version/Version150.php
@@ -0,0 +1,14 @@
+<?php
+namespace Elastica\QueryBuilder\Version;
+
+/**
+ * elasticsearch 1.5 DSL.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/1.5/index.html
+ *
+ * @author Igor Denisenko <im.denisenko@yahoo.com>
+ */
+class Version150 extends Version140
+{
+ // nothing was added nor removed
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Request.php b/vendor/ruflin/elastica/lib/Elastica/Request.php
index 6c6298be..ab26ff09 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Request.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Request.php
@@ -1,15 +1,11 @@
<?php
-
namespace Elastica;
use Elastica\Exception\InvalidException;
-use Elastica\JSON;
/**
- * Elastica Request object
+ * Elastica Request object.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
*/
class Request extends Param
@@ -26,13 +22,14 @@ class Request extends Param
protected $_connection;
/**
- * Construct
+ * Construct.
*
- * @param string $path Request path
- * @param string $method OPTIONAL Request method (use const's) (default = self::GET)
- * @param array $data OPTIONAL Data array
- * @param array $query OPTIONAL Query params
+ * @param string $path Request path
+ * @param string $method OPTIONAL Request method (use const's) (default = self::GET)
+ * @param array $data OPTIONAL Data array
+ * @param array $query OPTIONAL Query params
* @param Connection $connection
+ *
* @return \Elastica\Request OPTIONAL Connection object
*/
public function __construct($path, $method = self::GET, $data = array(), array $query = array(), Connection $connection = null)
@@ -48,10 +45,11 @@ class Request extends Param
}
/**
- * Sets the request method. Use one of the for consts
+ * Sets the request method. Use one of the for consts.
+ *
+ * @param string $method Request method
*
- * @param string $method Request method
- * @return \Elastica\Request Current object
+ * @return $this
*/
public function setMethod($method)
{
@@ -59,7 +57,7 @@ class Request extends Param
}
/**
- * Get request method
+ * Get request method.
*
* @return string Request method
*/
@@ -69,10 +67,11 @@ class Request extends Param
}
/**
- * Sets the request data
+ * Sets the request data.
*
- * @param array $data Request data
- * @return \Elastica\Request
+ * @param array $data Request data
+ *
+ * @return $this
*/
public function setData($data)
{
@@ -80,7 +79,7 @@ class Request extends Param
}
/**
- * Return request data
+ * Return request data.
*
* @return array Request data
*/
@@ -90,10 +89,11 @@ class Request extends Param
}
/**
- * Sets the request path
+ * Sets the request path.
+ *
+ * @param string $path Request path
*
- * @param string $path Request path
- * @return \Elastica\Request Current object
+ * @return $this
*/
public function setPath($path)
{
@@ -101,7 +101,7 @@ class Request extends Param
}
/**
- * Return request path
+ * Return request path.
*
* @return string Request path
*/
@@ -111,7 +111,7 @@ class Request extends Param
}
/**
- * Return query params
+ * Return query params.
*
* @return array Query params
*/
@@ -121,8 +121,9 @@ class Request extends Param
}
/**
- * @param array $query
- * @return \Elastica\Request
+ * @param array $query
+ *
+ * @return $this
*/
public function setQuery(array $query = array())
{
@@ -130,8 +131,9 @@ class Request extends Param
}
/**
- * @param \Elastica\Connection $connection
- * @return \Elastica\Request
+ * @param \Elastica\Connection $connection
+ *
+ * @return $this
*/
public function setConnection(Connection $connection)
{
@@ -141,9 +143,10 @@ class Request extends Param
}
/**
- * Return Connection Object
+ * Return Connection Object.
+ *
+ * @throws Exception\InvalidException If no valid connection was setted
*
- * @throws Exception\InvalidException
* @return \Elastica\Connection
*/
public function getConnection()
@@ -156,7 +159,7 @@ class Request extends Param
}
/**
- * Sends request to server
+ * Sends request to server.
*
* @return \Elastica\Response Response object
*/
@@ -177,11 +180,12 @@ class Request extends Param
if ($this->_connection) {
$data['connection'] = $this->_connection->getParams();
}
+
return $data;
}
/**
- * Converts request to curl request format
+ * Converts request to curl request format.
*
* @return string
*/
diff --git a/vendor/ruflin/elastica/lib/Elastica/Rescore/AbstractRescore.php b/vendor/ruflin/elastica/lib/Elastica/Rescore/AbstractRescore.php
index cb6c7cce..0839424d 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Rescore/AbstractRescore.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Rescore/AbstractRescore.php
@@ -1,20 +1,19 @@
<?php
-
namespace Elastica\Rescore;
+
use Elastica\Param;
/**
* Abstract rescore object. Should be extended by all rescorers.
*
- * @category Xodoa
- * @package Elastica
* @author Jason Hu <mjhu91@gmail.com>
- * @link http://www.elasticsearch.org/guide/reference/api/search/rescore/
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-rescore.html
*/
abstract class AbstractRescore extends Param
{
- /**
- * Overridden to return rescore as name
+ /**
+ * Overridden to return rescore as name.
*
* @return string name
*/
@@ -24,13 +23,14 @@ abstract class AbstractRescore extends Param
}
/**
- * Sets window_size
+ * Sets window_size.
*
* @param int $size
- * @return \Elastica\Rescore
+ *
+ * @return $this
*/
public function setWindowSize($size)
{
return $this->setParam('window_size', $size);
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Rescore/Query.php b/vendor/ruflin/elastica/lib/Elastica/Rescore/Query.php
index 5041f3ed..3b0a1071 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Rescore/Query.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Rescore/Query.php
@@ -1,21 +1,19 @@
<?php
-
namespace Elastica\Rescore;
use Elastica\Query as BaseQuery;
/**
- * Query Rescore
+ * Query Rescore.
*
- * @category Xodoa
- * @package Elastica
* @author Jason Hu <mjhu91@gmail.com>
- * @link http://www.elasticsearch.org/guide/reference/api/search/rescore/
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-rescore.html
*/
class Query extends AbstractRescore
{
/**
- * Constructor
+ * Constructor.
*
* @param string|\Elastica\Query\AbstractQuery $rescoreQuery
* @param string|\Elastica\Query\AbstractQuery $query
@@ -28,7 +26,7 @@ class Query extends AbstractRescore
/**
* Override default implementation so params are in the format
- * expected by elasticsearch
+ * expected by elasticsearch.
*
* @return array Rescore array
*/
@@ -44,10 +42,11 @@ class Query extends AbstractRescore
}
/**
- * Sets rescoreQuery object
+ * Sets rescoreQuery object.
+ *
+ * @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query
*
- * @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query
- * @return \Elastica\Query\Rescore
+ * @return $this
*/
public function setRescoreQuery($rescoreQuery)
{
@@ -61,10 +60,11 @@ class Query extends AbstractRescore
}
/**
- * Sets query_weight
+ * Sets query_weight.
*
* @param float $weight
- * @return \Elastica\Query\Rescore
+ *
+ * @return $this
*/
public function setQueryWeight($weight)
{
@@ -75,10 +75,11 @@ class Query extends AbstractRescore
}
/**
- * Sets rescore_query_weight
+ * Sets rescore_query_weight.
*
* @param float $size
- * @return \Elastica\Query\Rescore
+ *
+ * @return $this
*/
public function setRescoreQueryWeight($weight)
{
@@ -87,4 +88,4 @@ class Query extends AbstractRescore
return $this->setParam('query', $query);
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Response.php b/vendor/ruflin/elastica/lib/Elastica/Response.php
index 5c0ef24d..b537fe80 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Response.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Response.php
@@ -1,69 +1,65 @@
<?php
-
namespace Elastica;
use Elastica\Exception\JSONParseException;
use Elastica\Exception\NotFoundException;
-use Elastica\JSON;
/**
- * Elastica Response object
+ * Elastica Response object.
*
* Stores query time, and result array -> is given to result set, returned by ...
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
*/
class Response
{
/**
- * Query time
+ * Query time.
*
* @var float Query time
*/
protected $_queryTime = null;
/**
- * Response string (json)
+ * Response string (json).
*
* @var string Response
*/
protected $_responseString = '';
/**
- * Error
+ * Error.
*
- * @var boolean Error
+ * @var bool Error
*/
protected $_error = false;
/**
- * Transfer info
+ * Transfer info.
*
* @var array transfer info
*/
protected $_transferInfo = array();
/**
- * Response
+ * Response.
*
* @var \Elastica\Response Response object
*/
protected $_response = null;
/**
- * HTTP response status code
+ * HTTP response status code.
*
* @var int
*/
protected $_status = null;
/**
- * Construct
+ * Construct.
*
* @param string|array $responseString Response string (json)
- * @param int $responseStatus http status code
+ * @param int $responseStatus http status code
*/
public function __construct($responseString, $responseStatus = null)
{
@@ -76,7 +72,7 @@ class Response
}
/**
- * Error message
+ * Error message.
*
* @return string Error message
*/
@@ -93,7 +89,7 @@ class Response
}
/**
- * True if response has error
+ * True if response has error.
*
* @return bool True if response has error
*/
@@ -109,7 +105,7 @@ class Response
}
/**
- * True if response has failed shards
+ * True if response has failed shards.
*
* @return bool True if response has failed shards
*/
@@ -125,7 +121,7 @@ class Response
}
/**
- * Checks if the query returned ok
+ * Checks if the query returned ok.
*
* @return bool True if ok
*/
@@ -138,11 +134,19 @@ class Response
if ($data['status'] >= 200 && $data['status'] <= 300) {
return true;
}
+
return false;
}
+
if (isset($data['items'])) {
+ if (isset($data['errors']) && true === $data['errors']) {
+ return false;
+ }
+
foreach ($data['items'] as $item) {
- if (false == $item['index']['ok']) {
+ if (isset($item['index']['ok']) && false == $item['index']['ok']) {
+ return false;
+ } elseif (isset($item['index']['status']) && ($item['index']['status'] < 200 || $item['index']['status'] >= 300)) {
return false;
}
}
@@ -166,9 +170,8 @@ class Response
return $this->_status;
}
-
/**
- * Response data array
+ * Response data array.
*
* @return array Response data array
*/
@@ -214,17 +217,19 @@ class Response
* Sets the transfer info of the curl request. This function is called
* from the \Elastica\Client::_callService .
*
- * @param array $transferInfo The curl transfer information.
- * @return \Elastica\Response Current object
+ * @param array $transferInfo The curl transfer information.
+ *
+ * @return $this
*/
public function setTransferInfo(array $transferInfo)
{
$this->_transferInfo = $transferInfo;
+
return $this;
}
/**
- * This is only available if DEBUG constant is set to true
+ * Returns query execution time.
*
* @return float Query time
*/
@@ -234,10 +239,11 @@ class Response
}
/**
- * Sets the query time
+ * Sets the query time.
+ *
+ * @param float $queryTime Query time
*
- * @param float $queryTime Query time
- * @return \Elastica\Response Current object
+ * @return $this
*/
public function setQueryTime($queryTime)
{
@@ -247,26 +253,28 @@ class Response
}
/**
- * Time request took
+ * Time request took.
*
* @throws \Elastica\Exception\NotFoundException
- * @return int Time request took
+ *
+ * @return int Time request took
*/
public function getEngineTime()
{
$data = $this->getData();
if (!isset($data['took'])) {
- throw new NotFoundException("Unable to find the field [took]from the response");
+ throw new NotFoundException('Unable to find the field [took]from the response');
}
return $data['took'];
}
/**
- * Get the _shard statistics for the response
+ * Get the _shard statistics for the response.
*
* @throws \Elastica\Exception\NotFoundException
+ *
* @return array
*/
public function getShardsStatistics()
@@ -274,16 +282,17 @@ class Response
$data = $this->getData();
if (!isset($data['_shards'])) {
- throw new NotFoundException("Unable to find the field [_shards] from the response");
+ throw new NotFoundException('Unable to find the field [_shards] from the response');
}
return $data['_shards'];
}
/**
- * Get the _scroll value for the response
+ * Get the _scroll value for the response.
*
* @throws \Elastica\Exception\NotFoundException
+ *
* @return string
*/
public function getScrollId()
@@ -291,7 +300,7 @@ class Response
$data = $this->getData();
if (!isset($data['_scroll_id'])) {
- throw new NotFoundException("Unable to find the field [_scroll_id] from the response");
+ throw new NotFoundException('Unable to find the field [_scroll_id] from the response');
}
return $data['_scroll_id'];
diff --git a/vendor/ruflin/elastica/lib/Elastica/Result.php b/vendor/ruflin/elastica/lib/Elastica/Result.php
index e8aa8e3d..6b3c68f2 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Result.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Result.php
@@ -1,27 +1,24 @@
<?php
-
namespace Elastica;
/**
- * Elastica result item
+ * Elastica result item.
*
* Stores all information from a result
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
*/
class Result
{
/**
- * Hit array
+ * Hit array.
*
* @var array Hit array
*/
protected $_hit = array();
/**
- * Constructs a single results object
+ * Constructs a single results object.
*
* @param array $hit Hit data
*/
@@ -31,14 +28,15 @@ class Result
}
/**
- * Returns a param from the result hit array
+ * Returns a param from the result hit array.
*
* This function can be used to retrieve all data for which a specific
* function doesn't exist.
* If the param does not exist, an empty array is returned
*
- * @param string $name Param name
- * @return array Result data
+ * @param string $name Param name
+ *
+ * @return array Result data
*/
public function getParam($name)
{
@@ -50,18 +48,19 @@ class Result
}
/**
- * Test if a param from the result hit is set
+ * Test if a param from the result hit is set.
+ *
+ * @param string $name Param name to test
*
- * @param string $name Param name to test
- * @return boolean True if the param is set, false otherwise
+ * @return bool True if the param is set, false otherwise
*/
public function hasParam($name)
{
return isset($this->_hit[$name]);
- }
-
+ }
+
/**
- * Returns the hit id
+ * Returns the hit id.
*
* @return string Hit id
*/
@@ -71,7 +70,7 @@ class Result
}
/**
- * Returns the type of the result
+ * Returns the type of the result.
*
* @return string Result type
*/
@@ -81,7 +80,7 @@ class Result
}
/**
- * Returns list of fields
+ * Returns list of fields.
*
* @return array Fields list
*/
@@ -91,17 +90,17 @@ class Result
}
/**
- * Returns whether result has fields
- *
+ * Returns whether result has fields.
+ *
* @return bool
*/
public function hasFields()
{
return $this->hasParam('fields');
- }
-
+ }
+
/**
- * Returns the index name of the result
+ * Returns the index name of the result.
*
* @return string Index name
*/
@@ -111,7 +110,7 @@ class Result
}
/**
- * Returns the score of the result
+ * Returns the score of the result.
*
* @return float Result score
*/
@@ -121,7 +120,7 @@ class Result
}
/**
- * Returns the raw hit array
+ * Returns the raw hit array.
*
* @return array Hit array
*/
@@ -131,7 +130,7 @@ class Result
}
/**
- * Returns the version information from the hit
+ * Returns the version information from the hit.
*
* @return string|int Document version
*/
@@ -141,7 +140,7 @@ class Result
}
/**
- * Returns result data
+ * Returns result data.
*
* Checks for partial result data with getFields, falls back to getSource
*
@@ -157,7 +156,7 @@ class Result
}
/**
- * Returns the result source
+ * Returns the result source.
*
* @return array Source data array
*/
@@ -167,7 +166,7 @@ class Result
}
/**
- * Returns result data
+ * Returns result data.
*
* @return array Result data array
*/
@@ -187,12 +186,13 @@ class Result
}
/**
- * Magic function to directly access keys inside the result
+ * Magic function to directly access keys inside the result.
*
* Returns null if key does not exist
*
- * @param string $key Key name
- * @return mixed Key value
+ * @param string $key Key name
+ *
+ * @return mixed Key value
*/
public function __get($key)
{
@@ -200,11 +200,12 @@ class Result
return array_key_exists($key, $source) ? $source[$key] : null;
}
-
+
/**
- * Magic function to support isset() calls
+ * Magic function to support isset() calls.
*
* @param string $key Key name
+ *
* @return bool
*/
public function __isset($key)
diff --git a/vendor/ruflin/elastica/lib/Elastica/ResultSet.php b/vendor/ruflin/elastica/lib/Elastica/ResultSet.php
index 3bb94fb0..ae4141b9 100644
--- a/vendor/ruflin/elastica/lib/Elastica/ResultSet.php
+++ b/vendor/ruflin/elastica/lib/Elastica/ResultSet.php
@@ -1,43 +1,48 @@
<?php
-
namespace Elastica;
+
use Elastica\Exception\InvalidException;
/**
- * Elastica result set
+ * Elastica result set.
*
* List of all hits that are returned for a search on elasticsearch
* Result set implements iterator
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
*/
class ResultSet implements \Iterator, \Countable, \ArrayAccess
{
/**
- * Results
+ * Class for the static create method to use.
+ *
+ * @var string
+ */
+ protected static $_class = 'Elastica\\ResultSet';
+
+ /**
+ * Results.
*
* @var array Results
*/
protected $_results = array();
/**
- * Current position
+ * Current position.
*
* @var int Current position
*/
protected $_position = 0;
/**
- * Response
+ * Response.
*
* @var \Elastica\Response Response object
*/
protected $_response = null;
/**
- * Query
+ * Query.
*
* @var \Elastica\Query Query object
*/
@@ -49,7 +54,7 @@ class ResultSet implements \Iterator, \Countable, \ArrayAccess
protected $_took = 0;
/**
- * @var boolean
+ * @var bool
*/
protected $_timedOut = false;
@@ -64,7 +69,7 @@ class ResultSet implements \Iterator, \Countable, \ArrayAccess
protected $_maxScore = 0;
/**
- * Constructs ResultSet object
+ * Constructs ResultSet object.
*
* @param \Elastica\Response $response Response object
* @param \Elastica\Query $query Query object
@@ -77,7 +82,33 @@ class ResultSet implements \Iterator, \Countable, \ArrayAccess
}
/**
- * Loads all data into the results object (initialisation)
+ * Creates a new ResultSet object. Can be configured to return a different
+ * implementation of the ResultSet class.
+ *
+ * @param Response $response
+ * @param Query $query
+ *
+ * @return ResultSet
+ */
+ public static function create(Response $response, Query $query)
+ {
+ $class = static::$_class;
+
+ return new $class($response, $query);
+ }
+
+ /**
+ * Sets the class to be used for the static create method.
+ *
+ * @param string $class
+ */
+ public static function setClass($class)
+ {
+ static::$_class = $class;
+ }
+
+ /**
+ * Loads all data into the results object (initialisation).
*
* @param \Elastica\Response $response Response object
*/
@@ -97,7 +128,7 @@ class ResultSet implements \Iterator, \Countable, \ArrayAccess
}
/**
- * Returns all results
+ * Returns all results.
*
* @return Result[] Results
*/
@@ -107,29 +138,35 @@ class ResultSet implements \Iterator, \Countable, \ArrayAccess
}
/**
- * Returns true if the response contains suggestion results; false otherwise
+ * Returns true if the response contains suggestion results; false otherwise.
+ *
* @return bool
*/
- public function hasSuggests(){
+ public function hasSuggests()
+ {
$data = $this->_response->getData();
+
return isset($data['suggest']);
}
/**
- * Return all suggests
- *
- * @return array suggest results
- */
- public function getSuggests()
+ * Return all suggests.
+ *
+ * @return array suggest results
+ */
+ public function getSuggests()
{
$data = $this->_response->getData();
+
return isset($data['suggest']) ? $data['suggest'] : array();
}
/**
- * Returns whether facets exist
+ * Returns whether facets exist.
*
- * @return boolean Facet existence
+ * @return bool Facet existence
+ *
+ * @deprecated Facets are deprecated and will be removed in a future release. You are encouraged to migrate to aggregations instead.
*/
public function hasFacets()
{
@@ -139,9 +176,9 @@ class ResultSet implements \Iterator, \Countable, \ArrayAccess
}
/**
- * Returns whether aggregations exist
+ * Returns whether aggregations exist.
*
- * @return boolean Aggregation existence
+ * @return bool Aggregation existence
*/
public function hasAggregations()
{
@@ -151,7 +188,7 @@ class ResultSet implements \Iterator, \Countable, \ArrayAccess
}
/**
- * Returns all aggregation results
+ * Returns all aggregation results.
*
* @return array
*/
@@ -163,10 +200,13 @@ class ResultSet implements \Iterator, \Countable, \ArrayAccess
}
/**
- * Retrieve a specific aggregation from this result set
+ * Retrieve a specific aggregation from this result set.
+ *
* @param string $name the name of the desired aggregation
- * @return array
+ *
* @throws Exception\InvalidException if an aggregation by the given name cannot be found
+ *
+ * @return array
*/
public function getAggregation($name)
{
@@ -179,9 +219,11 @@ class ResultSet implements \Iterator, \Countable, \ArrayAccess
}
/**
- * Returns all facets results
+ * Returns all facets results.
*
* @return array Facet results
+ *
+ * @deprecated Facets are deprecated and will be removed in a future release. You are encouraged to migrate to aggregations instead.
*/
public function getFacets()
{
@@ -191,7 +233,7 @@ class ResultSet implements \Iterator, \Countable, \ArrayAccess
}
/**
- * Returns the total number of found hits
+ * Returns the total number of found hits.
*
* @return int Total hits
*/
@@ -201,7 +243,7 @@ class ResultSet implements \Iterator, \Countable, \ArrayAccess
}
/**
- * Returns the max score of the results found
+ * Returns the max score of the results found.
*
* @return float Max Score
*/
@@ -211,27 +253,27 @@ class ResultSet implements \Iterator, \Countable, \ArrayAccess
}
/**
- * Returns the total number of ms for this search to complete
- *
- * @return int Total time
- */
+ * Returns the total number of ms for this search to complete.
+ *
+ * @return int Total time
+ */
public function getTotalTime()
{
return (int) $this->_took;
}
/**
- * Returns true iff the query has timed out
- *
- * @return bool Timed out
- */
+ * Returns true iff the query has timed out.
+ *
+ * @return bool Timed out
+ */
public function hasTimedOut()
{
return (bool) $this->_timedOut;
}
/**
- * Returns response object
+ * Returns response object.
*
* @return \Elastica\Response Response object
*/
@@ -249,7 +291,7 @@ class ResultSet implements \Iterator, \Countable, \ArrayAccess
}
/**
- * Returns size of current set
+ * Returns size of current set.
*
* @return int Size of set
*/
@@ -259,7 +301,7 @@ class ResultSet implements \Iterator, \Countable, \ArrayAccess
}
/**
- * Returns size of current suggests
+ * Returns size of current suggests.
*
* @return int Size of suggests
*/
@@ -269,7 +311,7 @@ class ResultSet implements \Iterator, \Countable, \ArrayAccess
}
/**
- * Returns the current object of the set
+ * Returns the current object of the set.
*
* @return \Elastica\Result|bool Set object or false if not valid (no more entries)
*/
@@ -283,7 +325,7 @@ class ResultSet implements \Iterator, \Countable, \ArrayAccess
}
/**
- * Sets pointer (current) to the next item of the set
+ * Sets pointer (current) to the next item of the set.
*/
public function next()
{
@@ -293,7 +335,7 @@ class ResultSet implements \Iterator, \Countable, \ArrayAccess
}
/**
- * Returns the position of the current entry
+ * Returns the position of the current entry.
*
* @return int Current position
*/
@@ -303,7 +345,7 @@ class ResultSet implements \Iterator, \Countable, \ArrayAccess
}
/**
- * Check if an object exists at the current position
+ * Check if an object exists at the current position.
*
* @return bool True if object exists
*/
@@ -313,7 +355,7 @@ class ResultSet implements \Iterator, \Countable, \ArrayAccess
}
/**
- * Resets position to 0, restarts iterator
+ * Resets position to 0, restarts iterator.
*/
public function rewind()
{
@@ -321,11 +363,13 @@ class ResultSet implements \Iterator, \Countable, \ArrayAccess
}
/**
- * Whether a offset exists
+ * Whether a offset exists.
+ *
* @link http://php.net/manual/en/arrayaccess.offsetexists.php
*
- * @param integer $offset
- * @return boolean true on success or false on failure.
+ * @param int $offset
+ *
+ * @return bool true on success or false on failure.
*/
public function offsetExists($offset)
{
@@ -333,48 +377,54 @@ class ResultSet implements \Iterator, \Countable, \ArrayAccess
}
/**
- * Offset to retrieve
+ * Offset to retrieve.
+ *
* @link http://php.net/manual/en/arrayaccess.offsetget.php
*
- * @param integer $offset
- * @throws Exception\InvalidException
- * @return Result|null
+ * @param int $offset
+ *
+ * @throws Exception\InvalidException If offset doesn't exist
+ *
+ * @return Result|null
*/
public function offsetGet($offset)
{
if ($this->offsetExists($offset)) {
return $this->_results[$offset];
} else {
- throw new InvalidException("Offset does not exist.");
+ throw new InvalidException('Offset does not exist.');
}
}
/**
- * Offset to set
+ * Offset to set.
+ *
* @link http://php.net/manual/en/arrayaccess.offsetset.php
*
- * @param integer $offset
- * @param Result $value
- * @throws Exception\InvalidException
+ * @param int $offset
+ * @param Result $value
+ *
+ * @throws Exception\InvalidException
*/
public function offsetSet($offset, $value)
{
if (!($value instanceof Result)) {
- throw new InvalidException("ResultSet is a collection of Result only.");
+ throw new InvalidException('ResultSet is a collection of Result only.');
}
if (!isset($this->_results[$offset])) {
- throw new InvalidException("Offset does not exist.");
+ throw new InvalidException('Offset does not exist.');
}
$this->_results[$offset] = $value;
}
/**
- * Offset to unset
+ * Offset to unset.
+ *
* @link http://php.net/manual/en/arrayaccess.offsetunset.php
*
- * @param integer $offset
+ * @param int $offset
*/
public function offsetUnset($offset)
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/ScanAndScroll.php b/vendor/ruflin/elastica/lib/Elastica/ScanAndScroll.php
index c83054e8..6713856e 100644
--- a/vendor/ruflin/elastica/lib/Elastica/ScanAndScroll.php
+++ b/vendor/ruflin/elastica/lib/Elastica/ScanAndScroll.php
@@ -1,150 +1,80 @@
<?php
-
namespace Elastica;
/**
- * scan and scroll object
+ * Scan and Scroll Iterator.
*
- * @category Xodoa
- * @package Elastica
* @author Manuel Andreo Garcia <andreo.garcia@gmail.com>
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/scan-scroll.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/guide/current/scan-scroll.html
*/
-class ScanAndScroll implements \Iterator {
-
- /**
- * time value parameter
- *
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-scroll.html
- * @var string
- */
- public $expiryTime;
-
+class ScanAndScroll extends Scroll
+{
/**
* @var int
*/
public $sizePerShard;
/**
- * @var Search
- */
- protected $_search;
-
- /**
- * @var null|string
- */
- protected $_nextScrollId = null;
-
- /**
- * @var null|string
- */
- protected $_lastScrollId = null;
-
- /**
- * @var null|ResultSet
- */
- protected $_currentResultSet = null;
-
- /**
- * Constructs scroll iterator object
+ * Constructor.
*
* @param Search $search
* @param string $expiryTime
- * @param int $sizePerShard
+ * @param int $sizePerShard
*/
- public function __construct(Search $search, $expiryTime = '1m', $sizePerShard = 1000) {
- $this->_search = $search;
- $this->expiryTime = $expiryTime;
+ public function __construct(Search $search, $expiryTime = '1m', $sizePerShard = 1000)
+ {
$this->sizePerShard = $sizePerShard;
- }
- /**
- * Return the current result set
- *
- * @link http://php.net/manual/en/iterator.current.php
- * @return ResultSet
- */
- public function current() {
- return $this->_currentResultSet;
+ parent::__construct($search, $expiryTime);
}
/**
- * Perform next scroll search
+ * Initial scan search.
*
- * @link http://php.net/manual/en/iterator.next.php
- * @return void
- */
- public function next() {
- $this->_scroll();
- }
-
- /**
- * Return the scroll id of current scroll request
- *
- * @link http://php.net/manual/en/iterator.key.php
- * @return string
- */
- public function key() {
- return $this->_lastScrollId;
- }
-
- /**
- * Returns true if current result set contains one hit
- *
- * @link http://php.net/manual/en/iterator.valid.php
- * @return boolean
- */
- public function valid() {
- return
- $this->_nextScrollId !== null
- && $this->_currentResultSet !== null
- && $this->_currentResultSet->count() > 0;
- }
-
- /**
- * Start the initial scan search
* @link http://php.net/manual/en/iterator.rewind.php
- * @throws \Elastica\Exception\InvalidException
- * @return void
*/
- public function rewind() {
- $this->_search->getQuery()->setSize($this->sizePerShard);
+ public function rewind()
+ {
+ // reset state
+ $this->_nextScrollId = null;
+ $this->_options = array(null, null, null, null);
- $this->_search->setOption(Search::OPTION_SEARCH_TYPE, Search::OPTION_SEARCH_TYPE_SCAN);
- $this->_search->setOption(Search::OPTION_SCROLL, $this->expiryTime);
+ $this->_saveOptions();
// initial scan request
+ $this->_search->getQuery()->setSize($this->sizePerShard);
+ $this->_search->setOption(Search::OPTION_SCROLL, $this->expiryTime);
+ $this->_search->setOption(Search::OPTION_SCROLL_ID, null);
+ $this->_search->setOption(Search::OPTION_SEARCH_TYPE, Search::OPTION_SEARCH_TYPE_SCAN);
$this->_setScrollId($this->_search->search());
- // trigger first scroll request
- $this->_scroll();
+ $this->_revertOptions();
+
+ // first scroll request
+ $this->next();
}
/**
- * Perform next scroll search
- * @throws \Elastica\Exception\InvalidException
- * @return void
+ * Save all search options manipulated by Scroll.
*/
- protected function _scroll() {
- $this->_search->setOption(Search::OPTION_SEARCH_TYPE, Search::OPTION_SEARCH_TYPE_SCROLL);
- $this->_search->setOption(Search::OPTION_SCROLL_ID, $this->_nextScrollId);
+ protected function _saveOptions()
+ {
+ $query = $this->_search->getQuery();
+ if ($query->hasParam('size')) {
+ $this->_options[3] = $query->getParam('size');
+ }
- $resultSet = $this->_search->search();
- $this->_currentResultSet = $resultSet;
- $this->_setScrollId($resultSet);
+ parent::_saveOptions();
}
/**
- * Save last scroll id and extract the new one if possible
- * @param ResultSet $resultSet
+ * Revert search options to previously saved state.
*/
- protected function _setScrollId(ResultSet $resultSet) {
- $this->_lastScrollId = $this->_nextScrollId;
+ protected function _revertOptions()
+ {
+ $this->_search->getQuery()->setSize($this->_options[3]);
- $this->_nextScrollId = null;
- if($resultSet->getResponse()->isOk()) {
- $this->_nextScrollId = $resultSet->getResponse()->getScrollId();
- }
+ parent::_revertOptions();
}
-
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Script.php b/vendor/ruflin/elastica/lib/Elastica/Script.php
index 99d9a6aa..6df3d583 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Script.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Script.php
@@ -1,21 +1,19 @@
<?php
-
namespace Elastica;
use Elastica\Exception\InvalidException;
/**
- * Script objects, containing script internals
+ * Script objects, containing script internals.
*
- * @category Xodoa
- * @package Elastica
* @author avasilenko <aa.vasilenko@gmail.com>
- * @link http://www.elasticsearch.org/guide/reference/modules/scripting.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html
*/
class Script extends AbstractUpdateAction
{
- const LANG_MVEL = 'mvel';
- const LANG_JS = 'js';
+ const LANG_MVEL = 'mvel';
+ const LANG_JS = 'js';
const LANG_GROOVY = 'groovy';
const LANG_PYTHON = 'python';
const LANG_NATIVE = 'native';
@@ -38,9 +36,11 @@ class Script extends AbstractUpdateAction
public function __construct($script, array $params = null, $lang = null, $id = null)
{
$this->setScript($script);
+
if ($params) {
$this->setParams($params);
}
+
if ($lang) {
$this->setLang($lang);
}
@@ -52,10 +52,14 @@ class Script extends AbstractUpdateAction
/**
* @param string $lang
+ *
+ * @return $this
*/
public function setLang($lang)
{
$this->_lang = $lang;
+
+ return $this;
}
/**
@@ -68,10 +72,14 @@ class Script extends AbstractUpdateAction
/**
* @param string $script
+ *
+ * @return $this
*/
public function setScript($script)
{
$this->_script = $script;
+
+ return $this;
}
/**
@@ -83,9 +91,11 @@ class Script extends AbstractUpdateAction
}
/**
- * @param string|array|\Elastica\Script $data
+ * @param string|array|\Elastica\Script $data
+ *
* @throws \Elastica\Exception\InvalidException
- * @return \Elastica\Script
+ *
+ * @return self
*/
public static function create($data)
{
@@ -103,9 +113,11 @@ class Script extends AbstractUpdateAction
}
/**
- * @param array $data
+ * @param array $data
+ *
* @throws \Elastica\Exception\InvalidException
- * @return \Elastica\Script
+ *
+ * @return self
*/
protected static function _createFromArray(array $data)
{
@@ -118,6 +130,7 @@ class Script extends AbstractUpdateAction
if (isset($data['lang'])) {
$script->setLang($data['lang']);
}
+
if (isset($data['params'])) {
if (!is_array($data['params'])) {
throw new InvalidException("\$data['params'] should be array");
@@ -136,9 +149,11 @@ class Script extends AbstractUpdateAction
$array = array(
'script' => $this->_script,
);
+
if (!empty($this->_params)) {
$array['params'] = $this->_params;
}
+
if ($this->_lang) {
$array['lang'] = $this->_lang;
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/ScriptFields.php b/vendor/ruflin/elastica/lib/Elastica/ScriptFields.php
index 0a8b4871..41b5b913 100644
--- a/vendor/ruflin/elastica/lib/Elastica/ScriptFields.php
+++ b/vendor/ruflin/elastica/lib/Elastica/ScriptFields.php
@@ -1,15 +1,14 @@
<?php
-
namespace Elastica;
+
use Elastica\Exception\InvalidException;
/**
- * Container for scripts as fields
+ * Container for scripts as fields.
*
- * @category Xodoa
- * @package Elastica
* @author Sebastien Lavoie <github@lavoie.sl>
- * @link http://www.elasticsearch.org/guide/reference/api/search/script-fields.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-script-fields.html
*/
class ScriptFields extends Param
{
@@ -24,10 +23,12 @@ class ScriptFields extends Param
}
/**
- * @param string $name Name of the Script field
- * @param \Elastica\Script $script
+ * @param string $name Name of the Script field
+ * @param \Elastica\Script $script
+ *
* @throws \Elastica\Exception\InvalidException
- * @return \Elastica\ScriptFields
+ *
+ * @return $this
*/
public function addScript($name, Script $script)
{
@@ -40,8 +41,9 @@ class ScriptFields extends Param
}
/**
- * @param \Elastica\Script[]|array $scripts Associative array of string => Elastica\Script
- * @return \Elastica\ScriptFields
+ * @param \Elastica\Script[]|array $scripts Associative array of string => Elastica\Script
+ *
+ * @return $this
*/
public function setScripts(array $scripts)
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Scroll.php b/vendor/ruflin/elastica/lib/Elastica/Scroll.php
new file mode 100644
index 00000000..44fa73e9
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Scroll.php
@@ -0,0 +1,174 @@
+<?php
+namespace Elastica;
+
+/**
+ * Scroll Iterator.
+ *
+ * @author Manuel Andreo Garcia <andreo.garcia@gmail.com>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html
+ */
+class Scroll implements \Iterator
+{
+ /**
+ * @var string
+ */
+ public $expiryTime;
+
+ /**
+ * @var Search
+ */
+ protected $_search;
+
+ /**
+ * @var null|string
+ */
+ protected $_nextScrollId = null;
+
+ /**
+ * @var null|ResultSet
+ */
+ protected $_currentResultSet = null;
+
+ /**
+ * 0: scroll<br>
+ * 1: scroll id<br>
+ * 2: search type.
+ *
+ * @var array
+ */
+ protected $_options = array(null, null, null);
+
+ /**
+ * Constructor.
+ *
+ * @param Search $search
+ * @param string $expiryTime
+ */
+ public function __construct(Search $search, $expiryTime = '1m')
+ {
+ $this->_search = $search;
+ $this->expiryTime = $expiryTime;
+ }
+
+ /**
+ * Returns current result set.
+ *
+ * @link http://php.net/manual/en/iterator.current.php
+ *
+ * @return ResultSet
+ */
+ public function current()
+ {
+ return $this->_currentResultSet;
+ }
+
+ /**
+ * Next scroll search.
+ *
+ * @link http://php.net/manual/en/iterator.next.php
+ */
+ public function next()
+ {
+ $this->_saveOptions();
+
+ $this->_search->setOption(Search::OPTION_SCROLL, $this->expiryTime);
+ $this->_search->setOption(Search::OPTION_SCROLL_ID, $this->_nextScrollId);
+ $this->_search->setOption(Search::OPTION_SEARCH_TYPE, Search::OPTION_SEARCH_TYPE_SCROLL);
+ $this->_setScrollId($this->_search->search());
+
+ $this->_revertOptions();
+ }
+
+ /**
+ * Returns scroll id.
+ *
+ * @link http://php.net/manual/en/iterator.key.php
+ *
+ * @return string
+ */
+ public function key()
+ {
+ return $this->_nextScrollId;
+ }
+
+ /**
+ * Returns true if current result set contains at least one hit.
+ *
+ * @link http://php.net/manual/en/iterator.valid.php
+ *
+ * @return bool
+ */
+ public function valid()
+ {
+ return
+ $this->_nextScrollId !== null
+ && $this->_currentResultSet !== null
+ && $this->_currentResultSet->count() > 0;
+ }
+
+ /**
+ * Initial scroll search.
+ *
+ * @link http://php.net/manual/en/iterator.rewind.php
+ */
+ public function rewind()
+ {
+ // reset state
+ $this->_nextScrollId = null;
+ $this->_options = array(null, null, null);
+
+ // initial search
+ $this->_saveOptions();
+
+ $this->_search->setOption(Search::OPTION_SCROLL, $this->expiryTime);
+ $this->_search->setOption(Search::OPTION_SCROLL_ID, null);
+ $this->_search->setOption(Search::OPTION_SEARCH_TYPE, null);
+ $this->_setScrollId($this->_search->search());
+
+ $this->_revertOptions();
+ }
+
+ /**
+ * Prepares Scroll for next request.
+ *
+ * @param ResultSet $resultSet
+ */
+ protected function _setScrollId(ResultSet $resultSet)
+ {
+ $this->_currentResultSet = $resultSet;
+
+ $this->_nextScrollId = null;
+ if ($resultSet->getResponse()->isOk()) {
+ $this->_nextScrollId = $resultSet->getResponse()->getScrollId();
+ }
+ }
+
+ /**
+ * Save all search options manipulated by Scroll.
+ */
+ protected function _saveOptions()
+ {
+ if ($this->_search->hasOption(Search::OPTION_SCROLL)) {
+ $this->_options[0] = $this->_search->getOption(Search::OPTION_SCROLL);
+ }
+
+ if ($this->_search->hasOption(Search::OPTION_SCROLL_ID)) {
+ $this->_options[1] = $this->_search->getOption(Search::OPTION_SCROLL_ID);
+ }
+
+ if ($this->_search->hasOption(Search::OPTION_SEARCH_TYPE)) {
+ $this->_options[2] = $this->_search->getOption(Search::OPTION_SEARCH_TYPE);
+ }
+ }
+
+ /**
+ * Revert search options to previously saved state.
+ */
+ protected function _revertOptions()
+ {
+ $this->_search->setOption(Search::OPTION_SCROLL, $this->_options[0]);
+ $this->_search->setOption(Search::OPTION_SCROLL_ID, $this->_options[1]);
+ $this->_search->setOption(Search::OPTION_SEARCH_TYPE, $this->_options[2]);
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Search.php b/vendor/ruflin/elastica/lib/Elastica/Search.php
index 4163a1a2..7306eb75 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Search.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Search.php
@@ -1,15 +1,11 @@
<?php
-
namespace Elastica;
use Elastica\Exception\InvalidException;
-use Elastica\Suggest;
/**
- * Elastica search object
+ * Elastica search object.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
*/
class Search
@@ -26,6 +22,7 @@ class Search
const OPTION_SIZE = 'size';
const OPTION_SCROLL = 'scroll';
const OPTION_SCROLL_ID = 'scroll_id';
+ const OPTION_QUERY_CACHE = 'query_cache';
/*
* Search types
@@ -38,16 +35,17 @@ class Search
const OPTION_SEARCH_TYPE_QUERY_AND_FETCH = 'query_and_fetch';
const OPTION_SEARCH_TYPE_SUGGEST = 'suggest';
const OPTION_SEARCH_TYPE_SCROLL = 'scroll';
+ const OPTION_SEARCH_IGNORE_UNAVAILABLE = 'ignore_unavailable';
/**
- * Array of indices
+ * Array of indices.
*
* @var array
*/
protected $_indices = array();
/**
- * Array of types
+ * Array of types.
*
* @var array
*/
@@ -64,14 +62,14 @@ class Search
protected $_options = array();
/**
- * Client object
+ * Client object.
*
* @var \Elastica\Client
*/
protected $_client;
/**
- * Constructs search object
+ * Constructs search object.
*
* @param \Elastica\Client $client Client object
*/
@@ -81,11 +79,13 @@ class Search
}
/**
- * Adds a index to the list
+ * Adds a index to the list.
+ *
+ * @param \Elastica\Index|string $index Index object or string
*
- * @param \Elastica\Index|string $index Index object or string
* @throws \Elastica\Exception\InvalidException
- * @return \Elastica\Search Current object
+ *
+ * @return $this
*/
public function addIndex($index)
{
@@ -93,20 +93,21 @@ class Search
$index = $index->getName();
}
- if (!is_string($index)) {
+ if (!is_scalar($index)) {
throw new InvalidException('Invalid param type');
}
- $this->_indices[] = $index;
+ $this->_indices[] = (string) $index;
return $this;
}
/**
- * Add array of indices at once
+ * Add array of indices at once.
*
- * @param array $indices
- * @return \Elastica\Search
+ * @param array $indices
+ *
+ * @return $this
*/
public function addIndices(array $indices = array())
{
@@ -118,11 +119,13 @@ class Search
}
/**
- * Adds a type to the current search
+ * Adds a type to the current search.
+ *
+ * @param \Elastica\Type|string $type Type name or object
*
- * @param \Elastica\Type|string $type Type name or object
- * @return \Elastica\Search Search object
* @throws \Elastica\Exception\InvalidException
+ *
+ * @return $this
*/
public function addType($type)
{
@@ -140,10 +143,11 @@ class Search
}
/**
- * Add array of types
+ * Add array of types.
*
- * @param array $types
- * @return \Elastica\Search
+ * @param array $types
+ *
+ * @return $this
*/
public function addTypes(array $types = array())
{
@@ -155,8 +159,9 @@ class Search
}
/**
- * @param string|array|\Elastica\Query|\Elastica\Suggest|\Elastica\Query\AbstractQuery|\Elastica\Filter\AbstractFilter $query|
- * @return \Elastica\Search
+ * @param string|array|\Elastica\Query|\Elastica\Suggest|\Elastica\Query\AbstractQuery|\Elastica\Filter\AbstractFilter $query|
+ *
+ * @return $this
*/
public function setQuery($query)
{
@@ -166,9 +171,10 @@ class Search
}
/**
- * @param string $key
- * @param mixed $value
- * @return \Elastica\Search
+ * @param string $key
+ * @param mixed $value
+ *
+ * @return $this
*/
public function setOption($key, $value)
{
@@ -180,8 +186,9 @@ class Search
}
/**
- * @param array $options
- * @return \Elastica\Search
+ * @param array $options
+ *
+ * @return $this
*/
public function setOptions(array $options)
{
@@ -195,7 +202,7 @@ class Search
}
/**
- * @return \Elastica\Search
+ * @return $this
*/
public function clearOptions()
{
@@ -205,9 +212,10 @@ class Search
}
/**
- * @param string $key
- * @param mixed $value
- * @return \Elastica\Search
+ * @param string $key
+ * @param mixed $value
+ *
+ * @return $this
*/
public function addOption($key, $value)
{
@@ -223,7 +231,8 @@ class Search
}
/**
- * @param string $key
+ * @param string $key
+ *
* @return bool
*/
public function hasOption($key)
@@ -232,14 +241,16 @@ class Search
}
/**
- * @param string $key
- * @return mixed
+ * @param string $key
+ *
* @throws \Elastica\Exception\InvalidException
+ *
+ * @return mixed
*/
public function getOption($key)
{
if (!$this->hasOption($key)) {
- throw new InvalidException('Option ' . $key . ' does not exist');
+ throw new InvalidException('Option '.$key.' does not exist');
}
return $this->_options[$key];
@@ -254,9 +265,11 @@ class Search
}
/**
- * @param string $key
- * @return bool
+ * @param string $key
+ *
* @throws \Elastica\Exception\InvalidException
+ *
+ * @return bool
*/
protected function _validateOption($key)
{
@@ -271,14 +284,16 @@ class Search
case self::OPTION_SCROLL:
case self::OPTION_SCROLL_ID:
case self::OPTION_SEARCH_TYPE_SUGGEST:
+ case self::OPTION_SEARCH_IGNORE_UNAVAILABLE:
+ case self::OPTION_QUERY_CACHE:
return true;
}
- throw new InvalidException('Invalid option ' . $key);
+ throw new InvalidException('Invalid option '.$key);
}
/**
- * Return client object
+ * Return client object.
*
* @return \Elastica\Client Client object
*/
@@ -288,7 +303,7 @@ class Search
}
/**
- * Return array of indices
+ * Return array of indices.
*
* @return array List of index names
*/
@@ -307,6 +322,7 @@ class Search
/**
* @param Index|string $index
+ *
* @return bool
*/
public function hasIndex($index)
@@ -319,7 +335,7 @@ class Search
}
/**
- * Return array of types
+ * Return array of types.
*
* @return array List of types
*/
@@ -338,6 +354,7 @@ class Search
/**
* @param \Elastica\Type|string $type
+ *
* @return bool
*/
public function hasType($type)
@@ -362,10 +379,11 @@ class Search
}
/**
- * Creates new search object
+ * Creates new search object.
*
- * @param \Elastica\SearchableInterface $searchObject
- * @return \Elastica\Search
+ * @param \Elastica\SearchableInterface $searchObject
+ *
+ * @return Search
*/
public static function create(SearchableInterface $searchObject)
{
@@ -373,7 +391,7 @@ class Search
}
/**
- * Combines indices and types to the search request path
+ * Combines indices and types to the search request path.
*
* @return string Search path
*/
@@ -397,19 +415,21 @@ class Search
}
if (!empty($types)) {
- $path .= '/' . implode(',', $types);
+ $path .= '/'.implode(',', $types);
}
// Add full path based on indices and types -> could be all
- return $path . '/_search';
+ return $path.'/_search';
}
/**
- * Search in the set indices, types
+ * Search in the set indices, types.
+ *
+ * @param mixed $query
+ * @param int|array $options OPTIONAL Limit or associative array of options (option=>value)
*
- * @param mixed $query
- * @param int|array $options OPTIONAL Limit or associative array of options (option=>value)
* @throws \Elastica\Exception\InvalidException
+ *
* @return \Elastica\ResultSet
*/
public function search($query = '', $options = null)
@@ -436,13 +456,13 @@ class Search
$params
);
- return new ResultSet($response, $query);
+ return ResultSet::create($response, $query);
}
/**
- *
* @param mixed $query
- * @param $fullResult (default = false) By default only the total hit count is returned. If set to true, the full ResultSet including facets is returned.
+ * @param $fullResult (default = false) By default only the total hit count is returned. If set to true, the full ResultSet including aggregations is returned.
+ *
* @return int|ResultSet
*/
public function count($query = '', $fullResult = false)
@@ -458,15 +478,16 @@ class Search
$query->toArray(),
array(self::OPTION_SEARCH_TYPE => self::OPTION_SEARCH_TYPE_COUNT)
);
- $resultSet = new ResultSet($response, $query);
+ $resultSet = ResultSet::create($response, $query);
return $fullResult ? $resultSet : $resultSet->getTotalHits();
}
/**
- * @param array|int $options
- * @param string|array|\Elastica\Query $query
- * @return \Elastica\Search
+ * @param array|int $options
+ * @param string|array|\Elastica\Query $query
+ *
+ * @return $this
*/
public function setOptionsAndQuery($options = null, $query = '')
{
@@ -493,7 +514,8 @@ class Search
/**
* @param Suggest $suggest
- * @return Search
+ *
+ * @return $this
*/
public function setSuggest(Suggest $suggest)
{
@@ -501,14 +523,31 @@ class Search
}
/**
- * Returns the ScanAndScroll Iterator
+ * Returns the Scroll Iterator.
+ *
+ * @see Elastica\Scroll
+ *
+ * @param string $expiryTime
+ *
+ * @return Scroll
+ */
+ public function scroll($expiryTime = '1m')
+ {
+ return new Scroll($this, $expiryTime);
+ }
+
+ /**
+ * Returns the ScanAndScroll Iterator.
*
* @see Elastica\ScanAndScroll
+ *
* @param string $expiryTime
- * @param int $sizePerShard
+ * @param int $sizePerShard
+ *
* @return ScanAndScroll
*/
- public function scanAndScroll($expiryTime = '1m', $sizePerShard = 1000) {
+ public function scanAndScroll($expiryTime = '1m', $sizePerShard = 1000)
+ {
return new ScanAndScroll($this, $expiryTime, $sizePerShard);
}
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/SearchableInterface.php b/vendor/ruflin/elastica/lib/Elastica/SearchableInterface.php
index 372bcb11..abfacb85 100644
--- a/vendor/ruflin/elastica/lib/Elastica/SearchableInterface.php
+++ b/vendor/ruflin/elastica/lib/Elastica/SearchableInterface.php
@@ -1,18 +1,15 @@
<?php
-
namespace Elastica;
/**
- * Elastica searchable interface
+ * Elastica searchable interface.
*
- * @category Xodoa
- * @package Elastica
* @author Thibault Duplessis <thibault.duplessis@gmail.com>
*/
interface SearchableInterface
{
/**
- * Searches results for a query
+ * Searches results for a query.
*
* TODO: Improve sample code
* {
@@ -28,24 +25,27 @@ interface SearchableInterface
* }
* }
*
- * @param string|array|\Elastica\Query $query Array with all query data inside or a Elastica\Query object
- * @return \Elastica\ResultSet ResultSet with all results inside
+ * @param string|array|\Elastica\Query $query Array with all query data inside or a Elastica\Query object
+ *
+ * @return \Elastica\ResultSet ResultSet with all results inside
*/
public function search($query = '', $options = null);
/**
- * Counts results for a query
+ * Counts results for a query.
*
* If no query is set, matchall query is created
*
- * @param string|array|\Elastica\Query $query Array with all query data inside or a Elastica\Query object
- * @return int number of documents matching the query
+ * @param string|array|\Elastica\Query $query Array with all query data inside or a Elastica\Query object
+ *
+ * @return int number of documents matching the query
*/
public function count($query = '');
/**
* @param \Elastica\Query $query
- * @param array $options
+ * @param array $options
+ *
* @return \Elastica\Search
*/
public function createSearch($query = '', $options = null);
diff --git a/vendor/ruflin/elastica/lib/Elastica/Snapshot.php b/vendor/ruflin/elastica/lib/Elastica/Snapshot.php
index 4b32172c..80924b79 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Snapshot.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Snapshot.php
@@ -1,14 +1,13 @@
<?php
-
namespace Elastica;
use Elastica\Exception\NotFoundException;
use Elastica\Exception\ResponseException;
/**
- * Class Snapshot
- * @package Elastica
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/modules-snapshots.html
+ * Class Snapshot.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-snapshots.html
*/
class Snapshot
{
@@ -26,26 +25,32 @@ class Snapshot
}
/**
- * Register a snapshot repository
- * @param string $name the name of the repository
- * @param string $type the repository type ("fs" for file system)
- * @param array $settings Additional repository settings. If type "fs" is used, the "location" setting must be provided.
+ * Register a snapshot repository.
+ *
+ * @param string $name the name of the repository
+ * @param string $type the repository type ("fs" for file system)
+ * @param array $settings Additional repository settings. If type "fs" is used, the "location" setting must be provided.
+ *
* @return Response
*/
public function registerRepository($name, $type, $settings = array())
{
$data = array(
'type' => $type,
- 'settings' => $settings
+ 'settings' => $settings,
);
+
return $this->request($name, Request::PUT, $data);
}
/**
- * Retrieve a repository record by name
+ * Retrieve a repository record by name.
+ *
* @param string $name the name of the desired repository
+ *
* @throws Exception\ResponseException
* @throws Exception\NotFoundException
+ *
* @return array
*/
public function getRepository($name)
@@ -54,102 +59,118 @@ class Snapshot
$response = $this->request($name);
} catch (ResponseException $e) {
if ($e->getResponse()->getStatus() == 404) {
- throw new NotFoundException("Repository '" . $name . "' does not exist.");
+ throw new NotFoundException("Repository '".$name."' does not exist.");
}
throw $e;
}
$data = $response->getData();
+
return $data[$name];
}
/**
- * Retrieve all repository records
+ * Retrieve all repository records.
+ *
* @return array
*/
public function getAllRepositories()
{
- return $this->request("_all")->getData();
+ return $this->request('_all')->getData();
}
/**
- * Create a new snapshot
- * @param string $repository the name of the repository in which this snapshot should be stored
- * @param string $name the name of this snapshot
- * @param array $options optional settings for this snapshot
- * @param bool $waitForCompletion if true, the request will not return until the snapshot operation is complete
+ * Create a new snapshot.
+ *
+ * @param string $repository the name of the repository in which this snapshot should be stored
+ * @param string $name the name of this snapshot
+ * @param array $options optional settings for this snapshot
+ * @param bool $waitForCompletion if true, the request will not return until the snapshot operation is complete
+ *
* @return Response
*/
public function createSnapshot($repository, $name, $options = array(), $waitForCompletion = false)
{
- return $this->request($repository . '/' . $name, Request::PUT, $options, array('wait_for_completion' => $waitForCompletion));
+ return $this->request($repository.'/'.$name, Request::PUT, $options, array('wait_for_completion' => $waitForCompletion));
}
/**
- * Retrieve data regarding a specific snapshot
+ * Retrieve data regarding a specific snapshot.
+ *
* @param string $repository the name of the repository from which to retrieve the snapshot
- * @param string $name the name of the desired snapshot
+ * @param string $name the name of the desired snapshot
+ *
* @throws Exception\ResponseException
* @throws Exception\NotFoundException
+ *
* @return array
*/
public function getSnapshot($repository, $name)
{
try {
- $response = $this->request($repository . "/" . $name);
+ $response = $this->request($repository.'/'.$name);
} catch (ResponseException $e) {
if ($e->getResponse()->getStatus() == 404) {
- throw new NotFoundException("Snapshot '" . $name . "' does not exist in repository '" . $repository . "'.");
+ throw new NotFoundException("Snapshot '".$name."' does not exist in repository '".$repository."'.");
}
throw $e;
}
$data = $response->getData();
+
return $data['snapshots'][0];
}
/**
- * Retrieve data regarding all snapshots in the given repository
+ * Retrieve data regarding all snapshots in the given repository.
+ *
* @param string $repository the repository name
+ *
* @return array
*/
public function getAllSnapshots($repository)
{
- return $this->request($repository . "/_all")->getData();
+ return $this->request($repository.'/_all')->getData();
}
/**
- * Delete a snapshot
+ * Delete a snapshot.
+ *
* @param string $repository the repository in which the snapshot resides
- * @param string $name the name of the snapshot to be deleted
+ * @param string $name the name of the snapshot to be deleted
+ *
* @return Response
*/
public function deleteSnapshot($repository, $name)
{
- return $this->request($repository . "/" . $name, Request::DELETE);
+ return $this->request($repository.'/'.$name, Request::DELETE);
}
/**
- * Restore a snapshot
- * @param string $repository the name of the repository
- * @param string $name the name of the snapshot
- * @param array $options options for the restore operation
- * @param bool $waitForCompletion if true, the request will not return until the restore operation is complete
+ * Restore a snapshot.
+ *
+ * @param string $repository the name of the repository
+ * @param string $name the name of the snapshot
+ * @param array $options options for the restore operation
+ * @param bool $waitForCompletion if true, the request will not return until the restore operation is complete
+ *
* @return Response
*/
public function restoreSnapshot($repository, $name, $options = array(), $waitForCompletion = false)
{
- return $this->request($repository . "/" . $name . "/_restore", Request::POST, $options, array("wait_for_completion" => $waitForCompletion));
+ return $this->request($repository.'/'.$name.'/_restore', Request::POST, $options, array('wait_for_completion' => $waitForCompletion));
}
/**
- * Perform a snapshot request
- * @param string $path the URL
+ * Perform a snapshot request.
+ *
+ * @param string $path the URL
* @param string $method the HTTP method
- * @param array $data request body data
- * @param array $query query string parameters
+ * @param array $data request body data
+ * @param array $query query string parameters
+ *
* @return Response
*/
public function request($path, $method = Request::GET, $data = array(), array $query = array())
{
- return $this->_client->request("/_snapshot/" . $path, $method, $data, $query);
+ return $this->_client->request('/_snapshot/'.$path, $method, $data, $query);
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Status.php b/vendor/ruflin/elastica/lib/Elastica/Status.php
index a747b9a5..c22a5f61 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Status.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Status.php
@@ -1,42 +1,41 @@
<?php
-
namespace Elastica;
+
use Elastica\Exception\ResponseException;
use Elastica\Index\Status as IndexStatus;
/**
- * Elastica general status
+ * Elastica general status.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/api/admin-indices-status.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-status.html
*/
class Status
{
/**
- * Contains all status infos
+ * Contains all status infos.
*
* @var \Elastica\Response Response object
*/
protected $_response = null;
/**
- * Data
+ * Data.
*
* @var array Data
*/
protected $_data = array();
/**
- * Client object
+ * Client object.
*
* @var \Elastica\Client Client object
*/
protected $_client = null;
/**
- * Constructs Status object
+ * Constructs Status object.
*
* @param \Elastica\Client $client Client object
*/
@@ -47,7 +46,7 @@ class Status
}
/**
- * Returns status data
+ * Returns status data.
*
* @return array Status data
*/
@@ -57,7 +56,7 @@ class Status
}
/**
- * Returns status objects of all indices
+ * Returns status objects of all indices.
*
* @return array|\Elastica\Index\Status[] List of Elastica\Client\Index objects
*/
@@ -73,25 +72,21 @@ class Status
}
/**
- * Returns a list of the existing index names
+ * Returns a list of the existing index names.
*
* @return array Index names list
*/
public function getIndexNames()
{
- $names = array();
- foreach ($this->_data['indices'] as $name => $data) {
- $names[] = $name;
- }
-
- return $names;
+ return array_keys($this->_data['indices']);
}
/**
- * Checks if the given index exists
+ * Checks if the given index exists.
*
- * @param string $name Index name to check
- * @return bool True if index exists
+ * @param string $name Index name to check
+ *
+ * @return bool True if index exists
*/
public function indexExists($name)
{
@@ -99,10 +94,11 @@ class Status
}
/**
- * Checks if the given alias exists
+ * Checks if the given alias exists.
+ *
+ * @param string $name Alias name
*
- * @param string $name Alias name
- * @return bool True if alias exists
+ * @return bool True if alias exists
*/
public function aliasExists($name)
{
@@ -110,16 +106,17 @@ class Status
}
/**
- * Returns an array with all indices that the given alias name points to
+ * Returns an array with all indices that the given alias name points to.
+ *
+ * @param string $alias Alias name
*
- * @param string $alias Alias name
* @return array|\Elastica\Index[] List of Elastica\Index
*/
public function getIndicesWithAlias($alias)
{
$response = null;
try {
- $response = $this->_client->request('/_alias/' . $alias);
+ $response = $this->_client->request('/_alias/'.$alias);
} catch (ResponseException $e) {
$transferInfo = $e->getResponse()->getTransferInfo();
// 404 means the index alias doesn't exist which means no indexes have it.
@@ -133,11 +130,12 @@ class Status
foreach ($response->getData() as $name => $unused) {
$indices[] = new Index($this->_client, $name);
}
+
return $indices;
}
/**
- * Returns response object
+ * Returns response object.
*
* @return \Elastica\Response Response object
*/
@@ -147,7 +145,7 @@ class Status
}
/**
- * Return shards info
+ * Return shards info.
*
* @return array Shards info
*/
@@ -157,7 +155,7 @@ class Status
}
/**
- * Refresh status object
+ * Refresh status object.
*/
public function refresh()
{
@@ -167,7 +165,7 @@ class Status
}
/**
- * Refresh serverStatus object
+ * Refresh serverStatus object.
*/
public function getServerStatus()
{
diff --git a/vendor/ruflin/elastica/lib/Elastica/Suggest.php b/vendor/ruflin/elastica/lib/Elastica/Suggest.php
index dd5dbbcc..73b1ea36 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Suggest.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Suggest.php
@@ -1,43 +1,44 @@
<?php
-
namespace Elastica;
-
use Elastica\Exception\NotImplementedException;
use Elastica\Suggest\AbstractSuggest;
/**
- * Class Suggest
- * @package Elastica\Suggest
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-suggesters.html
+ * Class Suggest.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters.html
*/
class Suggest extends Param
{
/**
* @param AbstractSuggest $suggestion
*/
- function __construct(AbstractSuggest $suggestion = NULL)
+ public function __construct(AbstractSuggest $suggestion = null)
{
if (!is_null($suggestion)) {
$this->addSuggestion($suggestion);
}
}
-
/**
- * Set the global text for this suggester
+ * Set the global text for this suggester.
+ *
* @param string $text
- * @return \Elastica\Suggest
+ *
+ * @return $this
*/
public function setGlobalText($text)
{
- return $this->setParam("text", $text);
+ return $this->setParam('text', $text);
}
/**
- * Add a suggestion to this suggest clause
+ * Add a suggestion to this suggest clause.
+ *
* @param AbstractSuggest $suggestion
- * @return \Elastica\Suggest
+ *
+ * @return $this
*/
public function addSuggestion(AbstractSuggest $suggestion)
{
@@ -46,17 +47,19 @@ class Suggest extends Param
/**
* @param Suggest|AbstractSuggest $suggestion
- * @return \Elastica\Suggest
+ *
* @throws Exception\NotImplementedException
+ *
+ * @return self
*/
public static function create($suggestion)
{
- switch(true){
- case $suggestion instanceof Suggest:
+ switch (true) {
+ case $suggestion instanceof self:
return $suggestion;
case $suggestion instanceof AbstractSuggest:
return new self($suggestion);
}
throw new NotImplementedException();
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Suggest/AbstractSuggest.php b/vendor/ruflin/elastica/lib/Elastica/Suggest/AbstractSuggest.php
index e5f5e01c..00f21e44 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Suggest/AbstractSuggest.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Suggest/AbstractSuggest.php
@@ -1,13 +1,10 @@
<?php
-
namespace Elastica\Suggest;
-
use Elastica\Param;
/**
- * Class AbstractSuggestion
- * @package Elastica\Suggest
+ * Class AbstractSuggestion.
*/
abstract class AbstractSuggest extends Param
{
@@ -32,45 +29,52 @@ abstract class AbstractSuggest extends Param
}
/**
- * Suggest text must be set either globally or per suggestion
+ * Suggest text must be set either globally or per suggestion.
+ *
* @param string $text
- * @return \Elastica\Suggest\AbstractSuggest
+ *
+ * @return $this
*/
public function setText($text)
{
$this->_text = $text;
+
return $this;
}
/**
* @param string $field
- * @return \Elastica\Suggest\AbstractSuggest
+ *
+ * @return $this
*/
public function setField($field)
{
- return $this->setParam("field", $field);
+ return $this->setParam('field', $field);
}
/**
* @param int $size
- * @return \Elastica\Suggest\AbstractSuggest
+ *
+ * @return $this
*/
public function setSize($size)
{
- return $this->setParam("size", $size);
+ return $this->setParam('size', $size);
}
/**
* @param int $size maximum number of suggestions to be retrieved from each shard
- * @return \Elastica\Suggest\AbstractSuggest
+ *
+ * @return $this
*/
public function setShardSize($size)
{
- return $this->setParam("shard_size", $size);
+ return $this->setParam('shard_size', $size);
}
/**
- * Retrieve the name of this suggestion
+ * Retrieve the name of this suggestion.
+ *
* @return string
*/
public function getName()
@@ -87,6 +91,7 @@ abstract class AbstractSuggest extends Param
if (isset($this->_text)) {
$array['text'] = $this->_text;
}
+
return $array;
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Suggest/CandidateGenerator/AbstractCandidateGenerator.php b/vendor/ruflin/elastica/lib/Elastica/Suggest/CandidateGenerator/AbstractCandidateGenerator.php
index d9e6ac7c..6fba49db 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Suggest/CandidateGenerator/AbstractCandidateGenerator.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Suggest/CandidateGenerator/AbstractCandidateGenerator.php
@@ -1,11 +1,8 @@
<?php
-
namespace Elastica\Suggest\CandidateGenerator;
-
use Elastica\Param;
class AbstractCandidateGenerator extends Param
{
-
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Suggest/CandidateGenerator/DirectGenerator.php b/vendor/ruflin/elastica/lib/Elastica/Suggest/CandidateGenerator/DirectGenerator.php
index 0277a5ac..54ac7649 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Suggest/CandidateGenerator/DirectGenerator.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Suggest/CandidateGenerator/DirectGenerator.php
@@ -1,12 +1,10 @@
<?php
-
namespace Elastica\Suggest\CandidateGenerator;
-
/**
- * Class DirectGenerator
- * @package Elastica\Suggest\Phrase
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-suggesters-phrase.html#_direct_generators
+ * Class DirectGenerator.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-phrase.html#_direct_generators
*/
class DirectGenerator extends AbstractCandidateGenerator
{
@@ -23,105 +21,120 @@ class DirectGenerator extends AbstractCandidateGenerator
}
/**
- * Set the field name from which to fetch candidate suggestions
+ * Set the field name from which to fetch candidate suggestions.
+ *
* @param string $field
- * @return DirectGenerator
+ *
+ * @return $this
*/
public function setField($field)
{
- return $this->setParam("field", $field);
+ return $this->setParam('field', $field);
}
/**
- * Set the maximum corrections to be returned per suggest text token
+ * Set the maximum corrections to be returned per suggest text token.
+ *
* @param int $size
- * @return DirectGenerator
+ *
+ * @return $this
*/
public function setSize($size)
{
- return $this->setParam("size", $size);
+ return $this->setParam('size', $size);
}
/**
* @param string $mode see SUGGEST_MODE_* constants for options
- * @return DirectGenerator
+ *
+ * @return $this
*/
public function setSuggestMode($mode)
{
- return $this->setParam("suggest_mode", $mode);
+ return $this->setParam('suggest_mode', $mode);
}
/**
* @param int $max can only be a value between 1 and 2. Defaults to 2.
- * @return DirectGenerator
+ *
+ * @return $this
*/
public function setMaxEdits($max)
{
- return $this->setParam("max_edits", $max);
+ return $this->setParam('max_edits', $max);
}
/**
* @param int $length defaults to 1
- * @return DirectGenerator
+ *
+ * @return $this
*/
public function setPrefixLength($length)
{
- return $this->setParam("prefix_len", $length);
+ return $this->setParam('prefix_len', $length);
}
/**
* @param int $min defaults to 4
- * @return DirectGenerator
+ *
+ * @return $this
*/
public function setMinWordLength($min)
{
- return $this->setParam("min_word_len", $min);
+ return $this->setParam('min_word_len', $min);
}
/**
* @param int $max
- * @return DirectGenerator
+ *
+ * @return $this
*/
public function setMaxInspections($max)
{
- return $this->setParam("max_inspections", $max);
+ return $this->setParam('max_inspections', $max);
}
/**
* @param float $min
- * @return DirectGenerator
+ *
+ * @return $this
*/
public function setMinDocFrequency($min)
{
- return $this->setParam("min_doc_freq", $min);
+ return $this->setParam('min_doc_freq', $min);
}
/**
* @param float $max
- * @return DirectGenerator
+ *
+ * @return $this
*/
public function setMaxTermFrequency($max)
{
- return $this->setParam("max_term_freq", $max);
+ return $this->setParam('max_term_freq', $max);
}
/**
- * Set an analyzer to be applied to the original token prior to candidate generation
+ * Set an analyzer to be applied to the original token prior to candidate generation.
+ *
* @param string $pre an analyzer
- * @return DirectGenerator
+ *
+ * @return $this
*/
public function setPreFilter($pre)
{
- return $this->setParam("pre_filter", $pre);
+ return $this->setParam('pre_filter', $pre);
}
/**
- * Set an analyzer to be applied to generated tokens before they are passed to the phrase scorer
+ * Set an analyzer to be applied to generated tokens before they are passed to the phrase scorer.
+ *
* @param string $post
- * @return DirectGenerator
+ *
+ * @return $this
*/
public function setPostFilter($post)
{
- return $this->setParam("post_filter", $post);
+ return $this->setParam('post_filter', $post);
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Suggest/Completion.php b/vendor/ruflin/elastica/lib/Elastica/Suggest/Completion.php
new file mode 100644
index 00000000..0f0b3e61
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Suggest/Completion.php
@@ -0,0 +1,26 @@
+<?php
+namespace Elastica\Suggest;
+
+/**
+ * Comletion suggester.
+ *
+ * @author Igor Denisenko <im.denisenko@yahoo.com>
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html
+ */
+class Completion extends AbstractSuggest
+{
+ /**
+ * Set fuzzy parameter.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html#fuzzy
+ *
+ * @param array $fuzzy
+ *
+ * @return $this
+ */
+ public function setFuzzy(array $fuzzy)
+ {
+ return $this->setParam('fuzzy', $fuzzy);
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Suggest/Phrase.php b/vendor/ruflin/elastica/lib/Elastica/Suggest/Phrase.php
index 14630dc1..544f3678 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Suggest/Phrase.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Suggest/Phrase.php
@@ -1,109 +1,121 @@
<?php
-
namespace Elastica\Suggest;
use Elastica\Suggest\CandidateGenerator\AbstractCandidateGenerator;
-
/**
- * Class Phrase
- * @package Elastica\Suggest
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-suggesters-phrase.html
+ * Class Phrase.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-phrase.html
*/
class Phrase extends AbstractSuggest
{
/**
* @param string $analyzer
- * @return \Elastica\Suggest\Phrase
+ *
+ * @return $this
*/
public function setAnalyzer($analyzer)
{
- return $this->setParam("analyzer", $analyzer);
+ return $this->setParam('analyzer', $analyzer);
}
/**
- * Set the max size of the n-grams (shingles) in the field
+ * Set the max size of the n-grams (shingles) in the field.
+ *
* @param int $size
- * @return \Elastica\Suggest\Phrase
+ *
+ * @return $this
*/
public function setGramSize($size)
{
- return $this->setParam("gram_size", $size);
+ return $this->setParam('gram_size', $size);
}
/**
- * Set the likelihood of a term being misspelled even if the term exists in the dictionary
+ * Set the likelihood of a term being misspelled even if the term exists in the dictionary.
+ *
* @param float $likelihood Defaults to 0.95, meaning 5% of the words are misspelled.
- * @return \Elastica\Suggest\Phrase
+ *
+ * @return $this
*/
- public function setRealWorldErrorLikelihood($likelihood)
+ public function setRealWordErrorLikelihood($likelihood)
{
- return $this->setParam("real_world_error_likelihood", $likelihood);
+ return $this->setParam('real_word_error_likelihood', $likelihood);
}
/**
* Set the factor applied to the input phrases score to be used as a threshold for other suggestion candidates.
* Only candidates which score higher than this threshold will be included in the result.
+ *
* @param float $confidence Defaults to 1.0.
- * @return \Elastica\Suggest\Phrase
+ *
+ * @return $this
*/
public function setConfidence($confidence)
{
- return $this->setParam("confidence", $confidence);
+ return $this->setParam('confidence', $confidence);
}
/**
- * Set the maximum percentage of the terms considered to be misspellings in order to form a correction
+ * Set the maximum percentage of the terms considered to be misspellings in order to form a correction.
+ *
* @param float $max
- * @return \Elastica\Suggest\Phrase
+ *
+ * @return $this
*/
public function setMaxErrors($max)
{
- return $this->setParam("max_errors", $max);
+ return $this->setParam('max_errors', $max);
}
/**
* @param string $separator
- * @return \Elastica\Param
+ *
+ * @return $this
*/
public function setSeparator($separator)
{
- return $this->setParam("separator", $separator);
+ return $this->setParam('separator', $separator);
}
/**
- * Set suggestion highlighting
+ * Set suggestion highlighting.
+ *
* @param string $preTag
* @param string $postTag
- * @return \Elastica\Suggest\Phrase
+ *
+ * @return $this
*/
public function setHighlight($preTag, $postTag)
{
- return $this->setParam("highlight", array(
+ return $this->setParam('highlight', array(
'pre_tag' => $preTag,
- 'post_tag' => $postTag
+ 'post_tag' => $postTag,
));
}
/**
* @param float $discount
- * @return \Elastica\Suggest\Phrase
+ *
+ * @return $this
*/
public function setStupidBackoffSmoothing($discount = 0.4)
{
- return $this->setSmoothingModel("stupid_backoff", array(
- "discount" => $discount
+ return $this->setSmoothingModel('stupid_backoff', array(
+ 'discount' => $discount,
));
}
/**
* @param float $alpha
- * @return \Elastica\Suggest\Phrase
+ *
+ * @return $this
*/
public function setLaplaceSmoothing($alpha = 0.5)
{
- return $this->setSmoothingModel("laplace", array(
- "alpha" => $alpha
+ return $this->setSmoothingModel('laplace', array(
+ 'alpha' => $alpha,
));
}
@@ -111,38 +123,42 @@ class Phrase extends AbstractSuggest
* @param float $trigramLambda
* @param float $bigramLambda
* @param float $unigramLambda
- * @return \Elastica\Suggest\Phrase
+ *
+ * @return $this
*/
public function setLinearInterpolationSmoothing($trigramLambda, $bigramLambda, $unigramLambda)
{
- return $this->setSmoothingModel("linear_interpolation", array(
- "trigram_lambda" => $trigramLambda,
- "bigram_lambda" => $bigramLambda,
- "unigram_lambda" => $unigramLambda
+ return $this->setSmoothingModel('linear_interpolation', array(
+ 'trigram_lambda' => $trigramLambda,
+ 'bigram_lambda' => $bigramLambda,
+ 'unigram_lambda' => $unigramLambda,
));
}
/**
- * @param string $model the name of the smoothing model
- * @param array $params
- * @return \Elastica\Suggest\Phrase
+ * @param string $model the name of the smoothing model
+ * @param array $params
+ *
+ * @return $this
*/
public function setSmoothingModel($model, array $params)
{
- return $this->setParam("smoothing", array(
- $model => $params
+ return $this->setParam('smoothing', array(
+ $model => $params,
));
}
/**
* @param AbstractCandidateGenerator $generator
- * @return \Elastica\Suggest\Phrase
+ *
+ * @return $this
*/
public function addCandidateGenerator(AbstractCandidateGenerator $generator)
{
$generator = $generator->toArray();
$keys = array_keys($generator);
$values = array_values($generator);
+
return $this->addParam($keys[0], $values[0]);
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Suggest/Term.php b/vendor/ruflin/elastica/lib/Elastica/Suggest/Term.php
index 3fca1731..9f082873 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Suggest/Term.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Suggest/Term.php
@@ -1,12 +1,10 @@
<?php
-
namespace Elastica\Suggest;
-
/**
- * Class Term
- * @package Elastica\Suggest
- * @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-suggesters-term.html
+ * Class Term.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-term.html
*/
class Term extends AbstractSuggest
{
@@ -19,97 +17,113 @@ class Term extends AbstractSuggest
/**
* @param string $analyzer
- * @return \Elastica\Suggest\Term
+ *
+ * @return $this
*/
public function setAnalyzer($analyzer)
{
- return $this->setParam("analyzer", $analyzer);
+ return $this->setParam('analyzer', $analyzer);
}
/**
* @param string $sort see SORT_* constants for options
- * @return \Elastica\Suggest\Term
+ *
+ * @return $this
*/
public function setSort($sort)
{
- return $this->setParam("sort", $sort);
+ return $this->setParam('sort', $sort);
}
/**
* @param string $mode see SUGGEST_MODE_* constants for options
- * @return \Elastica\Suggest\Term
+ *
+ * @return $this
*/
public function setSuggestMode($mode)
{
- return $this->setParam("suggest_mode", $mode);
+ return $this->setParam('suggest_mode', $mode);
}
/**
- * If true, suggest terms will be lower cased after text analysis
+ * If true, suggest terms will be lower cased after text analysis.
+ *
* @param bool $lowercase
- * @return \Elastica\Suggest\Term
+ *
+ * @return $this
*/
public function setLowercaseTerms($lowercase = true)
{
- return $this->setParam("lowercase_terms", (bool)$lowercase);
+ return $this->setParam('lowercase_terms', (bool) $lowercase);
}
/**
- * Set the maximum edit distance candidate suggestions can have in order to be considered as a suggestion
+ * Set the maximum edit distance candidate suggestions can have in order to be considered as a suggestion.
+ *
* @param int $max Either 1 or 2. Any other value will result in an error.
- * @return \Elastica\Suggest\Term
+ *
+ * @return $this
*/
public function setMaxEdits($max)
{
- return $this->setParam("max_edits", (int)$max);
+ return $this->setParam('max_edits', (int) $max);
}
/**
- * The number of minimum prefix characters that must match in order to be a suggestion candidate
+ * The number of minimum prefix characters that must match in order to be a suggestion candidate.
+ *
* @param int $length Defaults to 1.
- * @return \Elastica\Suggest\Term
+ *
+ * @return $this
*/
public function setPrefixLength($length)
{
- return $this->setParam("prefix_len", (int)$length);
+ return $this->setParam('prefix_len', (int) $length);
}
/**
* The minimum length a suggest text term must have in order to be included.
+ *
* @param int $length Defaults to 4.
- * @return \Elastica\Suggest\Term
+ *
+ * @return $this
*/
public function setMinWordLength($length)
{
- return $this->setParam("min_word_len", (int)$length);
+ return $this->setParam('min_word_len', (int) $length);
}
/**
* @param int $max Defaults to 5.
- * @return \Elastica\Suggest\Term
+ *
+ * @return $this
*/
public function setMaxInspections($max)
{
- return $this->setParam("max_inspections", $max);
+ return $this->setParam('max_inspections', $max);
}
/**
- * Set the minimum number of documents in which a suggestion should appear
+ * Set the minimum number of documents in which a suggestion should appear.
+ *
* @param int|float $min Defaults to 0. If the value is greater than 1, it must be a whole number.
- * @return \Elastica\Suggest\Term
+ *
+ * @return $this
*/
public function setMinDocFrequency($min)
{
- return $this->setParam("min_doc_freq", $min);
+ return $this->setParam('min_doc_freq', $min);
}
/**
- * Set the maximum number of documents in which a suggest text token can exist in order to be included
+ * Set the maximum number of documents in which a suggest text token can exist in order to be included.
+ *
* @param float $max
- * @return \Elastica\Suggest\Term
+ *
+ * @return $this
*/
public function setMaxTermFrequency($max)
{
- return $this->setParam("max_term_freq", $max);
+ return $this->setParam('max_term_freq', $max);
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Tool/CrossIndex.php b/vendor/ruflin/elastica/lib/Elastica/Tool/CrossIndex.php
new file mode 100644
index 00000000..89fc0532
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Tool/CrossIndex.php
@@ -0,0 +1,160 @@
+<?php
+namespace Elastica\Tool;
+
+use Elastica\Bulk;
+use Elastica\Index;
+use Elastica\Query\MatchAll;
+use Elastica\ScanAndScroll;
+use Elastica\Search;
+use Elastica\Type;
+
+/**
+ * Functions to move documents and types between indices.
+ *
+ * @author Manuel Andreo Garcia <andreo.garcia@gmail.com>
+ */
+class CrossIndex
+{
+ /**
+ * Type option.
+ *
+ * type: string | string[] | \Elastica\Type | \Elastica\Type[] | null
+ * default: null (means all types)
+ */
+ const OPTION_TYPE = 'type';
+
+ /**
+ * Query option.
+ *
+ * type: see \Elastica\Query::create()
+ * default: Elastica\Query\MatchAll
+ */
+ const OPTION_QUERY = 'query';
+
+ /**
+ * Expiry time option.
+ *
+ * type: string (see Elastica\ScanAndScroll)
+ * default: '1m'
+ */
+ const OPTION_EXPIRY_TIME = 'expiryTime';
+
+ /**
+ * Size per shard option.
+ *
+ * type: int (see Elastica\ScanAndScroll)
+ * default: 1000
+ */
+ const OPTION_SIZE_PER_SHARD = 'sizePerShard';
+
+ /**
+ * Reindex documents from an old index to a new index.
+ *
+ * @link https://www.elastic.co/guide/en/elasticsearch/guide/master/reindex.html
+ *
+ * @param \Elastica\Index $oldIndex
+ * @param \Elastica\Index $newIndex
+ * @param array $options keys: CrossIndex::OPTION_* constants
+ *
+ * @return \Elastica\Index The new index object
+ */
+ public static function reindex(
+ Index $oldIndex,
+ Index $newIndex,
+ array $options = array()
+ ) {
+ // prepare search
+ $search = new Search($oldIndex->getClient());
+
+ $options = array_merge(
+ array(
+ self::OPTION_TYPE => null,
+ self::OPTION_QUERY => new MatchAll(),
+ self::OPTION_EXPIRY_TIME => '1m',
+ self::OPTION_SIZE_PER_SHARD => 1000,
+ ),
+ $options
+ );
+
+ $search->addIndex($oldIndex);
+ if (isset($options[self::OPTION_TYPE])) {
+ $type = $options[self::OPTION_TYPE];
+ $search->addTypes(is_array($type) ? $type : array($type));
+ }
+ $search->setQuery($options[self::OPTION_QUERY]);
+
+ // search on old index and bulk insert in new index
+ $scanAndScroll = new ScanAndScroll(
+ $search,
+ $options[self::OPTION_EXPIRY_TIME],
+ $options[self::OPTION_SIZE_PER_SHARD]
+ );
+ foreach ($scanAndScroll as $resultSet) {
+ $bulk = new Bulk($newIndex->getClient());
+ $bulk->setIndex($newIndex);
+
+ foreach ($resultSet as $result) {
+ $action = new Bulk\Action();
+ $action->setType($result->getType());
+ $action->setId($result->getId());
+ $action->setSource($result->getData());
+
+ $bulk->addAction($action);
+ }
+
+ $bulk->send();
+ }
+
+ $newIndex->refresh();
+
+ return $newIndex;
+ }
+
+ /**
+ * Copies type mappings and documents from an old index to a new index.
+ *
+ * @see \Elastica\Tool\CrossIndex::reindex()
+ *
+ * @param \Elastica\Index $oldIndex
+ * @param \Elastica\Index $newIndex
+ * @param array $options keys: CrossIndex::OPTION_* constants
+ *
+ * @return \Elastica\Index The new index object
+ */
+ public static function copy(
+ Index $oldIndex,
+ Index $newIndex,
+ array $options = array()
+ ) {
+ // normalize types to array of string
+ $types = array();
+ if (isset($options[self::OPTION_TYPE])) {
+ $types = $options[self::OPTION_TYPE];
+ $types = is_array($types) ? $types : array($types);
+
+ $types = array_map(
+ function ($type) {
+ if ($type instanceof Type) {
+ $type = $type->getName();
+ }
+
+ return (string) $type;
+ },
+ $types
+ );
+ }
+
+ // copy mapping
+ foreach ($oldIndex->getMapping() as $type => $mapping) {
+ if (!empty($types) && !in_array($type, $types, true)) {
+ continue;
+ }
+
+ $type = new Type($newIndex, $type);
+ $type->setMapping($mapping['properties']);
+ }
+
+ // copy documents
+ return self::reindex($oldIndex, $newIndex, $options);
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Transport/AbstractTransport.php b/vendor/ruflin/elastica/lib/Elastica/Transport/AbstractTransport.php
index d2ce0fb2..c40b5107 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Transport/AbstractTransport.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Transport/AbstractTransport.php
@@ -1,17 +1,14 @@
<?php
-
namespace Elastica\Transport;
use Elastica\Connection;
-use Elastica\Request;
use Elastica\Exception\InvalidException;
use Elastica\Param;
+use Elastica\Request;
/**
- * Elastica Abstract Transport object
+ * Elastica Abstract Transport object.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
*/
abstract class AbstractTransport extends Param
@@ -22,7 +19,7 @@ abstract class AbstractTransport extends Param
protected $_connection;
/**
- * Construct transport
+ * Construct transport.
*
* @param \Elastica\Connection $connection Connection object
*/
@@ -43,23 +40,28 @@ abstract class AbstractTransport extends Param
/**
* @param \Elastica\Connection $connection Connection object
+ *
+ * @return $this
*/
public function setConnection(Connection $connection)
{
$this->_connection = $connection;
+
+ return $this;
}
/**
- * Executes the transport request
+ * Executes the transport request.
+ *
+ * @param \Elastica\Request $request Request object
+ * @param array $params Hostname, port, path, ...
*
- * @param \Elastica\Request $request Request object
- * @param array $params Hostname, port, path, ...
* @return \Elastica\Response Response object
*/
abstract public function exec(Request $request, array $params);
/**
- * Create a transport
+ * Create a transport.
*
* The $transport parameter can be one of the following values:
*
@@ -68,10 +70,12 @@ abstract class AbstractTransport extends Param
* * array: An array with a "type" key which must be set to one of the two options. All other
* keys in the array will be set as parameters in the transport instance
*
- * @param mixed $transport A transport definition
+ * @param mixed $transport A transport definition
* @param \Elastica\Connection $connection A connection instance
- * @param array $params Parameters for the transport class
+ * @param array $params Parameters for the transport class
+ *
* @throws \Elastica\Exception\InvalidException
+ *
* @return AbstractTransport
*/
public static function create($transport, Connection $connection, array $params = array())
@@ -85,16 +89,16 @@ abstract class AbstractTransport extends Param
}
if (is_string($transport)) {
- $className = 'Elastica\\Transport\\' . $transport;
+ $className = 'Elastica\\Transport\\'.$transport;
if (!class_exists($className)) {
throw new InvalidException('Invalid transport');
}
- $transport = new $className;
+ $transport = new $className();
}
- if ($transport instanceof AbstractTransport) {
+ if ($transport instanceof self) {
$transport->setConnection($connection);
foreach ($params as $key => $value) {
diff --git a/vendor/ruflin/elastica/lib/Elastica/Transport/Guzzle.php b/vendor/ruflin/elastica/lib/Elastica/Transport/Guzzle.php
index 96ad8971..5c98d83b 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Transport/Guzzle.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Transport/Guzzle.php
@@ -1,133 +1,132 @@
<?php
-
namespace Elastica\Transport;
-use Elastica\Exception\Connection\HttpException;
+use Elastica\Connection;
use Elastica\Exception\Connection\GuzzleException;
use Elastica\Exception\PartialShardFailureException;
use Elastica\Exception\ResponseException;
-use Elastica\Exception\InvalidException;
-use Elastica\Connection;
+use Elastica\JSON;
use Elastica\Request;
use Elastica\Response;
-use Elastica\JSON;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\TransferException;
-use GuzzleHttp\Exception\ClientException;
use GuzzleHttp\Stream\Stream;
/**
- * Elastica Guzzle Transport object
+ * Elastica Guzzle Transport object.
*
- * @package Elastica
* @author Milan Magudia <milan@magudia.com>
*/
class Guzzle extends AbstractTransport
{
/**
- * Http scheme
+ * Http scheme.
*
* @var string Http scheme
*/
protected $_scheme = 'http';
/**
- * Curl resource to reuse
+ * Curl resource to reuse.
*
* @var resource Guzzle resource to reuse
*/
protected static $_guzzleClientConnection = null;
/**
- * Makes calls to the elasticsearch server
+ * Makes calls to the elasticsearch server.
*
* All calls that are made to the server are done through this function
*
- * @param \Elastica\Request $request
- * @param array $params Host, Port, ...
+ * @param \Elastica\Request $request
+ * @param array $params Host, Port, ...
+ *
* @throws \Elastica\Exception\ConnectionException
* @throws \Elastica\Exception\ResponseException
* @throws \Elastica\Exception\Connection\HttpException
- * @return \Elastica\Response Response object
+ *
+ * @return \Elastica\Response Response object
*/
public function exec(Request $request, array $params)
{
$connection = $this->getConnection();
- try {
- $client = $this->_getGuzzleClient($this->_getBaseUrl($connection), $connection->isPersistent());
+ $client = $this->_getGuzzleClient($this->_getBaseUrl($connection), $connection->isPersistent());
- $options = array();
- if ($connection->getTimeout()) {
- $options['timeout'] = $connection->getTimeout();
- }
+ $options = array(
+ 'exceptions' => false, // 4xx and 5xx is expected and NOT an exceptions in this context
+ );
+ if ($connection->getTimeout()) {
+ $options['timeout'] = $connection->getTimeout();
+ }
- if ($connection->getProxy()) {
- $options['proxy'] = $connection->getProxy();
- }
+ $proxy = $connection->getProxy();
- $req = $client->createRequest($request->getMethod(), $this->_getActionPath($request), $options);
- $req->setHeaders($connection->hasConfig('headers') ?: array());
+ // See: https://github.com/facebook/hhvm/issues/4875
+ if (is_null($proxy) && defined('HHVM_VERSION')) {
+ $proxy = getenv('http_proxy') ?: null;
+ }
+
+ if (!is_null($proxy)) {
+ $options['proxy'] = $proxy;
+ }
- $data = $request->getData();
- if (!empty($data) || '0' === $data) {
+ $req = $client->createRequest($request->getMethod(), $this->_getActionPath($request), $options);
+ $req->setHeaders($connection->hasConfig('headers') ? $connection->getConfig('headers') : array());
- if ($req->getMethod() == Request::GET) {
- $req->setMethod(Request::POST);
- }
+ $data = $request->getData();
+ if (!empty($data) || '0' === $data) {
+ if ($req->getMethod() == Request::GET) {
+ $req->setMethod(Request::POST);
+ }
- if ($this->hasParam('postWithRequestBody') && $this->getParam('postWithRequestBody') == true) {
- $request->setMethod(Request::POST);
- $req->setMethod(Request::POST);
- }
+ if ($this->hasParam('postWithRequestBody') && $this->getParam('postWithRequestBody') == true) {
+ $request->setMethod(Request::POST);
+ $req->setMethod(Request::POST);
+ }
- if (is_array($data)) {
- $content = JSON::stringify($data, 'JSON_ELASTICSEARCH');
- } else {
- $content = $data;
- }
- $req->setBody(Stream::factory($content));
+ if (is_array($data)) {
+ $content = JSON::stringify($data, 'JSON_ELASTICSEARCH');
+ } else {
+ $content = $data;
}
+ $req->setBody(Stream::factory($content));
+ }
+ try {
$start = microtime(true);
$res = $client->send($req);
$end = microtime(true);
+ } catch (TransferException $ex) {
+ throw new GuzzleException($ex, $request, new Response($ex->getMessage()));
+ }
- $response = new Response((string)$res->getBody(), $res->getStatusCode());
-
- if (defined('DEBUG') && DEBUG) {
- $response->setQueryTime($end - $start);
- }
-
- $response->setTransferInfo(
- array(
- 'request_header' => $request->getMethod(),
- 'http_code' => $res->getStatusCode()
- )
- );
-
- if ($response->hasError()) {
- throw new ResponseException($request, $response);
- }
+ $response = new Response((string) $res->getBody(), $res->getStatusCode());
+ $response->setQueryTime($end - $start);
- if ($response->hasFailedShards()) {
- throw new PartialShardFailureException($request, $response);
- }
+ $response->setTransferInfo(
+ array(
+ 'request_header' => $request->getMethod(),
+ 'http_code' => $res->getStatusCode(),
+ )
+ );
- return $response;
+ if ($response->hasError()) {
+ throw new ResponseException($request, $response);
+ }
- } catch (ClientException $e) {
- // ignore 4xx errors
- } catch (TransferException $e) {
- throw new GuzzleException($e, $request, new Response($e->getMessage()));
+ if ($response->hasFailedShards()) {
+ throw new PartialShardFailureException($request, $response);
}
+ return $response;
}
/**
- * Return Guzzle resource
+ * Return Guzzle resource.
+ *
+ * @param bool $persistent False if not persistent connection
*
- * @param bool $persistent False if not persistent connection
* @return resource Connection resource
*/
protected function _getGuzzleClient($baseUrl, $persistent = true)
@@ -140,9 +139,9 @@ class Guzzle extends AbstractTransport
}
/**
- * Builds the base url for the guzzle connection
+ * Builds the base url for the guzzle connection.
*
- * @param \Elastica\Connection $connection
+ * @param \Elastica\Connection $connection
*/
protected function _getBaseUrl(Connection $connection)
{
@@ -152,26 +151,27 @@ class Guzzle extends AbstractTransport
if (!empty($url)) {
$baseUri = $url;
} else {
- $baseUri = $this->_scheme . '://' . $connection->getHost() . ':' . $connection->getPort() . '/' . $connection->getPath();
+ $baseUri = $this->_scheme.'://'.$connection->getHost().':'.$connection->getPort().'/'.$connection->getPath();
}
+
return rtrim($baseUri, '/');
}
/**
- * Builds the action path url for each request
+ * Builds the action path url for each request.
*
- * @param \Elastica\Request $request
+ * @param \Elastica\Request $request
*/
protected function _getActionPath(Request $request)
{
$action = $request->getPath();
if ($action) {
- $action = '/'. ltrim($action, '/');
+ $action = '/'.ltrim($action, '/');
}
$query = $request->getQuery();
if (!empty($query)) {
- $action .= '?' . http_build_query($query);
+ $action .= '?'.http_build_query($query);
}
return $action;
diff --git a/vendor/ruflin/elastica/lib/Elastica/Transport/Http.php b/vendor/ruflin/elastica/lib/Elastica/Transport/Http.php
index 5606dbbc..1a33c0a6 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Transport/Http.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Transport/Http.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Transport;
use Elastica\Exception\Connection\HttpException;
@@ -10,39 +9,39 @@ use Elastica\Request;
use Elastica\Response;
/**
- * Elastica Http Transport object
+ * Elastica Http Transport object.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
*/
class Http extends AbstractTransport
{
/**
- * Http scheme
+ * Http scheme.
*
* @var string Http scheme
*/
protected $_scheme = 'http';
/**
- * Curl resource to reuse
+ * Curl resource to reuse.
*
* @var resource Curl resource to reuse
*/
protected static $_curlConnection = null;
/**
- * Makes calls to the elasticsearch server
+ * Makes calls to the elasticsearch server.
*
* All calls that are made to the server are done through this function
*
- * @param \Elastica\Request $request
- * @param array $params Host, Port, ...
+ * @param \Elastica\Request $request
+ * @param array $params Host, Port, ...
+ *
* @throws \Elastica\Exception\ConnectionException
* @throws \Elastica\Exception\ResponseException
* @throws \Elastica\Exception\Connection\HttpException
- * @return \Elastica\Response Response object
+ *
+ * @return \Elastica\Response Response object
*/
public function exec(Request $request, array $params)
{
@@ -56,7 +55,7 @@ class Http extends AbstractTransport
if (!empty($url)) {
$baseUri = $url;
} else {
- $baseUri = $this->_scheme . '://' . $connection->getHost() . ':' . $connection->getPort() . '/' . $connection->getPath();
+ $baseUri = $this->_scheme.'://'.$connection->getHost().':'.$connection->getPort().'/'.$connection->getPath();
}
$baseUri .= $request->getPath();
@@ -64,14 +63,26 @@ class Http extends AbstractTransport
$query = $request->getQuery();
if (!empty($query)) {
- $baseUri .= '?' . http_build_query($query);
+ $baseUri .= '?'.http_build_query($query);
}
curl_setopt($conn, CURLOPT_URL, $baseUri);
curl_setopt($conn, CURLOPT_TIMEOUT, $connection->getTimeout());
curl_setopt($conn, CURLOPT_FORBID_REUSE, 0);
+ /* @see Connection::setConnectTimeout() */
+ $connectTimeout = $connection->getConnectTimeout();
+ if ($connectTimeout > 0) {
+ curl_setopt($conn, CURLOPT_CONNECTTIMEOUT, $connectTimeout);
+ }
+
$proxy = $connection->getProxy();
+
+ // See: https://github.com/facebook/hhvm/issues/4875
+ if (is_null($proxy) && defined('HHVM_VERSION')) {
+ $proxy = getenv('http_proxy') ?: null;
+ }
+
if (!is_null($proxy)) {
curl_setopt($conn, CURLOPT_PROXY, $proxy);
}
@@ -83,7 +94,7 @@ class Http extends AbstractTransport
if (!empty($headersConfig)) {
$headers = array();
while (list($header, $headerValue) = each($headersConfig)) {
- array_push($headers, $header . ': ' . $headerValue);
+ array_push($headers, $header.': '.$headerValue);
}
curl_setopt($conn, CURLOPT_HTTPHEADER, $headers);
@@ -116,11 +127,6 @@ class Http extends AbstractTransport
curl_setopt($conn, CURLOPT_CUSTOMREQUEST, $httpMethod);
- if (defined('DEBUG') && DEBUG) {
- // Track request headers when in debug mode
- curl_setopt($conn, CURLINFO_HEADER_OUT, true);
- }
-
$start = microtime(true);
// cURL opt returntransfer leaks memory, therefore OB instead.
@@ -133,15 +139,10 @@ class Http extends AbstractTransport
// Checks if error exists
$errorNumber = curl_errno($conn);
- $response = new Response($responseString, curl_getinfo($this->_getConnection(), CURLINFO_HTTP_CODE));
-
- if (defined('DEBUG') && DEBUG) {
- $response->setQueryTime($end - $start);
- }
-
+ $response = new Response($responseString, curl_getinfo($conn, CURLINFO_HTTP_CODE));
+ $response->setQueryTime($end - $start);
$response->setTransferInfo(curl_getinfo($conn));
-
if ($response->hasError()) {
throw new ResponseException($request, $response);
}
@@ -158,7 +159,7 @@ class Http extends AbstractTransport
}
/**
- * Called to add additional curl params
+ * Called to add additional curl params.
*
* @param resource $curlConnection Curl connection
*/
@@ -172,9 +173,10 @@ class Http extends AbstractTransport
}
/**
- * Return Curl resource
+ * Return Curl resource.
+ *
+ * @param bool $persistent False if not persistent connection
*
- * @param bool $persistent False if not persistent connection
* @return resource Connection resource
*/
protected function _getConnection($persistent = true)
diff --git a/vendor/ruflin/elastica/lib/Elastica/Transport/HttpAdapter.php b/vendor/ruflin/elastica/lib/Elastica/Transport/HttpAdapter.php
new file mode 100644
index 00000000..efc27ab5
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Transport/HttpAdapter.php
@@ -0,0 +1,156 @@
+<?php
+namespace Elastica\Transport;
+
+use Elastica\Connection;
+use Elastica\Exception\PartialShardFailureException;
+use Elastica\Exception\ResponseException;
+use Elastica\JSON;
+use Elastica\Request as ElasticaRequest;
+use Elastica\Response as ElasticaResponse;
+use Ivory\HttpAdapter\HttpAdapterInterface;
+use Ivory\HttpAdapter\Message\Request as HttpAdapterRequest;
+use Ivory\HttpAdapter\Message\Response as HttpAdapterResponse;
+use Ivory\HttpAdapter\Message\Stream\StringStream;
+
+class HttpAdapter extends AbstractTransport
+{
+ /**
+ * @var HttpAdapterInterface
+ */
+ private $httpAdapter;
+
+ /**
+ * @var string
+ */
+ private $_scheme = 'http';
+
+ /**
+ * Construct transport.
+ */
+ public function __construct(Connection $connection = null, HttpAdapterInterface $httpAdapter)
+ {
+ parent::__construct($connection);
+ $this->httpAdapter = $httpAdapter;
+ }
+
+ /**
+ * Makes calls to the elasticsearch server.
+ *
+ * All calls that are made to the server are done through this function
+ *
+ * @param \Elastica\Request $elasticaRequest
+ * @param array $params Host, Port, ...
+ *
+ * @throws \Elastica\Exception\ConnectionException
+ * @throws \Elastica\Exception\ResponseException
+ * @throws \Elastica\Exception\Connection\HttpException
+ *
+ * @return \Elastica\Response Response object
+ */
+ public function exec(ElasticaRequest $elasticaRequest, array $params)
+ {
+ $connection = $this->getConnection();
+
+ if ($timeout = $connection->getTimeout()) {
+ $this->httpAdapter->getConfiguration()->setTimeout($timeout);
+ }
+
+ $httpAdapterRequest = $this->_createHttpAdapterRequest($elasticaRequest, $connection);
+
+ $start = microtime(true);
+ $httpAdapterResponse = $this->httpAdapter->sendRequest($httpAdapterRequest);
+ $end = microtime(true);
+
+ $elasticaResponse = $this->_createElasticaResponse($httpAdapterResponse, $connection);
+ $elasticaResponse->setQueryTime($end - $start);
+
+ $elasticaResponse->setTransferInfo(
+ array(
+ 'request_header' => $httpAdapterRequest->getMethod(),
+ 'http_code' => $httpAdapterResponse->getStatusCode(),
+ )
+ );
+
+ if ($elasticaResponse->hasError()) {
+ throw new ResponseException($elasticaRequest, $elasticaResponse);
+ }
+
+ if ($elasticaResponse->hasFailedShards()) {
+ throw new PartialShardFailureException($elasticaRequest, $elasticaResponse);
+ }
+
+ return $elasticaResponse;
+ }
+
+ /**
+ * @param HttpAdapterResponse $httpAdapterResponse
+ *
+ * @return ElasticaResponse
+ */
+ protected function _createElasticaResponse(HttpAdapterResponse $httpAdapterResponse)
+ {
+ return new ElasticaResponse((string) $httpAdapterResponse->getBody(), $httpAdapterResponse->getStatusCode());
+ }
+
+ /**
+ * @param ElasticaRequest $elasticaRequest
+ * @param Connection $connection
+ *
+ * @return HttpAdapterRequest
+ */
+ protected function _createHttpAdapterRequest(ElasticaRequest $elasticaRequest, Connection $connection)
+ {
+ $data = $elasticaRequest->getData();
+ $body = null;
+ $method = $elasticaRequest->getMethod();
+ $headers = $connection->hasConfig('headers') ?: array();
+ if (!empty($data) || '0' === $data) {
+ if ($method == ElasticaRequest::GET) {
+ $method = ElasticaRequest::POST;
+ }
+
+ if ($this->hasParam('postWithRequestBody') && $this->getParam('postWithRequestBody') == true) {
+ $elasticaRequest->setMethod(ElasticaRequest::POST);
+ $method = ElasticaRequest::POST;
+ }
+
+ if (is_array($data)) {
+ $body = JSON::stringify($data, 'JSON_ELASTICSEARCH');
+ } else {
+ $body = $data;
+ }
+ }
+
+ $url = $this->_getUri($elasticaRequest, $connection);
+ $streamBody = new StringStream($body);
+
+ return new HttpAdapterRequest($url, $method, HttpAdapterRequest::PROTOCOL_VERSION_1_1, $headers, $streamBody);
+ }
+
+ /**
+ * @param ElasticaRequest $request
+ * @param \Elastica\Connection $connection
+ *
+ * @return string
+ */
+ protected function _getUri(ElasticaRequest $request, Connection $connection)
+ {
+ $url = $connection->hasConfig('url') ? $connection->getConfig('url') : '';
+
+ if (!empty($url)) {
+ $baseUri = $url;
+ } else {
+ $baseUri = $this->_scheme.'://'.$connection->getHost().':'.$connection->getPort().'/'.$connection->getPath();
+ }
+
+ $baseUri .= $request->getPath();
+
+ $query = $request->getQuery();
+
+ if (!empty($query)) {
+ $baseUri .= '?'.http_build_query($query);
+ }
+
+ return $baseUri;
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Transport/Https.php b/vendor/ruflin/elastica/lib/Elastica/Transport/Https.php
index 64704039..b2b489dd 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Transport/Https.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Transport/Https.php
@@ -1,25 +1,22 @@
<?php
-
namespace Elastica\Transport;
/**
- * Elastica Http Transport object
+ * Elastica Http Transport object.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
*/
class Https extends Http
{
/**
- * Https scheme
+ * Https scheme.
*
* @var string https scheme
*/
protected $_scheme = 'https';
/**
- * Overloads setupCurl to set SSL params
+ * Overloads setupCurl to set SSL params.
*
* @param resource $connection Curl connection resource
*/
diff --git a/vendor/ruflin/elastica/lib/Elastica/Transport/Memcache.php b/vendor/ruflin/elastica/lib/Elastica/Transport/Memcache.php
index cf047b58..fb56cdf4 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Transport/Memcache.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Transport/Memcache.php
@@ -1,7 +1,7 @@
<?php
-
namespace Elastica\Transport;
+use Elastica\Exception\Connection\MemcacheException;
use Elastica\Exception\InvalidException;
use Elastica\Exception\PartialShardFailureException;
use Elastica\Exception\ResponseException;
@@ -10,31 +10,32 @@ use Elastica\Request;
use Elastica\Response;
/**
- * Elastica Memcache Transport object
+ * Elastica Memcache Transport object.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
+ *
+ * @deprecated The memcached transport is deprecated as of ES 1.5, and will be removed in ES 2.0
*/
class Memcache extends AbstractTransport
{
+ const MAX_KEY_LENGTH = 250;
+
/**
- * Makes calls to the elasticsearch server
+ * Makes calls to the elasticsearch server.
*
* @param \Elastica\Request $request
- * @param array $params Host, Port, ...
+ * @param array $params Host, Port, ...
+ *
* @throws \Elastica\Exception\ResponseException
* @throws \Elastica\Exception\InvalidException
- * @return \Elastica\Response Response object
+ *
+ * @return \Elastica\Response Response object
*/
public function exec(Request $request, array $params)
{
$memcache = new \Memcache();
$memcache->connect($this->getConnection()->getHost(), $this->getConnection()->getPort());
- // Finds right function name
- $function = strtolower($request->getMethod());
-
$data = $request->getData();
$content = '';
@@ -52,22 +53,34 @@ class Memcache extends AbstractTransport
$responseString = '';
- switch ($function) {
- case 'post':
- case 'put':
- $memcache->set($request->getPath(), $content);
+ $start = microtime(true);
+
+ switch ($request->getMethod()) {
+ case Request::POST:
+ case Request::PUT:
+ $key = $request->getPath();
+ $this->_checkKeyLength($key);
+ $memcache->set($key, $content);
break;
- case 'get':
- $responseString = $memcache->get($request->getPath() . '?source=' . $content);
+ case Request::GET:
+ $key = $request->getPath().'?source='.$content;
+ $this->_checkKeyLength($key);
+ $responseString = $memcache->get($key);
break;
- case 'delete':
+ case Request::DELETE:
+ $key = $request->getPath().'?source='.$content;
+ $this->_checkKeyLength($key);
+ $responseString = $memcache->delete($key);
break;
default:
- throw new InvalidException('Method ' . $function . ' is not supported in memcache transport');
-
+ case Request::HEAD:
+ throw new InvalidException('Method '.$request->getMethod().' is not supported in memcache transport');
}
+ $end = microtime(true);
+
$response = new Response($responseString);
+ $response->setQueryTime($end - $start);
if ($response->hasError()) {
throw new ResponseException($request, $response);
@@ -79,4 +92,18 @@ class Memcache extends AbstractTransport
return $response;
}
+
+ /**
+ * Check if key that will be used dont exceed 250 symbols.
+ *
+ * @param string $key
+ *
+ * @throws Elastica\Exception\Connection\MemcacheException If key is too long
+ */
+ private function _checkKeyLength($key)
+ {
+ if (strlen($key) >= self::MAX_KEY_LENGTH) {
+ throw new MemcacheException('Memcache key is too long');
+ }
+ }
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Transport/Null.php b/vendor/ruflin/elastica/lib/Elastica/Transport/Null.php
index 704e0e12..70dd9af1 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Transport/Null.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Transport/Null.php
@@ -1,44 +1,13 @@
<?php
-
namespace Elastica\Transport;
-use Elastica\JSON;
-use Elastica\Request;
-use Elastica\Response;
-
/**
- * Elastica Null Transport object
+ * Elastica Null Transport object.
+ *
+ * This class is for backward compatibility reason for all php < 7 versions. For PHP 7 and above use NullTransport as Null is reserved.
*
- * @package Elastica
* @author James Boehmer <james.boehmer@jamesboehmer.com>
*/
-class Null extends AbstractTransport
+class Null extends NullTransport
{
- /**
- * Null transport.
- *
- * @param \Elastica\Request $request
- * @param array $params Hostname, port, path, ...
- * @return \Elastica\Response Response empty object
- */
- public function exec(Request $request, array $params)
- {
- $response = array(
- "took" => 0,
- "timed_out" => FALSE,
- "_shards" => array(
- "total" => 0,
- "successful" => 0,
- "failed" => 0
- ),
- "hits" => array(
- "total" => 0,
- "max_score" => NULL,
- "hits" => array()
- ),
- "params" => $params
- );
-
- return new Response(JSON::stringify($response));
- }
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Transport/NullTransport.php b/vendor/ruflin/elastica/lib/Elastica/Transport/NullTransport.php
new file mode 100644
index 00000000..d24f2110
--- /dev/null
+++ b/vendor/ruflin/elastica/lib/Elastica/Transport/NullTransport.php
@@ -0,0 +1,46 @@
+<?php
+namespace Elastica\Transport;
+
+use Elastica\JSON;
+use Elastica\Request;
+use Elastica\Response;
+
+/**
+ * Elastica Null Transport object.
+ *
+ * This is used in case you just need a test transport that doesn't do any connection to an elasticsearch
+ * host but still returns a valid response object
+ *
+ * @author James Boehmer <james.boehmer@jamesboehmer.com>
+ */
+class NullTransport extends AbstractTransport
+{
+ /**
+ * Null transport.
+ *
+ * @param \Elastica\Request $request
+ * @param array $params Hostname, port, path, ...
+ *
+ * @return \Elastica\Response Response empty object
+ */
+ public function exec(Request $request, array $params)
+ {
+ $response = array(
+ 'took' => 0,
+ 'timed_out' => false,
+ '_shards' => array(
+ 'total' => 0,
+ 'successful' => 0,
+ 'failed' => 0,
+ ),
+ 'hits' => array(
+ 'total' => 0,
+ 'max_score' => null,
+ 'hits' => array(),
+ ),
+ 'params' => $params,
+ );
+
+ return new Response(JSON::stringify($response));
+ }
+}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Transport/Thrift.php b/vendor/ruflin/elastica/lib/Elastica/Transport/Thrift.php
index f58c51a2..5790f665 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Transport/Thrift.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Transport/Thrift.php
@@ -1,7 +1,7 @@
<?php
-
namespace Elastica\Transport;
+use Elastica\Connection;
use Elastica\Exception\Connection\ThriftException;
use Elastica\Exception\PartialShardFailureException;
use Elastica\Exception\ResponseException;
@@ -9,23 +9,22 @@ use Elastica\Exception\RuntimeException;
use Elastica\JSON;
use Elastica\Request;
use Elastica\Response;
-use Elastica\Connection;
use Elasticsearch\Method;
-use Elasticsearch\RestResponse;
use Elasticsearch\RestClient;
use Elasticsearch\RestRequest;
-use Thrift\Transport\TSocket;
-use Thrift\Transport\TFramedTransport;
-use Thrift\Transport\TBufferedTransport;
-use Thrift\Protocol\TBinaryProtocolAccelerated;
+use Elasticsearch\RestResponse;
use Thrift\Exception\TException;
+use Thrift\Protocol\TBinaryProtocolAccelerated;
+use Thrift\Transport\TBufferedTransport;
+use Thrift\Transport\TFramedTransport;
+use Thrift\Transport\TSocket;
/**
- * Elastica Thrift Transport object
+ * Elastica Thrift Transport object.
*
- * @category Xodoa
- * @package Elastica
* @author Mikhail Shamin <munk13@gmail.com>
+ *
+ * @deprecated The thrift transport is deprecated as of ES 1.5, and will be removed in ES 2.0
*/
class Thrift extends AbstractTransport
{
@@ -35,9 +34,10 @@ class Thrift extends AbstractTransport
protected $_clients = array();
/**
- * Construct transport
+ * Construct transport.
*
* @param \Elastica\Connection $connection Connection object
+ *
* @throws \Elastica\Exception\RuntimeException
*/
public function __construct(Connection $connection = null)
@@ -50,10 +50,11 @@ class Thrift extends AbstractTransport
/**
* @param string $host
- * @param int $port
- * @param int $sendTimeout msec
- * @param int $recvTimeout msec
- * @param bool $framedTransport
+ * @param int $port
+ * @param int $sendTimeout msec
+ * @param int $recvTimeout msec
+ * @param bool $framedTransport
+ *
* @return \Elasticsearch\RestClient
*/
protected function _createClient($host, $port, $sendTimeout = null, $recvTimeout = null, $framedTransport = false)
@@ -84,28 +85,32 @@ class Thrift extends AbstractTransport
/**
* @param string $host
- * @param int $port
- * @param int $sendTimeout
- * @param int $recvTimeout
- * @param bool $framedTransport
+ * @param int $port
+ * @param int $sendTimeout
+ * @param int $recvTimeout
+ * @param bool $framedTransport
+ *
* @return \Elasticsearch\RestClient
*/
protected function _getClient($host, $port, $sendTimeout = null, $recvTimeout = null, $framedTransport = false)
{
- $key = $host . ':' . $port;
+ $key = $host.':'.$port;
if (!isset($this->_clients[$key])) {
$this->_clients[$key] = $this->_createClient($host, $port, $sendTimeout, $recvTimeout, $framedTransport);
}
+
return $this->_clients[$key];
}
/**
- * Makes calls to the elasticsearch server
+ * Makes calls to the elasticsearch server.
*
* @param \Elastica\Request $request
- * @param array $params Host, Port, ...
+ * @param array $params Host, Port, ...
+ *
* @throws \Elastica\Exception\Connection\ThriftException
* @throws \Elastica\Exception\ResponseException
+ *
* @return \Elastica\Response Response object
*/
public function exec(Request $request, array $params)
@@ -156,9 +161,7 @@ class Thrift extends AbstractTransport
throw new ThriftException($e, $request, $response);
}
- if (defined('DEBUG') && DEBUG) {
- $response->setQueryTime($end - $start);
- }
+ $response->setQueryTime($end - $start);
if ($response->hasError()) {
throw new ResponseException($request, $response);
diff --git a/vendor/ruflin/elastica/lib/Elastica/Type.php b/vendor/ruflin/elastica/lib/Elastica/Type.php
index 1ed952db..8abec330 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Type.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Type.php
@@ -1,36 +1,31 @@
<?php
-
namespace Elastica;
-use Elastica\Document;
-use Elastica\Exception\RuntimeException;
use Elastica\Exception\InvalidException;
use Elastica\Exception\NotFoundException;
-use Elastica\Exception\ResponseException;
+use Elastica\Exception\RuntimeException;
use Elastica\Type\Mapping;
/**
- * Elastica type object
+ * Elastica type object.
*
* elasticsearch has for every types as a substructure. This object
* represents a type inside a context
* The hierarchy is as following: client -> index -> type -> document
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
*/
class Type implements SearchableInterface
{
/**
- * Index
+ * Index.
*
* @var \Elastica\Index Index object
*/
protected $_index = null;
/**
- * Type name
+ * Type name.
*
* @var string Type name
*/
@@ -42,10 +37,10 @@ class Type implements SearchableInterface
protected $_serializer;
/**
- * Creates a new type object inside the given index
+ * Creates a new type object inside the given index.
*
* @param \Elastica\Index $index Index Object
- * @param string $name Type name
+ * @param string $name Type name
*/
public function __construct(Index $index, $name)
{
@@ -54,9 +49,10 @@ class Type implements SearchableInterface
}
/**
- * Adds the given document to the search index
+ * Adds the given document to the search index.
+ *
+ * @param \Elastica\Document $doc Document with data
*
- * @param \Elastica\Document $doc Document with data
* @return \Elastica\Response
*/
public function addDocument(Document $doc)
@@ -111,8 +107,10 @@ class Type implements SearchableInterface
/**
* @param $object
* @param Document $doc
- * @return Response
+ *
* @throws Exception\RuntimeException
+ *
+ * @return Response
*/
public function addObject($object, Document $doc = null)
{
@@ -130,37 +128,46 @@ class Type implements SearchableInterface
}
/**
- * Update document, using update script. Requires elasticsearch >= 0.19.0
+ * Update document, using update script. Requires elasticsearch >= 0.19.0.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html
+ *
+ * @param \Elastica\Document|\Elastica\Script $data Document with update data
+ * @param array $options array of query params to use for query. For possible options check es api
*
- * @param \Elastica\Document|\Elastica\Script $data Document with update data
* @throws \Elastica\Exception\InvalidException
+ *
* @return \Elastica\Response
- * @link http://www.elasticsearch.org/guide/reference/api/update.html
*/
- public function updateDocument($data)
+ public function updateDocument($data, array $options = array())
{
if (!($data instanceof Document) && !($data instanceof Script)) {
- throw new \InvalidArgumentException("Data should be a Document or Script");
+ throw new \InvalidArgumentException('Data should be a Document or Script');
}
if (!$data->hasId()) {
throw new InvalidException('Document or Script id is not set');
}
+ $id = urlencode($data->getId());
+
return $this->getIndex()->getClient()->updateDocument(
- $data->getId(),
+ $id,
$data,
$this->getIndex()->getName(),
- $this->getName()
+ $this->getName(),
+ $options
);
}
/**
- * Uses _bulk to send documents to the server
+ * Uses _bulk to send documents to the server.
+ *
+ * @param array|\Elastica\Document[] $docs Array of Elastica\Document
*
- * @param array|\Elastica\Document[] $docs Array of Elastica\Document
* @return \Elastica\Bulk\ResponseSet
- * @link http://www.elasticsearch.org/guide/reference/api/bulk.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
*/
public function updateDocuments(array $docs)
{
@@ -172,11 +179,13 @@ class Type implements SearchableInterface
}
/**
- * Uses _bulk to send documents to the server
+ * Uses _bulk to send documents to the server.
+ *
+ * @param array|\Elastica\Document[] $docs Array of Elastica\Document
*
- * @param array|\Elastica\Document[] $docs Array of Elastica\Document
* @return \Elastica\Bulk\ResponseSet
- * @link http://www.elasticsearch.org/guide/reference/api/bulk.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
*/
public function addDocuments(array $docs)
{
@@ -188,11 +197,13 @@ class Type implements SearchableInterface
}
/**
- * Uses _bulk to send documents to the server
+ * Uses _bulk to send documents to the server.
*
* @param objects[] $objects
+ *
* @return \Elastica\Bulk\ResponseSet
- * @link http://www.elasticsearch.org/guide/reference/api/bulk.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
*/
public function addObjects(array $objects)
{
@@ -213,27 +224,25 @@ class Type implements SearchableInterface
}
/**
- * Get the document from search index
+ * Get the document from search index.
+ *
+ * @param string $id Document id
+ * @param array $options Options for the get request.
*
- * @param string $id Document id
- * @param array $options Options for the get request.
* @throws \Elastica\Exception\NotFoundException
+ * @throws \Elastica\Exception\ResponseException
+ *
* @return \Elastica\Document
*/
public function getDocument($id, $options = array())
{
$path = urlencode($id);
- try {
- $response = $this->request($path, Request::GET, array(), $options);
- $result = $response->getData();
- } catch (ResponseException $e) {
- throw new NotFoundException('doc id ' . $id . ' not found');
- }
+ $response = $this->request($path, Request::GET, array(), $options);
+ $result = $response->getData();
- $info = $response->getTransferInfo();
- if ($info['http_code'] !== 200) {
- throw new NotFoundException('doc id ' . $id . ' not found');
+ if (!isset($result['found']) || $result['found'] === false) {
+ throw new NotFoundException('doc id '.$id.' not found');
}
if (isset($result['fields'])) {
@@ -251,8 +260,9 @@ class Type implements SearchableInterface
}
/**
- * @param string $id
+ * @param string $id
* @param array|string $data
+ *
* @return Document
*/
public function createDocument($id = '', $data = array())
@@ -264,7 +274,7 @@ class Type implements SearchableInterface
}
/**
- * Returns the type name
+ * Returns the type name.
*
* @return string Type name
*/
@@ -274,9 +284,10 @@ class Type implements SearchableInterface
}
/**
- * Sets value type mapping for this type
+ * Sets value type mapping for this type.
+ *
+ * @param \Elastica\Type\Mapping|array $mapping Elastica\Type\MappingType object or property array with all mappings
*
- * @param \Elastica\Type\Mapping|array $mapping Elastica\Type\MappingType object or property array with all mappings
* @return \Elastica\Response
*/
public function setMapping($mapping)
@@ -288,7 +299,7 @@ class Type implements SearchableInterface
}
/**
- * Returns current mapping for the given type
+ * Returns current mapping for the given type.
*
* @return array Current mapping
*/
@@ -308,10 +319,11 @@ class Type implements SearchableInterface
}
/**
- * Create search object
+ * Create search object.
+ *
+ * @param string|array|\Elastica\Query $query Array with all query data inside or a Elastica\Query object
+ * @param int|array $options OPTIONAL Limit or associative array of options (option=>value)
*
- * @param string|array|\Elastica\Query $query Array with all query data inside or a Elastica\Query object
- * @param int|array $options OPTIONAL Limit or associative array of options (option=>value)
* @return \Elastica\Search
*/
public function createSearch($query = '', $options = null)
@@ -325,11 +337,13 @@ class Type implements SearchableInterface
}
/**
- * Do a search on this type
+ * Do a search on this type.
+ *
+ * @param string|array|\Elastica\Query $query Array with all query data inside or a Elastica\Query object
+ * @param int|array $options OPTIONAL Limit or associative array of options (option=>value)
+ *
+ * @return \Elastica\ResultSet ResultSet with all results inside
*
- * @param string|array|\Elastica\Query $query Array with all query data inside or a Elastica\Query object
- * @param int|array $options OPTIONAL Limit or associative array of options (option=>value)
- * @return \Elastica\ResultSet ResultSet with all results inside
* @see \Elastica\SearchableInterface::search
*/
public function search($query = '', $options = null)
@@ -340,10 +354,12 @@ class Type implements SearchableInterface
}
/**
- * Count docs by query
+ * Count docs by query.
+ *
+ * @param string|array|\Elastica\Query $query Array with all query data inside or a Elastica\Query object
+ *
+ * @return int number of documents matching the query
*
- * @param string|array|\Elastica\Query $query Array with all query data inside or a Elastica\Query object
- * @return int number of documents matching the query
* @see \Elastica\SearchableInterface::count
*/
public function count($query = '')
@@ -354,7 +370,7 @@ class Type implements SearchableInterface
}
/**
- * Returns index client
+ * Returns index client.
*
* @return \Elastica\Index Index object
*/
@@ -365,6 +381,7 @@ class Type implements SearchableInterface
/**
* @param \Elastica\Document $document
+ *
* @return \Elastica\Response
*/
public function deleteDocument(Document $document)
@@ -378,18 +395,21 @@ class Type implements SearchableInterface
'replication',
'consistency',
'refresh',
- 'timeout'
+ 'timeout',
)
);
+
return $this->deleteById($document->getId(), $options);
}
/**
- * Uses _bulk to delete documents from the server
+ * Uses _bulk to delete documents from the server.
+ *
+ * @param array|\Elastica\Document[] $docs Array of Elastica\Document
*
- * @param array|\Elastica\Document[] $docs Array of Elastica\Document
* @return \Elastica\Bulk\ResponseSet
- * @link http://www.elasticsearch.org/guide/reference/api/bulk.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
*/
public function deleteDocuments(array $docs)
{
@@ -401,14 +421,17 @@ class Type implements SearchableInterface
}
/**
- * Deletes an entry by its unique identifier
+ * Deletes an entry by its unique identifier.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete.html
+ *
+ * @param int|string $id Document id
+ * @param array $options
*
- * @param int|string $id Document id
- * @param array $options
* @throws \InvalidArgumentException
* @throws \Elastica\Exception\NotFoundException
- * @return \Elastica\Response Response object
- * @link http://www.elasticsearch.org/guide/reference/api/delete.html
+ *
+ * @return \Elastica\Response Response object
*/
public function deleteById($id, array $options = array())
{
@@ -423,17 +446,18 @@ class Type implements SearchableInterface
$responseData = $response->getData();
if (isset($responseData['found']) && false == $responseData['found']) {
- throw new NotFoundException('Doc id ' . $id . ' not found and can not be deleted');
+ throw new NotFoundException('Doc id '.$id.' not found and can not be deleted');
}
return $response;
}
/**
- * Deletes the given list of ids from this type
+ * Deletes the given list of ids from this type.
+ *
+ * @param array $ids
+ * @param string|false $routing Optional routing key for all ids
*
- * @param array $ids
- * @param string|false $routing Optional routing key for all ids
* @return \Elastica\Response Response object
*/
public function deleteIds(array $ids, $routing = false)
@@ -442,18 +466,21 @@ class Type implements SearchableInterface
}
/**
- * Deletes entries in the db based on a query
+ * Deletes entries in the db based on a query.
+ *
+ * @param \Elastica\Query|string $query Query object
+ * @param array $options Optional params
*
- * @param \Elastica\Query|string $query Query object
- * @param array $options Optional params
* @return \Elastica\Response
- * @link http://www.elasticsearch.org/guide/reference/api/delete-by-query.html
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html
*/
public function deleteByQuery($query, array $options = array())
{
if (is_string($query)) {
// query_string queries are not supported for delete by query operations
$options['q'] = $query;
+
return $this->request('_query', Request::DELETE, array(), $options);
}
$query = Query::create($query);
@@ -474,56 +501,64 @@ class Type implements SearchableInterface
}
/**
- * More like this query based on the given object
+ * More like this query based on the given object.
*
* The id in the given object has to be set
*
- * @param \Elastica\Document $doc Document to query for similar objects
- * @param array $params OPTIONAL Additional arguments for the query
- * @param string|array|\Elastica\Query $query OPTIONAL Query to filter the moreLikeThis results
- * @return \Elastica\ResultSet ResultSet with all results inside
- * @link http://www.elasticsearch.org/guide/reference/api/more-like-this.html
+ * @param \Elastica\Document $doc Document to query for similar objects
+ * @param array $params OPTIONAL Additional arguments for the query
+ * @param string|array|\Elastica\Query $query OPTIONAL Query to filter the moreLikeThis results
+ *
+ * @return \Elastica\ResultSet ResultSet with all results inside
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/search-more-like-this.html
*/
public function moreLikeThis(Document $doc, $params = array(), $query = array())
{
- $path = $doc->getId() . '/_mlt';
+ $path = $doc->getId().'/_mlt';
$query = Query::create($query);
$response = $this->request($path, Request::GET, $query->toArray(), $params);
- return new ResultSet($response, $query);
+ return ResultSet::create($response, $query);
}
/**
- * Makes calls to the elasticsearch server based on this type
+ * Makes calls to the elasticsearch server based on this type.
+ *
+ * @param string $path Path to call
+ * @param string $method Rest method to use (GET, POST, DELETE, PUT)
+ * @param array $data OPTIONAL Arguments as array
+ * @param array $query OPTIONAL Query params
*
- * @param string $path Path to call
- * @param string $method Rest method to use (GET, POST, DELETE, PUT)
- * @param array $data OPTIONAL Arguments as array
- * @param array $query OPTIONAL Query params
* @return \Elastica\Response Response object
*/
public function request($path, $method, $data = array(), array $query = array())
{
- $path = $this->getName() . '/' . $path;
+ $path = $this->getName().'/'.$path;
return $this->getIndex()->request($path, $method, $data, $query);
}
/**
- * Sets the serializer callable used in addObject
+ * Sets the serializer callable used in addObject.
+ *
* @see \Elastica\Type::addObject
*
* @param array|string $serializer @see \Elastica\Type::_serializer
+ *
+ * @return $this
*/
public function setSerializer($serializer)
{
$this->_serializer = $serializer;
+
+ return $this;
}
/**
- * Checks if the given type exists in Index
+ * Checks if the given type exists in Index.
*
* @return bool True if type exists
*/
@@ -532,6 +567,6 @@ class Type implements SearchableInterface
$response = $this->getIndex()->request($this->getName(), Request::HEAD);
$info = $response->getTransferInfo();
- return (bool)($info['http_code'] == 200);
+ return (bool) ($info['http_code'] == 200);
}
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Type/AbstractType.php b/vendor/ruflin/elastica/lib/Elastica/Type/AbstractType.php
index ba2e0430..648102d2 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Type/AbstractType.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Type/AbstractType.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Type;
use Elastica\Client;
@@ -24,8 +23,7 @@ use Elastica\Util;
* - $_indexParams: Parameters for the index
*
* @todo Add some settings examples to code
- * @category Xodoa
- * @package Elastica
+ *
* @author Nicolas Ruflin <spam@ruflin.com>
*/
abstract class AbstractType implements SearchableInterface
@@ -33,68 +31,69 @@ abstract class AbstractType implements SearchableInterface
const MAX_DOCS_PER_REQUEST = 1000;
/**
- * Index name
+ * Index name.
*
* @var string Index name
*/
protected $_indexName = '';
/**
- * Index name
+ * Index name.
*
* @var string Index name
*/
protected $_typeName = '';
/**
- * Client
+ * Client.
*
* @var \Elastica\Client Client object
*/
protected $_client = null;
/**
- * Index
+ * Index.
*
* @var \Elastica\Index Index object
*/
protected $_index = null;
/**
- * Type
+ * Type.
*
* @var \Elastica\Type Type object
*/
protected $_type = null;
/**
- * Mapping
+ * Mapping.
*
* @var array Mapping
*/
protected $_mapping = array();
/**
- * Index params
+ * Index params.
*
* @var array Index params
*/
protected $_indexParams = array();
/**
- * Source
+ * Source.
*
- * @var boolean Source
+ * @var bool Source
*/
protected $_source = true;
/**
- * Creates index object with client connection
+ * Creates index object with client connection.
*
* Reads index and type name from protected vars _indexName and _typeName.
* Has to be set in child class
*
- * @param \Elastica\Client $client OPTIONAL Client object
+ * @param \Elastica\Client $client OPTIONAL Client object
+ *
* @throws \Elastica\Exception\InvalidException
*/
public function __construct(Client $client = null)
@@ -117,7 +116,7 @@ abstract class AbstractType implements SearchableInterface
}
/**
- * Creates the index and sets the mapping for this type
+ * Creates the index and sets the mapping for this type.
*
* @param bool $recreate OPTIONAL Recreates the index if true (default = false)
*/
@@ -133,7 +132,8 @@ abstract class AbstractType implements SearchableInterface
/**
* @param \Elastica\Query $query
- * @param array|int $options
+ * @param array|int $options
+ *
* @return \Elastica\Search
*/
public function createSearch($query = '', $options = null)
@@ -142,10 +142,12 @@ abstract class AbstractType implements SearchableInterface
}
/**
- * Search on the type
+ * Search on the type.
+ *
+ * @param string|array|\Elastica\Query $query Array with all query data inside or a Elastica\Query object
+ *
+ * @return \Elastica\ResultSet ResultSet with all results inside
*
- * @param string|array|\Elastica\Query $query Array with all query data inside or a Elastica\Query object
- * @return \Elastica\ResultSet ResultSet with all results inside
* @see \Elastica\SearchableInterface::search
*/
public function search($query = '', $options = null)
@@ -154,10 +156,12 @@ abstract class AbstractType implements SearchableInterface
}
/**
- * Count docs in the type based on query
+ * Count docs in the type based on query.
+ *
+ * @param string|array|\Elastica\Query $query Array with all query data inside or a Elastica\Query object
+ *
+ * @return int number of documents matching the query
*
- * @param string|array|\Elastica\Query $query Array with all query data inside or a Elastica\Query object
- * @return int number of documents matching the query
* @see \Elastica\SearchableInterface::count
*/
public function count($query = '')
@@ -166,7 +170,7 @@ abstract class AbstractType implements SearchableInterface
}
/**
- * Returns the search index
+ * Returns the search index.
*
* @return \Elastica\Index Index object
*/
@@ -176,7 +180,7 @@ abstract class AbstractType implements SearchableInterface
}
/**
- * Returns type object
+ * Returns type object.
*
* @return \Elastica\Type Type object
*/
@@ -186,11 +190,12 @@ abstract class AbstractType implements SearchableInterface
}
/**
- * Converts given time to format: 1995-12-31T23:59:59Z
+ * Converts given time to format: 1995-12-31T23:59:59Z.
*
* This is the lucene date format
*
- * @param int $date Date input (could be string etc.) -> must be supported by strtotime
+ * @param int $date Date input (could be string etc.) -> must be supported by strtotime
+ *
* @return string Converted date string
*/
public function convertDate($date)
diff --git a/vendor/ruflin/elastica/lib/Elastica/Type/Mapping.php b/vendor/ruflin/elastica/lib/Elastica/Type/Mapping.php
index 920093fb..509f0ce2 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Type/Mapping.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Type/Mapping.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Type;
use Elastica\Exception\InvalidException;
@@ -7,34 +6,33 @@ use Elastica\Request;
use Elastica\Type;
/**
- * Elastica Mapping object
+ * Elastica Mapping object.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
- * @link http://www.elasticsearch.org/guide/reference/mapping/
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html
*/
class Mapping
{
/**
- * Mapping
+ * Mapping.
*
* @var array Mapping
*/
protected $_mapping = array();
/**
- * Type
+ * Type.
*
* @var \Elastica\Type Type object
*/
protected $_type = null;
/**
- * Construct Mapping
+ * Construct Mapping.
*
* @param \Elastica\Type $type OPTIONAL Type object
- * @param array $properties OPTIONAL Properties
+ * @param array $properties OPTIONAL Properties
*/
public function __construct(Type $type = null, array $properties = array())
{
@@ -50,8 +48,10 @@ class Mapping
/**
* Sets the mapping type
* Enter description here ...
- * @param \Elastica\Type $type Type object
- * @return \Elastica\Type\Mapping Current object
+ *
+ * @param \Elastica\Type $type Type object
+ *
+ * @return $this
*/
public function setType(Type $type)
{
@@ -61,10 +61,11 @@ class Mapping
}
/**
- * Sets the mapping properties
+ * Sets the mapping properties.
+ *
+ * @param array $properties Properties
*
- * @param array $properties Properties
- * @return \Elastica\Type\Mapping Mapping object
+ * @return $this
*/
public function setProperties(array $properties)
{
@@ -72,9 +73,9 @@ class Mapping
}
/**
- * Gets the mapping properties
+ * Gets the mapping properties.
*
- * @return array $properties Properties
+ * @return array $properties Properties
*/
public function getProperties()
{
@@ -82,10 +83,13 @@ class Mapping
}
/**
- * Sets the mapping _meta
+ * Sets the mapping _meta.
+ *
* @param array $meta metadata
- * @return \Elastica\Type\Mapping Mapping object
- * @link http://www.elasticsearch.org/guide/reference/mapping/meta.html
+ *
+ * @return $this
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-meta.html
*/
public function setMeta(array $meta)
{
@@ -93,7 +97,7 @@ class Mapping
}
/**
- * Returns mapping type
+ * Returns mapping type.
*
* @return \Elastica\Type Type
*/
@@ -103,14 +107,16 @@ class Mapping
}
/**
- * Sets source values
+ * Sets source values.
*
* To disable source, argument is
* array('enabled' => false)
*
- * @param array $source Source array
- * @return \Elastica\Type\Mapping Current object
- * @link http://www.elasticsearch.org/guide/reference/mapping/source-field.html
+ * @param array $source Source array
+ *
+ * @return $this
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-source-field.html
*/
public function setSource(array $source)
{
@@ -118,12 +124,13 @@ class Mapping
}
/**
- * Disables the source in the index
+ * Disables the source in the index.
*
* Param can be set to true to enable again
*
- * @param bool $enabled OPTIONAL (default = false)
- * @return \Elastica\Type\Mapping Current object
+ * @param bool $enabled OPTIONAL (default = false)
+ *
+ * @return $this
*/
public function disableSource($enabled = false)
{
@@ -131,7 +138,7 @@ class Mapping
}
/**
- * Sets raw parameters
+ * Sets raw parameters.
*
* Possible options:
* _uid
@@ -147,9 +154,10 @@ class Mapping
* _size
* properties
*
- * @param string $key Key name
- * @param mixed $value Key value
- * @return \Elastica\Type\Mapping Current object
+ * @param string $key Key name
+ * @param mixed $value Key value
+ *
+ * @return $this
*/
public function setParam($key, $value)
{
@@ -159,22 +167,25 @@ class Mapping
}
/**
- * Get raw parameters
+ * Get raw parameters.
*
* @see setParam
- * @param string $key Key name
- * @return mixed $value Key value
+ *
+ * @param string $key Key name
+ *
+ * @return mixed $value Key value
*/
public function getParam($key)
{
- return isset($this->_mapping[$key])?$this->_mapping[$key]:null;
+ return isset($this->_mapping[$key]) ? $this->_mapping[$key] : null;
}
/**
- * Sets params for the "_all" field
+ * Sets params for the "_all" field.
+ *
+ * @param array $params _all Params (enabled, store, term_vector, analyzer)
*
- * @param array $params _all Params (enabled, store, term_vector, analyzer)
- * @return \Elastica\Type\Mapping
+ * @return $this
*/
public function setAllField(array $params)
{
@@ -182,10 +193,11 @@ class Mapping
}
/**
- * Enables the "_all" field
+ * Enables the "_all" field.
*
- * @param bool $enabled OPTIONAL (default = true)
- * @return \Elastica\Type\Mapping
+ * @param bool $enabled OPTIONAL (default = true)
+ *
+ * @return $this
*/
public function enableAllField($enabled = true)
{
@@ -193,22 +205,23 @@ class Mapping
}
/**
- * Set TTL
+ * Set TTL.
+ *
+ * @param array $params TTL Params (enabled, default, ...)
*
- * @param array $params TTL Params (enabled, default, ...)
- * @return \Elastica\Type\Mapping
+ * @return $this
*/
public function setTtl(array $params)
{
return $this->setParam('_ttl', $params);
-
}
/**
- * Enables TTL for all documents in this type
+ * Enables TTL for all documents in this type.
*
- * @param bool $enabled OPTIONAL (default = true)
- * @return \Elastica\Type\Mapping
+ * @param bool $enabled OPTIONAL (default = true)
+ *
+ * @return $this
*/
public function enableTtl($enabled = true)
{
@@ -216,10 +229,11 @@ class Mapping
}
/**
- * Set parent type
+ * Set parent type.
+ *
+ * @param string $type Parent type
*
- * @param string $type Parent type
- * @return \Elastica\Type\Mapping
+ * @return $this
*/
public function setParent($type)
{
@@ -227,10 +241,11 @@ class Mapping
}
/**
- * Converts the mapping to an array
+ * Converts the mapping to an array.
*
* @throws \Elastica\Exception\InvalidException
- * @return array Mapping as array
+ *
+ * @return array Mapping as array
*/
public function toArray()
{
@@ -244,7 +259,7 @@ class Mapping
}
/**
- * Submits the mapping and sends it to the server
+ * Submits the mapping and sends it to the server.
*
* @return \Elastica\Response Response object
*/
@@ -256,22 +271,24 @@ class Mapping
}
/**
- * Creates a mapping object
+ * Creates a mapping object.
+ *
+ * @param array|\Elastica\Type\Mapping $mapping Mapping object or properties array
*
- * @param array|\Elastica\Type\Mapping $mapping Mapping object or properties array
- * @return \Elastica\Type\Mapping Mapping object
* @throws \Elastica\Exception\InvalidException If invalid type
+ *
+ * @return self
*/
public static function create($mapping)
{
if (is_array($mapping)) {
- $mappingObject = new Mapping();
+ $mappingObject = new self();
$mappingObject->setProperties($mapping);
} else {
$mappingObject = $mapping;
}
- if (!$mappingObject instanceof Mapping) {
+ if (!$mappingObject instanceof self) {
throw new InvalidException('Invalid object type');
}
diff --git a/vendor/ruflin/elastica/lib/Elastica/Util.php b/vendor/ruflin/elastica/lib/Elastica/Util.php
index 679bd558..a49f2d78 100644
--- a/vendor/ruflin/elastica/lib/Elastica/Util.php
+++ b/vendor/ruflin/elastica/lib/Elastica/Util.php
@@ -1,29 +1,27 @@
<?php
-
namespace Elastica;
-use Elastica\JSON;
-
/**
- * Elastica tools
+ * Elastica tools.
*
- * @category Xodoa
- * @package Elastica
* @author Nicolas Ruflin <spam@ruflin.com>
* @author Thibault Duplessis <thibault.duplessis@gmail.com>
* @author Oleg Zinchenko <olegz@default-value.com>
+ * @author Roberto Nygaard <roberto@nygaard.es>
*/
class Util
{
/**
* Replace the following reserved words: AND OR NOT
* and
- * escapes the following terms: + - && || ! ( ) { } [ ] ^ " ~ * ? : \
+ * escapes the following terms: + - && || ! ( ) { } [ ] ^ " ~ * ? : \.
*
- * @param string $term Query term to replace and escape
- * @return string Replaced and escaped query term
* @link http://lucene.apache.org/java/2_4_0/queryparsersyntax.html#Boolean%20operators
* @link http://lucene.apache.org/java/2_4_0/queryparsersyntax.html#Escaping%20Special%20Characters
+ *
+ * @param string $term Query term to replace and escape
+ *
+ * @return string Replaced and escaped query term
*/
public static function replaceBooleanWordsAndEscapeTerm($term)
{
@@ -36,78 +34,82 @@ class Util
/**
* Escapes the following terms (because part of the query language)
- * + - && || ! ( ) { } [ ] ^ " ~ * ? : \
+ * + - && || ! ( ) { } [ ] ^ " ~ * ? : \ < >.
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#_reserved_characters
+ *
+ * @param string $term Query term to escape
*
- * @param string $term Query term to escape
* @return string Escaped query term
- * @link http://lucene.apache.org/java/2_4_0/queryparsersyntax.html#Escaping%20Special%20Characters
*/
public static function escapeTerm($term)
{
$result = $term;
// \ escaping has to be first, otherwise escaped later once again
- $chars = array('\\', '+', '-', '&&', '||', '!', '(', ')', '{', '}', '[', ']', '^', '"', '~', '*', '?', ':');
+ $chars = array('\\', '+', '-', '&&', '||', '!', '(', ')', '{', '}', '[', ']', '^', '"', '~', '*', '?', ':', '/', '<', '>');
foreach ($chars as $char) {
- $result = str_replace($char, '\\' . $char, $result);
+ $result = str_replace($char, '\\'.$char, $result);
}
- // since elasticsearch uses lucene 4.0 / needs to be escaped by \\
- $result = str_replace('/', '\\\\/', $result);
-
return $result;
}
/**
* Replace the following reserved words (because part of the query language)
- * AND OR NOT
+ * AND OR NOT.
*
- * @param string $term Query term to replace
- * @return string Replaced query term
* @link http://lucene.apache.org/java/2_4_0/queryparsersyntax.html#Boolean%20operators
+ *
+ * @param string $term Query term to replace
+ *
+ * @return string Replaced query term
*/
public static function replaceBooleanWords($term)
{
- $replacementMap = array('AND'=>'&&', 'OR'=>'||', 'NOT'=>'!');
+ $replacementMap = array(' AND ' => ' && ', ' OR ' => ' || ', ' NOT ' => ' !');
$result = strtr($term, $replacementMap);
return $result;
}
/**
- * Converts a snake_case string to CamelCase
+ * Converts a snake_case string to CamelCase.
*
* For example: hello_world to HelloWorld
*
- * @param string $string snake_case string
+ * @param string $string snake_case string
+ *
* @return string CamelCase string
*/
public static function toCamelCase($string)
{
- return str_replace(" ", "", ucwords(str_replace("_", " ", $string)));
+ return str_replace(' ', '', ucwords(str_replace('_', ' ', $string)));
}
/**
- * Converts a CamelCase string to snake_case
+ * Converts a CamelCase string to snake_case.
*
* For Example HelloWorld to hello_world
*
- * @param string $string CamelCase String to Convert
+ * @param string $string CamelCase String to Convert
+ *
* @return string SnakeCase string
*/
public static function toSnakeCase($string)
{
$string = preg_replace('/([A-Z])/', '_$1', $string);
- return strtolower(substr($string,1));
+ return strtolower(substr($string, 1));
}
/**
- * Converts given time to format: 1995-12-31T23:59:59Z
+ * Converts given time to format: 1995-12-31T23:59:59Z.
*
* This is the lucene date format
*
- * @param int $date Date input (could be string etc.) -> must be supported by strtotime
+ * @param int $date Date input (could be string etc.) -> must be supported by strtotime
+ *
* @return string Converted date string
*/
public static function convertDate($date)
@@ -117,16 +119,35 @@ class Util
} else {
$timestamp = strtotime($date);
}
- $string = date('Y-m-d\TH:i:s\Z', $timestamp);
+ $string = date('Y-m-d\TH:i:s\Z', $timestamp);
+
+ return $string;
+ }
+
+ /**
+ * Convert a \DateTime object to format: 1995-12-31T23:59:59Z+02:00.
+ *
+ * Converts it to the lucene format, including the appropriate TimeZone
+ *
+ * @param \DateTime $dateTime
+ * @param bool $includeTimezone
+ *
+ * @return string
+ */
+ public static function convertDateTimeObject(\DateTime $dateTime, $includeTimezone = true)
+ {
+ $formatString = 'Y-m-d\TH:i:s'.($includeTimezone === true ? 'P' : '\Z');
+ $string = $dateTime->format($formatString);
return $string;
}
/**
* Tries to guess the name of the param, based on its class
- * Example: \Elastica\Filter\HasChildFilter => has_child
+ * Example: \Elastica\Filter\HasChildFilter => has_child.
*
* @param string|object Class or Class name
+ *
* @return string parameter name
*/
public static function getParamName($class)
@@ -136,36 +157,38 @@ class Util
}
$parts = explode('\\', $class);
- $last = array_pop($parts);
- $last = preg_replace('/(Facet|Query|Filter)$/', '', $last);
- $name = self::toSnakeCase($last);
+ $last = array_pop($parts);
+ $last = preg_replace('/(Facet|Query|Filter)$/', '', $last);
+ $name = self::toSnakeCase($last);
return $name;
}
/**
- * Converts Request to Curl console command
+ * Converts Request to Curl console command.
*
* @param Request $request
+ *
* @return string
*/
public static function convertRequestToCurlCommand(Request $request)
{
- $message = 'curl -X' . strtoupper($request->getMethod()) . ' ';
- $message .= '\'http://' . $request->getConnection()->getHost() . ':' . $request->getConnection()->getPort() . '/';
+ $message = 'curl -X'.strtoupper($request->getMethod()).' ';
+ $message .= '\'http://'.$request->getConnection()->getHost().':'.$request->getConnection()->getPort().'/';
$message .= $request->getPath();
$query = $request->getQuery();
if (!empty($query)) {
- $message .= '?' . http_build_query($query);
+ $message .= '?'.http_build_query($query);
}
$message .= '\'';
$data = $request->getData();
if (!empty($data)) {
- $message .= ' -d \'' . JSON::stringify($data) . '\'';
+ $message .= ' -d \''.JSON::stringify($data).'\'';
}
+
return $message;
}
}
diff --git a/vendor/ruflin/elastica/test/benchmark/BulkMemoryUsageTest.php b/vendor/ruflin/elastica/test/benchmark/BulkMemoryUsageTest.php
deleted file mode 100644
index 23e6521f..00000000
--- a/vendor/ruflin/elastica/test/benchmark/BulkMemoryUsageTest.php
+++ /dev/null
@@ -1,46 +0,0 @@
-<?php
-
-use Elastica\Client;
-use Elastica\Document;
-
-class BulkMemoryUsageTest extends \PHPUnit_Framework_TestCase
-{
-
- /**
- * Some memory usage stats
- *
- * Really simple and quite stupid ...
- */
- public function testServersArray()
- {
- $client = new Client();
- $index = $client->getIndex('test');
- $index->create(array(), true);
- $type = $index->getType('test');
-
- $data = array(
- 'text1' => 'Very long text for a string',
- 'text2' => 'But this is not very long',
- 'text3' => 'random or not random?',
- );
-
- $startMemory = memory_get_usage();
-
- for ($n = 1; $n < 10; $n++) {
- $docs = array();
-
- for ($i = 1; $i <= 3000; $i++) {
- $docs[] = new Document(uniqid(), $data);
- }
-
- $type->addDocuments($docs);
- $docs = array();
- }
-
- unset($docs);
-
- $endMemory = memory_get_usage();
-
- $this->assertLessThan(1.2, $endMemory/$startMemory);
- }
-}
diff --git a/vendor/ruflin/elastica/test/benchmark/ClientTest.php b/vendor/ruflin/elastica/test/benchmark/ClientTest.php
deleted file mode 100644
index e7a040f7..00000000
--- a/vendor/ruflin/elastica/test/benchmark/ClientTest.php
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-
-use Elastica\Client;
-use Elastica\Document;
-
-class ClientTest extends \PHPUnit_Framework_TestCase
-{
-
- public function testServersArray()
- {
- $client = new Client();
- $index = $client->getIndex('test');
- $index->create(array(), true);
- $type = $index->getType('test');
-
- $start = microtime(true);
-
- for ($i = 1; $i <= 10000; $i++) {
- $doc = new Document($i, array('test' => 1));
- $type->addDocument($doc);
- }
-
- // Refresh index
- $index->refresh();
-
- $end = microtime(true);
-
- //echo $end - $start;
-
- }
-}
diff --git a/vendor/ruflin/elastica/test/benchmark/phpunit.benchmark.xml b/vendor/ruflin/elastica/test/benchmark/phpunit.benchmark.xml
deleted file mode 100644
index a530de35..00000000
--- a/vendor/ruflin/elastica/test/benchmark/phpunit.benchmark.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<phpunit backupGlobals="false"
- backupStaticAttributes="false"
- bootstrap="../bootstrap.php"
- colors="true">
- <testsuites>
- <testsuite name="Transport">
- <file>TransportTest.php</file>
- </testsuite>
- </testsuites>
-</phpunit> \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/bin/install_php_memcache.sh b/vendor/ruflin/elastica/test/bin/install_php_memcache.sh
deleted file mode 100644
index dd046a56..00000000
--- a/vendor/ruflin/elastica/test/bin/install_php_memcache.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-
-# Build and install PHP Memcache extension
-wget http://pecl.php.net/get/memcache-${MEMCACHE_VER}.tgz
-tar -xzf memcache-${MEMCACHE_VER}.tgz
-sh -c "cd memcache-${MEMCACHE_VER} && phpize && ./configure --enable-memcache && make && sudo make install"
-echo "extension=memcache.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
-
diff --git a/vendor/ruflin/elastica/test/bin/run_elasticsearch.sh b/vendor/ruflin/elastica/test/bin/run_elasticsearch.sh
deleted file mode 100644
index ddbbef35..00000000
--- a/vendor/ruflin/elastica/test/bin/run_elasticsearch.sh
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/bin/bash
-
-check_port_http_code() {
- http_code=`echo $(curl -s -o /dev/null -w "%{http_code}" "http://localhost:$1")`
- return `test $http_code = "$2"`
-}
-
-wget http://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-${ES_VER}.tar.gz
-tar -xzf elasticsearch-${ES_VER}.tar.gz
-
-elasticsearch-${ES_VER}/bin/plugin -install elasticsearch/elasticsearch-mapper-attachments/${ES_MAPPER_ATTACHMENTS_VER}
-#elasticsearch-${ES_VER}/bin/plugin -install elasticsearch/elasticsearch-transport-thrift/${ES_TRANSPORT_THRIFT_VER}
-elasticsearch-${ES_VER}/bin/plugin -install geocluster-facet --url https://github.com/zenobase/geocluster-facet/releases/download/${ES_GEOCLUSTER_FACET_VER}/geocluster-facet-${ES_GEOCLUSTER_FACET_VER}.jar
-
-export JAVA_OPTS="-server"
-
-# start 3 elasticsearch instances
-for i in 0 1 2
-do
- echo "Setup node #$i"
-
- let "http_port = 9200 + $i"
- let "thrift_port = 9500 + $i"
-
- config_yml=elasticsearch-${ES_VER}/config/elasticsearch-$http_port.yml
-
- echo "Creating config $config_yml"
-
- cp elasticsearch-${ES_VER}/config/elasticsearch.yml $config_yml
-
- echo "index.number_of_shards: 2" >> $config_yml
- echo "index.number_of_replicas: 0" >> $config_yml
- echo "discovery.zen.ping.multicast.enabled: false" >> $config_yml
- echo "http.port: $http_port" >> $config_yml
- echo "thrift.port: $thrift_port" >> $config_yml
-
- # enable udp
- echo "bulk.udp.enabled: true" >> $config_yml
- echo "bulk.udp.bulk_actions: 5" >> $config_yml
-
- # enable dynamic scripting
- echo "script.disable_dynamic: false" >> $config_yml
-
- echo "Starting server on http port: $http_port"
-
- elasticsearch-${ES_VER}/bin/elasticsearch -d -Des.config=$config_yml &
-
- while ! check_port_http_code $http_port 200; do
- echo -n "."
- sleep 2s
- done
- echo ""
- echo "Server #$i is up"
-done
-
-echo "three elasticsearch nodes are up"
diff --git a/vendor/ruflin/elastica/test/bin/run_proxy.sh b/vendor/ruflin/elastica/test/bin/run_proxy.sh
deleted file mode 100644
index c62db8cd..00000000
--- a/vendor/ruflin/elastica/test/bin/run_proxy.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-sudo killall nginx 2>/dev/null
-
-echo "installing nginx"
-
-sudo apt-get install nginx
-
-echo "stopping stock nginx"
-
-/etc/init.d/nginx stop
-
-echo "running nginx"
-
-sudo nginx -p test/nginx/ -c nginx.conf
diff --git a/vendor/ruflin/elastica/test/bin/show_logs.sh b/vendor/ruflin/elastica/test/bin/show_logs.sh
deleted file mode 100644
index 0130d2a5..00000000
--- a/vendor/ruflin/elastica/test/bin/show_logs.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-
-cat elasticsearch-${ES_VER}/logs/* \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/bootstrap.php b/vendor/ruflin/elastica/test/bootstrap.php
index 5903f805..8a29cf0f 100644
--- a/vendor/ruflin/elastica/test/bootstrap.php
+++ b/vendor/ruflin/elastica/test/bootstrap.php
@@ -2,4 +2,4 @@
defined('BASE_PATH') || define('BASE_PATH', realpath(__DIR__));
-require dirname(__DIR__) . '/vendor/autoload.php';
+require dirname(__DIR__).'/vendor/autoload.php';
diff --git a/vendor/ruflin/elastica/test/data/test.jpg b/vendor/ruflin/elastica/test/data/test.jpg
new file mode 100644
index 00000000..d69e5672
--- /dev/null
+++ b/vendor/ruflin/elastica/test/data/test.jpg
Binary files differ
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/AvgTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/AvgTest.php
index 5c6fe13d..650a4655 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/AvgTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/AvgTest.php
@@ -1,38 +1,39 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Avg;
use Elastica\Document;
-use Elastica\Index;
use Elastica\Query;
class AvgTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex('avg');
- $docs = array(
- new Document('1', array('price' => 5)),
- new Document('2', array('price' => 8)),
- new Document('3', array('price' => 1)),
- new Document('4', array('price' => 3)),
- );
- $this->_index->getType('test')->addDocuments($docs);
- $this->_index->refresh();
+ $index = $this->_createIndex();
+
+ $index->getType('test')->addDocuments(array(
+ new Document(1, array('price' => 5)),
+ new Document(2, array('price' => 8)),
+ new Document(3, array('price' => 1)),
+ new Document(4, array('price' => 3)),
+ ));
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group functional
+ */
public function testAvgAggregation()
{
- $agg = new Avg("avg");
+ $agg = new Avg('avg');
$agg->setField('price');
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregations();
+ $results = $this->_getIndexForTest()->search($query)->getAggregations();
$this->assertEquals((5 + 8 + 1 + 3) / 4.0, $results['avg']['value']);
}
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/BaseAggregationTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/BaseAggregationTest.php
index 5569ca78..48003d7e 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/BaseAggregationTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/BaseAggregationTest.php
@@ -1,28 +1,8 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
-use Elastica\Index;
use Elastica\Test\Base;
abstract class BaseAggregationTest extends Base
{
- /**
- * @var Index
- */
- protected $_index;
-
- protected function tearDown()
- {
- parent::tearDown();
- if ($this->_index instanceof Index) {
- $this->_index->delete();
- }
- }
-
- protected function _createIndex($name = 'test', $delete = true, $shards = 1)
- {
- return parent::_createIndex('test_aggregation_' . $name, $delete, $shards);
- }
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/CardinalityTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/CardinalityTest.php
index d2f4d2be..7bc383f0 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/CardinalityTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/CardinalityTest.php
@@ -1,38 +1,132 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Cardinality;
use Elastica\Document;
use Elastica\Query;
class CardinalityTest extends BaseAggregationTest
{
- protected function setUp()
- {
- parent::setUp();
- $this->_index = $this->_createIndex("cardinality");
- $docs = array(
- new Document("1", array("color" => "blue")),
- new Document("2", array("color" => "blue")),
- new Document("3", array("color" => "red")),
- new Document("4", array("color" => "green")),
- );
- $this->_index->getType("test")->addDocuments($docs);
- $this->_index->refresh();
+ protected function _getIndexForTest()
+ {
+ $index = $this->_createIndex();
+
+ $index->getType('test')->addDocuments(array(
+ new Document(1, array('color' => 'blue')),
+ new Document(2, array('color' => 'blue')),
+ new Document(3, array('color' => 'red')),
+ new Document(4, array('color' => 'green')),
+ ));
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group functional
+ */
public function testCardinalityAggregation()
{
- $agg = new Cardinality("cardinality");
- $agg->setField("color");
+ $agg = new Cardinality('cardinality');
+ $agg->setField('color');
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("cardinality");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('cardinality');
$this->assertEquals(3, $results['value']);
}
+
+ /**
+ * @dataProvider invalidPrecisionThresholdProvider
+ * @expectedException \InvalidArgumentException
+ *
+ * @param $threshold
+ */
+ public function testInvalidPrecisionThreshold($threshold)
+ {
+ $agg = new Cardinality('threshold');
+ $agg->setPrecisionThreshold($threshold);
+ }
+
+ /**
+ * @dataProvider validPrecisionThresholdProvider
+ *
+ * @param $threshold
+ */
+ public function testPrecisionThreshold($threshold)
+ {
+ $agg = new Cardinality('threshold');
+ $agg->setPrecisionThreshold($threshold);
+
+ $this->assertNotNull($agg->getParam('precision_threshold'));
+ $this->assertInternalType('int', $agg->getParam('precision_threshold'));
+ }
+
+ public function invalidPrecisionThresholdProvider()
+ {
+ return array(
+ 'string' => array('100'),
+ 'float' => array(7.8),
+ 'boolean' => array(true),
+ 'array' => array(array()),
+ 'object' => array(new \StdClass()),
+ );
+ }
+
+ public function validPrecisionThresholdProvider()
+ {
+ return array(
+ 'negative-int' => array(-140),
+ 'zero' => array(0),
+ 'positive-int' => array(150),
+ 'more-than-max' => array(40001),
+ );
+ }
+
+ /**
+ * @dataProvider validRehashProvider
+ *
+ * @param bool $rehash
+ */
+ public function testRehash($rehash)
+ {
+ $agg = new Cardinality('rehash');
+ $agg->setRehash($rehash);
+
+ $this->assertNotNull($agg->getParam('rehash'));
+ $this->assertInternalType('boolean', $agg->getParam('rehash'));
+ }
+
+ /**
+ * @dataProvider invalidRehashProvider
+ * @expectedException \InvalidArgumentException
+ *
+ * @param mixed $rehash
+ */
+ public function testInvalidRehash($rehash)
+ {
+ $agg = new Cardinality('rehash');
+ $agg->setRehash($rehash);
+ }
+
+ public function invalidRehashProvider()
+ {
+ return array(
+ 'string' => array('100'),
+ 'int' => array(100),
+ 'float' => array(7.8),
+ 'array' => array(array()),
+ 'object' => array(new \StdClass()),
+ );
+ }
+
+ public function validRehashProvider()
+ {
+ return array(
+ 'true' => array(true),
+ 'false' => array(false),
+ );
+ }
}
-
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/DateHistogramTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/DateHistogramTest.php
index d5bd878c..ca115ccc 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/DateHistogramTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/DateHistogramTest.php
@@ -1,8 +1,6 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\DateHistogram;
use Elastica\Document;
use Elastica\Query;
@@ -10,34 +8,96 @@ use Elastica\Type\Mapping;
class DateHistogramTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex("date_histogram");
- $mapping = new Mapping();
- $mapping->setProperties(array(
- "created" => array("type" => "date")
+ $index = $this->_createIndex();
+ $type = $index->getType('test');
+
+ $type->setMapping(new Mapping(null, array(
+ 'created' => array('type' => 'date'),
+ )));
+
+ $type->addDocuments(array(
+ new Document(1, array('created' => '2014-01-29T00:20:00')),
+ new Document(2, array('created' => '2014-01-29T02:20:00')),
+ new Document(3, array('created' => '2014-01-29T03:20:00')),
));
- $type = $this->_index->getType("test");
- $type->setMapping($mapping);
- $docs = array(
- new Document("1", array("created" => 1390962135000)),
- new Document("2", array("created" => 1390965735000)),
- new Document("3", array("created" => 1390954935000)),
- );
- $type->addDocuments($docs);
- $this->_index->refresh();
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group functional
+ */
public function testDateHistogramAggregation()
{
- $agg = new DateHistogram("hist", "created", "1h");
+ $agg = new DateHistogram('hist', 'created', '1h');
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("hist");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('hist');
$this->assertEquals(3, sizeof($results['buckets']));
}
+
+ /**
+ * @group unit
+ */
+ public function testSetOffset()
+ {
+ $agg = new DateHistogram('hist', 'created', '1h');
+
+ $agg->setOffset('3m');
+
+ $expected = array(
+ 'date_histogram' => array(
+ 'field' => 'created',
+ 'interval' => '1h',
+ 'offset' => '3m',
+ ),
+ );
+
+ $this->assertEquals($expected, $agg->toArray());
+
+ $this->assertInstanceOf('Elastica\Aggregation\DateHistogram', $agg->setOffset('3m'));
+ }
+
+ /**
+ * @group functional
+ */
+ public function testSetOffsetWorks()
+ {
+ $agg = new DateHistogram('hist', 'created', '1m');
+ $agg->setOffset('+40s');
+
+ $query = new Query();
+ $query->addAggregation($agg);
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('hist');
+
+ $this->assertEquals('2014-01-29T00:19:40.000Z', $results['buckets'][0]['key_as_string']);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetTimezone()
+ {
+ $agg = new DateHistogram('hist', 'created', '1h');
+
+ $agg->setTimezone('-02:30');
+
+ $expected = array(
+ 'date_histogram' => array(
+ 'field' => 'created',
+ 'interval' => '1h',
+ 'time_zone' => '-02:30',
+ ),
+ );
+
+ $this->assertEquals($expected, $agg->toArray());
+
+ $this->assertInstanceOf('Elastica\Aggregation\DateHistogram', $agg->setTimezone('-02:30'));
+ }
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/DateRangeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/DateRangeTest.php
index 781f2112..b8078a4c 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/DateRangeTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/DateRangeTest.php
@@ -1,8 +1,6 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\DateRange;
use Elastica\Document;
use Elastica\Query;
@@ -10,42 +8,45 @@ use Elastica\Type\Mapping;
class DateRangeTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex("date_range");
- $mapping = new Mapping();
- $mapping->setProperties(array(
- "created" => array("type" => "date")
+ $index = $this->_createIndex();
+ $type = $index->getType('test');
+
+ $type->setMapping(new Mapping(null, array(
+ 'created' => array('type' => 'date'),
+ )));
+
+ $type->addDocuments(array(
+ new Document(1, array('created' => 1390962135000)),
+ new Document(2, array('created' => 1390965735000)),
+ new Document(3, array('created' => 1390954935000)),
));
- $type = $this->_index->getType("test");
- $type->setMapping($mapping);
- $docs = array(
- new Document("1", array("created" => 1390962135000)),
- new Document("2", array("created" => 1390965735000)),
- new Document("3", array("created" => 1390954935000)),
- );
- $type->addDocuments($docs);
- $this->_index->refresh();
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group functional
+ */
public function testDateRangeAggregation()
{
- $agg = new DateRange("date");
- $agg->setField("created");
+ $agg = new DateRange('date');
+ $agg->setField('created');
$agg->addRange(1390958535000)->addRange(null, 1390958535000);
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("date");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('date');
foreach ($results['buckets'] as $bucket) {
if (array_key_exists('to', $bucket)) {
$this->assertEquals(1, $bucket['doc_count']);
- } else if (array_key_exists('from', $bucket)) {
+ } elseif (array_key_exists('from', $bucket)) {
$this->assertEquals(2, $bucket['doc_count']);
}
}
}
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ExtendedStatsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ExtendedStatsTest.php
index e125c9c9..8c336245 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ExtendedStatsTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ExtendedStatsTest.php
@@ -1,36 +1,39 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\ExtendedStats;
use Elastica\Document;
use Elastica\Query;
class ExtendedStatsTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex("extended_stats");
- $docs = array(
- new Document("1", array("price" => 5)),
- new Document("2", array("price" => 8)),
- new Document("3", array("price" => 1)),
- new Document("4", array("price" => 3)),
- );
- $this->_index->getType("test")->addDocuments($docs);
- $this->_index->refresh();
+ $index = $this->_createIndex();
+
+ $index->getType('test')->addDocuments(array(
+ new Document(1, array('price' => 5)),
+ new Document(2, array('price' => 8)),
+ new Document(3, array('price' => 1)),
+ new Document(4, array('price' => 3)),
+ ));
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group functional
+ */
public function testExtendedStatsAggregation()
{
- $agg = new ExtendedStats("stats");
- $agg->setField("price");
+ $agg = new ExtendedStats('stats');
+ $agg->setField('price');
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("stats");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('stats');
$this->assertEquals(4, $results['count']);
$this->assertEquals(1, $results['min']);
@@ -40,4 +43,3 @@ class ExtendedStatsTest extends BaseAggregationTest
$this->assertTrue(array_key_exists('sum_of_squares', $results));
}
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/FilterTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/FilterTest.php
index dd4d4c2d..9198bb95 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/FilterTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/FilterTest.php
@@ -1,8 +1,6 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Avg;
use Elastica\Aggregation\Filter;
use Elastica\Document;
@@ -12,67 +10,104 @@ use Elastica\Query;
class FilterTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex("filter");
- $docs = array(
- new Document("1", array("price" => 5, "color" => "blue")),
- new Document("2", array("price" => 8, "color" => "blue")),
- new Document("3", array("price" => 1, "color" => "red")),
- new Document("4", array("price" => 3, "color" => "green")),
- );
- $this->_index->getType("test")->addDocuments($docs);
- $this->_index->refresh();
+ $index = $this->_createIndex();
+
+ $index->getType('test')->addDocuments(array(
+ new Document(1, array('price' => 5, 'color' => 'blue')),
+ new Document(2, array('price' => 8, 'color' => 'blue')),
+ new Document(3, array('price' => 1, 'color' => 'red')),
+ new Document(4, array('price' => 3, 'color' => 'green')),
+ ));
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group unit
+ */
public function testToArray()
{
$expected = array(
- "filter" => array("range" => array("stock" => array("gt" => 0))),
- "aggs" => array(
- "avg_price" => array("avg" => array("field" => "price"))
- )
+ 'filter' => array('range' => array('stock' => array('gt' => 0))),
+ 'aggs' => array(
+ 'avg_price' => array('avg' => array('field' => 'price')),
+ ),
);
- $agg = new Filter("in_stock_products");
- $agg->setFilter(new Range("stock", array("gt" => 0)));
- $avg = new Avg("avg_price");
- $avg->setField("price");
+ $agg = new Filter('in_stock_products');
+ $agg->setFilter(new Range('stock', array('gt' => 0)));
+ $avg = new Avg('avg_price');
+ $avg->setField('price');
$agg->addAggregation($avg);
$this->assertEquals($expected, $agg->toArray());
}
+ /**
+ * @group functional
+ */
public function testFilterAggregation()
{
- $agg = new Filter("filter");
- $agg->setFilter(new Term(array("color" => "blue")));
- $avg = new Avg("price");
- $avg->setField("price");
+ $agg = new Filter('filter');
+ $agg->setFilter(new Term(array('color' => 'blue')));
+ $avg = new Avg('price');
+ $avg->setField('price');
$agg->addAggregation($avg);
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("filter");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('filter');
$results = $results['price']['value'];
$this->assertEquals((5 + 8) / 2.0, $results);
}
+ /**
+ * @group functional
+ */
public function testFilterNoSubAggregation()
{
- $agg = new Avg("price");
- $agg->setField("price");
+ $agg = new Avg('price');
+ $agg->setField('price');
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("price");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('price');
$results = $results['value'];
$this->assertEquals((5 + 8 + 1 + 3) / 4.0, $results);
}
+
+ /**
+ * @group unit
+ */
+ public function testConstruct()
+ {
+ $agg = new Filter('foo', new Term(array('color' => 'blue')));
+
+ $expected = array(
+ 'filter' => array(
+ 'term' => array(
+ 'color' => 'blue',
+ ),
+ ),
+ );
+
+ $this->assertEquals($expected, $agg->toArray());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testConstructWithoutFilter()
+ {
+ $agg = new Filter('foo');
+ $this->assertEquals('foo', $agg->getName());
+ }
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/FiltersTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/FiltersTest.php
new file mode 100644
index 00000000..36ebcd45
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/FiltersTest.php
@@ -0,0 +1,120 @@
+<?php
+namespace Elastica\Test\Aggregation;
+
+use Elastica\Aggregation\Avg;
+use Elastica\Aggregation\Filter;
+use Elastica\Aggregation\Filters;
+use Elastica\Document;
+use Elastica\Filter\Term;
+use Elastica\Query;
+
+class FiltersTest extends BaseAggregationTest
+{
+ protected function _getIndexForTest()
+ {
+ $index = $this->_createIndex('filter');
+
+ $index->getType('test')->addDocuments(array(
+ new Document(1, array('price' => 5, 'color' => 'blue')),
+ new Document(2, array('price' => 8, 'color' => 'blue')),
+ new Document(3, array('price' => 1, 'color' => 'red')),
+ new Document(4, array('price' => 3, 'color' => 'green')),
+ ));
+
+ $index->refresh();
+
+ return $index;
+ }
+
+ /**
+ * @group unit
+ */
+ public function testToArrayUsingNamedFilters()
+ {
+ $expected = array(
+ 'filters' => array(
+ 'filters' => array(
+ 'blue' => array(
+ 'term' => array('color' => 'blue'),
+ ),
+ 'red' => array(
+ 'term' => array('color' => 'red'),
+ ),
+ ),
+ ),
+ 'aggs' => array(
+ 'avg_price' => array('avg' => array('field' => 'price')),
+ ),
+ );
+
+ $agg = new Filters('by_color');
+ $agg->addFilter(new Term(array('color' => 'blue')), 'blue');
+ $agg->addFilter(new Term(array('color' => 'red')), 'red');
+
+ $avg = new Avg('avg_price');
+ $avg->setField('price');
+ $agg->addAggregation($avg);
+
+ $this->assertEquals($expected, $agg->toArray());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testToArrayUsingAnonymousFilters()
+ {
+ $expected = array(
+ 'filters' => array(
+ 'filters' => array(
+ array(
+ 'term' => array('color' => 'blue'),
+ ),
+ array(
+ 'term' => array('color' => 'red'),
+ ),
+ ),
+ ),
+ 'aggs' => array(
+ 'avg_price' => array('avg' => array('field' => 'price')),
+ ),
+ );
+
+ $agg = new Filters('by_color');
+ $agg->addFilter(new Term(array('color' => 'blue')));
+ $agg->addFilter(new Term(array('color' => 'red')));
+
+ $avg = new Avg('avg_price');
+ $avg->setField('price');
+ $agg->addAggregation($avg);
+
+ $this->assertEquals($expected, $agg->toArray());
+ }
+
+ /**
+ * @group functional
+ */
+ public function testFilterAggregation()
+ {
+ $agg = new Filters('by_color');
+ $agg->addFilter(new Term(array('color' => 'blue')), 'blue');
+ $agg->addFilter(new Term(array('color' => 'red')), 'red');
+
+ $avg = new Avg('avg_price');
+ $avg->setField('price');
+ $agg->addAggregation($avg);
+
+ $query = new Query();
+ $query->addAggregation($agg);
+
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('by_color');
+
+ $resultsForBlue = $results['buckets']['blue'];
+ $resultsForRed = $results['buckets']['red'];
+
+ $this->assertEquals(2, $resultsForBlue['doc_count']);
+ $this->assertEquals(1, $resultsForRed['doc_count']);
+
+ $this->assertEquals((5 + 8) / 2, $resultsForBlue['avg_price']['value']);
+ $this->assertEquals(1, $resultsForRed['avg_price']['value']);
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GeoDistanceTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GeoDistanceTest.php
index 7fd677b1..f8a02d1d 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GeoDistanceTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GeoDistanceTest.php
@@ -1,8 +1,6 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\GeoDistance;
use Elastica\Document;
use Elastica\Query;
@@ -10,36 +8,39 @@ use Elastica\Type\Mapping;
class GeoDistanceTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex("geo_distance");
- $mapping = new Mapping();
- $mapping->setProperties(array(
- "location" => array("type" => "geo_point")
+ $index = $this->_createIndex();
+ $type = $index->getType('test');
+
+ $type->setMapping(new Mapping(null, array(
+ 'location' => array('type' => 'geo_point'),
+ )));
+
+ $type->addDocuments(array(
+ new Document(1, array('location' => array('lat' => 32.849437, 'lon' => -117.271732))),
+ new Document(2, array('location' => array('lat' => 32.798320, 'lon' => -117.246648))),
+ new Document(3, array('location' => array('lat' => 37.782439, 'lon' => -122.392560))),
));
- $type = $this->_index->getType("test");
- $type->setMapping($mapping);
- $docs = array(
- new Document("1", array("location" => array("lat" => 32.849437, "lon" => -117.271732))),
- new Document("2", array("location" => array("lat" => 32.798320, "lon" => -117.246648))),
- new Document("3", array("location" => array("lat" => 37.782439, "lon" => -122.392560))),
- );
- $type->addDocuments($docs);
- $this->_index->refresh();
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group functional
+ */
public function testGeoDistanceAggregation()
{
- $agg = new GeoDistance("geo", "location", array("lat" => 32.804654, "lon" => -117.242594));
+ $agg = new GeoDistance('geo', 'location', array('lat' => 32.804654, 'lon' => -117.242594));
$agg->addRange(null, 100);
- $agg->setUnit("mi");
+ $agg->setUnit('mi');
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("geo");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('geo');
$this->assertEquals(2, $results['buckets'][0]['doc_count']);
}
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GeohashGridTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GeohashGridTest.php
index 38a047f7..6e0d43fd 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GeohashGridTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GeohashGridTest.php
@@ -1,8 +1,6 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\GeohashGrid;
use Elastica\Document;
use Elastica\Query;
@@ -10,36 +8,39 @@ use Elastica\Type\Mapping;
class GeohashGridTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex("geohash_grid");
- $mapping = new Mapping();
- $mapping->setProperties(array(
- "location" => array("type" => "geo_point")
+ $index = $this->_createIndex();
+ $type = $index->getType('test');
+
+ $type->setMapping(new Mapping(null, array(
+ 'location' => array('type' => 'geo_point'),
+ )));
+
+ $type->addDocuments(array(
+ new Document(1, array('location' => array('lat' => 32.849437, 'lon' => -117.271732))),
+ new Document(2, array('location' => array('lat' => 32.798320, 'lon' => -117.246648))),
+ new Document(3, array('location' => array('lat' => 37.782439, 'lon' => -122.392560))),
));
- $type = $this->_index->getType("test");
- $type->setMapping($mapping);
- $docs = array(
- new Document("1", array("location" => array("lat" => 32.849437, "lon" => -117.271732))),
- new Document("2", array("location" => array("lat" => 32.798320, "lon" => -117.246648))),
- new Document("3", array("location" => array("lat" => 37.782439, "lon" => -122.392560))),
- );
- $type->addDocuments($docs);
- $this->_index->refresh();
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group functional
+ */
public function testGeohashGridAggregation()
{
- $agg = new GeohashGrid("hash", "location");
+ $agg = new GeohashGrid('hash', 'location');
$agg->setPrecision(3);
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("hash");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('hash');
$this->assertEquals(2, $results['buckets'][0]['doc_count']);
$this->assertEquals(1, $results['buckets'][1]['doc_count']);
}
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GlobalAggregationTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GlobalAggregationTest.php
index 80366f50..6ab086d0 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GlobalAggregationTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GlobalAggregationTest.php
@@ -1,27 +1,27 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Avg;
use Elastica\Aggregation\GlobalAggregation;
class GlobalAggregationTest extends BaseAggregationTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$expected = array(
- "global" => new \stdClass(),
- "aggs" => array(
- "avg_price" => array("avg" => array("field" => "price"))
- )
+ 'global' => new \stdClass(),
+ 'aggs' => array(
+ 'avg_price' => array('avg' => array('field' => 'price')),
+ ),
);
- $agg = new GlobalAggregation("all_products");
- $avg = new Avg("avg_price");
- $avg->setField("price");
+ $agg = new GlobalAggregation('all_products');
+ $avg = new Avg('avg_price');
+ $avg->setField('price');
$agg->addAggregation($avg);
$this->assertEquals($expected, $agg->toArray());
}
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/HistogramTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/HistogramTest.php
index 35032f43..ffdf73a4 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/HistogramTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/HistogramTest.php
@@ -1,40 +1,43 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
-use Elastica\Document;
use Elastica\Aggregation\Histogram;
+use Elastica\Document;
use Elastica\Query;
class HistogramTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex("histogram");
- $docs = array(
- new Document("1", array("price" => 5, "color" => "blue")),
- new Document("2", array("price" => 8, "color" => "blue")),
- new Document("3", array("price" => 1, "color" => "red")),
- new Document("4", array("price" => 30, "color" => "green")),
- new Document("5", array("price" => 40, "color" => "red")),
- new Document("6", array("price" => 35, "color" => "green")),
- new Document("7", array("price" => 42, "color" => "red")),
- new Document("8", array("price" => 41, "color" => "blue")),
- );
- $this->_index->getType("test")->addDocuments($docs);
- $this->_index->refresh();
+ $index = $this->_createIndex();
+
+ $index->getType('test')->addDocuments(array(
+ new Document(1, array('price' => 5, 'color' => 'blue')),
+ new Document(2, array('price' => 8, 'color' => 'blue')),
+ new Document(3, array('price' => 1, 'color' => 'red')),
+ new Document(4, array('price' => 30, 'color' => 'green')),
+ new Document(5, array('price' => 40, 'color' => 'red')),
+ new Document(6, array('price' => 35, 'color' => 'green')),
+ new Document(7, array('price' => 42, 'color' => 'red')),
+ new Document(8, array('price' => 41, 'color' => 'blue')),
+ ));
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group functional
+ */
public function testHistogramAggregation()
{
- $agg = new Histogram("hist", "price", 10);
+ $agg = new Histogram('hist', 'price', 10);
$agg->setMinimumDocumentCount(0); // should return empty buckets
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("hist");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('hist');
$buckets = $results['buckets'];
$this->assertEquals(5, sizeof($buckets));
@@ -42,4 +45,3 @@ class HistogramTest extends BaseAggregationTest
$this->assertEquals(2, $buckets[3]['doc_count']);
}
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/IpRangeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/IpRangeTest.php
index fce6f857..2f3099f6 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/IpRangeTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/IpRangeTest.php
@@ -1,8 +1,6 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\IpRange;
use Elastica\Document;
use Elastica\Query;
@@ -10,38 +8,42 @@ use Elastica\Type\Mapping;
class IpRangeTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex("ip_range");
- $mapping = new Mapping();
- $mapping->setProperties(array(
- "address" => array("type" => "ip")
+ $index = $this->_createIndex();
+ $type = $index->getType('test');
+
+ $type->setMapping(new Mapping(null, array(
+ 'address' => array('type' => 'ip'),
+ )));
+
+ $type->addDocuments(array(
+ new Document(1, array('address' => '192.168.1.100')),
+ new Document(2, array('address' => '192.168.1.150')),
+ new Document(3, array('address' => '192.168.1.200')),
));
- $type = $this->_index->getType("test");
- $type->setMapping($mapping);
- $docs = array(
- new Document("1", array("address" => "192.168.1.100")),
- new Document("2", array("address" => "192.168.1.150")),
- new Document("3", array("address" => "192.168.1.200")),
- );
- $type->addDocuments($docs);
- $this->_index->refresh();
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group functional
+ */
public function testIpRangeAggregation()
{
- $agg = new IpRange("ip", "address");
- $agg->addRange("192.168.1.101");
- $agg->addRange(null, "192.168.1.200");
-
- $cidrRange = "192.168.1.0/24";
+ $agg = new IpRange('ip', 'address');
+ $agg->addRange('192.168.1.101');
+ $agg->addRange(null, '192.168.1.200');
+
+ $cidrRange = '192.168.1.0/24';
$agg->addMaskRange($cidrRange);
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("ip");
-
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('ip');
+
foreach ($results['buckets'] as $bucket) {
if (array_key_exists('key', $bucket) && $bucket['key'] == $cidrRange) {
// the CIDR mask
@@ -53,4 +55,3 @@ class IpRangeTest extends BaseAggregationTest
}
}
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MaxTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MaxTest.php
index 0f5475b3..f057b81d 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MaxTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MaxTest.php
@@ -1,8 +1,6 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Max;
use Elastica\Document;
use Elastica\Query;
@@ -10,63 +8,72 @@ use Elastica\Script;
class MaxTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex('max');
- $docs = array(
- new Document('1', array('price' => 5)),
- new Document('2', array('price' => 8)),
- new Document('3', array('price' => 1)),
- new Document('4', array('price' => 3)),
- );
- $this->_index->getType('test')->addDocuments($docs);
- $this->_index->refresh();
+ $index = $this->_createIndex();
+
+ $index->getType('test')->addDocuments(array(
+ new Document(1, array('price' => 5)),
+ new Document(2, array('price' => 8)),
+ new Document(3, array('price' => 1)),
+ new Document(4, array('price' => 3)),
+ ));
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group unit
+ */
public function testToArray()
{
$expected = array(
- "max" => array(
- "field" => "price",
- "script" => "_value * conversion_rate",
- "params" => array(
- "conversion_rate" => 1.2
- )
+ 'max' => array(
+ 'field' => 'price',
+ 'script' => '_value * conversion_rate',
+ 'params' => array(
+ 'conversion_rate' => 1.2,
+ ),
+ ),
+ 'aggs' => array(
+ 'subagg' => array('max' => array('field' => 'foo')),
),
- "aggs" => array(
- "subagg" => array("max" => array("field" => "foo"))
- )
);
- $agg = new Max("min_price_in_euros");
- $agg->setField("price");
- $agg->setScript(new Script("_value * conversion_rate", array('conversion_rate' => 1.2)));
- $max = new Max("subagg");
- $max->setField("foo");
+ $agg = new Max('min_price_in_euros');
+ $agg->setField('price');
+ $agg->setScript(new Script('_value * conversion_rate', array('conversion_rate' => 1.2)));
+ $max = new Max('subagg');
+ $max->setField('foo');
$agg->addAggregation($max);
$this->assertEquals($expected, $agg->toArray());
}
+ /**
+ * @group functional
+ */
public function testMaxAggregation()
{
- $agg = new Max("min_price");
- $agg->setField("price");
+ $index = $this->_getIndexForTest();
+
+ $agg = new Max('min_price');
+ $agg->setField('price');
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("min_price");
+ $results = $index->search($query)->getAggregation('min_price');
$this->assertEquals(8, $results['value']);
// test using a script
- $agg->setScript(new Script("_value * conversion_rate", array("conversion_rate" => 1.2)));
+ $agg->setScript(new Script('_value * conversion_rate', array('conversion_rate' => 1.2)));
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("min_price");
+ $results = $index->search($query)->getAggregation('min_price');
$this->assertEquals(8 * 1.2, $results['value']);
}
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MinTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MinTest.php
index 44b52fb4..ce0ad5e7 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MinTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MinTest.php
@@ -1,38 +1,40 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Min;
use Elastica\Document;
use Elastica\Query;
class MinTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex('min');
- $docs = array(
- new Document('1', array('price' => 5)),
- new Document('2', array('price' => 8)),
- new Document('3', array('price' => 1)),
- new Document('4', array('price' => 3)),
- );
- $this->_index->getType('test')->addDocuments($docs);
- $this->_index->refresh();
+ $index = $this->_createIndex();
+
+ $index->getType('test')->addDocuments(array(
+ new Document(1, array('price' => 5)),
+ new Document(2, array('price' => 8)),
+ new Document(3, array('price' => 1)),
+ new Document(4, array('price' => 3)),
+ ));
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group functional
+ */
public function testMinAggregation()
{
- $agg = new Min("min_price");
- $agg->setField("price");
+ $agg = new Min('min_price');
+ $agg->setField('price');
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("min_price");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('min_price');
$this->assertEquals(1, $results['value']);
}
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MissingTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MissingTest.php
index 2a852ed0..85461879 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MissingTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MissingTest.php
@@ -1,37 +1,39 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Missing;
use Elastica\Document;
use Elastica\Query;
class MissingTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex('missing');
- $docs = array(
- new Document('1', array('price' => 5, "color" => "blue")),
- new Document('2', array('price' => 8, "color" => "blue")),
- new Document('3', array('price' => 1)),
- new Document('4', array('price' => 3, "color" => "green")),
- );
- $this->_index->getType('test')->addDocuments($docs);
- $this->_index->refresh();
+ $index = $this->_createIndex();
+
+ $index->getType('test')->addDocuments(array(
+ new Document(1, array('price' => 5, 'color' => 'blue')),
+ new Document(2, array('price' => 8, 'color' => 'blue')),
+ new Document(3, array('price' => 1)),
+ new Document(4, array('price' => 3, 'color' => 'green')),
+ ));
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group functional
+ */
public function testMissingAggregation()
{
- $agg = new Missing("missing", "color");
+ $agg = new Missing('missing', 'color');
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("missing");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('missing');
$this->assertEquals(1, $results['doc_count']);
}
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/NestedTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/NestedTest.php
index ed6de99e..58c5d13a 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/NestedTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/NestedTest.php
@@ -1,8 +1,6 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Min;
use Elastica\Aggregation\Nested;
use Elastica\Document;
@@ -11,52 +9,55 @@ use Elastica\Type\Mapping;
class NestedTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex("nested");
- $mapping = new Mapping();
- $mapping->setProperties(array(
- "resellers" => array(
- "type" => "nested",
- "properties" => array(
- "name" => array("type" => "string"),
- "price" => array("type" => "double")
- )
- )
- ));
- $type = $this->_index->getType("test");
- $type->setMapping($mapping);
- $docs = array(
- new Document("1", array(
- "resellers" => array(
- "name" => "spacely sprockets",
- "price" => 5.55
- )
+ $index = $this->_createIndex();
+ $type = $index->getType('test');
+
+ $type->setMapping(new Mapping(null, array(
+ 'resellers' => array(
+ 'type' => 'nested',
+ 'properties' => array(
+ 'name' => array('type' => 'string'),
+ 'price' => array('type' => 'double'),
+ ),
+ ),
+ )));
+
+ $type->addDocuments(array(
+ new Document(1, array(
+ 'resellers' => array(
+ 'name' => 'spacely sprockets',
+ 'price' => 5.55,
+ ),
)),
- new Document("1", array(
- "resellers" => array(
- "name" => "cogswell cogs",
- "price" => 4.98
- )
- ))
- );
- $type->addDocuments($docs);
- $this->_index->refresh();
+ new Document(2, array(
+ 'resellers' => array(
+ 'name' => 'cogswell cogs',
+ 'price' => 4.98,
+ ),
+ )),
+ ));
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group functional
+ */
public function testNestedAggregation()
{
- $agg = new Nested("resellers", "resellers");
- $min = new Min("min_price");
- $min->setField("price");
+ $agg = new Nested('resellers', 'resellers');
+ $min = new Min('min_price');
+ $min->setField('price');
$agg->addAggregation($min);
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("resellers");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('resellers');
$this->assertEquals(4.98, $results['min_price']['value']);
}
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/PercentilesTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/PercentilesTest.php
new file mode 100644
index 00000000..ee4dd2c5
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/PercentilesTest.php
@@ -0,0 +1,125 @@
+<?php
+namespace Elastica\Test\Aggregation;
+
+use Elastica\Aggregation\Percentiles;
+use Elastica\Document;
+use Elastica\Query;
+
+class PercentilesTest extends BaseAggregationTest
+{
+ /**
+ * @group functional
+ */
+ public function testConstruct()
+ {
+ $aggr = new Percentiles('price_percentile');
+ $this->assertEquals('price_percentile', $aggr->getName());
+
+ $aggr = new Percentiles('price_percentile', 'price');
+ $this->assertEquals('price', $aggr->getParam('field'));
+ }
+
+ /**
+ * @group functional
+ */
+ public function testSetField()
+ {
+ $aggr = new Percentiles('price_percentile');
+ $aggr->setField('price');
+
+ $this->assertEquals('price', $aggr->getParam('field'));
+ $this->assertInstanceOf('Elastica\Aggregation\Percentiles', $aggr->setField('price'));
+ }
+
+ /**
+ * @group functional
+ */
+ public function testSetCompression()
+ {
+ $aggr = new Percentiles('price_percentile');
+ $aggr->setCompression(200);
+ $this->assertEquals(200, $aggr->getParam('compression'));
+ $this->assertInstanceOf('Elastica\Aggregation\Percentiles', $aggr->setCompression(200));
+ }
+
+ /**
+ * @group functional
+ */
+ public function testSetPercents()
+ {
+ $percents = array(1, 2, 3);
+ $aggr = new Percentiles('price_percentile');
+ $aggr->setPercents($percents);
+ $this->assertEquals($percents, $aggr->getParam('percents'));
+ $this->assertInstanceOf('Elastica\Aggregation\Percentiles', $aggr->setPercents($percents));
+ }
+
+ /**
+ * @group functional
+ */
+ public function testAddPercent()
+ {
+ $percents = array(1, 2, 3);
+ $aggr = new Percentiles('price_percentile');
+ $aggr->setPercents($percents);
+ $this->assertEquals($percents, $aggr->getParam('percents'));
+ $aggr->addPercent(4);
+ $percents[] = 4;
+ $this->assertEquals($percents, $aggr->getParam('percents'));
+ $this->assertInstanceOf('Elastica\Aggregation\Percentiles', $aggr->addPercent(4));
+ }
+
+ /**
+ * @group functional
+ */
+ public function testSetScript()
+ {
+ $script = 'doc["load_time"].value / 20';
+ $aggr = new Percentiles('price_percentile');
+ $aggr->setScript($script);
+ $this->assertEquals($script, $aggr->getParam('script'));
+ $this->assertInstanceOf('Elastica\Aggregation\Percentiles', $aggr->setScript($script));
+ }
+
+ /**
+ * @group functional
+ */
+ public function testActualWork()
+ {
+ // prepare
+ $index = $this->_createIndex();
+ $type = $index->getType('offer');
+ $type->addDocuments(array(
+ new Document(1, array('price' => 100)),
+ new Document(2, array('price' => 200)),
+ new Document(3, array('price' => 300)),
+ new Document(4, array('price' => 400)),
+ new Document(5, array('price' => 500)),
+ new Document(6, array('price' => 600)),
+ new Document(7, array('price' => 700)),
+ new Document(8, array('price' => 800)),
+ new Document(9, array('price' => 900)),
+ new Document(10, array('price' => 1000)),
+ ));
+ $index->refresh();
+
+ // execute
+ $aggr = new Percentiles('price_percentile');
+ $aggr->setField('price');
+
+ $query = new Query();
+ $query->addAggregation($aggr);
+
+ $resultSet = $type->search($query);
+ $aggrResult = $resultSet->getAggregation('price_percentile');
+
+ // hope it's ok to hardcode results...
+ $this->assertEquals(109.0, $aggrResult['values']['1.0']);
+ $this->assertEquals(145.0, $aggrResult['values']['5.0']);
+ $this->assertEquals(325.0, $aggrResult['values']['25.0']);
+ $this->assertEquals(550.0, $aggrResult['values']['50.0']);
+ $this->assertEquals(775.0, $aggrResult['values']['75.0']);
+ $this->assertEquals(955.0, $aggrResult['values']['95.0']);
+ $this->assertEquals(991.0, $aggrResult['values']['99.0']);
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/RangeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/RangeTest.php
index fb5ca2fe..f96e4096 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/RangeTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/RangeTest.php
@@ -1,41 +1,78 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Range;
use Elastica\Document;
use Elastica\Query;
class RangeTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex('range');
- $docs = array(
- new Document('1', array('price' => 5)),
- new Document('2', array('price' => 8)),
- new Document('3', array('price' => 1)),
- new Document('4', array('price' => 3)),
- new Document('5', array('price' => 1.5)),
- new Document('6', array('price' => 2)),
- );
- $this->_index->getType('test')->addDocuments($docs);
- $this->_index->refresh();
+ $index = $this->_createIndex();
+
+ $index->getType('test')->addDocuments(array(
+ new Document(1, array('price' => 5)),
+ new Document(2, array('price' => 8)),
+ new Document(3, array('price' => 1)),
+ new Document(4, array('price' => 3)),
+ new Document(5, array('price' => 1.5)),
+ new Document(6, array('price' => 2)),
+ ));
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group functional
+ */
public function testRangeAggregation()
{
- $agg = new Range("range");
- $agg->setField("price");
+ $agg = new Range('range');
+ $agg->setField('price');
$agg->addRange(1.5, 5);
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("range");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('range');
$this->assertEquals(2, $results['buckets'][0]['doc_count']);
}
+
+ /**
+ * @group unit
+ */
+ public function testRangeAggregationWithKey()
+ {
+ $agg = new Range('range');
+ $agg->setField('price');
+ $agg->addRange(null, 50, 'cheap');
+ $agg->addRange(50, 100, 'average');
+ $agg->addRange(100, null, 'expensive');
+
+ $expected = array(
+ 'range' => array(
+ 'field' => 'price',
+ 'ranges' => array(
+ array(
+ 'to' => 50,
+ 'key' => 'cheap',
+ ),
+ array(
+ 'from' => 50,
+ 'to' => 100,
+ 'key' => 'average',
+ ),
+ array(
+ 'from' => 100,
+ 'key' => 'expensive',
+ ),
+ ),
+ ),
+ );
+
+ $this->assertEquals($expected, $agg->toArray());
+ }
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ReverseNestedTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ReverseNestedTest.php
index 215dac63..0e2ed2e6 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ReverseNestedTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ReverseNestedTest.php
@@ -1,86 +1,96 @@
<?php
-
namespace Elastica\Test\Aggregation;
-use Elastica\Aggregation\Terms;
use Elastica\Aggregation\Nested;
use Elastica\Aggregation\ReverseNested;
+use Elastica\Aggregation\Terms;
use Elastica\Document;
use Elastica\Query;
use Elastica\Type\Mapping;
class ReverseNestedTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex("nested");
+ $index = $this->_createIndex();
$mapping = new Mapping();
$mapping->setProperties(array(
- "comments" => array(
- "type" => "nested",
- "properties" => array(
- "name" => array("type" => "string"),
- "body" => array("type" => "string")
- )
- )
+ 'comments' => array(
+ 'type' => 'nested',
+ 'properties' => array(
+ 'name' => array('type' => 'string'),
+ 'body' => array('type' => 'string'),
+ ),
+ ),
));
- $type = $this->_index->getType("test");
+ $type = $index->getType('test');
$type->setMapping($mapping);
- $docs = array(
- new Document("1", array(
- "comments" => array(
+
+ $type->addDocuments(array(
+ new Document(1, array(
+ 'comments' => array(
array(
- "name" => "bob",
- "body" => "this is bobs comment",
+ 'name' => 'bob',
+ 'body' => 'this is bobs comment',
),
array(
- "name" => "john",
- "body" => "this is johns comment",
+ 'name' => 'john',
+ 'body' => 'this is johns comment',
),
),
- "tags" => array("foo", "bar"),
+ 'tags' => array('foo', 'bar'),
)),
- new Document("2", array(
- "comments" => array(
+ new Document(2, array(
+ 'comments' => array(
array(
- "name" => "bob",
- "body" => "this is another comment from bob",
+ 'name' => 'bob',
+ 'body' => 'this is another comment from bob',
),
array(
- "name" => "susan",
- "body" => "this is susans comment",
+ 'name' => 'susan',
+ 'body' => 'this is susans comment',
),
),
- "tags" => array("foo", "baz"),
- ))
- );
- $type->addDocuments($docs);
- $this->_index->refresh();
+ 'tags' => array('foo', 'baz'),
+ )),
+ ));
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group unit
+ */
public function testPathNotSetIfNull()
{
$agg = new ReverseNested('nested');
$this->assertFalse($agg->hasParam('path'));
}
+ /**
+ * @group unit
+ */
public function testPathSetIfNotNull()
{
$agg = new ReverseNested('nested', 'some_field');
$this->assertEquals('some_field', $agg->getParam('path'));
}
+ /**
+ * @group functional
+ */
public function testReverseNestedAggregation()
{
- $agg = new Nested("comments", "comments");
- $names = new Terms("name");
- $names->setField("comments.name");
+ $agg = new Nested('comments', 'comments');
+ $names = new Terms('name');
+ $names->setField('comments.name');
- $tags = new Terms("tags");
- $tags->setField("tags");
+ $tags = new Terms('tags');
+ $tags->setField('tags');
- $reverseNested = new ReverseNested("main");
+ $reverseNested = new ReverseNested('main');
$reverseNested->addAggregation($tags);
$names->addAggregation($reverseNested);
@@ -89,7 +99,7 @@ class ReverseNestedTest extends BaseAggregationTest
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("comments");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('comments');
$this->assertArrayHasKey('name', $results);
$nameResults = $results['name'];
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ScriptTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ScriptTest.php
new file mode 100644
index 00000000..bf32b251
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ScriptTest.php
@@ -0,0 +1,87 @@
+<?php
+namespace Elastica\Test\Aggregation;
+
+use Elastica\Aggregation\Sum;
+use Elastica\Document;
+use Elastica\Query;
+use Elastica\Script;
+
+class ScriptTest extends BaseAggregationTest
+{
+ protected function _getIndexForTest()
+ {
+ $index = $this->_createIndex();
+
+ $index->getType('test')->addDocuments(array(
+ new Document('1', array('price' => 5)),
+ new Document('2', array('price' => 8)),
+ new Document('3', array('price' => 1)),
+ new Document('4', array('price' => 3)),
+ ));
+
+ $index->refresh();
+
+ return $index;
+ }
+
+ /**
+ * @group functional
+ */
+ public function testAggregationScript()
+ {
+ $agg = new Sum('sum');
+ // x = (0..1) is groovy-specific syntax, to see if lang is recognized
+ $script = new Script("x = (0..1); return doc['price'].value", null, 'groovy');
+ $agg->setScript($script);
+
+ $query = new Query();
+ $query->addAggregation($agg);
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('sum');
+
+ $this->assertEquals(5 + 8 + 1 + 3, $results['value']);
+ }
+
+ /**
+ * @group functional
+ */
+ public function testAggregationScriptAsString()
+ {
+ $agg = new Sum('sum');
+ $agg->setScript("doc['price'].value");
+
+ $query = new Query();
+ $query->addAggregation($agg);
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('sum');
+
+ $this->assertEquals(5 + 8 + 1 + 3, $results['value']);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetScript()
+ {
+ $aggregation = 'sum';
+ $string = "doc['price'].value";
+ $params = array(
+ 'param1' => 'one',
+ 'param2' => 1,
+ );
+ $lang = 'groovy';
+
+ $agg = new Sum($aggregation);
+ $script = new Script($string, $params, $lang);
+ $agg->setScript($script);
+
+ $array = $agg->toArray();
+
+ $expected = array(
+ $aggregation => array(
+ 'script' => $string,
+ 'params' => $params,
+ 'lang' => $lang,
+ ),
+ );
+ $this->assertEquals($expected, $array);
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ScriptedMetricTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ScriptedMetricTest.php
new file mode 100644
index 00000000..31f5798b
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ScriptedMetricTest.php
@@ -0,0 +1,50 @@
+<?php
+namespace Elastica\Test\Aggregation;
+
+use Elastica\Aggregation\ScriptedMetric;
+use Elastica\Document;
+use Elastica\Query;
+use Elastica\Type\Mapping;
+
+class ScriptedMetricTest extends BaseAggregationTest
+{
+ protected function _getIndexForTest()
+ {
+ $index = $this->_createIndex();
+ $type = $index->getType('test');
+
+ $type->setMapping(new Mapping(null, array(
+ 'start' => array('type' => 'long'),
+ 'end' => array('type' => 'long'),
+ )));
+
+ $type->addDocuments(array(
+ new Document(1, array('start' => 100, 'end' => 200)),
+ new Document(2, array('start' => 200, 'end' => 250)),
+ new Document(3, array('start' => 300, 'end' => 450)),
+ ));
+
+ $index->refresh();
+
+ return $index;
+ }
+
+ /**
+ * @group functional
+ */
+ public function testScriptedMetricAggregation()
+ {
+ $agg = new ScriptedMetric(
+ 'scripted',
+ "_agg['durations'] = [:]",
+ "key = doc['start'].value+ \":\"+ doc['end'].value; _agg.durations[key] = doc['end'].value - doc['start'].value;",
+ 'values = []; for (item in _agg.durations) { values.add(item.value) }; return values'
+ );
+
+ $query = new Query();
+ $query->addAggregation($agg);
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('scripted');
+
+ $this->assertEquals(array(100, 50, 150), $results['value'][0]);
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/SignificantTermsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/SignificantTermsTest.php
new file mode 100644
index 00000000..8960768b
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/SignificantTermsTest.php
@@ -0,0 +1,72 @@
+<?php
+namespace Elastica\Test\Aggregation;
+
+use Elastica\Aggregation\SignificantTerms;
+use Elastica\Document;
+use Elastica\Filter\Terms as TermsFilter;
+use Elastica\Query;
+use Elastica\Query\Terms;
+
+class SignificantTermsTest extends BaseAggregationTest
+{
+ protected function _getIndexForTest()
+ {
+ $index = $this->_createIndex();
+ $colors = array('blue', 'blue', 'red', 'red', 'green', 'yellow', 'white', 'cyan', 'magenta');
+ $temperatures = array(1500, 1500, 1500, 1500, 2500, 3500, 4500, 5500, 6500, 7500, 7500, 8500, 9500);
+ $docs = array();
+ for ($i = 0;$i < 250;$i++) {
+ $docs[] = new Document($i, array('color' => $colors[$i % count($colors)], 'temperature' => $temperatures[$i % count($temperatures)]));
+ }
+ $index->getType('test')->addDocuments($docs);
+ $index->refresh();
+
+ return $index;
+ }
+
+ /**
+ * @group functional
+ */
+ public function testSignificantTermsAggregation()
+ {
+ $agg = new SignificantTerms('significantTerms');
+ $agg->setField('temperature');
+ $agg->setSize(1);
+
+ $termsQuery = new Terms();
+ $termsQuery->setTerms('color', array('blue', 'red', 'green', 'yellow', 'white'));
+
+ $query = new Query($termsQuery);
+ $query->addAggregation($agg);
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('significantTerms');
+
+ $this->assertEquals(1, count($results['buckets']));
+ $this->assertEquals(63, $results['buckets'][0]['doc_count']);
+ $this->assertEquals(79, $results['buckets'][0]['bg_count']);
+ $this->assertEquals('1500', $results['buckets'][0]['key_as_string']);
+ }
+
+ /**
+ * @group functional
+ */
+ public function testSignificantTermsAggregationWithBackgroundFilter()
+ {
+ $agg = new SignificantTerms('significantTerms');
+ $agg->setField('temperature');
+ $agg->setSize(1);
+ $termsFilter = new TermsFilter();
+ $termsFilter->setTerms('color', array('blue', 'red', 'green', 'yellow'));
+ $agg->setBackgroundFilter($termsFilter);
+
+ $termsQuery = new Terms();
+ $termsQuery->setTerms('color', array('blue', 'red', 'green', 'yellow', 'white'));
+
+ $query = new Query($termsQuery);
+ $query->addAggregation($agg);
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('significantTerms');
+
+ $this->assertEquals(15, $results['buckets'][0]['doc_count']);
+ $this->assertEquals(12, $results['buckets'][0]['bg_count']);
+ $this->assertEquals('4500', $results['buckets'][0]['key_as_string']);
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/StatsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/StatsTest.php
index 2d315abf..45c9d08c 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/StatsTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/StatsTest.php
@@ -1,36 +1,39 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Stats;
use Elastica\Document;
use Elastica\Query;
class StatsTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex('stats');
- $docs = array(
- new Document('1', array('price' => 5)),
- new Document('2', array('price' => 8)),
- new Document('3', array('price' => 1)),
- new Document('4', array('price' => 3)),
- );
- $this->_index->getType('test')->addDocuments($docs);
- $this->_index->refresh();
+ $index = $this->_createIndex();
+
+ $index->getType('test')->addDocuments(array(
+ new Document(1, array('price' => 5)),
+ new Document(2, array('price' => 8)),
+ new Document(3, array('price' => 1)),
+ new Document(4, array('price' => 3)),
+ ));
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group functional
+ */
public function testStatsAggregation()
{
- $agg = new Stats("stats");
- $agg->setField("price");
+ $agg = new Stats('stats');
+ $agg->setField('price');
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("stats");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('stats');
$this->assertEquals(4, $results['count']);
$this->assertEquals(1, $results['min']);
@@ -39,4 +42,3 @@ class StatsTest extends BaseAggregationTest
$this->assertEquals((5 + 8 + 1 + 3), $results['sum']);
}
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/SumTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/SumTest.php
index 3b3c56a2..b60e6e14 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/SumTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/SumTest.php
@@ -1,38 +1,40 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Sum;
use Elastica\Document;
use Elastica\Query;
class SumTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex('sum');
- $docs = array(
- new Document('1', array('price' => 5)),
- new Document('2', array('price' => 8)),
- new Document('3', array('price' => 1)),
- new Document('4', array('price' => 3)),
- );
- $this->_index->getType('test')->addDocuments($docs);
- $this->_index->refresh();
+ $index = $this->_createIndex();
+
+ $index->getType('test')->addDocuments(array(
+ new Document(1, array('price' => 5)),
+ new Document(2, array('price' => 8)),
+ new Document(3, array('price' => 1)),
+ new Document(4, array('price' => 3)),
+ ));
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group functional
+ */
public function testSumAggregation()
{
- $agg = new Sum("sum");
- $agg->setField("price");
+ $agg = new Sum('sum');
+ $agg->setField('price');
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("sum");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('sum');
$this->assertEquals(5 + 8 + 1 + 3, $results['value']);
}
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/TermsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/TermsTest.php
index d9f37a20..58eb02c2 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/TermsTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/TermsTest.php
@@ -1,39 +1,41 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Terms;
use Elastica\Document;
use Elastica\Query;
class TermsTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex("terms");
- $docs = array(
- new Document("1", array("color" => "blue")),
- new Document("2", array("color" => "blue")),
- new Document("3", array("color" => "red")),
- new Document("4", array("color" => "green")),
- );
- $this->_index->getType("test")->addDocuments($docs);
- $this->_index->refresh();
+ $index = $this->_createIndex();
+
+ $index->getType('test')->addDocuments(array(
+ new Document(1, array('color' => 'blue')),
+ new Document(2, array('color' => 'blue')),
+ new Document(3, array('color' => 'red')),
+ new Document(4, array('color' => 'green')),
+ ));
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group functional
+ */
public function testTermsAggregation()
{
- $agg = new Terms("terms");
- $agg->setField("color");
+ $agg = new Terms('terms');
+ $agg->setField('color');
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("terms");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('terms');
$this->assertEquals(2, $results['buckets'][0]['doc_count']);
- $this->assertEquals("blue", $results['buckets'][0]['key']);
+ $this->assertEquals('blue', $results['buckets'][0]['key']);
}
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/TopHitsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/TopHitsTest.php
new file mode 100644
index 00000000..afe23e27
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/TopHitsTest.php
@@ -0,0 +1,385 @@
+<?php
+namespace Elastica\Test\Aggregation;
+
+use Elastica\Aggregation\Terms;
+use Elastica\Aggregation\TopHits;
+use Elastica\Document;
+use Elastica\Query;
+use Elastica\Query\MatchAll;
+use Elastica\Query\SimpleQueryString;
+use Elastica\Script;
+use Elastica\ScriptFields;
+
+class TopHitsTest extends BaseAggregationTest
+{
+ protected function _getIndexForTest()
+ {
+ $index = $this->_createIndex();
+
+ $index->getType('questions')->addDocuments(array(
+ new Document(1, array(
+ 'tags' => array('linux'),
+ 'last_activity_date' => '2015-01-05',
+ 'title' => 'Question about linux #1',
+ )),
+ new Document(2, array(
+ 'tags' => array('linux'),
+ 'last_activity_date' => '2014-12-23',
+ 'title' => 'Question about linux #2',
+ )),
+ new Document(3, array(
+ 'tags' => array('windows'),
+ 'last_activity_date' => '2015-01-05',
+ 'title' => 'Question about windows #1',
+ )),
+ new Document(4, array(
+ 'tags' => array('windows'),
+ 'last_activity_date' => '2014-12-23',
+ 'title' => 'Question about windows #2',
+ )),
+ new Document(5, array(
+ 'tags' => array('osx', 'apple'),
+ 'last_activity_date' => '2014-12-23',
+ 'title' => 'Question about osx',
+ )),
+ ));
+
+ $index->refresh();
+
+ return $index;
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetSize()
+ {
+ $agg = new TopHits('agg_name');
+ $returnValue = $agg->setSize(12);
+ $this->assertEquals(12, $agg->getParam('size'));
+ $this->assertInstanceOf('Elastica\Aggregation\TopHits', $returnValue);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetFrom()
+ {
+ $agg = new TopHits('agg_name');
+ $returnValue = $agg->setFrom(12);
+ $this->assertEquals(12, $agg->getParam('from'));
+ $this->assertInstanceOf('Elastica\Aggregation\TopHits', $returnValue);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetSort()
+ {
+ $sort = array('last_activity_date' => array('order' => 'desc'));
+ $agg = new TopHits('agg_name');
+ $returnValue = $agg->setSort($sort);
+ $this->assertEquals($sort, $agg->getParam('sort'));
+ $this->assertInstanceOf('Elastica\Aggregation\TopHits', $returnValue);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetSource()
+ {
+ $fields = array('title', 'tags');
+ $agg = new TopHits('agg_name');
+ $returnValue = $agg->setSource($fields);
+ $this->assertEquals($fields, $agg->getParam('_source'));
+ $this->assertInstanceOf('Elastica\Aggregation\TopHits', $returnValue);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetVersion()
+ {
+ $agg = new TopHits('agg_name');
+ $returnValue = $agg->setVersion(true);
+ $this->assertTrue($agg->getParam('version'));
+ $this->assertInstanceOf('Elastica\Aggregation\TopHits', $returnValue);
+
+ $agg->setVersion(false);
+ $this->assertFalse($agg->getParam('version'));
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetExplain()
+ {
+ $agg = new TopHits('agg_name');
+ $returnValue = $agg->setExplain(true);
+ $this->assertTrue($agg->getParam('explain'));
+ $this->assertInstanceOf('Elastica\Aggregation\TopHits', $returnValue);
+
+ $agg->setExplain(false);
+ $this->assertFalse($agg->getParam('explain'));
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetHighlight()
+ {
+ $highlight = array(
+ 'fields' => array(
+ 'title',
+ ),
+ );
+ $agg = new TopHits('agg_name');
+ $returnValue = $agg->setHighlight($highlight);
+ $this->assertEquals($highlight, $agg->getParam('highlight'));
+ $this->assertInstanceOf('Elastica\Aggregation\TopHits', $returnValue);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetFieldDataFields()
+ {
+ $fields = array('title', 'tags');
+ $agg = new TopHits('agg_name');
+ $returnValue = $agg->setFieldDataFields($fields);
+ $this->assertEquals($fields, $agg->getParam('fielddata_fields'));
+ $this->assertInstanceOf('Elastica\Aggregation\TopHits', $returnValue);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetScriptFields()
+ {
+ $script = new Script('1 + 2');
+ $scriptFields = new ScriptFields(array('three' => $script));
+
+ $agg = new TopHits('agg_name');
+ $returnValue = $agg->setScriptFields($scriptFields);
+ $this->assertEquals($scriptFields->toArray(), $agg->getParam('script_fields'));
+ $this->assertInstanceOf('Elastica\Aggregation\TopHits', $returnValue);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testAddScriptField()
+ {
+ $script = new Script('2+3');
+ $agg = new TopHits('agg_name');
+ $returnValue = $agg->addScriptField('five', $script);
+ $this->assertEquals(array('five' => $script->toArray()), $agg->getParam('script_fields'));
+ $this->assertInstanceOf('Elastica\Aggregation\TopHits', $returnValue);
+ }
+
+ protected function getOuterAggregationResult($innerAggr)
+ {
+ $outerAggr = new Terms('top_tags');
+ $outerAggr->setField('tags');
+ $outerAggr->setMinimumDocumentCount(2);
+ $outerAggr->addAggregation($innerAggr);
+
+ $query = new Query(new MatchAll());
+ $query->addAggregation($outerAggr);
+
+ return $this->_getIndexForTest()->search($query)->getAggregation('top_tags');
+ }
+
+ /**
+ * @group functional
+ */
+ public function testAggregateUpdatedRecently()
+ {
+ $aggr = new TopHits('top_tag_hits');
+ $aggr->setSize(1);
+ $aggr->setSort(array('last_activity_date' => array('order' => 'desc')));
+
+ $resultDocs = array();
+ $outerAggrResult = $this->getOuterAggregationResult($aggr);
+ foreach ($outerAggrResult['buckets'] as $bucket) {
+ foreach ($bucket['top_tag_hits']['hits']['hits'] as $doc) {
+ $resultDocs[] = $doc['_id'];
+ }
+ }
+ $this->assertEquals(array(1, 3), $resultDocs);
+ }
+
+ /**
+ * @group functional
+ */
+ public function testAggregateUpdatedFarAgo()
+ {
+ $aggr = new TopHits('top_tag_hits');
+ $aggr->setSize(1);
+ $aggr->setSort(array('last_activity_date' => array('order' => 'asc')));
+
+ $resultDocs = array();
+ $outerAggrResult = $this->getOuterAggregationResult($aggr);
+ foreach ($outerAggrResult['buckets'] as $bucket) {
+ foreach ($bucket['top_tag_hits']['hits']['hits'] as $doc) {
+ $resultDocs[] = $doc['_id'];
+ }
+ }
+ $this->assertEquals(array(2, 4), $resultDocs);
+ }
+
+ /**
+ * @group functional
+ */
+ public function testAggregateTwoDocumentPerTag()
+ {
+ $aggr = new TopHits('top_tag_hits');
+ $aggr->setSize(2);
+
+ $resultDocs = array();
+ $outerAggrResult = $this->getOuterAggregationResult($aggr);
+ foreach ($outerAggrResult['buckets'] as $bucket) {
+ foreach ($bucket['top_tag_hits']['hits']['hits'] as $doc) {
+ $resultDocs[] = $doc['_id'];
+ }
+ }
+ $this->assertEquals(array(1, 2, 3, 4), $resultDocs);
+ }
+
+ /**
+ * @group functional
+ */
+ public function testAggregateTwoDocumentPerTagWithOffset()
+ {
+ $aggr = new TopHits('top_tag_hits');
+ $aggr->setSize(2);
+ $aggr->setFrom(1);
+ $aggr->setSort(array('last_activity_date' => array('order' => 'desc')));
+
+ $resultDocs = array();
+ $outerAggrResult = $this->getOuterAggregationResult($aggr);
+ foreach ($outerAggrResult['buckets'] as $bucket) {
+ foreach ($bucket['top_tag_hits']['hits']['hits'] as $doc) {
+ $resultDocs[] = $doc['_id'];
+ }
+ }
+ $this->assertEquals(array(2, 4), $resultDocs);
+ }
+
+ /**
+ * @group functional
+ */
+ public function testAggregateWithLimitedSource()
+ {
+ $aggr = new TopHits('top_tag_hits');
+ $aggr->setSource(array('title'));
+
+ $resultDocs = array();
+ $outerAggrResult = $this->getOuterAggregationResult($aggr);
+ foreach ($outerAggrResult['buckets'] as $bucket) {
+ foreach ($bucket['top_tag_hits']['hits']['hits'] as $doc) {
+ $this->assertArrayHasKey('title', $doc['_source']);
+ $this->assertArrayNotHasKey('tags', $doc['_source']);
+ $this->assertArrayNotHasKey('last_activity_date', $doc['_source']);
+ }
+ }
+ }
+
+ /**
+ * @group functional
+ */
+ public function testAggregateWithVersion()
+ {
+ $aggr = new TopHits('top_tag_hits');
+ $aggr->setVersion(true);
+
+ $resultDocs = array();
+ $outerAggrResult = $this->getOuterAggregationResult($aggr);
+ foreach ($outerAggrResult['buckets'] as $bucket) {
+ foreach ($bucket['top_tag_hits']['hits']['hits'] as $doc) {
+ $this->assertArrayHasKey('_version', $doc);
+ }
+ }
+ }
+
+ /**
+ * @group functional
+ */
+ public function testAggregateWithExplain()
+ {
+ $aggr = new TopHits('top_tag_hits');
+ $aggr->setExplain(true);
+
+ $resultDocs = array();
+ $outerAggrResult = $this->getOuterAggregationResult($aggr);
+ foreach ($outerAggrResult['buckets'] as $bucket) {
+ foreach ($bucket['top_tag_hits']['hits']['hits'] as $doc) {
+ $this->assertArrayHasKey('_explanation', $doc);
+ }
+ }
+ }
+
+ /**
+ * @group functional
+ */
+ public function testAggregateWithScriptFields()
+ {
+ $aggr = new TopHits('top_tag_hits');
+ $aggr->setSize(1);
+ $aggr->setScriptFields(array('three' => new Script('1 + 2')));
+ $aggr->addScriptField('five', new Script('3 + 2'));
+
+ $resultDocs = array();
+ $outerAggrResult = $this->getOuterAggregationResult($aggr);
+ foreach ($outerAggrResult['buckets'] as $bucket) {
+ foreach ($bucket['top_tag_hits']['hits']['hits'] as $doc) {
+ $this->assertEquals(3, $doc['fields']['three'][0]);
+ $this->assertEquals(5, $doc['fields']['five'][0]);
+ }
+ }
+ }
+
+ /**
+ * @group functional
+ */
+ public function testAggregateWithHighlight()
+ {
+ $queryString = new SimpleQueryString('linux', array('title'));
+
+ $aggr = new TopHits('top_tag_hits');
+ $aggr->setHighlight(array('fields' => array('title' => new \stdClass())));
+
+ $query = new Query($queryString);
+ $query->addAggregation($aggr);
+
+ $resultSet = $this->_getIndexForTest()->search($query);
+ $aggrResult = $resultSet->getAggregation('top_tag_hits');
+
+ foreach ($aggrResult['hits']['hits'] as $doc) {
+ $this->assertArrayHasKey('highlight', $doc);
+ $this->assertRegExp('#<em>linux</em>#', $doc['highlight']['title'][0]);
+ }
+ }
+
+ /**
+ * @group functional
+ */
+ public function testAggregateWithFieldData()
+ {
+ $aggr = new TopHits('top_tag_hits');
+ $aggr->setFieldDataFields(array('title'));
+
+ $query = new Query(new MatchAll());
+ $query->addAggregation($aggr);
+
+ $resultSet = $this->_getIndexForTest()->search($query);
+ $aggrResult = $resultSet->getAggregation('top_tag_hits');
+
+ foreach ($aggrResult['hits']['hits'] as $doc) {
+ $this->assertArrayHasKey('fields', $doc);
+ $this->assertArrayHasKey('title', $doc['fields']);
+ $this->assertArrayNotHasKey('tags', $doc['fields']);
+ $this->assertArrayNotHasKey('last_activity_date', $doc['fields']);
+ }
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ValueCountTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ValueCountTest.php
index 5eba9ea4..21b63cbe 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ValueCountTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ValueCountTest.php
@@ -1,38 +1,40 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\ValueCount;
use Elastica\Document;
use Elastica\Query;
class ValueCountTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex('value_count');
- $docs = array(
- new Document('1', array('price' => 5)),
- new Document('2', array('price' => 8)),
- new Document('3', array('price' => 1)),
- new Document('4', array('price' => 3)),
- new Document('5', array('price' => 3)),
- );
- $this->_index->getType('test')->addDocuments($docs);
- $this->_index->refresh();
+ $index = $this->_createIndex();
+
+ $index->getType('test')->addDocuments(array(
+ new Document(1, array('price' => 5)),
+ new Document(2, array('price' => 8)),
+ new Document(3, array('price' => 1)),
+ new Document(4, array('price' => 3)),
+ new Document(5, array('price' => 3)),
+ ));
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group functional
+ */
public function testValueCountAggregation()
{
- $agg = new ValueCount("count", "price");
+ $agg = new ValueCount('count', 'price');
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("count");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('count');
$this->assertEquals(5, $results['value']);
}
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Base.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Base.php
index 55cd8873..c826c747 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Base.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Base.php
@@ -1,31 +1,142 @@
<?php
-
namespace Elastica\Test;
use Elastica\Client;
+use Elastica\Connection;
+use Elastica\Index;
class Base extends \PHPUnit_Framework_TestCase
{
- protected function _getClient()
+ /**
+ * @param array $params Additional configuration params. Host and Port are already set
+ * @param callback $callback
+ *
+ * @return Client
+ */
+ protected function _getClient(array $params = array(), $callback = null)
+ {
+ $config = array(
+ 'host' => $this->_getHost(),
+ 'port' => $this->_getPort(),
+ );
+
+ $config = array_merge($config, $params);
+
+ return new Client($config, $callback);
+ }
+
+ /**
+ * @return string Host to es for elastica tests
+ */
+ protected function _getHost()
+ {
+ return getenv('ES_HOST') ?: Connection::DEFAULT_HOST;
+ }
+
+ /**
+ * @return int Port to es for elastica tests
+ */
+ protected function _getPort()
+ {
+ return getenv('ES_PORT') ?: Connection::DEFAULT_PORT;
+ }
+
+ /**
+ * @return string Proxy url string
+ */
+ protected function _getProxyUrl()
+ {
+ $proxyHost = getenv('PROXY_HOST') ?: Connection::DEFAULT_HOST;
+
+ return 'http://'.$proxyHost.':12345';
+ }
+
+ /**
+ * @return string Proxy url string to proxy which returns 403
+ */
+ protected function _getProxyUrl403()
{
- return new Client(array(
- 'host' => getenv('ES_HOST') ?: 'localhost',
- 'port' => getenv('ES_PORT') ?: 9200,
- ));
+ $proxyHost = getenv('PROXY_HOST') ?: Connection::DEFAULT_HOST;
+
+ return 'http://'.$proxyHost.':12346';
}
/**
- * @param string $name Index name
- * @param bool $delete Delete index if it exists
- * @param int $shards Number of shards to create
+ * @param string $name Index name
+ * @param bool $delete Delete index if it exists
+ * @param int $shards Number of shards to create
+ *
* @return \Elastica\Index
*/
- protected function _createIndex($name = 'test', $delete = true, $shards = 1)
+ protected function _createIndex($name = null, $delete = true, $shards = 1)
{
+ if (is_null($name)) {
+ $name = preg_replace('/[^a-z]/i', '', strtolower(get_called_class())).uniqid();
+ }
+
$client = $this->_getClient();
- $index = $client->getIndex('elastica_' . $name);
+ $index = $client->getIndex('elastica_'.$name);
$index->create(array('index' => array('number_of_shards' => $shards, 'number_of_replicas' => 0)), $delete);
return $index;
}
+
+ protected function _waitForAllocation(Index $index)
+ {
+ do {
+ $settings = $index->getStatus()->get();
+ $allocated = true;
+ foreach ($settings['shards'] as $shard) {
+ if ($shard[0]['routing']['state'] != 'STARTED') {
+ $allocated = false;
+ }
+ }
+ } while (!$allocated);
+ }
+
+ protected function setUp()
+ {
+ parent::setUp();
+
+ $hasGroup = $this->_isUnitGroup() || $this->_isFunctionalGroup() || $this->_isShutdownGroup() || $this->_isBenchmarkGroup();
+ $this->assertTrue($hasGroup, 'Every test must have one of "unit", "functional", "shutdown" or "benchmark" group');
+ }
+
+ protected function tearDown()
+ {
+ if ($this->_isFunctionalGroup()) {
+ $this->_getClient()->getIndex('_all')->delete();
+ $this->_getClient()->getIndex('_all')->clearCache();
+ }
+
+ parent::tearDown();
+ }
+
+ protected function _isUnitGroup()
+ {
+ $groups = \PHPUnit_Util_Test::getGroups(get_class($this), $this->getName(false));
+
+ return in_array('unit', $groups);
+ }
+
+ protected function _isFunctionalGroup()
+ {
+ $groups = \PHPUnit_Util_Test::getGroups(get_class($this), $this->getName(false));
+
+ return in_array('functional', $groups);
+ }
+
+ protected function _isShutdownGroup()
+ {
+ $groups = \PHPUnit_Util_Test::getGroups(get_class($this), $this->getName(false));
+
+ return in_array('shutdown', $groups);
+ }
+
+ protected function _isBenchmarkGroup()
+ {
+ $groups = \PHPUnit_Util_Test::getGroups(get_class($this), $this->getName(false));
+
+ return in_array('benchmark', $groups);
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Bulk/ActionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Bulk/ActionTest.php
index 178883a8..e4588e70 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Bulk/ActionTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Bulk/ActionTest.php
@@ -1,64 +1,61 @@
<?php
-
namespace Elastica\Test\Bulk;
use Elastica\Bulk\Action;
-use Elastica\Bulk;
-use Elastica\Client;
-use Elastica\Exception\Bulk\ResponseException;
use Elastica\Index;
use Elastica\Test\Base as BaseTest;
-use Elastica\Bulk\ResponseSet;
-use Elastica\Response;
use Elastica\Type;
class ActionTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testAction()
{
$action = new Action();
$this->assertEquals('index', $action->getOpType());
$this->assertFalse($action->hasSource());
- $expected = '{"index":{}}' . "\n";
+ $expected = '{"index":{}}'."\n";
$this->assertEquals($expected, $action->toString());
$action->setIndex('index');
- $expected = '{"index":{"_index":"index"}}' . "\n";
+ $expected = '{"index":{"_index":"index"}}'."\n";
$this->assertEquals($expected, $action->toString());
$action->setType('type');
- $expected = '{"index":{"_index":"index","_type":"type"}}' . "\n";
+ $expected = '{"index":{"_index":"index","_type":"type"}}'."\n";
$this->assertEquals($expected, $action->toString());
$action->setId(1);
- $expected = '{"index":{"_index":"index","_type":"type","_id":1}}' . "\n";
+ $expected = '{"index":{"_index":"index","_type":"type","_id":1}}'."\n";
$this->assertEquals($expected, $action->toString());
$action->setRouting(1);
- $expected = '{"index":{"_index":"index","_type":"type","_id":1,"_routing":1}}' . "\n";
+ $expected = '{"index":{"_index":"index","_type":"type","_id":1,"_routing":1}}'."\n";
$this->assertEquals($expected, $action->toString());
- $client = new Client();
+ $client = $this->_getClient();
$index = new Index($client, 'index2');
$type = new Type($index, 'type2');
$action->setIndex($index);
- $expected = '{"index":{"_index":"index2","_type":"type","_id":1,"_routing":1}}' . "\n";
+ $expected = '{"index":{"_index":"index2","_type":"type","_id":1,"_routing":1}}'."\n";
$this->assertEquals($expected, $action->toString());
$action->setType($type);
- $expected = '{"index":{"_index":"index2","_type":"type2","_id":1,"_routing":1}}' . "\n";
+ $expected = '{"index":{"_index":"index2","_type":"type2","_id":1,"_routing":1}}'."\n";
$this->assertEquals($expected, $action->toString());
$action->setSource(array('user' => 'name'));
- $expected = '{"index":{"_index":"index2","_type":"type2","_id":1,"_routing":1}}' . "\n";
- $expected.= '{"user":"name"}' . "\n";
+ $expected = '{"index":{"_index":"index2","_type":"type2","_id":1,"_routing":1}}'."\n";
+ $expected .= '{"user":"name"}'."\n";
$this->assertEquals($expected, $action->toString());
$this->assertTrue($action->hasSource());
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Bulk/ResponseSetTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Bulk/ResponseSetTest.php
index d1495fce..949dcf7a 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Bulk/ResponseSetTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Bulk/ResponseSetTest.php
@@ -1,17 +1,16 @@
<?php
-
namespace Elastica\Test\Bulk;
-use Elastica\Bulk\Action;
use Elastica\Bulk;
+use Elastica\Bulk\Action;
use Elastica\Exception\Bulk\ResponseException;
-use Elastica\Test\Base as BaseTest;
-use Elastica\Bulk\ResponseSet;
use Elastica\Response;
+use Elastica\Test\Base as BaseTest;
class ResponseSetTest extends BaseTest
{
/**
+ * @group unit
* @dataProvider isOkDataProvider
*/
public function testIsOk($responseData, $actions, $expected)
@@ -20,6 +19,9 @@ class ResponseSetTest extends BaseTest
$this->assertEquals($expected, $responseSet->isOk());
}
+ /**
+ * @group unit
+ */
public function testGetError()
{
list($responseData, $actions) = $this->_getFixture();
@@ -55,6 +57,9 @@ class ResponseSetTest extends BaseTest
}
}
+ /**
+ * @group unit
+ */
public function testGetBulkResponses()
{
list($responseData, $actions) = $this->_getFixture();
@@ -76,6 +81,9 @@ class ResponseSetTest extends BaseTest
}
}
+ /**
+ * @group unit
+ */
public function testIterator()
{
list($responseData, $actions) = $this->_getFixture();
@@ -119,12 +127,14 @@ class ResponseSetTest extends BaseTest
$return[] = array($responseData, $actions, true);
$responseData['items'][2]['index']['ok'] = false;
$return[] = array($responseData, $actions, false);
+
return $return;
}
/**
* @param array $responseData
* @param array $actions
+ *
* @return \Elastica\Bulk\ResponseSet
*/
protected function _createResponseSet(array $responseData, array $actions)
@@ -138,6 +148,7 @@ class ResponseSetTest extends BaseTest
$bulk = new Bulk($client);
$bulk->addActions($actions);
+
return $bulk->send();
}
@@ -156,7 +167,7 @@ class ResponseSetTest extends BaseTest
'_id' => '1',
'_version' => 1,
'ok' => true,
- )
+ ),
),
array(
'index' => array(
@@ -165,7 +176,7 @@ class ResponseSetTest extends BaseTest
'_id' => '2',
'_version' => 1,
'ok' => true,
- )
+ ),
),
array(
'index' => array(
@@ -174,15 +185,16 @@ class ResponseSetTest extends BaseTest
'_id' => '3',
'_version' => 1,
'ok' => true,
- )
- )
- )
+ ),
+ ),
+ ),
);
$bulkResponses = array(
new Action(),
new Action(),
new Action(),
);
+
return array($responseData, $bulkResponses);
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/BulkTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/BulkTest.php
index 3396fe86..c3ff15bc 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/BulkTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/BulkTest.php
@@ -1,24 +1,24 @@
<?php
-
namespace Elastica\Test;
use Elastica\Bulk;
use Elastica\Bulk\Action;
-use Elastica\Client;
+use Elastica\Bulk\Action\AbstractDocument;
use Elastica\Document;
use Elastica\Exception\Bulk\ResponseException;
-use Elastica\Exception\InvalidException;
use Elastica\Exception\NotFoundException;
-use Elastica\Test\Base as BaseTest;
-use Elastica\Bulk\Action\AbstractDocument;
use Elastica\Filter\Script;
+use Elastica\Test\Base as BaseTest;
class BulkTest extends BaseTest
{
-
+ /**
+ * @group functional
+ */
public function testSend()
{
$index = $this->_createIndex();
+ $indexName = $index->getName();
$type = $index->getType('bulk_test');
$type2 = $index->getType('bulk_test2');
$client = $index->getClient();
@@ -28,14 +28,13 @@ class BulkTest extends BaseTest
$newDocument3 = $type->createDocument(3, array('name' => 'The Human Torch'));
$newDocument4 = $type->createDocument(null, array('name' => 'The Thing'));
- $newDocument1->setPercolate('*');
$newDocument3->setOpType(Document::OP_TYPE_CREATE);
$documents = array(
$newDocument1,
$newDocument2,
$newDocument3,
- $newDocument4
+ $newDocument4,
);
$bulk = new Bulk($client);
@@ -63,29 +62,29 @@ class BulkTest extends BaseTest
$data = $bulk->toArray();
$expected = array(
- array('index' => array('_index' => 'elastica_test', '_type' => 'bulk_test', '_id' => 1, '_percolate' => '*')),
+ array('index' => array('_index' => $indexName, '_type' => 'bulk_test', '_id' => 1)),
array('name' => 'Mister Fantastic'),
array('index' => array('_id' => 2)),
array('name' => 'Invisible Woman'),
- array('create' => array('_index' => 'elastica_test', '_type' => 'bulk_test', '_id' => 3)),
+ array('create' => array('_index' => $indexName, '_type' => 'bulk_test', '_id' => 3)),
array('name' => 'The Human Torch'),
- array('index' => array('_index' => 'elastica_test', '_type' => 'bulk_test')),
+ array('index' => array('_index' => $indexName, '_type' => 'bulk_test')),
array('name' => 'The Thing'),
);
$this->assertEquals($expected, $data);
- $expected = '{"index":{"_index":"elastica_test","_type":"bulk_test","_id":1,"_percolate":"*"}}
+ $expected = '{"index":{"_index":"'.$indexName.'","_type":"bulk_test","_id":1}}
{"name":"Mister Fantastic"}
{"index":{"_id":2}}
{"name":"Invisible Woman"}
-{"create":{"_index":"elastica_test","_type":"bulk_test","_id":3}}
+{"create":{"_index":"'.$indexName.'","_type":"bulk_test","_id":3}}
{"name":"The Human Torch"}
-{"index":{"_index":"elastica_test","_type":"bulk_test"}}
+{"index":{"_index":"'.$indexName.'","_type":"bulk_test"}}
{"name":"The Thing"}
';
$expected = str_replace(PHP_EOL, "\n", $expected);
- $this->assertEquals($expected, (string)str_replace(PHP_EOL, "\n", (string)$bulk));
+ $this->assertEquals($expected, (string) str_replace(PHP_EOL, "\n", (string) $bulk));
$response = $bulk->send();
@@ -107,14 +106,13 @@ class BulkTest extends BaseTest
$this->assertEquals(3, $type->count());
$this->assertEquals(1, $type2->count());
-
$bulk = new Bulk($client);
$bulk->addDocument($newDocument3, Action::OP_TYPE_DELETE);
$data = $bulk->toArray();
$expected = array(
- array('delete' => array('_index' => 'elastica_test', '_type' => 'bulk_test', '_id' => 3)),
+ array('delete' => array('_index' => $indexName, '_type' => 'bulk_test', '_id' => 3)),
);
$this->assertEquals($expected, $data);
@@ -132,6 +130,9 @@ class BulkTest extends BaseTest
}
}
+ /**
+ * @group functional
+ */
public function testUnicodeBulkSend()
{
$index = $this->_createIndex();
@@ -146,7 +147,7 @@ class BulkTest extends BaseTest
$documents = array(
$newDocument1,
$newDocument2,
- $newDocument3
+ $newDocument3,
);
$bulk = new Bulk($client);
@@ -160,9 +161,12 @@ class BulkTest extends BaseTest
$this->assertSame($newDocument3, $actions[2]->getDocument());
}
+ /**
+ * @group functional
+ */
public function testSetIndexType()
{
- $client = new Client();
+ $client = $this->_getClient();
$index = $client->getIndex('index');
$type = $index->getType('type');
@@ -198,9 +202,12 @@ class BulkTest extends BaseTest
$this->assertEquals('type', $bulk->getType());
}
+ /**
+ * @group unit
+ */
public function testAddActions()
{
- $client = new Client();
+ $client = $this->_getClient();
$bulk = new Bulk($client);
$action1 = new Action(Action::OP_TYPE_DELETE);
@@ -216,7 +223,7 @@ class BulkTest extends BaseTest
$actions = array(
$action1,
- $action2
+ $action2,
);
$bulk->addActions($actions);
@@ -227,6 +234,9 @@ class BulkTest extends BaseTest
$this->assertSame($action2, $getActions[1]);
}
+ /**
+ * @group unit
+ */
public function testAddRawData()
{
$bulk = new Bulk($this->_getClient());
@@ -277,6 +287,7 @@ class BulkTest extends BaseTest
}
/**
+ * @group unit
* @dataProvider invalidRawDataProvider
* @expectedException \Elastica\Exception\InvalidException
*/
@@ -298,7 +309,7 @@ class BulkTest extends BaseTest
array('user' => array('name' => 'hans')),
array('user' => array('name' => 'mans')),
),
- 'Two sources for one action'
+ 'Two sources for one action',
),
array(
array(
@@ -306,29 +317,32 @@ class BulkTest extends BaseTest
array('user' => array('name' => 'hans')),
array('upsert' => array('_index' => 'test', '_type' => 'user', '_id' => '2')),
),
- 'Invalid optype for action'
+ 'Invalid optype for action',
),
array(
array(
array('user' => array('name' => 'mans')),
),
- 'Source without action'
+ 'Source without action',
),
array(
array(
array(),
),
- 'Empty array'
+ 'Empty array',
),
array(
array(
'dummy',
),
- 'String as data'
- )
+ 'String as data',
+ ),
);
}
+ /**
+ * @group unit
+ */
public function testCreateAbstractDocumentWithInvalidData()
{
//Wrong class type
@@ -350,6 +364,9 @@ class BulkTest extends BaseTest
}
}
+ /**
+ * @group functional
+ */
public function testErrorRequest()
{
$index = $this->_createIndex();
@@ -379,6 +396,9 @@ class BulkTest extends BaseTest
}
}
+ /**
+ * @group functional
+ */
public function testRawDocumentDataRequest()
{
$index = $this->_createIndex();
@@ -413,13 +433,14 @@ class BulkTest extends BaseTest
$response = $type->search();
$this->assertEquals(3, $response->count());
- foreach (array("Mister", "Invisible", "Torch") as $name) {
+ foreach (array('Mister', 'Invisible', 'Torch') as $name) {
$result = $type->search($name);
$this->assertEquals(1, count($result->getResults()));
}
}
/**
+ * @group functional
* @dataProvider udpDataProvider
*/
public function testUdp($clientConfig, $host, $port, $shouldFail = false)
@@ -427,7 +448,7 @@ class BulkTest extends BaseTest
if (!function_exists('socket_create')) {
$this->markTestSkipped('Function socket_create() does not exist.');
}
- $client = new Client($clientConfig);
+ $client = $this->_getClient($clientConfig);
$index = $client->getIndex('elastica_test');
$index->create(array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0)), true);
$type = $index->getType('udp_test');
@@ -467,6 +488,9 @@ class BulkTest extends BaseTest
}
}
+ /**
+ * @group functional
+ */
public function testUpdate()
{
$index = $this->_createIndex();
@@ -599,6 +623,9 @@ class BulkTest extends BaseTest
$index->delete();
}
+ /**
+ * @group unit
+ */
public function testGetPath()
{
$client = $this->_getClient();
@@ -609,13 +636,16 @@ class BulkTest extends BaseTest
$indexName = 'testIndex';
$bulk->setIndex($indexName);
- $this->assertEquals($indexName . '/_bulk', $bulk->getPath());
+ $this->assertEquals($indexName.'/_bulk', $bulk->getPath());
$typeName = 'testType';
$bulk->setType($typeName);
- $this->assertEquals($indexName . '/' . $typeName . '/_bulk', $bulk->getPath());
+ $this->assertEquals($indexName.'/'.$typeName.'/_bulk', $bulk->getPath());
}
+ /**
+ * @group functional
+ */
public function testRetry()
{
$index = $this->_createIndex();
@@ -634,7 +664,7 @@ class BulkTest extends BaseTest
$metadata = $actions[0]->getMetadata();
$this->assertEquals(5, $metadata[ '_retry_on_conflict' ]);
- $script = new \Elastica\Script( '' );
+ $script = new \Elastica\Script('');
$script->setRetryOnConflict(5);
$bulk = new Bulk($client);
@@ -646,65 +676,116 @@ class BulkTest extends BaseTest
$this->assertEquals(5, $metadata[ '_retry_on_conflict' ]);
}
+ /**
+ * @group unit
+ */
+ public function testSetShardTimeout()
+ {
+ $bulk = new Bulk($this->_getClient());
+ $this->assertInstanceOf('Elastica\Bulk', $bulk->setShardTimeout(10));
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetRequestParam()
+ {
+ $bulk = new Bulk($this->_getClient());
+ $this->assertInstanceOf('Elastica\Bulk', $bulk->setRequestParam('key', 'value'));
+ }
+
+ /**
+ * @group benchmark
+ */
+ public function testMemoryUsage()
+ {
+ $type = $this->_createIndex()->getType('test');
+
+ $data = array(
+ 'text1' => 'Very long text for a string',
+ 'text2' => 'But this is not very long',
+ 'text3' => 'random or not random?',
+ );
+
+ $startMemory = memory_get_usage();
+
+ for ($n = 1; $n < 10; $n++) {
+ $docs = array();
+
+ for ($i = 1; $i <= 3000; $i++) {
+ $docs[] = new Document(uniqid(), $data);
+ }
+
+ $type->addDocuments($docs);
+ $docs = array();
+ }
+
+ unset($docs);
+
+ $endMemory = memory_get_usage();
+
+ $this->assertLessThan(1.3, $endMemory / $startMemory);
+ }
+
public function udpDataProvider()
{
return array(
array(
array(),
null,
- null
+ null,
),
array(
array(),
- 'localhost',
- null
+ $this->_getHost(),
+ null,
),
array(
array(),
null,
- 9700
+ 9700,
),
array(
array(),
- 'localhost',
- 9700
+ $this->_getHost(),
+ 9700,
),
array(
array(
'udp' => array(
- 'host' => 'localhost',
+ 'host' => $this->_getHost(),
'port' => 9700,
- )
+ ),
),
null,
- null
+ null,
),
array(
array(
'udp' => array(
- 'host' => 'localhost',
+ 'host' => $this->_getHost(),
'port' => 9800,
- )
+ ),
),
- 'localhost',
- 9700
+ $this->_getHost(),
+ 9700,
),
array(
array(
'udp' => array(
- 'host' => 'localhost',
+ 'host' => $this->_getHost(),
'port' => 9800,
- )
+ ),
),
null,
null,
- true
+ true,
),
array(
array(),
- 'localhost',
+ $this->_getHost(),
9800,
- true
+ true,
),
);
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ClientTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ClientTest.php
index 94ee2ead..a5f2b46f 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/ClientTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ClientTest.php
@@ -1,31 +1,34 @@
<?php
-
namespace Elastica\Test;
-use Elastica\Client;
use Elastica\Connection;
use Elastica\Document;
-use Elastica\Exception\ClientException;
use Elastica\Exception\Connection\HttpException;
-use Elastica\Script;
+use Elastica\Exception\InvalidException;
use Elastica\Index;
use Elastica\Request;
+use Elastica\Script;
use Elastica\Test\Base as BaseTest;
use Elastica\Type;
class ClientTest extends BaseTest
{
-
+ /**
+ * @group unit
+ */
public function testConstruct()
{
$client = $this->_getClient();
$this->assertCount(1, $client->getConnections());
}
+ /**
+ * @group functional
+ */
public function testConnectionsArray()
{
// Creates a new index 'xodoa' and a type 'user' inside this index
- $client = new Client(array('connections' => array(array('host' => 'localhost', 'port' => 9200))));
+ $client = $this->_getClient(array('connections' => array(array('host' => $this->_getHost(), 'port' => 9200))));
$index = $client->getIndex('elastica_test1');
$index->create(array(), true);
@@ -53,12 +56,15 @@ class ClientTest extends BaseTest
$resultSet = $type->search('rolf');
}
+ /**
+ * @group functional
+ */
public function testTwoServersSame()
{
// Creates a new index 'xodoa' and a type 'user' inside this index
- $client = new Client(array('connections' => array(
- array('host' => 'localhost', 'port' => 9200),
- array('host' => 'localhost', 'port' => 9200),
+ $client = $this->_getClient(array('connections' => array(
+ array('host' => $this->_getHost(), 'port' => 9200),
+ array('host' => $this->_getHost(), 'port' => 9200),
)));
$index = $client->getIndex('elastica_test1');
$index->create(array(), true);
@@ -67,17 +73,17 @@ class ClientTest extends BaseTest
// Adds 1 document to the index
$doc1 = new Document(1,
- array('username' => 'hans', 'test' => array('2', '3', '5'))
+ array('username' => 'hans', 'test' => array('2', '3', '5'))
);
$type->addDocument($doc1);
// Adds a list of documents with _bulk upload to the index
$docs = array();
$docs[] = new Document(2,
- array('username' => 'john', 'test' => array('1', '3', '6'))
+ array('username' => 'john', 'test' => array('1', '3', '6'))
);
$docs[] = new Document(3,
- array('username' => 'rolf', 'test' => array('2', '3', '7'))
+ array('username' => 'rolf', 'test' => array('2', '3', '7'))
);
$type->addDocuments($docs);
@@ -87,30 +93,45 @@ class ClientTest extends BaseTest
$resultSet = $type->search('rolf');
}
+ /**
+ * @group unit
+ */
public function testConnectionParamsArePreparedForConnectionsOption()
{
- $client = new Client(array('connections' => array(array('url' => 'https://localhost:9200'))));
+ $url = 'https://'.$this->_getHost().':9200';
+ $client = $this->_getClient(array('connections' => array(array('url' => $url))));
$connection = $client->getConnection();
- $this->assertEquals('https://localhost:9200', $connection->getConfig('url'));
+ $this->assertEquals($url, $connection->getConfig('url'));
}
+ /**
+ * @group unit
+ */
public function testConnectionParamsArePreparedForServersOption()
{
- $client = new Client(array('servers' => array(array('url' => 'https://localhost:9200'))));
+ $url = 'https://'.$this->_getHost().':9200';
+ $client = $this->_getClient(array('servers' => array(array('url' => $url))));
$connection = $client->getConnection();
- $this->assertEquals('https://localhost:9200', $connection->getConfig('url'));
+ $this->assertEquals($url, $connection->getConfig('url'));
}
+ /**
+ * @group unit
+ */
public function testConnectionParamsArePreparedForDefaultOptions()
{
- $client = new Client(array('url' => 'https://localhost:9200'));
+ $url = 'https://'.$this->_getHost().':9200';
+ $client = $this->_getClient(array('url' => $url));
$connection = $client->getConnection();
- $this->assertEquals('https://localhost:9200', $connection->getConfig('url'));
+ $this->assertEquals($url, $connection->getConfig('url'));
}
+ /**
+ * @group functional
+ */
public function testBulk()
{
$client = $this->_getClient();
@@ -125,6 +146,9 @@ class ClientTest extends BaseTest
$client->bulk($params);
}
+ /**
+ * @group functional
+ */
public function testOptimizeAll()
{
$client = $this->_getClient();
@@ -134,6 +158,7 @@ class ClientTest extends BaseTest
}
/**
+ * @group unit
* @expectedException \Elastica\Exception\InvalidException
*/
public function testAddDocumentsEmpty()
@@ -143,7 +168,9 @@ class ClientTest extends BaseTest
}
/**
- * Test bulk operations on Index
+ * Test bulk operations on Index.
+ *
+ * @group functional
*/
public function testBulkIndex()
{
@@ -159,7 +186,7 @@ class ClientTest extends BaseTest
$index->updateDocuments(array(
new Document(1, array('name' => 'AnonCoin'), 'altcoin'),
- new Document(2, array('name' => 'iXcoin'), 'altcoin')
+ new Document(2, array('name' => 'iXcoin'), 'altcoin'),
));
$this->assertEquals('AnonCoin', $index->getType('altcoin')->getDocument(1)->get('name'));
@@ -174,7 +201,9 @@ class ClientTest extends BaseTest
}
/**
- * Test bulk operations on Type
+ * Test bulk operations on Type.
+ *
+ * @group functional
*/
public function testBulkType()
{
@@ -190,7 +219,7 @@ class ClientTest extends BaseTest
$type->updateDocuments(array(
new Document(1, array('name' => 'LiteCoin')),
- new Document(2, array('name' => 'NameCoin'))
+ new Document(2, array('name' => 'NameCoin')),
));
$this->assertEquals('LiteCoin', $type->getDocument(1)->get('name'));
@@ -204,6 +233,9 @@ class ClientTest extends BaseTest
$type->getDocument(2);
}
+ /**
+ * @group functional
+ */
public function testUpdateDocuments()
{
$indexName = 'test';
@@ -243,27 +275,29 @@ class ClientTest extends BaseTest
}
/**
- * Test deleteIds method using string parameters
- *
- * This test ensures that the deleteIds method of
- * the \Elastica\Client can properly accept and use
- * an $index parameter and $type parameter that are
- * strings
- *
- * This test is a bit more verbose than just sending the
- * values to deleteIds and checking for exceptions or
- * warnings.
- *
- * It will add a document, search for it, then delete it
- * using the parameter types we are interested in, and then
- * re-search to verify that they have been deleted
- */
+ * Test deleteIds method using string parameters.
+ *
+ * This test ensures that the deleteIds method of
+ * the \Elastica\Client can properly accept and use
+ * an $index parameter and $type parameter that are
+ * strings
+ *
+ * This test is a bit more verbose than just sending the
+ * values to deleteIds and checking for exceptions or
+ * warnings.
+ *
+ * It will add a document, search for it, then delete it
+ * using the parameter types we are interested in, and then
+ * re-search to verify that they have been deleted
+ *
+ * @group functional
+ */
public function testDeleteIdsIdxStringTypeString()
{
$data = array('username' => 'hans');
$userSearch = 'username:hans';
- $index = $this->_createIndex('test', true, 2);
+ $index = $this->_createIndex(null, true, 2);
// Create the index, deleting it first if it already exists
$index->create(array(), true);
@@ -289,8 +323,8 @@ class ClientTest extends BaseTest
// deleteIds are the type we are testing for
$idxString = $index->getName();
$typeString = $type->getName();
- $this->assertEquals(true, is_string($idxString));
- $this->assertEquals(true, is_string($typeString));
+ $this->assertTrue(is_string($idxString));
+ $this->assertTrue(is_string($typeString));
// Try to delete doc with a routing value which hashes to
// a different shard then the id.
@@ -318,22 +352,24 @@ class ClientTest extends BaseTest
}
/**
- * Test deleteIds method using string parameter for $index
- * and object parameter for $type
- *
- * This test ensures that the deleteIds method of
- * the \Elastica\Client can properly accept and use
- * an $index parameter that is a string and a $type
- * parameter that is of type \Elastica\Type
- *
- * This test is a bit more verbose than just sending the
- * values to deleteIds and checking for exceptions or
- * warnings.
- *
- * It will add a document, search for it, then delete it
- * using the parameter types we are interested in, and then
- * re-search to verify that they have been deleted
- */
+ * Test deleteIds method using string parameter for $index
+ * and object parameter for $type.
+ *
+ * This test ensures that the deleteIds method of
+ * the \Elastica\Client can properly accept and use
+ * an $index parameter that is a string and a $type
+ * parameter that is of type \Elastica\Type
+ *
+ * This test is a bit more verbose than just sending the
+ * values to deleteIds and checking for exceptions or
+ * warnings.
+ *
+ * It will add a document, search for it, then delete it
+ * using the parameter types we are interested in, and then
+ * re-search to verify that they have been deleted
+ *
+ * @group functional
+ */
public function testDeleteIdsIdxStringTypeObject()
{
$data = array('username' => 'hans');
@@ -363,8 +399,8 @@ class ClientTest extends BaseTest
// And verify that the variables we are doing to send to
// deleteIds are the type we are testing for
$idxString = $index->getName();
- $this->assertEquals(true, is_string($idxString));
- $this->assertEquals(true, ($type instanceof Type));
+ $this->assertTrue(is_string($idxString));
+ $this->assertInstanceOf('Elastica\Type', $type);
// Using the existing $index and $type variables which
// are \Elastica\Index and \Elastica\Type objects respectively
@@ -380,22 +416,24 @@ class ClientTest extends BaseTest
}
/**
- * Test deleteIds method using object parameter for $index
- * and string parameter for $type
- *
- * This test ensures that the deleteIds method of
- * the \Elastica\Client can properly accept and use
- * an $index parameter that is of type Elasitca_Index
- * and a $type parameter that is a string
- *
- * This test is a bit more verbose than just sending the
- * values to deleteIds and checking for exceptions or
- * warnings.
- *
- * It will add a document, search for it, then delete it
- * using the parameter types we are interested in, and then
- * re-search to verify that they have been deleted
- */
+ * Test deleteIds method using object parameter for $index
+ * and string parameter for $type.
+ *
+ * This test ensures that the deleteIds method of
+ * the \Elastica\Client can properly accept and use
+ * an $index parameter that is of type Elasitca_Index
+ * and a $type parameter that is a string
+ *
+ * This test is a bit more verbose than just sending the
+ * values to deleteIds and checking for exceptions or
+ * warnings.
+ *
+ * It will add a document, search for it, then delete it
+ * using the parameter types we are interested in, and then
+ * re-search to verify that they have been deleted
+ *
+ * @group functional
+ */
public function testDeleteIdsIdxObjectTypeString()
{
$data = array('username' => 'hans');
@@ -425,8 +463,8 @@ class ClientTest extends BaseTest
// And verify that the variables we are doing to send to
// deleteIds are the type we are testing for
$typeString = $type->getName();
- $this->assertEquals(true, ($index instanceof Index));
- $this->assertEquals(true, is_string($typeString));
+ $this->assertInstanceOf('Elastica\Index', $index);
+ $this->assertTrue(is_string($typeString));
// Using the existing $index and $type variables which
// are \Elastica\Index and \Elastica\Type objects respectively
@@ -442,22 +480,24 @@ class ClientTest extends BaseTest
}
/**
- * Test deleteIds method using object parameter for $index
- * and object parameter for $type
- *
- * This test ensures that the deleteIds method of
- * the \Elastica\Client can properly accept and use
- * an $index parameter that is an object and a $type
- * parameter that is of type \Elastica\Type
- *
- * This test is a bit more verbose than just sending the
- * values to deleteIds and checking for exceptions or
- * warnings.
- *
- * It will add a document, search for it, then delete it
- * using the parameter types we are interested in, and then
- * re-search to verify that they have been deleted
- */
+ * Test deleteIds method using object parameter for $index
+ * and object parameter for $type.
+ *
+ * This test ensures that the deleteIds method of
+ * the \Elastica\Client can properly accept and use
+ * an $index parameter that is an object and a $type
+ * parameter that is of type \Elastica\Type
+ *
+ * This test is a bit more verbose than just sending the
+ * values to deleteIds and checking for exceptions or
+ * warnings.
+ *
+ * It will add a document, search for it, then delete it
+ * using the parameter types we are interested in, and then
+ * re-search to verify that they have been deleted
+ *
+ * @group functional
+ */
public function testDeleteIdsIdxObjectTypeObject()
{
$data = array('username' => 'hans');
@@ -486,8 +526,8 @@ class ClientTest extends BaseTest
// And verify that the variables we are doing to send to
// deleteIds are the type we are testing for
- $this->assertEquals(true, ($index instanceof Index));
- $this->assertEquals(true, ($type instanceof Type));
+ $this->assertInstanceOf('Elastica\Index', $index);
+ $this->assertInstanceOf('Elastica\Type', $type);
// Using the existing $index and $type variables which
// are \Elastica\Index and \Elastica\Type objects respectively
@@ -502,13 +542,16 @@ class ClientTest extends BaseTest
$this->assertEquals(0, $totalHits);
}
+ /**
+ * @group functional
+ */
public function testOneInvalidConnection()
{
$client = $this->_getClient();
// First connection work, second should not work
- $connection1 = new Connection(array('port' => '9100', 'timeout' => 2));
- $connection2 = new Connection(array('port' => '9200', 'timeout' => 2));
+ $connection1 = new Connection(array('port' => '9100', 'timeout' => 2, 'host' => $this->_getHost()));
+ $connection2 = new Connection(array('port' => '9200', 'timeout' => 2, 'host' => $this->_getHost()));
$client->setConnections(array($connection1, $connection2));
@@ -523,6 +566,9 @@ class ClientTest extends BaseTest
$this->assertTrue($connections[0]->isEnabled() == false || $connections[1]->isEnabled() == false);
}
+ /**
+ * @group functional
+ */
public function testTwoInvalidConnection()
{
$client = $this->_getClient();
@@ -537,7 +583,6 @@ class ClientTest extends BaseTest
$client->request('_status', Request::GET);
$this->fail('Should throw exception as no connection valid');
} catch (HttpException $e) {
- $this->assertTrue(true);
}
$connections = $client->getConnections();
@@ -550,7 +595,9 @@ class ClientTest extends BaseTest
}
/**
- * Tests if the callback works in case a connection is down
+ * Tests if the callback works in case a connection is down.
+ *
+ * @group functional
*/
public function testCallback()
{
@@ -558,7 +605,7 @@ class ClientTest extends BaseTest
$object = $this;
// Callback function which verifies that disabled connection objects are returned
- $callback = function($connection, $exception, $client) use (&$object, &$count) {
+ $callback = function ($connection, $exception, $client) use (&$object, &$count) {
$object->assertInstanceOf('Elastica\Connection', $connection);
$object->assertInstanceOf('Elastica\Exception\ConnectionException', $exception);
$object->assertInstanceOf('Elastica\Client', $client);
@@ -566,7 +613,7 @@ class ClientTest extends BaseTest
$count++;
};
- $client = new Client(array(), $callback);
+ $client = $this->_getClient(array(), $callback);
// First connection work, second should not work
$connection1 = new Connection(array('port' => '9101', 'timeout' => 2));
@@ -587,17 +634,23 @@ class ClientTest extends BaseTest
$this->assertEquals(2, $count);
}
+ /**
+ * @group functional
+ */
public function testUrlConstructor()
{
- $url = 'http://localhost:9200/';
+ $url = 'http://'.$this->_getHost().':9200/';
// Url should overwrite invalid host
- $client = new Client(array('url' => $url, 'port' => '9101', 'timeout' => 2));
+ $client = $this->_getClient(array('url' => $url, 'port' => '9101', 'timeout' => 2));
$response = $client->request('_status');
$this->assertInstanceOf('Elastica\Response', $response);
}
+ /**
+ * @group functional
+ */
public function testUpdateDocumentByDocument()
{
$index = $this->_createIndex();
@@ -622,6 +675,9 @@ class ClientTest extends BaseTest
$this->assertEquals('value3added', $data['field3']);
}
+ /**
+ * @group functional
+ */
public function testUpdateDocumentByScript()
{
$index = $this->_createIndex();
@@ -647,6 +703,9 @@ class ClientTest extends BaseTest
$this->assertArrayNotHasKey('field3', $data);
}
+ /**
+ * @group functional
+ */
public function testUpdateDocumentByScriptWithUpsert()
{
$index = $this->_createIndex();
@@ -689,6 +748,9 @@ class ClientTest extends BaseTest
$this->assertArrayNotHasKey('field3', $data);
}
+ /**
+ * @group functional
+ */
public function testUpdateDocumentByRawData()
{
$index = $this->_createIndex();
@@ -701,7 +763,7 @@ class ClientTest extends BaseTest
$rawData = array(
'doc' => array(
'field2' => 'value2',
- )
+ ),
);
$response = $client->updateDocument(1, $rawData, $index->getName(), $type->getName(), array('retry_on_conflict' => 1));
@@ -717,6 +779,9 @@ class ClientTest extends BaseTest
$this->assertEquals('value2', $data['field2']);
}
+ /**
+ * @group functional
+ */
public function testUpdateDocumentByDocumentWithUpsert()
{
$index = $this->_createIndex();
@@ -748,6 +813,9 @@ class ClientTest extends BaseTest
$this->assertEquals('value2updated', $data['field2']);
}
+ /**
+ * @group functional
+ */
public function testDocAsUpsert()
{
$index = $this->_createIndex();
@@ -775,6 +843,9 @@ class ClientTest extends BaseTest
$this->assertEquals('value2', $data['field2']);
}
+ /**
+ * @group functional
+ */
public function testUpdateWithInvalidType()
{
$index = $this->_createIndex();
@@ -792,6 +863,9 @@ class ClientTest extends BaseTest
}
}
+ /**
+ * @group functional
+ */
public function testDeleteDocuments()
{
$index = $this->_createIndex();
@@ -834,9 +908,12 @@ class ClientTest extends BaseTest
$this->assertEquals(1, $type->count());
}
+ /**
+ * @group functional
+ */
public function testLastRequestResponse()
{
- $client = new Client();
+ $client = $this->_getClient();
$response = $client->request('_status');
$this->assertInstanceOf('Elastica\Response', $response);
@@ -851,6 +928,9 @@ class ClientTest extends BaseTest
$this->assertSame($response, $lastResponse);
}
+ /**
+ * @group functional
+ */
public function testUpdateDocumentPopulateFields()
{
$index = $this->_createIndex();
@@ -907,6 +987,9 @@ class ClientTest extends BaseTest
$this->assertArrayNotHasKey('field4', $data);
}
+ /**
+ * @group functional
+ */
public function testAddDocumentsWithoutIds()
{
$docs = array();
@@ -933,6 +1016,9 @@ class ClientTest extends BaseTest
}
}
+ /**
+ * @group unit
+ */
public function testConfigValue()
{
$config = array(
@@ -940,11 +1026,11 @@ class ClientTest extends BaseTest
'level2' => array(
'level3' => 'value3',
),
- 'level21' => 'value21'
+ 'level21' => 'value21',
),
- 'level11' => 'value11'
+ 'level11' => 'value11',
);
- $client = new Client($config);
+ $client = $this->_getClient($config);
$this->assertNull($client->getConfigValue('level12'));
$this->assertFalse($client->getConfigValue('level12', false));
@@ -958,51 +1044,117 @@ class ClientTest extends BaseTest
$this->assertEquals('value3', $client->getConfigValue(array('level1', 'level2', 'level3')));
$this->assertInternalType('array', $client->getConfigValue(array('level1', 'level2')));
}
-
-
+
+ /**
+ * @group functional
+ */
public function testArrayQuery()
{
- $client = new Client();
-
+ $client = $this->_getClient();
+
$index = $client->getIndex('test');
$index->create(array(), true);
$type = $index->getType('test');
$type->addDocument(new Document(1, array('username' => 'ruflin')));
$index->refresh();
-
+
$query = array(
'query' => array(
'query_string' => array(
'query' => 'ruflin',
- )
- )
+ ),
+ ),
);
-
- $path = $index->getName() . '/' . $type->getName() . '/_search';
-
+
+ $path = $index->getName().'/'.$type->getName().'/_search';
+
$response = $client->request($path, Request::GET, $query);
$responseArray = $response->getData();
-
+
$this->assertEquals(1, $responseArray['hits']['total']);
}
-
+
+ /**
+ * @group functional
+ */
public function testJSONQuery()
{
- $client = new Client();
-
+ $client = $this->_getClient();
+
$index = $client->getIndex('test');
$index->create(array(), true);
$type = $index->getType('test');
$type->addDocument(new Document(1, array('username' => 'ruflin')));
$index->refresh();
-
+
$query = '{"query":{"query_string":{"query":"ruflin"}}}';
- $path = $index->getName() . '/' . $type->getName() . '/_search';
-
+ $path = $index->getName().'/'.$type->getName().'/_search';
+
$response = $client->request($path, Request::GET, $query);
$responseArray = $response->getData();
-
+
$this->assertEquals(1, $responseArray['hits']['total']);
}
+
+ /**
+ * @group unit
+ */
+ public function testAddHeader()
+ {
+ $client = $this->_getClient();
+
+ // add one header
+ $client->addHeader('foo', 'bar');
+ $this->assertEquals(array('foo' => 'bar'), $client->getConfigValue('headers'));
+
+ // check class
+ $this->assertInstanceOf('Elastica\Client', $client->addHeader('foo', 'bar'));
+
+ // check invalid parameters
+ try {
+ $client->addHeader(new \stdClass(), 'foo');
+ $this->fail('Header name is not a string but exception not thrown');
+ } catch (InvalidException $ex) {
+ }
+
+ try {
+ $client->addHeader('foo', new \stdClass());
+ $this->fail('Header value is not a string but exception not thrown');
+ } catch (InvalidException $ex) {
+ }
+ }
+
+ /**
+ * @group unit
+ */
+ public function testRemoveHeader()
+ {
+ $client = $this->_getClient();
+
+ // set headers
+ $headers = array(
+ 'first' => 'first value',
+ 'second' => 'second value',
+ );
+ foreach ($headers as $key => $value) {
+ $client->addHeader($key, $value);
+ }
+ $this->assertEquals($headers, $client->getConfigValue('headers'));
+
+ // remove one
+ $client->removeHeader('first');
+ unset($headers['first']);
+ $this->assertEquals($headers, $client->getConfigValue('headers'));
+
+ // check class
+ $this->assertInstanceOf('Elastica\Client', $client->removeHeader('second'));
+
+ // check invalid parameter
+ try {
+ $client->removeHeader(new \stdClass());
+ $this->fail('Header name is not a string but exception not thrown');
+ } catch (InvalidException $ex) {
+ }
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/IndexTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/IndexTest.php
index 085ac13a..00a121fc 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/IndexTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/IndexTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Cluster\Health;
use Elastica\Cluster\Health\Index as HealthIndex;
@@ -14,91 +13,123 @@ class IndexTest extends BaseTest
public function setUp()
{
+ parent::setUp();
+
$data = array(
- "status" => "yellow",
- "number_of_shards" => 1,
- "number_of_replicas" => 2,
- "active_primary_shards" => 3,
- "active_shards" => 4,
- "relocating_shards" => 5,
- "initializing_shards" => 6,
- "unassigned_shards" => 7,
- "shards" => array(
- "0" => array(
- "status" => "yellow",
- "primary_active" => false,
- "active_shards" => 0,
- "relocating_shards" => 1,
- "initializing_shards" => 0,
- "unassigned_shards" => 1
+ 'status' => 'yellow',
+ 'number_of_shards' => 1,
+ 'number_of_replicas' => 2,
+ 'active_primary_shards' => 3,
+ 'active_shards' => 4,
+ 'relocating_shards' => 5,
+ 'initializing_shards' => 6,
+ 'unassigned_shards' => 7,
+ 'shards' => array(
+ '0' => array(
+ 'status' => 'yellow',
+ 'primary_active' => false,
+ 'active_shards' => 0,
+ 'relocating_shards' => 1,
+ 'initializing_shards' => 0,
+ 'unassigned_shards' => 1,
),
- "1" => array(
- "status" => "yellow",
- "primary_active" => true,
- "active_shards" => 1,
- "relocating_shards" => 0,
- "initializing_shards" => 0,
- "unassigned_shards" => 1
+ '1' => array(
+ 'status' => 'yellow',
+ 'primary_active' => true,
+ 'active_shards' => 1,
+ 'relocating_shards' => 0,
+ 'initializing_shards' => 0,
+ 'unassigned_shards' => 1,
),
- "2" => array(
- "status" => "green",
- "primary_active" => true,
- "active_shards" => 1,
- "relocating_shards" => 0,
- "initializing_shards" => 0,
- "unassigned_shards" => 0,
+ '2' => array(
+ 'status' => 'green',
+ 'primary_active' => true,
+ 'active_shards' => 1,
+ 'relocating_shards' => 0,
+ 'initializing_shards' => 0,
+ 'unassigned_shards' => 0,
),
- )
+ ),
);
$this->_index = new HealthIndex('test', $data);
}
+ /**
+ * @group unit
+ */
public function testGetName()
{
$this->assertEquals('test', $this->_index->getName());
}
+ /**
+ * @group unit
+ */
public function testGetStatus()
{
$this->assertEquals('yellow', $this->_index->getStatus());
}
+ /**
+ * @group unit
+ */
public function testGetNumberOfShards()
{
$this->assertEquals(1, $this->_index->getNumberOfShards());
}
+ /**
+ * @group unit
+ */
public function testGetNumberOfReplicas()
{
$this->assertEquals(2, $this->_index->getNumberOfReplicas());
}
+ /**
+ * @group unit
+ */
public function testGetActivePrimaryShards()
{
$this->assertEquals(3, $this->_index->getActivePrimaryShards());
}
+ /**
+ * @group unit
+ */
public function testGetActiveShards()
{
$this->assertEquals(4, $this->_index->getActiveShards());
}
+ /**
+ * @group unit
+ */
public function testGetRelocatingShards()
{
$this->assertEquals(5, $this->_index->getRelocatingShards());
}
+ /**
+ * @group unit
+ */
public function testGetInitializingShards()
{
$this->assertEquals(6, $this->_index->getInitializingShards());
}
+ /**
+ * @group unit
+ */
public function testGetUnassignedShards()
{
$this->assertEquals(7, $this->_index->getUnassignedShards());
}
+ /**
+ * @group unit
+ */
public function testGetShards()
{
$shards = $this->_index->getShards();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/ShardTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/ShardTest.php
index b63195a0..5a436623 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/ShardTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/ShardTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Cluster\Health;
use Elastica\Cluster\Health\Shard as HealthShard;
@@ -14,6 +13,8 @@ class ShardTest extends BaseTest
public function setUp()
{
+ parent::setUp();
+
$shardData = array(
'status' => 'red',
'primary_active' => true,
@@ -26,36 +27,57 @@ class ShardTest extends BaseTest
$this->_shard = new HealthShard(2, $shardData);
}
+ /**
+ * @group unit
+ */
public function testGetShardNumber()
{
$this->assertEquals(2, $this->_shard->getShardNumber());
}
+ /**
+ * @group unit
+ */
public function testGetStatus()
{
$this->assertEquals('red', $this->_shard->getStatus());
}
+ /**
+ * @group unit
+ */
public function testisPrimaryActive()
{
$this->assertTrue($this->_shard->isPrimaryActive());
}
+ /**
+ * @group unit
+ */
public function testIsActive()
{
$this->assertTrue($this->_shard->isActive());
}
+ /**
+ * @group unit
+ */
public function testIsRelocating()
{
$this->assertFalse($this->_shard->isRelocating());
}
+ /**
+ * @group unit
+ */
public function testIsInitialized()
{
$this->assertFalse($this->_shard->isInitialized());
}
+ /**
+ * @group unit
+ */
public function testIsUnassigned()
{
$this->assertTrue($this->_shard->isUnassigned());
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/HealthTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/HealthTest.php
index 054af3f7..bb3e82ec 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/HealthTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/HealthTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Cluster;
use Elastica\Test\Base as BaseTest;
@@ -11,8 +10,10 @@ class HealthTest extends BaseTest
*/
protected $_health;
- public function setUp()
+ protected function setUp()
{
+ parent::setUp();
+
$data = array(
'cluster_name' => 'test_cluster',
'status' => 'green',
@@ -49,56 +50,89 @@ class HealthTest extends BaseTest
$this->_health = $health;
}
+ /**
+ * @group unit
+ */
public function testGetClusterName()
{
$this->assertEquals('test_cluster', $this->_health->getClusterName());
}
+ /**
+ * @group unit
+ */
public function testGetStatus()
{
$this->assertEquals('green', $this->_health->getStatus());
}
+ /**
+ * @group unit
+ */
public function testGetTimedOut()
{
$this->assertFalse($this->_health->getTimedOut());
}
+ /**
+ * @group unit
+ */
public function testGetNumberOfNodes()
{
$this->assertEquals(10, $this->_health->getNumberOfNodes());
}
+ /**
+ * @group unit
+ */
public function testGetNumberOfDataNodes()
{
$this->assertEquals(8, $this->_health->getNumberOfDataNodes());
}
+ /**
+ * @group unit
+ */
public function testGetActivePrimaryShards()
{
$this->assertEquals(3, $this->_health->getActivePrimaryShards());
}
+ /**
+ * @group unit
+ */
public function testGetActiveShards()
{
$this->assertEquals(4, $this->_health->getActiveShards());
}
+ /**
+ * @group unit
+ */
public function testGetRelocatingShards()
{
$this->assertEquals(2, $this->_health->getRelocatingShards());
}
+ /**
+ * @group unit
+ */
public function testGetInitializingShards()
{
$this->assertEquals(7, $this->_health->getInitializingShards());
}
+ /**
+ * @group unit
+ */
public function testGetUnassignedShards()
{
$this->assertEquals(5, $this->_health->getUnassignedShards());
}
+ /**
+ * @group unit
+ */
public function testGetIndices()
{
$indices = $this->_health->getIndices();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/SettingsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/SettingsTest.php
index a093feef..2a52fc8f 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/SettingsTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/SettingsTest.php
@@ -1,14 +1,16 @@
<?php
-
namespace Elastica\Test\Cluster;
+use Elastica\Cluster\Settings;
use Elastica\Document;
use Elastica\Exception\ResponseException;
use Elastica\Test\Base as BaseTest;
-use Elastica\Cluster\Settings;
class SettingsTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testSetTransient()
{
$index = $this->_createIndex();
@@ -21,13 +23,16 @@ class SettingsTest extends BaseTest
$settings->setTransient('discovery.zen.minimum_master_nodes', 2);
$data = $settings->get();
- $this->assertEquals(2, $data['transient']['discovery.zen.minimum_master_nodes']);
+ $this->assertEquals(2, $data['transient']['discovery']['zen']['minimum_master_nodes']);
$settings->setTransient('discovery.zen.minimum_master_nodes', 1);
$data = $settings->get();
- $this->assertEquals(1, $data['transient']['discovery.zen.minimum_master_nodes']);
+ $this->assertEquals(1, $data['transient']['discovery']['zen']['minimum_master_nodes']);
}
+ /**
+ * @group functional
+ */
public function testSetPersistent()
{
$index = $this->_createIndex();
@@ -40,21 +45,23 @@ class SettingsTest extends BaseTest
$settings->setPersistent('discovery.zen.minimum_master_nodes', 2);
$data = $settings->get();
- $this->assertEquals(2, $data['persistent']['discovery.zen.minimum_master_nodes']);
+ $this->assertEquals(2, $data['persistent']['discovery']['zen']['minimum_master_nodes']);
$settings->setPersistent('discovery.zen.minimum_master_nodes', 1);
$data = $settings->get();
- $this->assertEquals(1, $data['persistent']['discovery.zen.minimum_master_nodes']);
+ $this->assertEquals(1, $data['persistent']['discovery']['zen']['minimum_master_nodes']);
}
+ /**
+ * @group functional
+ */
public function testSetReadOnly()
{
// Create two indices to check that the complete cluster is read only
$settings = new Settings($this->_getClient());
$settings->setReadOnly(false);
- $index1 = $this->_createIndex('test1');
- $index2 = $this->_createIndex('test2');
-
+ $index1 = $this->_createIndex();
+ $index2 = $this->_createIndex();
$doc1 = new Document(null, array('hello' => 'world'));
$doc2 = new Document(null, array('hello' => 'world'));
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ClusterTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ClusterTest.php
index ae5fb980..ebd89f01 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/ClusterTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ClusterTest.php
@@ -1,26 +1,28 @@
<?php
-
namespace Elastica\Test;
-use Elastica\Client;
use Elastica\Cluster;
use Elastica\Test\Base as BaseTest;
class ClusterTest extends BaseTest
{
-
+ /**
+ * @group functional
+ */
public function testGetNodeNames()
{
$client = $this->_getClient();
$cluster = new Cluster($client);
- $names = $cluster->getNodeNames();
-
- $this->assertInternalType('array', $names);
- $this->assertGreaterThan(0, count($names));
+ foreach ($cluster->getNodeNames() as $name) {
+ $this->assertEquals('Elastica', $name);
+ }
}
+ /**
+ * @group functional
+ */
public function testGetNodes()
{
$client = $this->_getClient();
@@ -35,6 +37,9 @@ class ClusterTest extends BaseTest
$this->assertGreaterThan(0, count($nodes));
}
+ /**
+ * @group functional
+ */
public function testGetState()
{
$client = $this->_getClient();
@@ -44,28 +49,14 @@ class ClusterTest extends BaseTest
}
/**
- * @expectedException \Elastica\Exception\ConnectionException
+ * @group functional
*/
- public function testShutdown()
- {
- $this->markTestSkipped('This test shuts down the cluster which means the following tests would not work');
- $client = $this->_getClient();
- $cluster = $client->getCluster();
-
- $cluster->shutdown('2s');
-
- sleep(5);
-
- $client->getStatus();
- }
-
public function testGetIndexNames()
{
$client = $this->_getClient();
$cluster = $client->getCluster();
- $indexName = 'elastica_test999';
- $index = $this->_createIndex($indexName);
+ $index = $this->_createIndex();
$index->delete();
$cluster->refresh();
@@ -73,7 +64,7 @@ class ClusterTest extends BaseTest
$indexNames = $cluster->getIndexNames();
$this->assertNotContains($index->getName(), $indexNames);
- $index = $this->_createIndex($indexName);
+ $index = $this->_createIndex();
$cluster->refresh();
// Now index should exist
@@ -81,6 +72,9 @@ class ClusterTest extends BaseTest
$this->assertContains($index->getname(), $indexNames);
}
+ /**
+ * @group functional
+ */
public function testGetHealth()
{
$client = $this->_getClient();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/ConnectionPoolTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/ConnectionPoolTest.php
new file mode 100644
index 00000000..ee03587a
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/ConnectionPoolTest.php
@@ -0,0 +1,112 @@
+<?php
+namespace Elastica\Test\Connection;
+
+use Elastica\Connection;
+use Elastica\Connection\ConnectionPool;
+use Elastica\Connection\Strategy\StrategyFactory;
+use Elastica\Test\Base as BaseTest;
+
+/**
+ * @author chabior
+ */
+class ConnectionPoolTest extends BaseTest
+{
+ /**
+ * @group unit
+ */
+ public function testConstruct()
+ {
+ $pool = $this->createPool();
+
+ $this->assertEquals($this->getConnections(), $pool->getConnections());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetConnections()
+ {
+ $pool = $this->createPool();
+
+ $connections = $this->getConnections(5);
+
+ $pool->setConnections($connections);
+
+ $this->assertEquals($connections, $pool->getConnections());
+
+ $this->assertInstanceOf('Elastica\Connection\ConnectionPool', $pool->setConnections($connections));
+ }
+
+ /**
+ * @group unit
+ */
+ public function testAddConnection()
+ {
+ $pool = $this->createPool();
+ $pool->setConnections(array());
+
+ $connections = $this->getConnections(5);
+
+ foreach ($connections as $connection) {
+ $pool->addConnection($connection);
+ }
+
+ $this->assertEquals($connections, $pool->getConnections());
+
+ $this->assertInstanceOf('Elastica\Connection\ConnectionPool', $pool->addConnection($connections[0]));
+ }
+
+ /**
+ * @group unit
+ */
+ public function testHasConnection()
+ {
+ $pool = $this->createPool();
+
+ $this->assertTrue($pool->hasConnection());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testFailHasConnections()
+ {
+ $pool = $this->createPool();
+
+ $pool->setConnections(array());
+
+ $this->assertFalse($pool->hasConnection());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testGetConnection()
+ {
+ $pool = $this->createPool();
+
+ $this->assertInstanceOf('Elastica\Connection', $pool->getConnection());
+ }
+
+ protected function getConnections($quantity = 1)
+ {
+ $params = array();
+ $connections = array();
+
+ for ($i = 0; $i < $quantity; $i++) {
+ $connections[] = new Connection($params);
+ }
+
+ return $connections;
+ }
+
+ protected function createPool()
+ {
+ $connections = $this->getConnections();
+ $strategy = StrategyFactory::create('Simple');
+
+ $pool = new ConnectionPool($connections, $strategy);
+
+ return $pool;
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/CallbackStrategyTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/CallbackStrategyTest.php
new file mode 100644
index 00000000..de8290ae
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/CallbackStrategyTest.php
@@ -0,0 +1,97 @@
+<?php
+namespace Elastica\Test\Connection\Strategy;
+
+use Elastica\Connection\Strategy\CallbackStrategy;
+use Elastica\Test\Base;
+
+/**
+ * Description of CallbackStrategyTest.
+ *
+ * @author chabior
+ */
+class CallbackStrategyTest extends Base
+{
+ /**
+ * @group unit
+ */
+ public function testInvoke()
+ {
+ $count = 0;
+
+ $callback = function ($connections) use (&$count) {
+ $count++;
+ };
+
+ $strategy = new CallbackStrategy($callback);
+ $strategy->getConnection(array());
+
+ $this->assertEquals(1, $count);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testIsValid()
+ {
+ // closure is valid
+ $isValid = CallbackStrategy::isValid(function () {});
+ $this->assertTrue($isValid);
+
+ // object implementing __invoke
+ $isValid = CallbackStrategy::isValid(new CallbackStrategyTestHelper());
+ $this->assertTrue($isValid);
+
+ // static method as string
+ $isValid = CallbackStrategy::isValid('Elastica\Test\Connection\Strategy\CallbackStrategyTestHelper::getFirstConnectionStatic');
+ $this->assertTrue($isValid);
+
+ // static method as array
+ $isValid = CallbackStrategy::isValid(array('Elastica\Test\Connection\Strategy\CallbackStrategyTestHelper', 'getFirstConnectionStatic'));
+ $this->assertTrue($isValid);
+
+ // object method
+ $isValid = CallbackStrategy::isValid(array(new CallbackStrategyTestHelper(), 'getFirstConnectionStatic'));
+ $this->assertTrue($isValid);
+
+ // function name
+ $isValid = CallbackStrategy::isValid('array_pop');
+ $this->assertTrue($isValid);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testFailIsValid()
+ {
+ $isValid = CallbackStrategy::isValid(new \stdClass());
+ $this->assertFalse($isValid);
+
+ $isValid = CallbackStrategy::isValid('array_pop_pop_pop_pop_pop_pop');
+ $this->assertFalse($isValid);
+ }
+
+ /**
+ * @group functional
+ */
+ public function testConnection()
+ {
+ $count = 0;
+
+ $config = array('connectionStrategy' => function ($connections) use (&$count) {
+ ++$count;
+
+ return current($connections);
+ });
+
+ $client = $this->_getClient($config);
+ $response = $client->request('/_aliases');
+
+ $this->assertEquals(1, $count);
+
+ $this->assertTrue($response->isOk());
+
+ $strategy = $client->getConnectionStrategy();
+
+ $this->assertInstanceOf('Elastica\Connection\Strategy\CallbackStrategy', $strategy);
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/CallbackStrategyTestHelper.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/CallbackStrategyTestHelper.php
new file mode 100644
index 00000000..b15efe91
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/CallbackStrategyTestHelper.php
@@ -0,0 +1,20 @@
+<?php
+namespace Elastica\Test\Connection\Strategy;
+
+class CallbackStrategyTestHelper
+{
+ public function __invoke($connections)
+ {
+ return $connections[0];
+ }
+
+ public function getFirstConnection($connections)
+ {
+ return $connections[0];
+ }
+
+ public static function getFirstConnectionStatic($connections)
+ {
+ return $connections[0];
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/EmptyStrategy.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/EmptyStrategy.php
new file mode 100644
index 00000000..8d2aa5df
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/EmptyStrategy.php
@@ -0,0 +1,17 @@
+<?php
+namespace Elastica\Test\Connection\Strategy;
+
+use Elastica\Connection\Strategy\StrategyInterface;
+
+/**
+ * Description of EmptyStrategy.
+ *
+ * @author chabior
+ */
+class EmptyStrategy implements StrategyInterface
+{
+ public function getConnection($connections)
+ {
+ return;
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/RoundRobinTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/RoundRobinTest.php
new file mode 100644
index 00000000..0dedbc22
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/RoundRobinTest.php
@@ -0,0 +1,128 @@
+<?php
+namespace Elastica\Test\Connection\Strategy;
+
+use Elastica\Connection;
+use Elastica\Connection\Strategy\RoundRobin;
+use Elastica\Exception\ConnectionException;
+use Elastica\Response;
+use Elastica\Test\Base;
+
+/**
+ * Description of RoundRobinTest.
+ *
+ * @author chabior
+ */
+class RoundRobinTest extends Base
+{
+ /**
+ * @var int Number of seconds to wait before timeout is called. Is set low for tests to have fast tests.
+ */
+ protected $_timeout = 1;
+
+ /**
+ * @group functional
+ */
+ public function testConnection()
+ {
+ $config = array('connectionStrategy' => 'RoundRobin');
+ $client = $this->_getClient($config);
+ $response = $client->request('/_aliases');
+ /* @var $response Response */
+
+ $this->_checkResponse($response);
+
+ $this->_checkStrategy($client);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testOldStrategySetted()
+ {
+ $config = array('roundRobin' => true);
+ $client = $this->_getClient($config);
+
+ $this->_checkStrategy($client);
+ }
+
+ /**
+ * @group functional
+ * @expectedException \Elastica\Exception\ConnectionException
+ */
+ public function testFailConnection()
+ {
+ $config = array('connectionStrategy' => 'RoundRobin', 'host' => '255.255.255.0', 'timeout' => $this->_timeout);
+ $client = $this->_getClient($config);
+
+ $this->_checkStrategy($client);
+
+ $client->request('/_aliases');
+ }
+
+ /**
+ * @group functional
+ */
+ public function testWithOneFailConnection()
+ {
+ $connections = array(
+ new Connection(array('host' => '255.255.255.0', 'timeout' => $this->_timeout)),
+ new Connection(array('host' => $this->_getHost(), 'timeout' => $this->_timeout)),
+ );
+
+ $count = 0;
+ $callback = function ($connection, $exception, $client) use (&$count) {
+ ++$count;
+ };
+
+ $client = $this->_getClient(array('connectionStrategy' => 'RoundRobin'), $callback);
+ $client->setConnections($connections);
+
+ $response = $client->request('/_aliases');
+ /* @var $response Response */
+
+ $this->_checkResponse($response);
+
+ $this->_checkStrategy($client);
+
+ $this->assertLessThan(count($connections), $count);
+ }
+
+ /**
+ * @group functional
+ */
+ public function testWithNoValidConnection()
+ {
+ $connections = array(
+ new Connection(array('host' => '255.255.255.0', 'timeout' => $this->_timeout)),
+ new Connection(array('host' => '45.45.45.45', 'port' => '80', 'timeout' => $this->_timeout)),
+ new Connection(array('host' => '10.123.213.123', 'timeout' => $this->_timeout)),
+ );
+
+ $count = 0;
+ $client = $this->_getClient(array('roundRobin' => true), function () use (&$count) {
+ ++$count;
+ });
+
+ $client->setConnections($connections);
+
+ try {
+ $client->request('/_aliases');
+ $this->fail('Should throw exception as no connection valid');
+ } catch (ConnectionException $e) {
+ $this->assertEquals(count($connections), $count);
+ $this->_checkStrategy($client);
+ }
+ }
+
+ protected function _checkStrategy($client)
+ {
+ $strategy = $client->getConnectionStrategy();
+
+ $this->assertInstanceOf('Elastica\Connection\Strategy\RoundRobin', $strategy);
+ }
+
+ protected function _checkResponse($response)
+ {
+ $this->assertTrue($response->isOk());
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/SimpleTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/SimpleTest.php
new file mode 100644
index 00000000..3b6ac89d
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/SimpleTest.php
@@ -0,0 +1,113 @@
+<?php
+namespace Elastica\Test\Connection\Strategy;
+
+use Elastica\Connection;
+use Elastica\Exception\ConnectionException;
+use Elastica\Test\Base;
+
+/**
+ * Description of SimplyTest.
+ *
+ * @author chabior
+ */
+class SimpleTest extends Base
+{
+ /**
+ * @var int Number of seconds to wait before timeout is called. Is set low for tests to have fast tests.
+ */
+ protected $_timeout = 1;
+
+ /**
+ * @group functional
+ */
+ public function testConnection()
+ {
+ $client = $this->_getClient();
+ $response = $client->request('/_aliases');
+ /* @var $response \Elastica\Response */
+
+ $this->_checkResponse($response);
+
+ $this->_checkStrategy($client);
+ }
+
+ /**
+ * @group functional
+ * @expectedException \Elastica\Exception\ConnectionException
+ */
+ public function testFailConnection()
+ {
+ $config = array('host' => '255.255.255.0', 'timeout' => $this->_timeout);
+ $client = $this->_getClient($config);
+
+ $this->_checkStrategy($client);
+
+ $client->request('/_aliases');
+ }
+
+ /**
+ * @group functional
+ */
+ public function testWithOneFailConnection()
+ {
+ $connections = array(
+ new Connection(array('host' => '255.255.255.0', 'timeout' => $this->_timeout)),
+ new Connection(array('host' => $this->_getHost(), 'timeout' => $this->_timeout)),
+ );
+
+ $count = 0;
+ $callback = function ($connection, $exception, $client) use (&$count) {
+ ++$count;
+ };
+
+ $client = $this->_getClient(array(), $callback);
+ $client->setConnections($connections);
+
+ $response = $client->request('/_aliases');
+ /* @var $response Response */
+
+ $this->_checkResponse($response);
+
+ $this->_checkStrategy($client);
+
+ $this->assertLessThan(count($connections), $count);
+ }
+
+ /**
+ * @group functional
+ */
+ public function testWithNoValidConnection()
+ {
+ $connections = array(
+ new Connection(array('host' => '255.255.255.0', 'timeout' => $this->_timeout)),
+ new Connection(array('host' => '45.45.45.45', 'port' => '80', 'timeout' => $this->_timeout)),
+ new Connection(array('host' => '10.123.213.123', 'timeout' => $this->_timeout)),
+ );
+
+ $count = 0;
+ $client = $this->_getClient(array(), function () use (&$count) {
+ ++$count;
+ });
+
+ $client->setConnections($connections);
+
+ try {
+ $client->request('/_aliases');
+ $this->fail('Should throw exception as no connection valid');
+ } catch (ConnectionException $e) {
+ $this->assertEquals(count($connections), $count);
+ }
+ }
+
+ protected function _checkStrategy($client)
+ {
+ $strategy = $client->getConnectionStrategy();
+
+ $this->assertInstanceOf('Elastica\Connection\Strategy\Simple', $strategy);
+ }
+
+ protected function _checkResponse($response)
+ {
+ $this->assertTrue($response->isOk());
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/StrategyFactoryTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/StrategyFactoryTest.php
new file mode 100644
index 00000000..978f8fd5
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/StrategyFactoryTest.php
@@ -0,0 +1,84 @@
+<?php
+namespace Elastica\Test\Connection\Strategy;
+
+use Elastica\Connection\Strategy\StrategyFactory;
+use Elastica\Test\Base;
+
+/**
+ * Description of StrategyFactoryTest.
+ *
+ * @author chabior
+ */
+class StrategyFactoryTest extends Base
+{
+ /**
+ * @group unit
+ */
+ public function testCreateCallbackStrategy()
+ {
+ $callback = function ($connections) {
+ };
+
+ $strategy = StrategyFactory::create($callback);
+
+ $this->assertInstanceOf('Elastica\Connection\Strategy\CallbackStrategy', $strategy);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testCreateByName()
+ {
+ $strategyName = 'Simple';
+
+ $strategy = StrategyFactory::create($strategyName);
+
+ $this->assertInstanceOf('Elastica\Connection\Strategy\Simple', $strategy);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testCreateByClass()
+ {
+ $strategy = new EmptyStrategy();
+
+ $this->assertEquals($strategy, StrategyFactory::create($strategy));
+ }
+
+ /**
+ * @group unit
+ */
+ public function testCreateByClassName()
+ {
+ $strategyName = '\\Elastica\Test\Connection\Strategy\\EmptyStrategy';
+
+ $strategy = StrategyFactory::create($strategyName);
+
+ $this->assertInstanceOf($strategyName, $strategy);
+ }
+
+ /**
+ * @group unit
+ * @expectedException \InvalidArgumentException
+ */
+ public function testFailCreate()
+ {
+ $strategy = new \stdClass();
+
+ StrategyFactory::create($strategy);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testNoCollisionWithGlobalNamespace()
+ {
+ // create collision
+ if (!class_exists('Simple')) {
+ class_alias('Elastica\Util', 'Simple');
+ }
+ $strategy = StrategyFactory::create('Simple');
+ $this->assertInstanceOf('Elastica\Connection\Strategy\Simple', $strategy);
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ConnectionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ConnectionTest.php
index 80cab9f0..7600524b 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/ConnectionTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ConnectionTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test;
use Elastica\Connection;
@@ -8,7 +7,9 @@ use Elastica\Test\Base as BaseTest;
class ConnectionTest extends BaseTest
{
-
+ /**
+ * @group unit
+ */
public function testEmptyConstructor()
{
$connection = new Connection();
@@ -17,10 +18,14 @@ class ConnectionTest extends BaseTest
$this->assertEquals(Connection::DEFAULT_TRANSPORT, $connection->getTransport());
$this->assertInstanceOf('Elastica\Transport\AbstractTransport', $connection->getTransportObject());
$this->assertEquals(Connection::TIMEOUT, $connection->getTimeout());
+ $this->assertEquals(Connection::CONNECT_TIMEOUT, $connection->getConnectTimeout());
$this->assertEquals(array(), $connection->getConfig());
$this->assertTrue($connection->isEnabled());
}
+ /**
+ * @group unit
+ */
public function testEnabledDisable()
{
$connection = new Connection();
@@ -32,6 +37,7 @@ class ConnectionTest extends BaseTest
}
/**
+ * @group unit
* @expectedException \Elastica\Exception\ConnectionException
*/
public function testInvalidConnection()
@@ -45,6 +51,9 @@ class ConnectionTest extends BaseTest
$request->send();
}
+ /**
+ * @group unit
+ */
public function testCreate()
{
$connection = Connection::create();
@@ -60,6 +69,7 @@ class ConnectionTest extends BaseTest
}
/**
+ * @group unit
* @expectedException \Elastica\Exception\InvalidException
* @expectedException \Elastica\Exception\InvalidException
*/
@@ -68,6 +78,9 @@ class ConnectionTest extends BaseTest
Connection::create('test');
}
+ /**
+ * @group unit
+ */
public function testGetConfig()
{
$url = 'test';
@@ -76,6 +89,9 @@ class ConnectionTest extends BaseTest
$this->assertEquals($url, $connection->getConfig('url'));
}
+ /**
+ * @group unit
+ */
public function testGetConfigWithArrayUsedForTransport()
{
$connection = new Connection(array('transport' => array('type' => 'Http')));
@@ -83,6 +99,7 @@ class ConnectionTest extends BaseTest
}
/**
+ * @group unit
* @expectedException Elastica\Exception\InvalidException
* @expectedExceptionMessage Invalid transport
*/
@@ -93,6 +110,7 @@ class ConnectionTest extends BaseTest
}
/**
+ * @group unit
* @expectedException \Elastica\Exception\InvalidException
*/
public function testGetConfigInvalidValue()
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/DocumentTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/DocumentTest.php
index 27fc5184..969c5b22 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/DocumentTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/DocumentTest.php
@@ -1,20 +1,21 @@
<?php
-
namespace Elastica\Test;
use Elastica\Document;
use Elastica\Exception\InvalidException;
-use Elastica\Script;
use Elastica\Index;
-use Elastica\Type;
use Elastica\Test\Base as BaseTest;
+use Elastica\Type;
class DocumentTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testAddFile()
{
$fileName = '/dev/null';
- if(!file_exists($fileName)){
+ if (!file_exists($fileName)) {
$this->markTestSkipped("File {$fileName} does not exist.");
}
$doc = new Document();
@@ -22,6 +23,9 @@ class DocumentTest extends BaseTest
$this->assertInstanceOf('Elastica\Document', $returnValue);
}
+ /**
+ * @group unit
+ */
public function testAddGeoPoint()
{
$doc = new Document();
@@ -29,6 +33,9 @@ class DocumentTest extends BaseTest
$this->assertInstanceOf('Elastica\Document', $returnValue);
}
+ /**
+ * @group unit
+ */
public function testSetData()
{
$doc = new Document();
@@ -36,6 +43,9 @@ class DocumentTest extends BaseTest
$this->assertInstanceOf('Elastica\Document', $returnValue);
}
+ /**
+ * @group unit
+ */
public function testToArray()
{
$id = 17;
@@ -49,6 +59,9 @@ class DocumentTest extends BaseTest
$this->assertEquals($result, $doc->toArray());
}
+ /**
+ * @group unit
+ */
public function testSetType()
{
$document = new Document();
@@ -68,6 +81,9 @@ class DocumentTest extends BaseTest
$this->assertEquals('type', $document->getType());
}
+ /**
+ * @group unit
+ */
public function testSetIndex()
{
$document = new Document();
@@ -85,6 +101,9 @@ class DocumentTest extends BaseTest
$this->assertEquals('type2', $document->getType());
}
+ /**
+ * @group unit
+ */
public function testHasId()
{
$document = new Document();
@@ -97,6 +116,9 @@ class DocumentTest extends BaseTest
$this->assertTrue($document->hasId());
}
+ /**
+ * @group unit
+ */
public function testGetOptions()
{
$document = new Document();
@@ -134,6 +156,9 @@ class DocumentTest extends BaseTest
$this->assertArrayNotHasKey('parent', $options);
}
+ /**
+ * @group unit
+ */
public function testGetSetHasRemove()
{
$document = new Document(1, array('field1' => 'value1', 'field2' => 'value2', 'field3' => 'value3', 'field4' => null));
@@ -185,6 +210,9 @@ class DocumentTest extends BaseTest
$this->assertNotEquals($data, $newData);
}
+ /**
+ * @group unit
+ */
public function testDataPropertiesOverloading()
{
$document = new Document(1, array('field1' => 'value1', 'field2' => 'value2', 'field3' => 'value3', 'field4' => null));
@@ -234,6 +262,9 @@ class DocumentTest extends BaseTest
$this->assertNotEquals($data, $newData);
}
+ /**
+ * @group unit
+ */
public function testSetTtl()
{
$document = new Document();
@@ -254,6 +285,9 @@ class DocumentTest extends BaseTest
$this->assertEquals('1d', $document->getTtl());
}
+ /**
+ * @group unit
+ */
public function testSerializedData()
{
$data = '{"user":"rolf"}';
@@ -283,6 +317,9 @@ class DocumentTest extends BaseTest
}
}
+ /**
+ * @group unit
+ */
public function testUpsert()
{
$document = new Document();
@@ -298,6 +335,9 @@ class DocumentTest extends BaseTest
$this->assertSame($upsert, $document->getUpsert());
}
+ /**
+ * @group unit
+ */
public function testDocAsUpsert()
{
$document = new Document();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ExampleTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ExampleTest.php
index 0331e389..efdc04eb 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/ExampleTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ExampleTest.php
@@ -1,30 +1,33 @@
<?php
-
namespace Elastica\Test;
-use Elastica\Client;
use Elastica\Document;
use Elastica\Test\Base as BaseTest;
/**
- * Tests the example code
+ * Tests the example code.
*/
class ExampleTest extends BaseTest
{
- public function testBasicGettingStarted() {
-
- $client = new \Elastica\Client();
- $index = $client->getIndex('ruflin');
- $type = $index->getType('users');
-
- $id = 2;
- $data = array('firstname' => 'Nicolas', 'lastname' => 'Ruflin');
- $doc = new \Elastica\Document($id, $data);
-
- $type->addDocument($doc);
-
- }
-
+ /**
+ * @group functional
+ */
+ public function testBasicGettingStarted()
+ {
+ $client = $this->_getClient();
+ $index = $client->getIndex('ruflin');
+ $type = $index->getType('users');
+
+ $id = 2;
+ $data = array('firstname' => 'Nicolas', 'lastname' => 'Ruflin');
+ $doc = new Document($id, $data);
+
+ $type->addDocument($doc);
+ }
+
+ /**
+ * @group functional
+ */
public function testExample()
{
// Creates a new index 'xodoa' and a type 'user' inside this index
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/AbstractExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/AbstractExceptionTest.php
new file mode 100644
index 00000000..ea84218a
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/AbstractExceptionTest.php
@@ -0,0 +1,31 @@
+<?php
+namespace Elastica\Test\Exception;
+
+use Elastica\Test\Base as BaseTest;
+
+abstract class AbstractExceptionTest extends BaseTest
+{
+ protected function _getExceptionClass()
+ {
+ $reflection = new \ReflectionObject($this);
+
+ // Elastica\Test\Exception\RuntimeExceptionTest => Elastica\Exception\RuntimeExceptionTest
+ $name = preg_replace('/^Elastica\\\\Test/', 'Elastica', $reflection->getName());
+
+ // Elastica\Exception\RuntimeExceptionTest => Elastica\Exception\RuntimeException
+ $name = preg_replace('/Test$/', '', $name);
+
+ return $name;
+ }
+
+ /**
+ * @group unit
+ */
+ public function testInheritance()
+ {
+ $className = $this->_getExceptionClass();
+ $reflection = new \ReflectionClass($className);
+ $this->assertTrue($reflection->isSubclassOf('Exception'));
+ $this->assertTrue($reflection->implementsInterface('Elastica\Exception\ExceptionInterface'));
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Bulk/Response/ActionExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Bulk/Response/ActionExceptionTest.php
new file mode 100644
index 00000000..38a2f873
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Bulk/Response/ActionExceptionTest.php
@@ -0,0 +1,8 @@
+<?php
+namespace Elastica\Test\Exception\Bulk\Response;
+
+use Elastica\Test\Exception\AbstractExceptionTest;
+
+class ActionExceptionTest extends AbstractExceptionTest
+{
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Bulk/ResponseExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Bulk/ResponseExceptionTest.php
new file mode 100644
index 00000000..2164f0e3
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Bulk/ResponseExceptionTest.php
@@ -0,0 +1,8 @@
+<?php
+namespace Elastica\Test\Exception\Bulk;
+
+use Elastica\Test\Exception\AbstractExceptionTest;
+
+class ResponseExceptionTest extends AbstractExceptionTest
+{
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Bulk/UdpExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Bulk/UdpExceptionTest.php
new file mode 100644
index 00000000..2b7660bf
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Bulk/UdpExceptionTest.php
@@ -0,0 +1,8 @@
+<?php
+namespace Elastica\Test\Exception\Bulk;
+
+use Elastica\Test\Exception\AbstractExceptionTest;
+
+class UdpExceptionTest extends AbstractExceptionTest
+{
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/BulkExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/BulkExceptionTest.php
new file mode 100644
index 00000000..1bd07689
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/BulkExceptionTest.php
@@ -0,0 +1,6 @@
+<?php
+namespace Elastica\Test\Exception;
+
+class BulkExceptionTest extends AbstractExceptionTest
+{
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ClientExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ClientExceptionTest.php
new file mode 100644
index 00000000..3f75e456
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ClientExceptionTest.php
@@ -0,0 +1,6 @@
+<?php
+namespace Elastica\Test\Exception;
+
+class ClientExceptionTest extends AbstractExceptionTest
+{
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Connection/GuzzleExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Connection/GuzzleExceptionTest.php
new file mode 100644
index 00000000..48a39de4
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Connection/GuzzleExceptionTest.php
@@ -0,0 +1,14 @@
+<?php
+namespace Elastica\Test\Exception\Connection;
+
+use Elastica\Test\Exception\AbstractExceptionTest;
+
+class GuzzleExceptionTest extends AbstractExceptionTest
+{
+ public static function setUpBeforeClass()
+ {
+ if (!class_exists('GuzzleHttp\\Client')) {
+ self::markTestSkipped('guzzlehttp/guzzle package should be installed to run guzzle transport tests');
+ }
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Connection/HttpExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Connection/HttpExceptionTest.php
new file mode 100644
index 00000000..39d58013
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Connection/HttpExceptionTest.php
@@ -0,0 +1,8 @@
+<?php
+namespace Elastica\Test\Exception\Connection;
+
+use Elastica\Test\Exception\AbstractExceptionTest;
+
+class HttpExceptionTest extends AbstractExceptionTest
+{
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Connection/MemcacheExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Connection/MemcacheExceptionTest.php
new file mode 100644
index 00000000..5bf8fd35
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Connection/MemcacheExceptionTest.php
@@ -0,0 +1,8 @@
+<?php
+namespace Elastica\Test\Exception\Connection;
+
+use Elastica\Test\Exception\AbstractExceptionTest;
+
+class MemcacheExceptionTest extends AbstractExceptionTest
+{
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Connection/ThriftExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Connection/ThriftExceptionTest.php
new file mode 100644
index 00000000..5cef43be
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Connection/ThriftExceptionTest.php
@@ -0,0 +1,14 @@
+<?php
+namespace Elastica\Test\Exception\Connection;
+
+use Elastica\Test\Exception\AbstractExceptionTest;
+
+class ThriftExceptionTest extends AbstractExceptionTest
+{
+ public static function setUpBeforeClass()
+ {
+ if (!class_exists('Elasticsearch\\RestClient')) {
+ self::markTestSkipped('munkie/elasticsearch-thrift-php package should be installed to run thrift exception tests');
+ }
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ConnectionExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ConnectionExceptionTest.php
new file mode 100644
index 00000000..5196b29e
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ConnectionExceptionTest.php
@@ -0,0 +1,6 @@
+<?php
+namespace Elastica\Test\Exception;
+
+class ConnectionExceptionTest extends AbstractExceptionTest
+{
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ElasticsearchExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ElasticsearchExceptionTest.php
new file mode 100644
index 00000000..d11894f7
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ElasticsearchExceptionTest.php
@@ -0,0 +1,6 @@
+<?php
+namespace Elastica\Test\Exception;
+
+class ElasticsearchExceptionTest extends AbstractExceptionTest
+{
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/InvalidExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/InvalidExceptionTest.php
new file mode 100644
index 00000000..e6e11899
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/InvalidExceptionTest.php
@@ -0,0 +1,6 @@
+<?php
+namespace Elastica\Test\Exception;
+
+class InvalidExceptionTest extends AbstractExceptionTest
+{
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/JSONParseExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/JSONParseExceptionTest.php
new file mode 100644
index 00000000..4fd01c49
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/JSONParseExceptionTest.php
@@ -0,0 +1,6 @@
+<?php
+namespace Elastica\Test\Exception;
+
+class JSONParseExceptionTest extends AbstractExceptionTest
+{
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/NotFoundExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/NotFoundExceptionTest.php
new file mode 100644
index 00000000..ff80a708
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/NotFoundExceptionTest.php
@@ -0,0 +1,6 @@
+<?php
+namespace Elastica\Test\Exception;
+
+class NotFoundExceptionTest extends AbstractExceptionTest
+{
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/NotImplementedTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/NotImplementedExceptionTest.php
index ff704638..117aa012 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/NotImplementedTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/NotImplementedExceptionTest.php
@@ -1,22 +1,18 @@
<?php
-
namespace Elastica\Test\Exception;
use Elastica\Exception\NotImplementedException;
-use Elastica\Test\Base as BaseTest;
-class NotImplementedTest extends BaseTest
+class NotImplementedExceptionTest extends AbstractExceptionTest
{
+ /**
+ * @group unit
+ */
public function testInstance()
{
$code = 4;
$message = 'Hello world';
$exception = new NotImplementedException($message, $code);
-
- $this->assertInstanceOf('Elastica\Exception\NotImplementedException', $exception);
- $this->assertInstanceOf('Elastica\Exception\ExceptionInterface', $exception);
- $this->assertInstanceOf('Exception', $exception);
-
$this->assertEquals($message, $exception->getMessage());
$this->assertEquals($code, $exception->getCode());
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/PartialShardFailureExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/PartialShardFailureExceptionTest.php
index 31698e26..afcca1ec 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/PartialShardFailureExceptionTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/PartialShardFailureExceptionTest.php
@@ -1,25 +1,25 @@
<?php
-
namespace Elastica\Test\Exception;
use Elastica\Document;
use Elastica\Exception\PartialShardFailureException;
use Elastica\Query;
use Elastica\ResultSet;
-use Elastica\Test\Base as BaseTest;
-class PartialShardFailureExceptionTest extends BaseTest
+class PartialShardFailureExceptionTest extends AbstractExceptionTest
{
-
+ /**
+ * @group functional
+ */
public function testPartialFailure()
{
$client = $this->_getClient();
$index = $client->getIndex('elastica_partial_failure');
$index->create(array(
'index' => array(
- 'number_of_shards' => 5,
- 'number_of_replicas' => 0
- )
+ 'number_of_shards' => 5,
+ 'number_of_replicas' => 0,
+ ),
), true);
$type = $index->getType('folks');
@@ -51,5 +51,4 @@ class PartialShardFailureExceptionTest extends BaseTest
$this->assertEquals(0, count($resultSet->getResults()));
}
}
-
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/QueryBuilderExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/QueryBuilderExceptionTest.php
new file mode 100644
index 00000000..375731ba
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/QueryBuilderExceptionTest.php
@@ -0,0 +1,6 @@
+<?php
+namespace Elastica\Test\Exception;
+
+class QueryBuilderExceptionTest extends AbstractExceptionTest
+{
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ResponseExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ResponseExceptionTest.php
index 06b5462b..6fc975e7 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ResponseExceptionTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ResponseExceptionTest.php
@@ -1,14 +1,14 @@
<?php
-
namespace Elastica\Test\Exception;
use Elastica\Document;
use Elastica\Exception\ResponseException;
-use Elastica\Test\Base as BaseTest;
-class ResponseExceptionTest extends BaseTest
+class ResponseExceptionTest extends AbstractExceptionTest
{
-
+ /**
+ * @group functional
+ */
public function testCreateExistingIndex()
{
$this->_createIndex('woo', true);
@@ -22,15 +22,18 @@ class ResponseExceptionTest extends BaseTest
}
}
+ /**
+ * @group functional
+ */
public function testBadType()
{
- $index = $this->_createIndex('woo');
- $type = $index->getType('test');
+ $index = $this->_createIndex();
+ $type = $index->getType('test');
$type->setMapping(array(
'num' => array(
- 'type' => 'long'
- )
+ 'type' => 'long',
+ ),
));
try {
@@ -44,9 +47,12 @@ class ResponseExceptionTest extends BaseTest
}
}
+ /**
+ * @group functional
+ */
public function testWhatever()
{
- $index = $this->_createIndex('woo');
+ $index = $this->_createIndex();
$index->delete();
try {
@@ -56,5 +62,4 @@ class ResponseExceptionTest extends BaseTest
$this->assertEquals(404, $ex->getElasticsearchException()->getCode());
}
}
-
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/RuntimeExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/RuntimeExceptionTest.php
new file mode 100644
index 00000000..9dd18951
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/RuntimeExceptionTest.php
@@ -0,0 +1,6 @@
+<?php
+namespace Elastica\Test\Exception;
+
+class RuntimeExceptionTest extends AbstractExceptionTest
+{
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/DateHistogramTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/DateHistogramTest.php
index 46dcdbf9..96d30aa2 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/DateHistogramTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/DateHistogramTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Facet;
use Elastica\Document;
@@ -11,6 +10,9 @@ use Elastica\Type\Mapping;
class DateHistogramTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testClassHierarchy()
{
$facet = new DateHistogram('dateHist1');
@@ -19,7 +21,51 @@ class DateHistogramTest extends BaseTest
unset($facet);
}
- public function testTest()
+ /**
+ * @group functional
+ */
+ public function testQuery()
+ {
+ $client = $this->_getClient();
+ $index = $client->getIndex('test');
+ $index->create(array(), true);
+ $type = $index->getType('helloworld');
+
+ $mapping = new Mapping($type, array(
+ 'name' => array('type' => 'string', 'store' => 'no'),
+ 'dtmPosted' => array('type' => 'date', 'store' => 'no', 'format' => 'yyyy-MM-dd HH:mm:ss'),
+ ));
+ $type->setMapping($mapping);
+
+ $doc = new Document(1, array('name' => 'nicolas ruflin', 'dtmPosted' => '2011-06-23 21:53:00'));
+ $type->addDocument($doc);
+ $doc = new Document(2, array('name' => 'raul martinez jr', 'dtmPosted' => '2011-06-23 09:53:00'));
+ $type->addDocument($doc);
+ $doc = new Document(3, array('name' => 'rachelle clemente', 'dtmPosted' => '2011-07-08 08:53:00'));
+ $type->addDocument($doc);
+ $doc = new Document(4, array('name' => 'elastica search', 'dtmPosted' => '2011-07-08 01:53:00'));
+ $type->addDocument($doc);
+
+ $facet = new DateHistogram('dateHist1');
+ $facet->setInterval('day');
+ $facet->setField('dtmPosted');
+
+ $query = new Query();
+ $query->addFacet($facet);
+ $query->setQuery(new MatchAll());
+ $index->refresh();
+
+ $response = $type->search($query);
+ $facets = $response->getFacets();
+
+ $this->assertEquals(4, $response->getTotalHits());
+ $this->assertEquals(2, count($facets['dateHist1']['entries']));
+ }
+
+ /**
+ * @group functional
+ */
+ public function testFactor()
{
$client = $this->_getClient();
$index = $client->getIndex('test');
@@ -28,22 +74,23 @@ class DateHistogramTest extends BaseTest
$mapping = new Mapping($type, array(
'name' => array('type' => 'string', 'store' => 'no'),
- 'dtmPosted' => array('type' => 'date', 'store' => 'no', 'format' => 'yyyy-MM-dd HH:mm:ss')
+ 'dtmPosted' => array('type' => 'long', 'store' => 'no'),
));
$type->setMapping($mapping);
- $doc = new Document(1, array('name' => 'nicolas ruflin', 'dtmPosted' => "2011-06-23 21:53:00"));
+ $doc = new Document(1, array('name' => 'nicolas ruflin', 'dtmPosted' => 1308865980));
$type->addDocument($doc);
- $doc = new Document(2, array('name' => 'raul martinez jr', 'dtmPosted' => "2011-06-23 09:53:00"));
+ $doc = new Document(2, array('name' => 'raul martinez jr', 'dtmPosted' => 1308822780));
$type->addDocument($doc);
- $doc = new Document(3, array('name' => 'rachelle clemente', 'dtmPosted' => "2011-07-08 08:53:00"));
+ $doc = new Document(3, array('name' => 'rachelle clemente', 'dtmPosted' => 1310115180));
$type->addDocument($doc);
- $doc = new Document(4, array('name' => 'elastica search', 'dtmPosted' => "2011-07-08 01:53:00"));
+ $doc = new Document(4, array('name' => 'elastica search', 'dtmPosted' => 1310089980));
$type->addDocument($doc);
$facet = new DateHistogram('dateHist1');
- $facet->setInterval("day");
- $facet->setField("dtmPosted");
+ $facet->setInterval('day');
+ $facet->setField('dtmPosted');
+ $facet->setFactor(1000);
$query = new Query();
$query->addFacet($facet);
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/FilterTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/FilterTest.php
index ca6f5ba3..622923fe 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/FilterTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/FilterTest.php
@@ -1,15 +1,17 @@
<?php
-
namespace Elastica\Test\Facet;
use Elastica\Document;
-use Elastica\Filter\Term;
use Elastica\Facet\Filter;
+use Elastica\Filter\Term;
use Elastica\Query;
use Elastica\Test\Base as BaseTest;
class FilterTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testFilter()
{
$client = $this->_getClient();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/GeoClusterTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/GeoClusterTest.php
index d06b58f9..f771ac32 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/GeoClusterTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/GeoClusterTest.php
@@ -1,42 +1,50 @@
<?php
-
namespace Elastica\Test\Facet;
+use Elastica\Document;
+use Elastica\Facet\GeoCluster;
+use Elastica\Query;
use Elastica\Test\Base as BaseTest;
-
-class GeoClusterTest extends BaseTest{
- public function testQuery() {
+use Elastica\Type\Mapping;
+
+class GeoClusterTest extends BaseTest
+{
+ /**
+ * @group functional
+ */
+ public function testQuery()
+ {
$client = $this->_getClient();
$nodes = $client->getCluster()->getNodes();
- if(!$nodes[0]->getInfo()->hasPlugin('geocluster-facet')){
+ if (!$nodes[0]->getInfo()->hasPlugin('geocluster-facet')) {
$this->markTestSkipped('geocluster-facet plugin not installed');
}
- $index = $this->_createIndex('geocluster_test');
+ $index = $this->_createIndex();
$type = $index->getType('testQuery');
$geoField = 'location';
- $type->setMapping(new \Elastica\Type\Mapping($type, array(
- $geoField => array( 'type' => 'geo_point', 'lat_lon' => true )
+ $type->setMapping(new Mapping($type, array(
+ $geoField => array('type' => 'geo_point', 'lat_lon' => true),
)));
- $doc = new \Elastica\Document(1, array('name' => 'item1', 'location' => array(20,20)));
+ $doc = new Document(1, array('name' => 'item1', 'location' => array(20, 20)));
$type->addDocument($doc);
- $doc = new \Elastica\Document(2, array('name' => 'item2', 'location' => array(20,20)));
+ $doc = new Document(2, array('name' => 'item2', 'location' => array(20, 20)));
$type->addDocument($doc);
- $doc = new \Elastica\Document(3, array('name' => 'item3', 'location' => array(20,20)));
+ $doc = new Document(3, array('name' => 'item3', 'location' => array(20, 20)));
$type->addDocument($doc);
$index->refresh();
- $facet = new \Elastica\Facet\GeoCluster('clusters');
+ $facet = new GeoCluster('clusters');
$facet
->setField($geoField)
->setFactor(1)
->setShowIds(false);
- $query = new \Elastica\Query();
+ $query = new Query();
$query->setFacets(array($facet));
$response = $type->search($query);
@@ -46,4 +54,4 @@ class GeoClusterTest extends BaseTest{
$index->delete();
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/QueryTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/QueryTest.php
index ef5d7ccd..8e0231aa 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/QueryTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/QueryTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Facet;
use Elastica\Document;
@@ -10,6 +9,9 @@ use Elastica\Test\Base as BaseTest;
class QueryTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testFilter()
{
$client = $this->_getClient();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/StatisticalTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/StatisticalTest.php
index 0b528a79..dc374289 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/StatisticalTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/StatisticalTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Facet;
use Elastica\Document;
@@ -8,8 +7,14 @@ use Elastica\Query;
use Elastica\Query\MatchAll;
use Elastica\Test\Base as BaseTest;
+/**
+ * @todo Add test for Statistical with setScript
+ */
class StatisticalTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testStatisticalWithSetField()
{
$client = $this->_getClient();
@@ -41,6 +46,9 @@ class StatisticalTest extends BaseTest
$this->assertEquals(45, $facets['stats']['max']);
}
+ /**
+ * @group functional
+ */
public function testStatisticalWithSetFields()
{
$client = $this->_getClient();
@@ -56,7 +64,7 @@ class StatisticalTest extends BaseTest
$type->addDocument($doc);
$facet = new Statistical('stats');
- $facet->setFields(array('price','price2'));
+ $facet->setFields(array('price', 'price2'));
$query = new Query();
$query->addFacet($facet);
@@ -71,12 +79,4 @@ class StatisticalTest extends BaseTest
$this->assertEquals(10, $facets['stats']['min']);
$this->assertEquals(90, $facets['stats']['max']);
}
-
- /**
- * @todo
- */
- public function testStatisticalWithSetScript()
- {
- $this->markTestIncomplete('Test for setting the script value');
- }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/TermsStatsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/TermsStatsTest.php
index bea9b78d..e3377930 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/TermsStatsTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/TermsStatsTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Facet;
use Elastica\Document;
@@ -10,96 +9,105 @@ use Elastica\Test\Base as BaseTest;
class TermsStatsTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testOrder()
{
$client = $this->_getClient();
- $index = $client->getIndex( 'test' );
- $index->create( array( ), true );
- $type = $index->getType( 'helloworld' );
-
- $doc = new Document( 1, array( 'name' => 'tom', 'paid' => 7 ) );
- $type->addDocument( $doc );
- $doc = new Document( 2, array( 'name' => 'tom', 'paid' => 2 ) );
- $type->addDocument( $doc );
- $doc = new Document( 3, array( 'name' => 'tom', 'paid' => 5 ) );
- $type->addDocument( $doc );
- $doc = new Document( 4, array( 'name' => 'mike', 'paid' => 13 ) );
- $type->addDocument( $doc );
- $doc = new Document( 5, array( 'name' => 'mike', 'paid' => 1 ) );
- $type->addDocument( $doc );
- $doc = new Document( 6, array( 'name' => 'mike', 'paid' => 15 ) );
- $type->addDocument( $doc );
-
- $facet = new TermsStats( 'test' );
- $facet->setKeyField( 'name' );
- $facet->setValueField( 'paid' );
- $facet->setOrder( 'reverse_total' );
+ $index = $client->getIndex('test');
+ $index->create(array(), true);
+ $type = $index->getType('helloworld');
+
+ $doc = new Document(1, array('name' => 'tom', 'paid' => 7));
+ $type->addDocument($doc);
+ $doc = new Document(2, array('name' => 'tom', 'paid' => 2));
+ $type->addDocument($doc);
+ $doc = new Document(3, array('name' => 'tom', 'paid' => 5));
+ $type->addDocument($doc);
+ $doc = new Document(4, array('name' => 'mike', 'paid' => 13));
+ $type->addDocument($doc);
+ $doc = new Document(5, array('name' => 'mike', 'paid' => 1));
+ $type->addDocument($doc);
+ $doc = new Document(6, array('name' => 'mike', 'paid' => 15));
+ $type->addDocument($doc);
+
+ $facet = new TermsStats('test');
+ $facet->setKeyField('name');
+ $facet->setValueField('paid');
+ $facet->setOrder('reverse_total');
$query = new Query();
- $query->addFacet( $facet );
- $query->setQuery( new MatchAll() );
+ $query->addFacet($facet);
+ $query->setQuery(new MatchAll());
$index->refresh();
- $response = $type->search( $query );
- $facets = $response->getFacets();
+ $response = $type->search($query);
+ $facets = $response->getFacets();
- $this->assertEquals(14, $facets[ 'test' ][ 'terms' ][0]['total'] );
- $this->assertEquals(29, $facets[ 'test' ][ 'terms' ][1]['total'] );
+ $this->assertEquals(14, $facets[ 'test' ][ 'terms' ][0]['total']);
+ $this->assertEquals(29, $facets[ 'test' ][ 'terms' ][1]['total']);
}
+ /**
+ * @group functional
+ */
public function testQuery()
{
$client = $this->_getClient();
- $index = $client->getIndex( 'test' );
- $index->create( array( ), true );
- $type = $index->getType( 'helloworld' );
-
- $doc = new Document( 1, array( 'name' => 'tom', 'paid' => 7 ) );
- $type->addDocument( $doc );
- $doc = new Document( 2, array( 'name' => 'tom', 'paid' => 2 ) );
- $type->addDocument( $doc );
- $doc = new Document( 3, array( 'name' => 'tom', 'paid' => 5 ) );
- $type->addDocument( $doc );
- $doc = new Document( 4, array( 'name' => 'mike', 'paid' => 13 ) );
- $type->addDocument( $doc );
- $doc = new Document( 5, array( 'name' => 'mike', 'paid' => 1 ) );
- $type->addDocument( $doc );
- $doc = new Document( 6, array( 'name' => 'mike', 'paid' => 15 ) );
- $type->addDocument( $doc );
-
- $facet = new TermsStats( 'test' );
- $facet->setKeyField( 'name' );
- $facet->setValueField( 'paid' );
+ $index = $client->getIndex('test');
+ $index->create(array(), true);
+ $type = $index->getType('helloworld');
+
+ $doc = new Document(1, array('name' => 'tom', 'paid' => 7));
+ $type->addDocument($doc);
+ $doc = new Document(2, array('name' => 'tom', 'paid' => 2));
+ $type->addDocument($doc);
+ $doc = new Document(3, array('name' => 'tom', 'paid' => 5));
+ $type->addDocument($doc);
+ $doc = new Document(4, array('name' => 'mike', 'paid' => 13));
+ $type->addDocument($doc);
+ $doc = new Document(5, array('name' => 'mike', 'paid' => 1));
+ $type->addDocument($doc);
+ $doc = new Document(6, array('name' => 'mike', 'paid' => 15));
+ $type->addDocument($doc);
+
+ $facet = new TermsStats('test');
+ $facet->setKeyField('name');
+ $facet->setValueField('paid');
$query = new Query();
- $query->addFacet( $facet );
- $query->setQuery( new MatchAll() );
+ $query->addFacet($facet);
+ $query->setQuery(new MatchAll());
$index->refresh();
- $response = $type->search( $query );
- $facets = $response->getFacets();
+ $response = $type->search($query);
+ $facets = $response->getFacets();
- $this->assertEquals( 2, count( $facets[ 'test' ][ 'terms' ] ) );
+ $this->assertEquals(2, count($facets[ 'test' ][ 'terms' ]));
foreach ($facets[ 'test' ][ 'terms' ] as $facet) {
if ($facet[ 'term' ] === 'tom') {
- $this->assertEquals( 14, $facet[ 'total' ] );
+ $this->assertEquals(14, $facet[ 'total' ]);
}
if ($facet[ 'term' ] === 'mike') {
- $this->assertEquals( 29, $facet[ 'total' ] );
+ $this->assertEquals(29, $facet[ 'total' ]);
}
}
}
- public function testSetSize()
- {
- $facet = new TermsStats( 'test' );
- $facet->setSize(100);
+ /**
+ * @group unit
+ */
+ public function testSetSize()
+ {
+ $facet = new TermsStats('test');
+ $facet->setSize(100);
- $data = $facet->toArray();
+ $data = $facet->toArray();
- $this->assertArrayHasKey('size', $data['terms_stats']);
- $this->assertEquals(100, $data['terms_stats']['size']);
- }
+ $this->assertArrayHasKey('size', $data['terms_stats']);
+ $this->assertEquals(100, $data['terms_stats']['size']);
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/TermsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/TermsTest.php
index e8521c5c..f4c95796 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/TermsTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/TermsTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Facet;
use Elastica\Document;
@@ -10,6 +9,9 @@ use Elastica\Test\Base as BaseTest;
class TermsTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testQuery()
{
$client = $this->_getClient();
@@ -39,6 +41,9 @@ class TermsTest extends BaseTest
$this->assertEquals(3, count($facets['test']['terms']));
}
+ /**
+ * @group functional
+ */
public function testFacetScript()
{
$client = $this->_getClient();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/AbstractTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/AbstractTest.php
index 1e47819f..3ba64dd1 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/AbstractTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/AbstractTest.php
@@ -1,11 +1,13 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Test\Base as BaseTest;
class AbstractTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testSetCached()
{
$stubFilter = $this->getStub();
@@ -19,6 +21,9 @@ class AbstractTest extends BaseTest
$this->assertFalse($arrayFilter['_cache']);
}
+ /**
+ * @group unit
+ */
public function testSetCachedDefaultValue()
{
$stubFilter = $this->getStub();
@@ -28,6 +33,9 @@ class AbstractTest extends BaseTest
$this->assertTrue($arrayFilter['_cache']);
}
+ /**
+ * @group unit
+ */
public function testSetCacheKey()
{
$stubFilter = $this->getStub();
@@ -40,6 +48,7 @@ class AbstractTest extends BaseTest
}
/**
+ * @group unit
* @expectedException \Elastica\Exception\InvalidException
*/
public function testSetCacheKeyEmptyKey()
@@ -51,6 +60,9 @@ class AbstractTest extends BaseTest
$stubFilter->setCacheKey($cacheKey);
}
+ /**
+ * @group unit
+ */
public function testSetName()
{
$stubFilter = $this->getStub();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolAndTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolAndTest.php
index 672c6c67..a8f47633 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolAndTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolAndTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Document;
@@ -9,6 +8,9 @@ use Elastica\Test\Base as BaseTest;
class BoolAndTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$and = new BoolAnd();
@@ -23,13 +25,16 @@ class BoolAndTest extends BaseTest
$expectedArray = array(
'and' => array(
$idsFilter->toArray(),
- $idsFilter->toArray()
- )
+ $idsFilter->toArray(),
+ ),
);
$this->assertEquals($expectedArray, $and->toArray());
}
+ /**
+ * @group functional
+ */
public function testSetCache()
{
$client = $this->_getClient();
@@ -37,12 +42,11 @@ class BoolAndTest extends BaseTest
$index->create(array(), true);
$type = $index->getType('test');
- $doc = new Document(1, array('name' => 'hello world'));
- $type->addDocument($doc);
- $doc = new Document(2, array('name' => 'nicolas ruflin'));
- $type->addDocument($doc);
- $doc = new Document(3, array('name' => 'ruflin'));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'hello world')),
+ new Document(2, array('name' => 'nicolas ruflin')),
+ new Document(3, array('name' => 'ruflin')),
+ ));
$and = new BoolAnd();
@@ -62,4 +66,21 @@ class BoolAndTest extends BaseTest
$this->assertEquals(1, $resultSet->count());
}
+
+ /**
+ * @group unit
+ */
+ public function testConstruct()
+ {
+ $ids1 = new Ids('foo', array(1, 2));
+ $ids2 = new Ids('bar', array(3, 4));
+
+ $and1 = new BoolAnd(array($ids1, $ids2));
+
+ $and2 = new BoolAnd();
+ $and2->addFilter($ids1);
+ $and2->addFilter($ids2);
+
+ $this->assertEquals($and1->toArray(), $and2->toArray());
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolFilterTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolFilterTest.php
new file mode 100644
index 00000000..ec7728af
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolFilterTest.php
@@ -0,0 +1,200 @@
+<?php
+namespace Elastica\Test\Filter;
+
+use Elastica\Document;
+use Elastica\Filter\BoolFilter;
+use Elastica\Filter\Ids;
+use Elastica\Filter\Term;
+use Elastica\Filter\Terms;
+use Elastica\Query;
+use Elastica\Test\Base as BaseTest;
+
+class BoolFilterTest extends BaseTest
+{
+ /**
+ * @return array
+ */
+ public function getTestToArrayData()
+ {
+ $out = array();
+
+ // case #0
+ $mainBool = new BoolFilter();
+
+ $idsFilter1 = new Ids();
+ $idsFilter1->setIds(1);
+ $idsFilter2 = new Ids();
+ $idsFilter2->setIds(2);
+ $idsFilter3 = new Ids();
+ $idsFilter3->setIds(3);
+
+ $childBool = new BoolFilter();
+ $childBool->addShould(array($idsFilter1, $idsFilter2));
+ $mainBool->addShould(array($childBool, $idsFilter3));
+
+ $expectedArray = array(
+ 'bool' => array(
+ 'should' => array(
+ array(
+ array(
+ 'bool' => array(
+ 'should' => array(
+ array(
+ $idsFilter1->toArray(),
+ $idsFilter2->toArray(),
+ ),
+ ),
+ ),
+ ),
+ $idsFilter3->toArray(),
+ ),
+ ),
+ ),
+ );
+ $out[] = array($mainBool, $expectedArray);
+
+ // case #1 _cache parameter should be supported
+ $bool = new BoolFilter();
+ $terms = new Terms('field1', array('value1', 'value2'));
+ $termsNot = new Terms('field2', array('value1', 'value2'));
+ $bool->addMust($terms);
+ $bool->addMustNot($termsNot);
+ $bool->setCached(true);
+ $bool->setCacheKey('my-cache-key');
+ $expected = array(
+ 'bool' => array(
+ 'must' => array(
+ $terms->toArray(),
+ ),
+ 'must_not' => array(
+ $termsNot->toArray(),
+ ),
+ '_cache' => true,
+ '_cache_key' => 'my-cache-key',
+ ),
+ );
+ $out[] = array($bool, $expected);
+
+ return $out;
+ }
+
+ /**
+ * @group unit
+ * @dataProvider getTestToArrayData()
+ *
+ * @param Bool $bool
+ * @param array $expectedArray
+ */
+ public function testToArray(BoolFilter $bool, $expectedArray)
+ {
+ $this->assertEquals($expectedArray, $bool->toArray());
+ }
+
+ /**
+ * @group functional
+ */
+ public function testBoolFilter()
+ {
+ $index = $this->_createIndex();
+ $type = $index->getType('book');
+
+ //index some test data
+ $type->addDocuments(array(
+ new Document(1, array('author' => 'Michael Shermer', 'title' => 'The Believing Brain', 'publisher' => 'Robinson')),
+ new Document(2, array('author' => 'Jared Diamond', 'title' => 'Guns, Germs and Steel', 'publisher' => 'Vintage')),
+ new Document(3, array('author' => 'Jared Diamond', 'title' => 'Collapse', 'publisher' => 'Penguin')),
+ new Document(4, array('author' => 'Richard Dawkins', 'title' => 'The Selfish Gene', 'publisher' => 'OUP Oxford')),
+ new Document(5, array('author' => 'Anthony Burges', 'title' => 'A Clockwork Orange', 'publisher' => 'Penguin')),
+ ));
+
+ $index->refresh();
+
+ //use the terms lookup feature to query for some data
+ //build query
+ //must
+ // should
+ // author = jared
+ // author = richard
+ // must_not
+ // publisher = penguin
+
+ //construct the query
+ $query = new Query();
+ $mainBoolFilter = new BoolFilter();
+ $shouldFilter = new BoolFilter();
+ $authorFilter1 = new Term();
+ $authorFilter1->setTerm('author', 'jared');
+ $authorFilter2 = new Term();
+ $authorFilter2->setTerm('author', 'richard');
+ $shouldFilter->addShould(array($authorFilter1, $authorFilter2));
+
+ $mustNotFilter = new BoolFilter();
+ $publisherFilter = new Term();
+ $publisherFilter->setTerm('publisher', 'penguin');
+ $mustNotFilter->addMustNot($publisherFilter);
+
+ $mainBoolFilter->addMust(array($shouldFilter, $mustNotFilter));
+ $query->setPostFilter($mainBoolFilter);
+ //execute the query
+ $results = $index->search($query);
+
+ //check the number of results
+ $this->assertEquals($results->count(), 2, 'Bool filter with child Bool filters: number of results check');
+
+ //count compare the id's
+ $ids = array();
+ /** @var \Elastica\Result $result **/
+ foreach ($results as $result) {
+ $ids[] = $result->getId();
+ }
+ $this->assertEquals($ids, array('2', '4'), 'Bool filter with child Bool filters: result ID check');
+
+ $index->delete();
+ }
+
+ /**
+ * @group unit
+ * @expectedException \Elastica\Exception\InvalidException
+ */
+ public function testAddMustInvalidException()
+ {
+ $filter = new BoolFilter();
+ $filter->addMust('fail!');
+ }
+
+ /**
+ * @group unit
+ * @expectedException \Elastica\Exception\InvalidException
+ */
+ public function testAddMustNotInvalidException()
+ {
+ $filter = new BoolFilter();
+ $filter->addMustNot('fail!');
+ }
+
+ /**
+ * @group unit
+ * @expectedException \Elastica\Exception\InvalidException
+ */
+ public function testAddShouldInvalidException()
+ {
+ $filter = new BoolFilter();
+ $filter->addShould('fail!');
+ }
+
+ /**
+ * Small unit test to check if also the old object name works.
+ *
+ * @group unit
+ * @expectedException \Elastica\Exception\InvalidException
+ */
+ public function testOldObject()
+ {
+ if (version_compare(phpversion(), 7, '>=')) {
+ self::markTestSkipped('These objects are not supported in PHP 7');
+ }
+
+ $filter = new \Elastica\Filter\Bool();
+ $filter->addShould('fail!');
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolNotTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolNotTest.php
index adcebf45..75461496 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolNotTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolNotTest.php
@@ -1,13 +1,15 @@
<?php
-
namespace Elastica\Test\Filter;
-use Elastica\Filter\Ids;
use Elastica\Filter\BoolNot;
+use Elastica\Filter\Ids;
use Elastica\Test\Base as BaseTest;
class BoolNotTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$idsFilter = new Ids();
@@ -16,8 +18,8 @@ class BoolNotTest extends BaseTest
$expectedArray = array(
'not' => array(
- 'filter' => $idsFilter->toArray()
- )
+ 'filter' => $idsFilter->toArray(),
+ ),
);
$this->assertEquals($expectedArray, $filter->toArray());
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolOrTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolOrTest.php
index 25234a8c..6462d1fa 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolOrTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolOrTest.php
@@ -1,14 +1,16 @@
<?php
-
namespace Elastica\Test\Filter;
-use Elastica\Filter\AbstractFilter;
+use Elastica\Document;
use Elastica\Filter\BoolOr;
use Elastica\Filter\Ids;
use Elastica\Test\Base as BaseTest;
class BoolOrTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testAddFilter()
{
$filter = $this->getMockForAbstractClass('Elastica\Filter\AbstractFilter');
@@ -17,6 +19,9 @@ class BoolOrTest extends BaseTest
$this->assertInstanceOf('Elastica\Filter\BoolOr', $returnValue);
}
+ /**
+ * @group unit
+ */
public function testToArray()
{
$orFilter = new BoolOr();
@@ -33,10 +38,53 @@ class BoolOrTest extends BaseTest
$expectedArray = array(
'or' => array(
$filter1->toArray(),
- $filter2->toArray()
- )
+ $filter2->toArray(),
+ ),
);
$this->assertEquals($expectedArray, $orFilter->toArray());
}
+
+ /**
+ * @group unit
+ */
+ public function testConstruct()
+ {
+ $ids1 = new Ids('foo', array(1, 2));
+ $ids2 = new Ids('bar', array(3, 4));
+
+ $and1 = new BoolOr(array($ids1, $ids2));
+
+ $and2 = new BoolOr();
+ $and2->addFilter($ids1);
+ $and2->addFilter($ids2);
+
+ $this->assertEquals($and1->toArray(), $and2->toArray());
+ }
+
+ /**
+ * @group functional
+ */
+ public function testOrFilter()
+ {
+ $index = $this->_createIndex();
+ $type = $index->getType('test');
+
+ $doc1 = new Document('', array('categoryId' => 1));
+ $doc2 = new Document('', array('categoryId' => 2));
+ $doc3 = new Document('', array('categoryId' => 3));
+
+ $type->addDocument($doc1);
+ $type->addDocument($doc2);
+ $type->addDocument($doc3);
+
+ $index->refresh();
+
+ $boolOr = new \Elastica\Filter\BoolOr();
+ $boolOr->addFilter(new \Elastica\Filter\Term(array('categoryId' => '1')));
+ $boolOr->addFilter(new \Elastica\Filter\Term(array('categoryId' => '2')));
+
+ $resultSet = $type->search($boolOr);
+ $this->assertEquals(2, $resultSet->count());
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolTest.php
deleted file mode 100644
index 60eb3a45..00000000
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolTest.php
+++ /dev/null
@@ -1,107 +0,0 @@
-<?php
-
-namespace Elastica\Test\Filter;
-
-use \Elastica\Query;
-use Elastica\Filter\Bool;
-use Elastica\Filter\Term;
-use Elastica\Filter\Ids;
-use Elastica\Test\Base as BaseTest;
-
-class BoolTest extends BaseTest
-{
- public function testToArray()
- {
- $mainBool = new Bool();
-
- $idsFilter1 = new Ids();
- $idsFilter1->setIds(1);
- $idsFilter2 = new Ids();
- $idsFilter2->setIds(2);
- $idsFilter3 = new Ids();
- $idsFilter3->setIds(3);
-
- $childBool = new Bool();
- $childBool->addShould(array($idsFilter1, $idsFilter2));
- $mainBool->addShould(array($childBool, $idsFilter3));
-
- $expectedArray = array(
- 'bool' => array(
- 'should' => array(
- array(
- array(
- 'bool' => array(
- 'should' => array(
- array(
- $idsFilter1->toArray(),
- $idsFilter2->toArray()
- )
- )
- )
- ),
- $idsFilter3->toArray()
- )
- )
- )
- );
-
- $this->assertEquals($expectedArray, $mainBool->toArray());
- }
-
- public function testBoolFilter()
- {
- $index = $this->_createIndex('bool_filter_test');
- $type = $index->getType('book');
-
- //index some test data
- $type->addDocument(new \Elastica\Document(1, array('author' => 'Michael Shermer', 'title' => 'The Believing Brain', 'publisher' => 'Robinson')));
- $type->addDocument(new \Elastica\Document(2, array('author' => 'Jared Diamond', 'title' => 'Guns, Germs and Steel', 'publisher' => 'Vintage')));
- $type->addDocument(new \Elastica\Document(3, array('author' => 'Jared Diamond', 'title' => 'Collapse', 'publisher' => 'Penguin')));
- $type->addDocument(new \Elastica\Document(4, array('author' => 'Richard Dawkins', 'title' => 'The Selfish Gene', 'publisher' => 'OUP Oxford')));
- $type->addDocument(new \Elastica\Document(5, array('author' => 'Anthony Burges', 'title' => 'A Clockwork Orange', 'publisher' => 'Penguin')));
-
- $index->refresh();
-
- //use the terms lookup feature to query for some data
- //build query
- //must
- // should
- // author = jared
- // author = richard
- // must_not
- // publisher = penguin
-
- //construct the query
- $query = new Query();
- $mainBoolFilter = new Bool();
- $shouldFilter = new Bool();
- $authorFilter1 = new Term();
- $authorFilter1->setTerm('author', 'jared');
- $authorFilter2 = new Term();
- $authorFilter2->setTerm('author', 'richard');
- $shouldFilter->addShould(array($authorFilter1, $authorFilter2));
-
- $mustNotFilter = new Bool();
- $publisherFilter = new Term();
- $publisherFilter->setTerm('publisher', 'penguin');
- $mustNotFilter->addMustNot($publisherFilter);
-
- $mainBoolFilter->addMust(array($shouldFilter, $mustNotFilter));
- $query->setFilter($mainBoolFilter);
- //execute the query
- $results = $index->search($query);
-
- //check the number of results
- $this->assertEquals($results->count(), 2, 'Bool filter with child Bool filters: number of results check');
-
- //count compare the id's
- $ids = array();
- /** @var \Elastica\Result $result **/
- foreach($results as $result){
- $ids[] = $result->getId();
- }
- $this->assertEquals($ids, array("2","4"), 'Bool filter with child Bool filters: result ID check');
-
- $index->delete();
- }
-}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/ExistsTests.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/ExistsTest.php
index 9e4f5b67..25afa724 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/ExistsTests.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/ExistsTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Filter\Exists;
@@ -7,6 +6,9 @@ use Elastica\Test\Base as BaseTest;
class ExistsTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$field = 'test';
@@ -16,6 +18,9 @@ class ExistsTest extends BaseTest
$this->assertEquals($expectedArray, $filter->toArray());
}
+ /**
+ * @group unit
+ */
public function testSetField()
{
$field = 'test';
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoBoundingBoxTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoBoundingBoxTest.php
new file mode 100644
index 00000000..8fdde965
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoBoundingBoxTest.php
@@ -0,0 +1,55 @@
+<?php
+namespace Elastica\Test\Filter;
+
+use Elastica\Filter\GeoBoundingBox;
+use Elastica\Test\Base as BaseTest;
+
+class GeoBoundingBoxTest extends BaseTest
+{
+ /**
+ * @group unit
+ */
+ public function testAddCoordinates()
+ {
+ $key = 'pin.location';
+ $coords = array('40.73, -74.1', '40.01, -71.12');
+ $filter = new GeoBoundingBox($key, array('1,2', '3,4'));
+
+ $filter->addCoordinates($key, $coords);
+ $expectedArray = array('top_left' => $coords[0], 'bottom_right' => $coords[1]);
+ $this->assertEquals($expectedArray, $filter->getParam($key));
+
+ $returnValue = $filter->addCoordinates($key, $coords);
+ $this->assertInstanceOf('Elastica\Filter\GeoBoundingBox', $returnValue);
+ }
+
+ /**
+ * @group unit
+ * @expectedException \Elastica\Exception\InvalidException
+ */
+ public function testAddCoordinatesInvalidException()
+ {
+ $filter = new GeoBoundingBox('foo', array());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testToArray()
+ {
+ $key = 'pin.location';
+ $coords = array('40.73, -74.1', '40.01, -71.12');
+ $filter = new GeoBoundingBox($key, $coords);
+
+ $expectedArray = array(
+ 'geo_bounding_box' => array(
+ $key => array(
+ 'top_left' => $coords[0],
+ 'bottom_right' => $coords[1],
+ ),
+ ),
+ );
+
+ $this->assertEquals($expectedArray, $filter->toArray());
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoDistanceRangeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoDistanceRangeTest.php
index 4c4d2bcc..203a45de 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoDistanceRangeTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoDistanceRangeTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Document;
@@ -10,12 +9,12 @@ use Elastica\Test\Base as BaseTest;
class GeoDistanceRangeTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testGeoPoint()
{
- $client = $this->_getClient();
- $index = $client->getIndex('test');
- $index->create(array(), true);
-
+ $index = $this->_createIndex();
$type = $index->getType('test');
// Set mapping
@@ -53,7 +52,7 @@ class GeoDistanceRangeTest extends BaseTest
);
$query = new Query(new MatchAll());
- $query->setFilter($geoFilter);
+ $query->setPostFilter($geoFilter);
$this->assertEquals(1, $type->search($query)->count());
// Both points should be inside
@@ -64,13 +63,14 @@ class GeoDistanceRangeTest extends BaseTest
array('gte' => '0km', 'lte' => '40000km')
);
$query = new Query(new MatchAll());
- $query->setFilter($geoFilter);
+ $query->setPostFilter($geoFilter);
$index->refresh();
$this->assertEquals(2, $type->search($query)->count());
}
/**
+ * @group unit
* @expectedException \Elastica\Exception\InvalidException
*/
public function testInvalidRange()
@@ -83,6 +83,7 @@ class GeoDistanceRangeTest extends BaseTest
}
/**
+ * @group unit
* @dataProvider invalidLocationDataProvider
* @expectedException \Elastica\Exception\InvalidException
*/
@@ -96,6 +97,7 @@ class GeoDistanceRangeTest extends BaseTest
}
/**
+ * @group unit
* @dataProvider constructDataProvider
*/
public function testConstruct($key, $location, $ranges, $expected)
@@ -130,7 +132,7 @@ class GeoDistanceRangeTest extends BaseTest
),
array(
false,
- )
+ ),
);
}
@@ -149,8 +151,8 @@ class GeoDistanceRangeTest extends BaseTest
'from' => '10km',
'to' => '20km',
'location' => 'u09tvqx',
- )
- )
+ ),
+ ),
),
array(
'location',
@@ -168,8 +170,8 @@ class GeoDistanceRangeTest extends BaseTest
'from' => '10km',
'include_lower' => true,
'location' => 'u09tvqx',
- )
- )
+ ),
+ ),
),
array(
'location',
@@ -189,8 +191,8 @@ class GeoDistanceRangeTest extends BaseTest
'lat' => 48.86,
'lon' => 2.35,
),
- )
- )
+ ),
+ ),
),
array(
'location',
@@ -210,9 +212,9 @@ class GeoDistanceRangeTest extends BaseTest
'lat' => 48.86,
'lon' => 2.35,
),
- )
- )
- )
+ ),
+ ),
+ ),
);
}
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoDistanceTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoDistanceTest.php
index a5049914..b61b4adc 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoDistanceTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoDistanceTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Document;
@@ -10,11 +9,12 @@ use Elastica\Test\Base as BaseTest;
class GeoDistanceTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testGeoPoint()
{
- $client = $this->_getClient();
- $index = $client->getIndex('test');
- $index->create(array(), true);
+ $index = $this->_createIndex();
$type = $index->getType('test');
@@ -49,25 +49,28 @@ class GeoDistanceTest extends BaseTest
$geoFilter = new GeoDistance('point', array('lat' => 30, 'lon' => 40), '1km');
$query = new Query(new MatchAll());
- $query->setFilter($geoFilter);
+ $query->setPostFilter($geoFilter);
$this->assertEquals(1, $type->search($query)->count());
// Both points should be inside
$query = new Query();
$geoFilter = new GeoDistance('point', array('lat' => 30, 'lon' => 40), '40000km');
$query = new Query(new MatchAll());
- $query->setFilter($geoFilter);
+ $query->setPostFilter($geoFilter);
$index->refresh();
$this->assertEquals(2, $type->search($query)->count());
}
+ /**
+ * @group unit
+ */
public function testConstructLatlon()
{
$key = 'location';
$location = array(
'lat' => 48.86,
- 'lon' => 2.35
+ 'lon' => 2.35,
);
$distance = '10km';
@@ -76,8 +79,8 @@ class GeoDistanceTest extends BaseTest
$expected = array(
'geo_distance' => array(
$key => $location,
- 'distance' => $distance
- )
+ 'distance' => $distance,
+ ),
);
$data = $filter->toArray();
@@ -85,6 +88,9 @@ class GeoDistanceTest extends BaseTest
$this->assertEquals($expected, $data);
}
+ /**
+ * @group unit
+ */
public function testConstructGeohash()
{
$key = 'location';
@@ -96,8 +102,8 @@ class GeoDistanceTest extends BaseTest
$expected = array(
'geo_distance' => array(
$key => $location,
- 'distance' => $distance
- )
+ 'distance' => $distance,
+ ),
);
$data = $filter->toArray();
@@ -105,6 +111,9 @@ class GeoDistanceTest extends BaseTest
$this->assertEquals($expected, $data);
}
+ /**
+ * @group unit
+ */
public function testSetDistanceType()
{
$filter = new GeoDistance('location', array('lat' => 48.86, 'lon' => 2.35), '10km');
@@ -116,6 +125,9 @@ class GeoDistanceTest extends BaseTest
$this->assertEquals($distanceType, $data['geo_distance']['distance_type']);
}
+ /**
+ * @group unit
+ */
public function testSetOptimizeBbox()
{
$filter = new GeoDistance('location', array('lat' => 48.86, 'lon' => 2.35), '10km');
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoPolygonTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoPolygonTest.php
index 7ebd738c..b56f73b0 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoPolygonTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoPolygonTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Document;
@@ -10,11 +9,12 @@ use Elastica\Test\Base as BaseTest;
class GeoPolygonTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testGeoPoint()
{
- $client = $this->_getClient();
- $index = $client->getIndex('test');
- $index->create(array(), true);
+ $index = $this->_createIndex();
$type = $index->getType('test');
@@ -49,7 +49,7 @@ class GeoPolygonTest extends BaseTest
$geoFilter = new GeoPolygon('location', $points);
$query = new Query(new MatchAll());
- $query->setFilter($geoFilter);
+ $query->setPostFilter($geoFilter);
$this->assertEquals(1, $type->search($query)->count());
// Both points should be inside
@@ -58,7 +58,7 @@ class GeoPolygonTest extends BaseTest
$geoFilter = new GeoPolygon('location', $points);
$query = new Query(new MatchAll());
- $query->setFilter($geoFilter);
+ $query->setPostFilter($geoFilter);
$this->assertEquals(2, $type->search($query)->count());
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapePreIndexedTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapePreIndexedTest.php
index 21afec1a..96453527 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapePreIndexedTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapePreIndexedTest.php
@@ -1,66 +1,67 @@
<?php
-
-
namespace Elastica\Test\Filter;
use Elastica\Filter\AbstractGeoShape;
use Elastica\Filter\GeoShapePreIndexed;
-use Elastica\Query\MatchAll;
use Elastica\Query\Filtered;
+use Elastica\Query\MatchAll;
use Elastica\Test\Base as BaseTest;
class GeoShapePreIndexedTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testGeoProvided()
{
- $indexName = 'geo_shape_filter_test';
- $index = $this->_createIndex($indexName);
+ $index = $this->_createIndex();
+ $indexName = $index->getName();
$type = $index->getType('type');
$otherType = $index->getType('other_type');
// create mapping
$mapping = new \Elastica\Type\Mapping($type, array(
'location' => array(
- 'type' => 'geo_shape'
- )
+ 'type' => 'geo_shape',
+ ),
));
$type->setMapping($mapping);
// create other type mapping
$otherMapping = new \Elastica\Type\Mapping($type, array(
'location' => array(
- 'type' => 'geo_shape'
- )
+ 'type' => 'geo_shape',
+ ),
));
$otherType->setMapping($otherMapping);
// add type docs
$type->addDocument(new \Elastica\Document('1', array(
'location' => array(
- "type" => "envelope",
- "coordinates" => array(
+ 'type' => 'envelope',
+ 'coordinates' => array(
array(0.0, 50.0),
- array(50.0, 0.0)
- )
- )
+ array(50.0, 0.0),
+ ),
+ ),
)));
// add other type docs
$otherType->addDocument(new \Elastica\Document('2', array(
'location' => array(
- "type" => "envelope",
- "coordinates" => array(
+ 'type' => 'envelope',
+ 'coordinates' => array(
array(25.0, 75.0),
- array(75.0, 25.0)
- )
- )
+ array(75.0, 25.0),
+ ),
+ ),
)));
$index->optimize();
$index->refresh();
$gsp = new GeoShapePreIndexed(
- 'location', '1', 'type', 'elastica_'.$indexName, 'location'
+ 'location', '1', 'type', $indexName, 'location'
);
$gsp->setRelation(AbstractGeoShape::RELATION_INTERSECT);
@@ -70,12 +71,12 @@ class GeoShapePreIndexedTest extends BaseTest
'indexed_shape' => array(
'id' => '1',
'type' => 'type',
- 'index' => 'elastica_'.$indexName,
- 'path' => 'location'
+ 'index' => $indexName,
+ 'path' => 'location',
),
- 'relation' => $gsp->getRelation()
- )
- )
+ 'relation' => $gsp->getRelation(),
+ ),
+ ),
);
$this->assertEquals($expected, $gsp->toArray());
@@ -87,4 +88,15 @@ class GeoShapePreIndexedTest extends BaseTest
$index->delete();
}
-} \ No newline at end of file
+
+ /**
+ * @group unit
+ */
+ public function testSetRelation()
+ {
+ $gsp = new GeoShapePreIndexed('location', '1', 'type', 'indexName', 'location');
+ $gsp->setRelation(AbstractGeoShape::RELATION_INTERSECT);
+ $this->assertEquals(AbstractGeoShape::RELATION_INTERSECT, $gsp->getRelation());
+ $this->assertInstanceOf('Elastica\Filter\GeoShapePreIndexed', $gsp->setRelation(AbstractGeoShape::RELATION_INTERSECT));
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapeProvidedTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapeProvidedTest.php
index 146150a3..d631e44e 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapeProvidedTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapeProvidedTest.php
@@ -1,38 +1,41 @@
<?php
-
-
namespace Elastica\Test\Filter;
+use Elastica\Document;
use Elastica\Filter\AbstractGeoShape;
use Elastica\Filter\GeoShapeProvided;
use Elastica\Query\Filtered;
use Elastica\Query\MatchAll;
use Elastica\Test\Base as BaseTest;
+use Elastica\Type\Mapping;
class GeoShapeProvidedTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testConstructEnvelope()
{
- $index = $this->_createIndex('geo_shape_filter_test');
+ $index = $this->_createIndex();
$type = $index->getType('test');
// create mapping
- $mapping = new \Elastica\Type\Mapping($type, array(
+ $mapping = new Mapping($type, array(
'location' => array(
- 'type' => 'geo_shape'
- )
+ 'type' => 'geo_shape',
+ ),
));
$type->setMapping($mapping);
// add docs
- $type->addDocument(new \Elastica\Document(1, array(
+ $type->addDocument(new Document(1, array(
'location' => array(
- "type" => "envelope",
- "coordinates" => array(
+ 'type' => 'envelope',
+ 'coordinates' => array(
array(-50.0, 50.0),
- array(50.0, -50.0)
- )
- )
+ array(50.0, -50.0),
+ ),
+ ),
)));
$index->optimize();
@@ -40,7 +43,7 @@ class GeoShapeProvidedTest extends BaseTest
$envelope = array(
array(25.0, 75.0),
- array(75.0, 25.0)
+ array(75.0, 25.0),
);
$gsp = new GeoShapeProvided('location', $envelope);
@@ -49,11 +52,11 @@ class GeoShapeProvidedTest extends BaseTest
'location' => array(
'shape' => array(
'type' => GeoShapeProvided::TYPE_ENVELOPE,
- 'coordinates' => $envelope
+ 'coordinates' => $envelope,
),
- 'relation' => AbstractGeoShape::RELATION_INTERSECT
+ 'relation' => AbstractGeoShape::RELATION_INTERSECT,
),
- )
+ ),
);
$this->assertEquals($expected, $gsp->toArray());
@@ -62,10 +65,11 @@ class GeoShapeProvidedTest extends BaseTest
$results = $type->search($query);
$this->assertEquals(1, $results->count());
-
- $index->delete();
}
+ /**
+ * @group unit
+ */
public function testConstructPolygon()
{
$polygon = array(array(102.0, 2.0), array(103.0, 2.0), array(103.0, 3.0), array(103.0, 3.0), array(102.0, 2.0));
@@ -76,13 +80,24 @@ class GeoShapeProvidedTest extends BaseTest
'location' => array(
'shape' => array(
'type' => GeoShapeProvided::TYPE_POLYGON,
- 'coordinates' => $polygon
+ 'coordinates' => $polygon,
),
- 'relation' => $gsp->getRelation()
+ 'relation' => $gsp->getRelation(),
),
- )
+ ),
);
$this->assertEquals($expected, $gsp->toArray());
}
-} \ No newline at end of file
+
+ /**
+ * @group unit
+ */
+ public function testSetRelation()
+ {
+ $gsp = new GeoShapeProvided('location', array(array(25.0, 75.0), array(75.0, 25.0)));
+ $gsp->setRelation(AbstractGeoShape::RELATION_INTERSECT);
+ $this->assertEquals(AbstractGeoShape::RELATION_INTERSECT, $gsp->getRelation());
+ $this->assertInstanceOf('Elastica\Filter\GeoShapeProvided', $gsp->setRelation(AbstractGeoShape::RELATION_INTERSECT));
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeohashCellTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeohashCellTest.php
index 7cb8aef6..7ef0d04f 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeohashCellTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeohashCellTest.php
@@ -1,12 +1,17 @@
<?php
-
namespace Elastica\Test\Filter;
-use Elastica\Test\Base as BaseTest;
+use Elastica\Document;
use Elastica\Filter\GeohashCell;
+use Elastica\Query;
+use Elastica\Test\Base as BaseTest;
+use Elastica\Type\Mapping;
class GeohashCellTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$filter = new GeohashCell('pin', array('lat' => 37.789018, 'lon' => -122.391506), '50m');
@@ -14,43 +19,46 @@ class GeohashCellTest extends BaseTest
'geohash_cell' => array(
'pin' => array(
'lat' => 37.789018,
- 'lon' => -122.391506
+ 'lon' => -122.391506,
),
'precision' => '50m',
- 'neighbors' => false
- )
+ 'neighbors' => false,
+ ),
);
$this->assertEquals($expected, $filter->toArray());
}
+ /**
+ * @group functional
+ */
public function testFilter()
{
- $index = $this->_createIndex('geohash_filter_test');
+ $index = $this->_createIndex();
$type = $index->getType('test');
- $mapping = new \Elastica\Type\Mapping($type, array(
+ $mapping = new Mapping($type, array(
'pin' => array(
'type' => 'geo_point',
'geohash' => true,
- 'geohash_prefix' => true
- )
+ 'geohash_prefix' => true,
+ ),
));
$type->setMapping($mapping);
- $type->addDocument(new \Elastica\Document(1, array('pin' => '9q8yyzm0zpw8')));
- $type->addDocument(new \Elastica\Document(2, array('pin' => '9mudgb0yued0')));
+ $type->addDocument(new Document(1, array('pin' => '9q8yyzm0zpw8')));
+ $type->addDocument(new Document(2, array('pin' => '9mudgb0yued0')));
$index->refresh();
$filter = new GeohashCell('pin', array('lat' => 32.828326, 'lon' => -117.255854));
- $query = new \Elastica\Query();
- $query->setFilter($filter);
+ $query = new Query();
+ $query->setPostFilter($filter);
$results = $type->search($query);
$this->assertEquals(1, $results->count());
//test precision parameter
$filter = new GeohashCell('pin', '9', 1);
- $query = new \Elastica\Query();
- $query->setFilter($filter);
+ $query = new Query();
+ $query->setPostFilter($filter);
$results = $type->search($query);
$this->assertEquals(2, $results->count());
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/HasChildTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/HasChildTest.php
index 8bba8173..00af1def 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/HasChildTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/HasChildTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Document;
@@ -9,6 +8,9 @@ use Elastica\Test\Base as BaseTest;
class HasChildTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$q = new MatchAll();
@@ -20,35 +22,71 @@ class HasChildTest extends BaseTest
$expectedArray = array(
'has_child' => array(
'query' => $q->toArray(),
- 'type' => $type
- )
+ 'type' => $type,
+ ),
);
$this->assertEquals($expectedArray, $filter->toArray());
}
- public function testSetScope()
+ /**
+ * @group functional
+ */
+ public function testSetType()
{
- $q = new MatchAll();
+ $index = $this->prepareSearchData();
- $type = 'test';
+ $filter = new HasChild(new MatchAll(), 'type_name');
+ $this->assertEquals('type_name', $filter->getParam('type'));
- $scope = 'foo';
+ $filter->setType('new_type_name');
+ $this->assertEquals('new_type_name', $filter->getParam('type'));
- $filter = new HasChild($q, $type);
- $filter->setScope($scope);
+ $type = $index->getType('foo');
+ $filter = new HasChild(new MatchAll(), $type);
+ $this->assertEquals('foo', $filter->getParam('type'));
- $expectedArray = array(
- 'has_child' => array(
- 'query' => $q->toArray(),
- 'type' => $type,
- '_scope' => $scope
- )
- );
+ $type = $index->getType('bar');
+ $filter->setType($type);
+ $this->assertEquals('bar', $filter->getParam('type'));
- $this->assertEquals($expectedArray, $filter->toArray());
+ $returnValue = $filter->setType('last');
+ $this->assertInstanceOf('Elastica\Filter\HasChild', $returnValue);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetMinimumChildrenCount()
+ {
+ $query = new MatchAll();
+ $filter = new HasChild($query, 'test');
+
+ $filter->setMinimumChildrenCount(2);
+ $this->assertEquals(2, $filter->getParam('min_children'));
+
+ $returnValue = $filter->setMinimumChildrenCount(2);
+ $this->assertInstanceOf('Elastica\Filter\HasChild', $returnValue);
}
+ /**
+ * @group unit
+ */
+ public function testSetMaximumChildrenCount()
+ {
+ $query = new MatchAll();
+ $filter = new HasChild($query, 'test');
+
+ $filter->setMaximumChildrenCount(10);
+ $this->assertEquals(10, $filter->getParam('max_children'));
+
+ $returnValue = $filter->setMaximumChildrenCount(10);
+ $this->assertInstanceOf('Elastica\Filter\HasChild', $returnValue);
+ }
+
+ /**
+ * @group unit
+ */
public function testFilterInsideHasChild()
{
$f = new \Elastica\Filter\MatchAll();
@@ -60,14 +98,16 @@ class HasChildTest extends BaseTest
$expectedArray = array(
'has_child' => array(
'filter' => $f->toArray(),
- 'type' => $type
- )
+ 'type' => $type,
+ ),
);
$this->assertEquals($expectedArray, $filter->toArray());
-
}
+ /**
+ * @group functional
+ */
public function testFilterInsideHasChildSearch()
{
$index = $this->prepareSearchData();
@@ -77,7 +117,7 @@ class HasChildTest extends BaseTest
$filter = new HasChild($f, 'child');
$searchQuery = new \Elastica\Query();
- $searchQuery->setFilter($filter);
+ $searchQuery->setPostFilter($filter);
$searchResults = $index->search($searchQuery);
$this->assertEquals(1, $searchResults->count());
@@ -88,6 +128,9 @@ class HasChildTest extends BaseTest
$this->assertEquals($expected, $result);
}
+ /**
+ * @group functional
+ */
public function testQueryInsideHasChildSearch()
{
$index = $this->prepareSearchData();
@@ -97,7 +140,7 @@ class HasChildTest extends BaseTest
$filter = new HasChild($f, 'child');
$searchQuery = new \Elastica\Query();
- $searchQuery->setFilter($filter);
+ $searchQuery->setPostFilter($filter);
$searchResults = $index->search($searchQuery);
$this->assertEquals(1, $searchResults->count());
@@ -107,24 +150,27 @@ class HasChildTest extends BaseTest
$this->assertEquals($expected, $result);
}
-
+
+ /**
+ * @group functional
+ */
public function testTypeInsideHasChildSearch()
{
$index = $this->prepareSearchData();
-
+
$f = new \Elastica\Query\Match();
$f->setField('alt.name', 'testname');
$filter = new HasChild($f, 'child');
-
+
$searchQuery = new \Elastica\Query();
- $searchQuery->setFilter($filter);
+ $searchQuery->setPostFilter($filter);
$searchResults = $index->search($searchQuery);
-
+
$this->assertEquals(1, $searchResults->count());
-
+
$result = $searchResults->current()->getData();
$expected = array('id' => 'parent2', 'user' => 'parent2', 'email' => 'parent2@test.com');
-
+
$this->assertEquals($expected, $result);
}
@@ -135,7 +181,7 @@ class HasChildTest extends BaseTest
$index->create(array(), true);
$parentType = $index->getType('parent');
-
+
$childType = $index->getType('child');
$childMapping = new \Elastica\Type\Mapping($childType);
$childMapping->setParent('parent');
@@ -144,7 +190,7 @@ class HasChildTest extends BaseTest
$altType = $index->getType('alt');
$altDoc = new Document('alt1', array('name' => 'altname'));
$altType->addDocument($altDoc);
-
+
$parent1 = new Document('parent1', array('id' => 'parent1', 'user' => 'parent1', 'email' => 'parent1@test.com'));
$parentType->addDocument($parent1);
$parent2 = new Document('parent2', array('id' => 'parent2', 'user' => 'parent2', 'email' => 'parent2@test.com'));
@@ -161,6 +207,7 @@ class HasChildTest extends BaseTest
$childType->addDocument($child3);
$index->refresh();
+
return $index;
}
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/HasParentTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/HasParentTest.php
index 7998372b..50143dda 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/HasParentTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/HasParentTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Document;
@@ -9,6 +8,9 @@ use Elastica\Test\Base as BaseTest;
class HasParentTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$q = new MatchAll();
@@ -20,35 +22,41 @@ class HasParentTest extends BaseTest
$expectedArray = array(
'has_parent' => array(
'query' => $q->toArray(),
- 'type' => $type
- )
+ 'type' => $type,
+ ),
);
$this->assertEquals($expectedArray, $filter->toArray());
}
- public function testSetScope()
+ /**
+ * @group functional
+ */
+ public function testSetType()
{
- $q = new MatchAll();
+ $index = $this->prepareSearchData();
- $type = 'test';
+ $filter = new HasParent(new MatchAll(), 'type_name');
+ $this->assertEquals('type_name', $filter->getParam('type'));
- $scope = 'foo';
+ $filter->setType('new_type_name');
+ $this->assertEquals('new_type_name', $filter->getParam('type'));
- $filter = new HasParent($q, $type);
- $filter->setScope($scope);
+ $type = $index->getType('foo');
+ $filter = new HasParent(new MatchAll(), $type);
+ $this->assertEquals('foo', $filter->getParam('type'));
- $expectedArray = array(
- 'has_parent' => array(
- 'query' => $q->toArray(),
- 'type' => $type,
- '_scope' => $scope
- )
- );
+ $type = $index->getType('bar');
+ $filter->setType($type);
+ $this->assertEquals('bar', $filter->getParam('type'));
- $this->assertEquals($expectedArray, $filter->toArray());
+ $returnValue = $filter->setType('last');
+ $this->assertInstanceOf('Elastica\Filter\HasParent', $returnValue);
}
+ /**
+ * @group unit
+ */
public function testFilterInsideHasParent()
{
$f = new \Elastica\Filter\MatchAll();
@@ -60,14 +68,16 @@ class HasParentTest extends BaseTest
$expectedArray = array(
'has_parent' => array(
'filter' => $f->toArray(),
- 'type' => $type
- )
+ 'type' => $type,
+ ),
);
$this->assertEquals($expectedArray, $filter->toArray());
-
}
+ /**
+ * @group functional
+ */
public function testFilterInsideHasParentSearch()
{
$index = $this->prepareSearchData();
@@ -77,7 +87,7 @@ class HasParentTest extends BaseTest
$filter = new HasParent($f, 'parent');
$searchQuery = new \Elastica\Query();
- $searchQuery->setFilter($filter);
+ $searchQuery->setPostFilter($filter);
$searchResults = $index->search($searchQuery);
$this->assertEquals(1, $searchResults->count());
@@ -88,6 +98,9 @@ class HasParentTest extends BaseTest
$this->assertEquals($expected, $result);
}
+ /**
+ * @group functional
+ */
public function testQueryInsideHasParentSearch()
{
$index = $this->prepareSearchData();
@@ -97,7 +110,7 @@ class HasParentTest extends BaseTest
$filter = new HasParent($f, 'parent');
$searchQuery = new \Elastica\Query();
- $searchQuery->setFilter($filter);
+ $searchQuery->setPostFilter($filter);
$searchResults = $index->search($searchQuery);
$this->assertEquals(1, $searchResults->count());
@@ -134,6 +147,7 @@ class HasParentTest extends BaseTest
$childType->addDocument($child2);
$index->refresh();
+
return $index;
}
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/IdsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/IdsTest.php
index 3d6af870..8395f39a 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/IdsTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/IdsTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Document;
@@ -10,81 +9,82 @@ use Elastica\Test\Base as BaseTest;
class IdsTest extends BaseTest
{
- protected $_index;
- protected $_type;
-
- public function setUp()
+ protected function _getIndexForTest()
{
- $client = $this->_getClient();
- $index = $client->getIndex('test');
- $index->create(array(), true);
-
- $type1 = $index->getType('helloworld1');
- $type2 = $index->getType('helloworld2');
+ $index = $this->_createIndex();
// Add documents to first type
+ $docs = array();
for ($i = 1; $i < 100; $i++) {
- $doc = new Document($i, array('name' => 'ruflin'));
- $type1->addDocument($doc);
+ $docs[] = new Document($i, array('name' => 'ruflin'));
}
+ $index->getType('helloworld1')->addDocuments($docs);
// Add documents to second type
+ $docs = array();
for ($i = 1; $i < 100; $i++) {
- $doc = new Document($i, array('name' => 'ruflin'));
- $type2->addDocument($doc);
+ $docs[] = new Document($i, array('name' => 'ruflin'));
}
-
// This is a special id that will only be in the second type
- $doc = new Document('101', array('name' => 'ruflin'));
- $type2->addDocument($doc);
+ $docs[] = new Document(101, array('name' => 'ruflin'));
+ $index->getType('helloworld2')->addDocuments($docs);
$index->optimize();
$index->refresh();
- $this->_type = $type1;
- $this->_index = $index;
+ return $index;
}
- public function tearDown()
+ protected function _getTypeForTest()
{
- $client = $this->_getClient();
- $index = $client->getIndex('test');
- $index->delete();
+ return $this->_getIndexForTest()->getType('helloworld1');
}
+ /**
+ * @group functional
+ */
public function testSetIdsSearchSingle()
{
$filter = new Ids();
$filter->setIds('1');
$query = Query::create($filter);
- $resultSet = $this->_type->search($query);
+ $resultSet = $this->_getTypeForTest()->search($query);
$this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testSetIdsSearchArray()
{
$filter = new Ids();
$filter->setIds(array(1, 7, 13));
$query = Query::create($filter);
- $resultSet = $this->_type->search($query);
+ $resultSet = $this->_getTypeForTest()->search($query);
$this->assertEquals(3, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testAddIdsSearchSingle()
{
$filter = new Ids();
$filter->addId('39');
$query = Query::create($filter);
- $resultSet = $this->_type->search($query);
+ $resultSet = $this->_getTypeForTest()->search($query);
$this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testAddIdsSearchSingleNotInType()
{
$filter = new Ids();
@@ -94,11 +94,14 @@ class IdsTest extends BaseTest
$filter->addId(104);
$query = Query::create($filter);
- $resultSet = $this->_type->search($query);
+ $resultSet = $this->_getTypeForTest()->search($query);
$this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testComboIdsSearchArray()
{
$filter = new Ids();
@@ -106,11 +109,14 @@ class IdsTest extends BaseTest
$filter->addId('39');
$query = Query::create($filter);
- $resultSet = $this->_type->search($query);
+ $resultSet = $this->_getTypeForTest()->search($query);
$this->assertEquals(4, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testSetTypeSingleSearchSingle()
{
$filter = new Ids();
@@ -118,11 +124,14 @@ class IdsTest extends BaseTest
$filter->setType('helloworld1');
$query = Query::create($filter);
- $resultSet = $this->_index->search($query);
+ $resultSet = $this->_getIndexForTest()->search($query);
$this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testSetTypeSingleSearchArray()
{
$filter = new Ids();
@@ -130,11 +139,14 @@ class IdsTest extends BaseTest
$filter->setType('helloworld1');
$query = Query::create($filter);
- $resultSet = $this->_index->search($query);
+ $resultSet = $this->_getIndexForTest()->search($query);
$this->assertEquals(2, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testSetTypeSingleSearchSingleDocInOtherType()
{
$filter = new Ids();
@@ -144,12 +156,15 @@ class IdsTest extends BaseTest
$filter->setType('helloworld1');
$query = Query::create($filter);
- $resultSet = $this->_type->search($query);
+ $resultSet = $this->_getTypeForTest()->search($query);
// ...therefore 0 results should be returned
$this->assertEquals(0, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testSetTypeSingleSearchArrayDocInOtherType()
{
$filter = new Ids();
@@ -159,12 +174,15 @@ class IdsTest extends BaseTest
$filter->setType('helloworld1');
$query = Query::create($filter);
- $resultSet = $this->_type->search($query);
+ $resultSet = $this->_getTypeForTest()->search($query);
// ...therefore only 1 result should be returned
$this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testSetTypeArraySearchArray()
{
$filter = new Ids();
@@ -172,11 +190,14 @@ class IdsTest extends BaseTest
$filter->setType(array('helloworld1', 'helloworld2'));
$query = Query::create($filter);
- $resultSet = $this->_index->search($query);
+ $resultSet = $this->_getIndexForTest()->search($query);
$this->assertEquals(4, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testSetTypeArraySearchSingle()
{
$filter = new Ids();
@@ -184,18 +205,40 @@ class IdsTest extends BaseTest
$filter->setType(array('helloworld1', 'helloworld2'));
$query = Query::create($filter);
- $resultSet = $this->_index->search($query);
+ $resultSet = $this->_getIndexForTest()->search($query);
$this->assertEquals(2, $resultSet->count());
}
+ /**
+ * @group unit
+ */
public function testFilterTypeAndTypeCollision()
{
// This test ensures that Elastica\Type and Elastica\Filter\Type
- // do not collide when used together, which at one point
+ // do not collide when used together, which at one point
// happened because of a use statement in Elastica\Filter\Ids
// Test goal is to make sure a Fatal Error is not triggered
$filterType = new Type();
$filter = new Ids();
}
+
+ /**
+ * @group unit
+ */
+ public function testAddType()
+ {
+ $type = $this->_getClient()->getIndex('indexname')->getType('typename');
+
+ $filter = new Ids();
+
+ $filter->addType('foo');
+ $this->assertEquals(array('foo'), $filter->getParam('type'));
+
+ $filter->addType($type);
+ $this->assertEquals(array('foo', $type->getName()), $filter->getParam('type'));
+
+ $returnValue = $filter->addType('bar');
+ $this->assertInstanceOf('Elastica\Filter\Ids', $returnValue);
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/IndicesTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/IndicesTest.php
index b682a5ce..bc78aa6b 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/IndicesTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/IndicesTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Document;
@@ -13,81 +12,114 @@ use Elastica\Test\Base as BaseTest;
class IndicesTest extends BaseTest
{
/**
- * @var Index
+ * @group unit
*/
- protected $_index1;
-
- /**
- * @var Index
- */
- protected $_index2;
-
- protected function setUp()
- {
- parent::setUp();
- $this->_index1 = $this->_createIndex('indices_filter_1');
- $this->_index2 = $this->_createIndex('indices_filter_2');
- $this->_index1->addAlias("indices_filter");
- $this->_index2->addAlias("indices_filter");
- $docs = array(
- new Document("1", array("color" => "blue")),
- new Document("2", array("color" => "green")),
- new Document("3", array("color" => "blue")),
- new Document("4", array("color" => "yellow")),
- );
- $this->_index1->getType("test")->addDocuments($docs);
- $this->_index2->getType("test")->addDocuments($docs);
- $this->_index1->refresh();
- $this->_index2->refresh();
- }
-
- protected function tearDown()
- {
- $this->_index1->delete();
- $this->_index2->delete();
- parent::tearDown();
- }
-
public function testToArray()
{
$expected = array(
- "indices" => array(
- "indices" => array("index1", "index2"),
- "filter" => array(
- "term" => array("tag" => "wow")
+ 'indices' => array(
+ 'indices' => array('index1', 'index2'),
+ 'filter' => array(
+ 'term' => array('tag' => 'wow'),
),
- "no_match_filter" => array(
- "term" => array("tag" => "such filter")
- )
- )
+ 'no_match_filter' => array(
+ 'term' => array('tag' => 'such filter'),
+ ),
+ ),
);
- $filter = new Indices(new Term(array("tag" => "wow")), array("index1", "index2"));
- $filter->setNoMatchFilter(new Term(array("tag" => "such filter")));
+ $filter = new Indices(new Term(array('tag' => 'wow')), array('index1', 'index2'));
+ $filter->setNoMatchFilter(new Term(array('tag' => 'such filter')));
$this->assertEquals($expected, $filter->toArray());
}
+ /**
+ * @group functional
+ */
public function testIndicesFilter()
{
- $filter = new Indices(new BoolNot(new Term(array("color" => "blue"))), array($this->_index1->getName()));
- $filter->setNoMatchFilter(new BoolNot(new Term(array("color" => "yellow"))));
+ $docs = array(
+ new Document(1, array('color' => 'blue')),
+ new Document(2, array('color' => 'green')),
+ new Document(3, array('color' => 'blue')),
+ new Document(4, array('color' => 'yellow')),
+ );
+
+ $index1 = $this->_createIndex();
+ $index1->addAlias('indices_filter');
+ $index1->getType('test')->addDocuments($docs);
+ $index1->refresh();
+
+ $index2 = $this->_createIndex();
+ $index2->addAlias('indices_filter');
+ $index2->getType('test')->addDocuments($docs);
+ $index2->refresh();
+
+ $filter = new Indices(new BoolNot(new Term(array('color' => 'blue'))), array($index1->getName()));
+ $filter->setNoMatchFilter(new BoolNot(new Term(array('color' => 'yellow'))));
$query = new Query();
- $query->setFilter($filter);
+ $query->setPostFilter($filter);
// search over the alias
- $index = $this->_getClient()->getIndex("indices_filter");
+ $index = $this->_getClient()->getIndex('indices_filter');
$results = $index->search($query);
// ensure that the proper docs have been filtered out for each index
$this->assertEquals(5, $results->count());
foreach ($results->getResults() as $result) {
$data = $result->getData();
- $color = $data["color"];
- if ($result->getIndex() == $this->_index1->getName()) {
- $this->assertNotEquals("blue", $color);
+ $color = $data['color'];
+ if ($result->getIndex() === $index1->getName()) {
+ $this->assertNotEquals('blue', $color);
} else {
- $this->assertNotEquals("yellow", $color);
+ $this->assertNotEquals('yellow', $color);
}
}
}
+
+ /**
+ * @group unit
+ */
+ public function testSetIndices()
+ {
+ $client = $this->_getClient();
+ $index1 = $client->getIndex('index1');
+ $index2 = $client->getIndex('index2');
+
+ $indices = array('one', 'two');
+ $filter = new Indices(new Term(array('color' => 'blue')), $indices);
+ $this->assertEquals($indices, $filter->getParam('indices'));
+
+ $indices[] = 'three';
+ $filter->setIndices($indices);
+ $this->assertEquals($indices, $filter->getParam('indices'));
+
+ $filter->setIndices(array($index1, $index2));
+ $expected = array($index1->getName(), $index2->getName());
+ $this->assertEquals($expected, $filter->getParam('indices'));
+
+ $returnValue = $filter->setIndices($indices);
+ $this->assertInstanceOf('Elastica\Filter\Indices', $returnValue);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testAddIndex()
+ {
+ $client = $this->_getClient();
+ $index = $client->getIndex('someindex');
+
+ $filter = new Indices(new Term(array('color' => 'blue')), array());
+
+ $filter->addIndex($index);
+ $expected = array($index->getName());
+ $this->assertEquals($expected, $filter->getParam('indices'));
+
+ $filter->addIndex('foo');
+ $expected = array($index->getName(), 'foo');
+ $this->assertEquals($expected, $filter->getParam('indices'));
+
+ $returnValue = $filter->addIndex('bar');
+ $this->assertInstanceOf('Elastica\Filter\Indices', $returnValue);
+ }
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/LimitTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/LimitTest.php
new file mode 100644
index 00000000..0cdfee39
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/LimitTest.php
@@ -0,0 +1,34 @@
+<?php
+namespace Elastica\Test\Filter;
+
+use Elastica\Filter\Limit;
+use Elastica\Test\Base as BaseTest;
+
+class LimitTest extends BaseTest
+{
+ /**
+ * @group unit
+ */
+ public function testSetType()
+ {
+ $filter = new Limit(10);
+ $this->assertEquals(10, $filter->getParam('value'));
+
+ $this->assertInstanceOf('Elastica\Filter\Limit', $filter->setLimit(20));
+ $this->assertEquals(20, $filter->getParam('value'));
+ }
+
+ /**
+ * @group unit
+ */
+ public function testToArray()
+ {
+ $filter = new Limit(15);
+
+ $expectedArray = array(
+ 'limit' => array('value' => 15),
+ );
+
+ $this->assertEquals($expectedArray, $filter->toArray());
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MatchAllTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MatchAllTest.php
index 6696f11d..9bfd511f 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MatchAllTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MatchAllTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Filter\MatchAll;
@@ -7,6 +6,9 @@ use Elastica\Test\Base as BaseTest;
class MatchAllTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$filter = new MatchAll();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MissingTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MissingTest.php
new file mode 100644
index 00000000..f87df790
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MissingTest.php
@@ -0,0 +1,78 @@
+<?php
+namespace Elastica\Test\Filter;
+
+use Elastica\Filter\Missing;
+use Elastica\Test\Base as BaseTest;
+
+class MissingTest extends BaseTest
+{
+ /**
+ * @group unit
+ */
+ public function testToArray()
+ {
+ $filter = new Missing('field_name');
+ $expectedArray = array('missing' => array('field' => 'field_name'));
+ $this->assertEquals($expectedArray, $filter->toArray());
+
+ $filter = new Missing('field_name');
+ $filter->setExistence(true);
+ $expectedArray = array('missing' => array('field' => 'field_name', 'existence' => true));
+ $this->assertEquals($expectedArray, $filter->toArray());
+
+ $filter = new Missing('field_name');
+ $filter->setNullValue(true);
+ $expectedArray = array('missing' => array('field' => 'field_name', 'null_value' => true));
+ $this->assertEquals($expectedArray, $filter->toArray());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetField()
+ {
+ $filter = new Missing('field_name');
+
+ $this->assertEquals('field_name', $filter->getParam('field'));
+
+ $filter->setField('new_field_name');
+ $this->assertEquals('new_field_name', $filter->getParam('field'));
+
+ $returnValue = $filter->setField('very_new_field_name');
+ $this->assertInstanceOf('Elastica\Filter\Missing', $returnValue);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetExistence()
+ {
+ $filter = new Missing('field_name');
+
+ $filter->setExistence(true);
+ $this->assertTrue($filter->getParam('existence'));
+
+ $filter->setExistence(false);
+ $this->assertFalse($filter->getParam('existence'));
+
+ $returnValue = $filter->setExistence(true);
+ $this->assertInstanceOf('Elastica\Filter\Missing', $returnValue);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetNullValue()
+ {
+ $filter = new Missing('field_name');
+
+ $filter->setNullValue(true);
+ $this->assertTrue($filter->getParam('null_value'));
+
+ $filter->setNullValue(false);
+ $this->assertFalse($filter->getParam('null_value'));
+
+ $returnValue = $filter->setNullValue(true);
+ $this->assertInstanceOf('Elastica\Filter\Missing', $returnValue);
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MultiTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MultiTest.php
index f6513338..cc8a56e8 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MultiTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MultiTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Filter\AbstractMulti;
@@ -8,6 +7,9 @@ use Elastica\Test\Base as BaseTest;
class AbstractMultiTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testConstruct()
{
$stub = $this->getStub();
@@ -15,6 +17,9 @@ class AbstractMultiTest extends BaseTest
$this->assertEmpty($stub->getFilters());
}
+ /**
+ * @group unit
+ */
public function testAddFilter()
{
$stub = $this->getStub();
@@ -23,12 +28,15 @@ class AbstractMultiTest extends BaseTest
$stub->addFilter($filter);
$expected = array(
- $filter->toArray()
+ $filter->toArray(),
);
$this->assertEquals($expected, $stub->getFilters());
}
+ /**
+ * @group unit
+ */
public function testSetFilters()
{
$stub = $this->getStub();
@@ -37,12 +45,15 @@ class AbstractMultiTest extends BaseTest
$stub->setFilters(array($filter));
$expected = array(
- $filter->toArray()
+ $filter->toArray(),
);
$this->assertEquals($expected, $stub->getFilters());
}
+ /**
+ * @group unit
+ */
public function testToArray()
{
$stub = $this->getStub();
@@ -52,13 +63,16 @@ class AbstractMultiTest extends BaseTest
$expected = array(
$stub->getBaseName() => array(
- $filter->toArray()
- )
+ $filter->toArray(),
+ ),
);
$this->assertEquals($expected, $stub->toArray());
}
+ /**
+ * @group unit
+ */
public function testToArrayWithParam()
{
$stub = $this->getStub();
@@ -72,9 +86,9 @@ class AbstractMultiTest extends BaseTest
$stub->getBaseName() => array(
'_cache' => true,
'filters' => array(
- $filter->toArray()
- )
- )
+ $filter->toArray(),
+ ),
+ ),
);
$this->assertEquals($expected, $stub->toArray());
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NestedFilterWithSetFilterTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NestedFilterWithSetFilterTest.php
index 12dbb598..96a49a77 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NestedFilterWithSetFilterTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NestedFilterWithSetFilterTest.php
@@ -1,121 +1,110 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Document;
use Elastica\Filter\Nested;
use Elastica\Filter\Terms;
use Elastica\Search;
-use Elastica\Type\Mapping;
use Elastica\Test\Base as BaseTest;
+use Elastica\Type\Mapping;
class NestedFilterWithSetFilterTest extends BaseTest
{
- public function setUp()
+ protected function _getIndexForTest()
{
- $client = $this->_getClient();
- $index = $client->getIndex('elastica_test_filter_nested_abstract_filter');
- $index->create(array(), true);
+ $index = $this->_createIndex();
$type = $index->getType('user');
- $mapping = new Mapping();
- $mapping->setProperties(
- array(
- 'firstname' => array('type' => 'string', 'store' => 'yes'),
- // default is store => no expected
- 'lastname' => array('type' => 'string'),
- 'hobbies' => array(
- 'type' => 'nested',
- 'include_in_parent' => true,
- 'properties' => array('hobby' => array('type' => 'string'))
- )
- )
- );
- $type->setMapping($mapping);
- // Adds a list of documents with _bulk upload to the index
- $docs = array();
- $docs[] = new Document(1,
- array(
+ $type->setMapping(new Mapping(null, array(
+ 'firstname' => array('type' => 'string', 'store' => 'yes'),
+ // default is store => no expected
+ 'lastname' => array('type' => 'string'),
+ 'hobbies' => array(
+ 'type' => 'nested',
+ 'include_in_parent' => true,
+ 'properties' => array('hobby' => array('type' => 'string')),
+ ),
+ )));
+
+ $type->addDocuments(array(
+ new Document(1, array(
'firstname' => 'Nicolas',
'lastname' => 'Ruflin',
'hobbies' => array(
- array('hobby' => 'opensource')
- )
- )
- );
- $docs[] = new Document(2,
- array(
+ array('hobby' => 'opensource'),
+ ),
+ )),
+ new Document(2, array(
'firstname' => 'Nicolas',
'lastname' => 'Ippolito',
'hobbies' => array(
array('hobby' => 'opensource'),
array('hobby' => 'guitar'),
- )
- )
- );
- $response = $type->addDocuments($docs);
+ ),
+ )),
+ ));
- // Refresh index
$index->refresh();
- }
- public function tearDown()
- {
- $client = $this->_getClient();
- $index = $client->getIndex('elastica_test_filter_nested_abstract_filter');
- $index->delete();
+ return $index;
}
+ /**
+ * @group unit
+ */
public function testToArray()
{
- $f = new Nested();
- $this->assertEquals(array('nested' => array()), $f->toArray());
- $q = new Terms();
- $q->setTerms('hobby', array('guitar'));
- $f->setPath('hobbies');
- $f->setFilter($q);
+ $filter = new Nested();
+ $this->assertEquals(array('nested' => array()), $filter->toArray());
+ $query = new Terms();
+ $query->setTerms('hobby', array('guitar'));
+ $filter->setPath('hobbies');
+ $filter->setFilter($query);
$expectedArray = array(
'nested' => array(
'path' => 'hobbies',
'filter' => array('terms' => array(
- 'hobby' => array('guitar')
- ))
- )
+ 'hobby' => array('guitar'),
+ )),
+ ),
);
- $this->assertEquals($expectedArray, $f->toArray());
+ $this->assertEquals($expectedArray, $filter->toArray());
}
+ /**
+ * @group functional
+ */
public function testShouldReturnTheRightNumberOfResult()
{
- $f = new Nested();
- $this->assertEquals(array('nested' => array()), $f->toArray());
- $q = new Terms();
- $q->setTerms('hobby', array('guitar'));
- $f->setPath('hobbies');
- $f->setFilter($q);
+ $filter = new Nested();
+ $this->assertEquals(array('nested' => array()), $filter->toArray());
+ $query = new Terms();
+ $query->setTerms('hobby', array('guitar'));
+ $filter->setPath('hobbies');
+ $filter->setFilter($query);
- $c = $this->_getClient();
- $s = new Search($c);
- $i = $c->getIndex('elastica_test_filter_nested_abstract_filter');
- $s->addIndex($i);
- $r = $s->search($f);
+ $client = $this->_getClient();
+ $search = new Search($client);
+ $index = $this->_getIndexForTest();
+ $search->addIndex($index);
+ $resultSet = $search->search($filter);
- $this->assertEquals(1, $r->getTotalHits());
+ $this->assertEquals(1, $resultSet->getTotalHits());
- $f = new Nested();
- $this->assertEquals(array('nested' => array()), $f->toArray());
- $q = new Terms();
- $q->setTerms('hobby', array('opensource'));
- $f->setPath('hobbies');
- $f->setFilter($q);
+ $filter = new Nested();
+ $this->assertEquals(array('nested' => array()), $filter->toArray());
+ $query = new Terms();
+ $query->setTerms('hobby', array('opensource'));
+ $filter->setPath('hobbies');
+ $filter->setFilter($query);
- $c = $this->_getClient();
- $s = new Search($c);
- $i = $c->getIndex('elastica_test_filter_nested_abstract_filter');
- $s->addIndex($i);
- $r = $s->search($f);
- $this->assertEquals(2, $r->getTotalHits());
+ $client = $this->_getClient();
+ $search = new Search($client);
+ $index = $this->_getIndexForTest();
+ $search->addIndex($index);
+ $resultSet = $search->search($filter);
+ $this->assertEquals(2, $resultSet->getTotalHits());
}
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NestedTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NestedTest.php
index 8d0d2004..8eb42d37 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NestedTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NestedTest.php
@@ -1,21 +1,18 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Document;
use Elastica\Filter\Nested;
use Elastica\Query\Terms;
use Elastica\Search;
-use Elastica\Type\Mapping;
use Elastica\Test\Base as BaseTest;
+use Elastica\Type\Mapping;
class NestedTest extends BaseTest
{
- public function setUp()
+ protected function _getIndexForTest()
{
- $client = $this->_getClient();
- $index = $client->getIndex('elastica_test_filter_nested');
- $index->create(array(), true);
+ $index = $this->_createIndex('elastica_test_filter_nested');
$type = $index->getType('user');
$mapping = new Mapping();
$mapping->setProperties(
@@ -26,96 +23,105 @@ class NestedTest extends BaseTest
'hobbies' => array(
'type' => 'nested',
'include_in_parent' => true,
- 'properties' => array('hobby' => array('type' => 'string'))
- )
+ 'properties' => array('hobby' => array('type' => 'string')),
+ ),
)
);
$type->setMapping($mapping);
- // Adds a list of documents with _bulk upload to the index
- $docs = array();
- $docs[] = new Document(1,
- array(
- 'firstname' => 'Nicolas',
- 'lastname' => 'Ruflin',
- 'hobbies' => array(
- array('hobby' => 'opensource')
+ $response = $type->addDocuments(array(
+ new Document(1,
+ array(
+ 'firstname' => 'Nicolas',
+ 'lastname' => 'Ruflin',
+ 'hobbies' => array(
+ array('hobby' => 'opensource'),
+ ),
)
- )
- );
- $docs[] = new Document(2,
- array(
- 'firstname' => 'Nicolas',
- 'lastname' => 'Ippolito',
- 'hobbies' => array(
- array('hobby' => 'opensource'),
- array('hobby' => 'guitar'),
+ ),
+ new Document(2,
+ array(
+ 'firstname' => 'Nicolas',
+ 'lastname' => 'Ippolito',
+ 'hobbies' => array(
+ array('hobby' => 'opensource'),
+ array('hobby' => 'guitar'),
+ ),
)
- )
- );
- $response = $type->addDocuments($docs);
+ ),
+ ));
- // Refresh index
$index->refresh();
- }
- public function tearDown()
- {
- $client = $this->_getClient();
- $index = $client->getIndex('elastica_test_filter_nested');
- $index->delete();
+ return $index;
}
+ /**
+ * @group unit
+ */
public function testToArray()
{
- $f = new Nested();
- $this->assertEquals(array('nested' => array()), $f->toArray());
- $q = new Terms();
- $q->setTerms('hobby', array('guitar'));
- $f->setPath('hobbies');
- $f->setQuery($q);
+ $filter = new Nested();
+ $this->assertEquals(array('nested' => array()), $filter->toArray());
+ $query = new Terms();
+ $query->setTerms('hobby', array('guitar'));
+ $filter->setPath('hobbies');
+ $filter->setQuery($query);
$expectedArray = array(
'nested' => array(
'path' => 'hobbies',
'query' => array('terms' => array(
- 'hobby' => array('guitar')
- ))
- )
+ 'hobby' => array('guitar'),
+ )),
+ ),
);
- $this->assertEquals($expectedArray, $f->toArray());
+ $this->assertEquals($expectedArray, $filter->toArray());
}
+ /**
+ * @group functional
+ */
public function testShouldReturnTheRightNumberOfResult()
{
- $f = new Nested();
- $this->assertEquals(array('nested' => array()), $f->toArray());
- $q = new Terms();
- $q->setTerms('hobby', array('guitar'));
- $f->setPath('hobbies');
- $f->setQuery($q);
-
- $c = $this->_getClient();
- $s = new Search($c);
- $i = $c->getIndex('elastica_test_filter_nested');
- $s->addIndex($i);
- $r = $s->search($f);
-
- $this->assertEquals(1, $r->getTotalHits());
-
- $f = new Nested();
- $this->assertEquals(array('nested' => array()), $f->toArray());
- $q = new Terms();
- $q->setTerms('hobby', array('opensource'));
- $f->setPath('hobbies');
- $f->setQuery($q);
-
- $c = $this->_getClient();
- $s = new Search($c);
- $i = $c->getIndex('elastica_test_filter_nested');
- $s->addIndex($i);
- $r = $s->search($f);
- $this->assertEquals(2, $r->getTotalHits());
+ $filter = new Nested();
+ $this->assertEquals(array('nested' => array()), $filter->toArray());
+ $query = new Terms();
+ $query->setTerms('hobby', array('guitar'));
+ $filter->setPath('hobbies');
+ $filter->setQuery($query);
+
+ $search = new Search($this->_getClient());
+ $search->addIndex($this->_getIndexForTest());
+ $resultSet = $search->search($filter);
+ $this->assertEquals(1, $resultSet->getTotalHits());
+
+ $filter = new Nested();
+ $this->assertEquals(array('nested' => array()), $filter->toArray());
+ $query = new Terms();
+ $query->setTerms('hobby', array('opensource'));
+ $filter->setPath('hobbies');
+ $filter->setQuery($query);
+
+ $search = new Search($this->_getClient());
+ $search->addIndex($this->_getIndexForTest());
+ $resultSet = $search->search($filter);
+ $this->assertEquals(2, $resultSet->getTotalHits());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetJoin()
+ {
+ $filter = new Nested();
+
+ $this->assertTrue($filter->setJoin(true)->getParam('join'));
+
+ $this->assertFalse($filter->setJoin(false)->getParam('join'));
+
+ $returnValue = $filter->setJoin(true);
+ $this->assertInstanceOf('Elastica\Filter\Nested', $returnValue);
}
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NumericRangeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NumericRangeTest.php
index 6cc2de06..590b5137 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NumericRangeTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NumericRangeTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Filter\NumericRange;
@@ -7,6 +6,9 @@ use Elastica\Test\Base as BaseTest;
class NumericRangeTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testAddField()
{
$rangeFilter = new NumericRange();
@@ -14,6 +16,9 @@ class NumericRangeTest extends BaseTest
$this->assertInstanceOf('Elastica\Filter\NumericRange', $returnValue);
}
+ /**
+ * @group unit
+ */
public function testToArray()
{
$filter = new NumericRange();
@@ -23,8 +28,8 @@ class NumericRangeTest extends BaseTest
$expectedArray = array(
'numeric_range' => array(
- 'name' => $fromTo
- )
+ 'name' => $fromTo,
+ ),
);
$this->assertEquals($expectedArray, $filter->toArray());
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/PrefixTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/PrefixTest.php
index 16362140..aab37615 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/PrefixTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/PrefixTest.php
@@ -1,14 +1,16 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Document;
use Elastica\Filter\Prefix;
-use Elastica\Type\Mapping;
use Elastica\Test\Base as BaseTest;
+use Elastica\Type\Mapping;
class PrefixTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$field = 'name';
@@ -18,30 +20,21 @@ class PrefixTest extends BaseTest
$expectedArray = array(
'prefix' => array(
- $field => $prefix
- )
+ $field => $prefix,
+ ),
);
$this->assertequals($expectedArray, $filter->toArray());
}
+ /**
+ * @group functional
+ */
public function testDifferentPrefixes()
{
$client = $this->_getClient();
$index = $client->getIndex('test');
- /*$indexParams = array(
- 'analysis' => array(
- 'analyzer' => array(
- 'lw' => array(
- 'type' => 'custom',
- 'tokenizer' => 'keyword',
- 'filter' => array('lowercase')
- )
- ),
- )
- );*/
-
$index->create(array(), true);
$type = $index->getType('test');
@@ -50,17 +43,13 @@ class PrefixTest extends BaseTest
)
);
$type->setMapping($mapping);
-
- $doc = new Document(1, array('name' => 'Basel-Stadt'));
- $type->addDocument($doc);
- $doc = new Document(2, array('name' => 'New York'));
- $type->addDocument($doc);
- $doc = new Document(3, array('name' => 'Baden'));
- $type->addDocument($doc);
- $doc = new Document(4, array('name' => 'Baden Baden'));
- $type->addDocument($doc);
- $doc = new Document(5, array('name' => 'New Orleans'));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'Basel-Stadt')),
+ new Document(2, array('name' => 'New York')),
+ new Document(3, array('name' => 'Baden')),
+ new Document(4, array('name' => 'Baden Baden')),
+ new Document(5, array('name' => 'New Orleans')),
+ ));
$index->refresh();
@@ -86,6 +75,9 @@ class PrefixTest extends BaseTest
$this->assertEquals(0, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testDifferentPrefixesLowercase()
{
$client = $this->_getClient();
@@ -97,10 +89,10 @@ class PrefixTest extends BaseTest
'lw' => array(
'type' => 'custom',
'tokenizer' => 'keyword',
- 'filter' => array('lowercase')
- )
+ 'filter' => array('lowercase'),
+ ),
),
- )
+ ),
);
$index->create($indexParams, true);
@@ -112,16 +104,13 @@ class PrefixTest extends BaseTest
);
$type->setMapping($mapping);
- $doc = new Document(1, array('name' => 'Basel-Stadt'));
- $type->addDocument($doc);
- $doc = new Document(2, array('name' => 'New York'));
- $type->addDocument($doc);
- $doc = new Document(3, array('name' => 'Baden'));
- $type->addDocument($doc);
- $doc = new Document(4, array('name' => 'Baden Baden'));
- $type->addDocument($doc);
- $doc = new Document(5, array('name' => 'New Orleans'));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'Basel-Stadt')),
+ new Document(2, array('name' => 'New York')),
+ new Document(3, array('name' => 'Baden')),
+ new Document(4, array('name' => 'Baden Baden')),
+ new Document(5, array('name' => 'New Orleans')),
+ ));
$index->refresh();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/QueryTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/QueryTest.php
index 0a331098..23754510 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/QueryTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/QueryTest.php
@@ -1,13 +1,15 @@
<?php
-
namespace Elastica\Test\Filter;
-use Elastica\Query\QueryString;
use Elastica\Filter\Query;
+use Elastica\Query\QueryString;
use Elastica\Test\Base as BaseTest;
class QueryTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testSimple()
{
$query = new QueryString('foo bar');
@@ -17,13 +19,16 @@ class QueryTest extends BaseTest
'query' => array(
'query_string' => array(
'query' => 'foo bar',
- )
- )
+ ),
+ ),
);
$this->assertEquals($expected, $filter->toArray());
}
+ /**
+ * @group unit
+ */
public function testExtended()
{
$query = new QueryString('foo bar');
@@ -37,8 +42,8 @@ class QueryTest extends BaseTest
'query' => 'foo bar',
),
),
- '_cache' => true
- )
+ '_cache' => true,
+ ),
);
$this->assertEquals($expected, $filter->toArray());
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/RangeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/RangeTest.php
index bf2cb260..b7cad3ac 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/RangeTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/RangeTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Filter\Range;
@@ -7,6 +6,9 @@ use Elastica\Test\Base as BaseTest;
class RangeTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testAddField()
{
$rangeFilter = new Range();
@@ -14,19 +16,46 @@ class RangeTest extends BaseTest
$this->assertInstanceOf('Elastica\Filter\Range', $returnValue);
}
+ /**
+ * @group unit
+ */
public function testToArray()
{
+ $field = 'field_name';
+ $range = array('gte' => 10, 'lte' => 99);
+
$filter = new Range();
+ $filter->addField($field, $range);
+ $expectedArray = array('range' => array($field => $range));
+ $this->assertEquals($expectedArray, $filter->toArray());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetExecution()
+ {
+ $field = 'field_name';
+ $range = array('gte' => 10, 'lte' => 99);
+ $filter = new Range('field_name', $range);
- $fromTo = array('from' => 'ra', 'to' => 'ru');
- $filter->addField('name', $fromTo);
+ $filter->setExecution('fielddata');
+ $this->assertEquals('fielddata', $filter->getParam('execution'));
- $expectedArray = array(
- 'range' => array(
- 'name' => $fromTo
- )
- );
+ $returnValue = $filter->setExecution('index');
+ $this->assertInstanceOf('Elastica\Filter\Range', $returnValue);
+ }
- $this->assertEquals($expectedArray, $filter->toArray());
+ /**
+ * Tests that parent fields are not overwritten by the toArray method.
+ *
+ * @group unit
+ */
+ public function testSetCachedNotOverwritten()
+ {
+ $filter = new Range('field_name', array());
+ $filter->setCached(true);
+ $array = $filter->toArray();
+ $this->assertTrue($array['range']['_cache']);
}
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/RegexpTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/RegexpTest.php
index e06064dd..6e3a0395 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/RegexpTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/RegexpTest.php
@@ -1,14 +1,16 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Document;
use Elastica\Filter\Regexp;
-use Elastica\Type\Mapping;
use Elastica\Test\Base as BaseTest;
+use Elastica\Type\Mapping;
class RegexpTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$field = 'name';
@@ -18,13 +20,41 @@ class RegexpTest extends BaseTest
$expectedArray = array(
'regexp' => array(
- $field => $regexp
- )
+ $field => $regexp,
+ ),
);
$this->assertequals($expectedArray, $filter->toArray());
}
+ /**
+ * @group unit
+ */
+ public function testToArrayWithOptions()
+ {
+ $field = 'name';
+ $regexp = 'ruf';
+ $options = array(
+ 'flags' => 'ALL',
+ );
+
+ $filter = new Regexp($field, $regexp, $options);
+
+ $expectedArray = array(
+ 'regexp' => array(
+ $field => array(
+ 'value' => $regexp,
+ 'flags' => 'ALL',
+ ),
+ ),
+ );
+
+ $this->assertequals($expectedArray, $filter->toArray());
+ }
+
+ /**
+ * @group functional
+ */
public function testDifferentRegexp()
{
$client = $this->_getClient();
@@ -38,17 +68,13 @@ class RegexpTest extends BaseTest
)
);
$type->setMapping($mapping);
-
- $doc = new Document(1, array('name' => 'Basel-Stadt'));
- $type->addDocument($doc);
- $doc = new Document(2, array('name' => 'New York'));
- $type->addDocument($doc);
- $doc = new Document(3, array('name' => 'Baden'));
- $type->addDocument($doc);
- $doc = new Document(4, array('name' => 'Baden Baden'));
- $type->addDocument($doc);
- $doc = new Document(5, array('name' => 'New Orleans'));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'Basel-Stadt')),
+ new Document(2, array('name' => 'New York')),
+ new Document(3, array('name' => 'Baden')),
+ new Document(4, array('name' => 'Baden Baden')),
+ new Document(5, array('name' => 'New Orleans')),
+ ));
$index->refresh();
@@ -74,6 +100,9 @@ class RegexpTest extends BaseTest
$this->assertEquals(0, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testDifferentRegexpLowercase()
{
$client = $this->_getClient();
@@ -85,10 +114,10 @@ class RegexpTest extends BaseTest
'lw' => array(
'type' => 'custom',
'tokenizer' => 'keyword',
- 'filter' => array('lowercase')
- )
+ 'filter' => array('lowercase'),
+ ),
),
- )
+ ),
);
$index->create($indexParams, true);
@@ -99,17 +128,13 @@ class RegexpTest extends BaseTest
)
);
$type->setMapping($mapping);
-
- $doc = new Document(1, array('name' => 'Basel-Stadt'));
- $type->addDocument($doc);
- $doc = new Document(2, array('name' => 'New York'));
- $type->addDocument($doc);
- $doc = new Document(3, array('name' => 'Baden'));
- $type->addDocument($doc);
- $doc = new Document(4, array('name' => 'Baden Baden'));
- $type->addDocument($doc);
- $doc = new Document(5, array('name' => 'New Orleans'));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'Basel-Stadt')),
+ new Document(2, array('name' => 'New York')),
+ new Document(3, array('name' => 'Baden')),
+ new Document(4, array('name' => 'Baden Baden')),
+ new Document(5, array('name' => 'New Orleans')),
+ ));
$index->refresh();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/ScriptTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/ScriptTest.php
index 65ea628e..fdec0381 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/ScriptTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/ScriptTest.php
@@ -1,13 +1,15 @@
<?php
-
namespace Elastica\Test\Filter;
-use Elastica\Script;
use Elastica\Filter\Script as ScriptFilter;
+use Elastica\Script;
use Elastica\Test\Base as BaseTest;
class ScriptTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$string = '_score * 2.0';
@@ -20,11 +22,14 @@ class ScriptTest extends BaseTest
$expected = array(
'script' => array(
'script' => $string,
- )
+ ),
);
$this->assertEquals($expected, $array);
}
+ /**
+ * @group unit
+ */
public function testSetScript()
{
$string = '_score * 2.0';
@@ -45,7 +50,7 @@ class ScriptTest extends BaseTest
'script' => $string,
'params' => $params,
'lang' => $lang,
- )
+ ),
);
$this->assertEquals($expected, $array);
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TermTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TermTest.php
index 9a116851..9c8f5a2a 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TermTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TermTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Filter\Term;
@@ -7,7 +6,9 @@ use Elastica\Test\Base as BaseTest;
class TermTest extends BaseTest
{
-
+ /**
+ * @group unit
+ */
public function testToArray()
{
$query = new Term();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TermsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TermsTest.php
index 96994730..bb37ba96 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TermsTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TermsTest.php
@@ -1,54 +1,129 @@
<?php
-
namespace Elastica\Test\Filter;
+use Elastica\Document;
use Elastica\Filter\Terms;
+use Elastica\Query;
use Elastica\Test\Base as BaseTest;
class TermsTest extends BaseTest
{
-
+ /**
+ * @group functional
+ */
public function testLookup()
{
- $index = $this->_createIndex('terms_filter_test');
+ $index = $this->_createIndex();
$type1 = $index->getType('musicians');
$type2 = $index->getType('bands');
//index some test data
- $type1->addDocument(new \Elastica\Document(1, array('name' => 'robert', 'lastName' => 'plant')));
- $type1->addDocument(new \Elastica\Document(2, array('name' => 'jimmy', 'lastName' => 'page')));
- $type1->addDocument(new \Elastica\Document(3, array('name' => 'john paul', 'lastName' => 'jones')));
- $type1->addDocument(new \Elastica\Document(4, array('name' => 'john', 'lastName' => 'bonham')));
- $type1->addDocument(new \Elastica\Document(5, array('name' => 'jimi', 'lastName' => 'hendrix')));
+ $type1->addDocuments(array(
+ new Document(1, array('name' => 'robert', 'lastName' => 'plant')),
+ new Document(2, array('name' => 'jimmy', 'lastName' => 'page')),
+ new Document(3, array('name' => 'john paul', 'lastName' => 'jones')),
+ new Document(4, array('name' => 'john', 'lastName' => 'bonham')),
+ new Document(5, array('name' => 'jimi', 'lastName' => 'hendrix')),
+ ));
- $type2->addDocument(new \Elastica\Document('led zeppelin', array('members' => array('plant', 'page', 'jones', 'bonham'))));
+ $type2->addDocument(new Document('led zeppelin', array('members' => array('plant', 'page', 'jones', 'bonham'))));
$index->refresh();
//use the terms lookup feature to query for some data
$termsFilter = new Terms();
- $termsFilter->setLookup('lastName', $type2, 'led zeppelin', 'members', NULL);
- $query = new \Elastica\Query();
- $query->setFilter($termsFilter);
+ $termsFilter->setLookup('lastName', $type2, 'led zeppelin', 'members', null);
+ $query = new Query();
+ $query->setPostFilter($termsFilter);
$results = $index->search($query);
$this->assertEquals($results->count(), 4, 'Terms lookup with null index');
-
+
$termsFilter->setLookup('lastName', $type2, 'led zeppelin', 'members', $index);
- $query->setFilter($termsFilter);
+ $query->setPostFilter($termsFilter);
$results = $index->search($query);
$this->assertEquals($results->count(), 4, 'Terms lookup with index as object');
-
+
//Query with index given as string
$termsFilter->setLookup('lastName', $type2, 'led zeppelin', 'members', $index->getName());
- $query->setFilter($termsFilter);
+ $query->setPostFilter($termsFilter);
$results = $index->search($query);
$this->assertEquals($results->count(), 4, 'Terms lookup with index as string');
-
+
//Query with array of options
$termsFilter->setLookup('lastName', $type2, 'led zeppelin', 'members', array('index' => $index, 'cache' => false));
- $query->setFilter($termsFilter);
+ $query->setPostFilter($termsFilter);
$results = $index->search($query);
$this->assertEquals($results->count(), 4, 'Terms lookup with options array');
-
+
$index->delete();
}
+
+ /**
+ * @group unit
+ */
+ public function testSetExecution()
+ {
+ $filter = new Terms('color', array('blue', 'green'));
+
+ $filter->setExecution('bool');
+ $this->assertEquals('bool', $filter->getParam('execution'));
+
+ $returnValue = $filter->setExecution('bool');
+ $this->assertInstanceOf('Elastica\Filter\Terms', $returnValue);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetTerms()
+ {
+ $field = 'color';
+ $terms = array('blue', 'green');
+
+ $filter = new Terms();
+ $filter->setTerms($field, $terms);
+ $expected = array('terms' => array($field => $terms));
+ $this->assertEquals($expected, $filter->toArray());
+
+ $returnValue = $filter->setTerms($field, $terms);
+ $this->assertInstanceOf('Elastica\Filter\Terms', $returnValue);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testAddTerm()
+ {
+ $filter = new Terms('color', array('blue'));
+
+ $filter->addTerm('green');
+ $expected = array('terms' => array('color' => array('blue', 'green')));
+ $this->assertEquals($expected, $filter->toArray());
+
+ $returnValue = $filter->addTerm('cyan');
+ $this->assertInstanceOf('Elastica\Filter\Terms', $returnValue);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testToArray()
+ {
+ $filter = new Terms('color', array());
+ $expected = array('terms' => array('color' => array()));
+ $this->assertEquals($expected, $filter->toArray());
+
+ $filter = new Terms('color', array('cyan'));
+ $expected = array('terms' => array('color' => array('cyan')));
+ $this->assertEquals($expected, $filter->toArray());
+ }
+
+ /**
+ * @group unit
+ * @expectedException \Elastica\Exception\InvalidException
+ */
+ public function testToArrayInvalidException()
+ {
+ $filter = new Terms();
+ $filter->toArray();
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TypeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TypeTest.php
index fcada826..8da19273 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TypeTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TypeTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Filter\Type;
@@ -7,6 +6,9 @@ use Elastica\Test\Base as BaseTest;
class TypeTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testSetType()
{
$typeFilter = new Type();
@@ -14,12 +16,15 @@ class TypeTest extends BaseTest
$this->assertInstanceOf('Elastica\Filter\Type', $returnValue);
}
+ /**
+ * @group unit
+ */
public function testToArray()
{
$typeFilter = new Type('type_name');
$expectedArray = array(
- 'type' => array('value' => 'type_name')
+ 'type' => array('value' => 'type_name'),
);
$this->assertEquals($expectedArray, $typeFilter->toArray());
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Index/SettingsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Index/SettingsTest.php
index 4f74d22b..1562c7a0 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Index/SettingsTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Index/SettingsTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Index;
use Elastica\Document;
@@ -10,6 +9,9 @@ use Elastica\Test\Base as BaseTest;
class SettingsTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testGet()
{
$indexName = 'elasticatest';
@@ -28,6 +30,9 @@ class SettingsTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testGetWithAlias()
{
$indexName = 'elasticatest';
@@ -50,6 +55,9 @@ class SettingsTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testSetNumberOfReplicas()
{
$indexName = 'test';
@@ -70,6 +78,9 @@ class SettingsTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testSetRefreshInterval()
{
$indexName = 'test';
@@ -91,6 +102,9 @@ class SettingsTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testGetRefreshInterval()
{
$indexName = 'test';
@@ -112,6 +126,9 @@ class SettingsTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testSetMergePolicy()
{
$indexName = 'test';
@@ -133,6 +150,9 @@ class SettingsTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testSetMergeFactor()
{
$indexName = 'test';
@@ -157,6 +177,9 @@ class SettingsTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testSetMergePolicyType()
{
$indexName = 'test';
@@ -181,14 +204,16 @@ class SettingsTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testSetReadOnly()
{
- $index = $this->_createIndex('test');
+ $index = $this->_createIndex();
//wait for the shards to be allocated
$this->_waitForAllocation($index);
$index->getSettings()->setReadOnly(false);
-
// Add document to normal index
$doc1 = new Document(null, array('hello' => 'world'));
$doc2 = new Document(null, array('hello' => 'world'));
@@ -196,11 +221,11 @@ class SettingsTest extends BaseTest
$type = $index->getType('test');
$type->addDocument($doc1);
- $this->assertEquals('false', $index->getSettings()->get('blocks.read_only')); //ES returns a string for this setting
+ $this->assertFalse($index->getSettings()->getReadOnly());
// Try to add doc to read only index
$index->getSettings()->setReadOnly(true);
- $this->assertEquals('true', $index->getSettings()->get('blocks.read_only'));
+ $this->assertTrue($index->getSettings()->getReadOnly());
try {
$type->addDocument($doc2);
@@ -208,7 +233,7 @@ class SettingsTest extends BaseTest
} catch (ResponseException $e) {
$message = $e->getMessage();
$this->assertContains('ClusterBlockException', $message);
- $this->assertContains('index read-only', $message);
+ $this->assertContains('index write', $message);
}
// Remove read only, add document
@@ -223,10 +248,12 @@ class SettingsTest extends BaseTest
$index->delete();
}
-
+ /**
+ * @group functional
+ */
public function testGetSetBlocksRead()
{
- $index = $this->_createIndex('elastica-test');
+ $index = $this->_createIndex();
$index->refresh();
$settings = $index->getSettings();
@@ -244,9 +271,12 @@ class SettingsTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testGetSetBlocksWrite()
{
- $index = $this->_createIndex('elastica-test');
+ $index = $this->_createIndex();
$index->refresh();
$settings = $index->getSettings();
@@ -264,9 +294,12 @@ class SettingsTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testGetSetBlocksMetadata()
{
- $index = $this->_createIndex('elastica-test');
+ $index = $this->_createIndex();
$index->refresh();
$settings = $index->getSettings();
@@ -285,16 +318,21 @@ class SettingsTest extends BaseTest
$index->delete();
}
- protected function _waitForAllocation(Index $index)
+ /**
+ * @group functional
+ */
+ public function testNotFoundIndex()
{
- do {
- $settings = $index->getStatus()->get();
- $allocated = true;
- foreach ($settings['shards'] as $shard) {
- if ($shard[0]['routing']['state'] != 'STARTED') {
- $allocated = false;
- }
- }
- } while (!$allocated);
+ $client = $this->_getClient();
+ $index = $client->getIndex('not_found_index');
+ //wait for the shards to be allocated
+
+ try {
+ $settings = $index->getSettings()->get();
+ $this->fail('Should throw exception because of index not found');
+ } catch (ResponseException $e) {
+ $message = $e->getMessage();
+ $this->assertContains('IndexMissingException', $message);
+ }
}
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Index/StatsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Index/StatsTest.php
index 5e8e8d57..d0bb7838 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Index/StatsTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Index/StatsTest.php
@@ -1,12 +1,13 @@
<?php
-
namespace Elastica\Test\Index;
use Elastica\Test\Base as BaseTest;
class StatsTest extends BaseTest
{
-
+ /**
+ * @group functional
+ */
public function testGetSettings()
{
$indexName = 'test';
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Index/StatusTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Index/StatusTest.php
index 8a056a53..24f22ffd 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Index/StatusTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Index/StatusTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Index;
use Elastica\Index\Status as IndexStatus;
@@ -7,6 +6,9 @@ use Elastica\Test\Base as BaseTest;
class StatusTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testGetAliases()
{
$indexName = 'test';
@@ -31,6 +33,9 @@ class StatusTest extends BaseTest
$this->assertTrue(in_array($aliasName, $aliases));
}
+ /**
+ * @group functional
+ */
public function testHasAlias()
{
$indexName = 'test';
@@ -50,6 +55,9 @@ class StatusTest extends BaseTest
$this->assertTrue($status->hasAlias($aliasName));
}
+ /**
+ * @group functional
+ */
public function testGetSettings()
{
$indexName = 'test';
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/IndexTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/IndexTest.php
index 8e4ac306..25ac53c2 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/IndexTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/IndexTest.php
@@ -1,21 +1,23 @@
<?php
-
namespace Elastica\Test;
-use Elastica\Client;
use Elastica\Document;
use Elastica\Exception\ResponseException;
use Elastica\Index;
+use Elastica\Query\HasChild;
use Elastica\Query\QueryString;
+use Elastica\Query\SimpleQueryString;
use Elastica\Query\Term;
use Elastica\Status;
+use Elastica\Test\Base as BaseTest;
use Elastica\Type;
use Elastica\Type\Mapping;
-use Elastica\Query\HasChild;
-use Elastica\Test\Base as BaseTest;
class IndexTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testMapping()
{
$index = $this->_createIndex();
@@ -41,13 +43,15 @@ class IndexTest extends BaseTest
$result = $type->search('hanswurst');
}
- public function testGetMappingAlias() {
+ /**
+ * @group functional
+ */
+ public function testGetMappingAlias()
+ {
+ $index = $this->_createIndex();
+ $indexName = $index->getName();
- $indexName = 'test-mapping';
$aliasName = 'test-mapping-alias';
-
- $index = $this->_createIndex($indexName);
- $indexName = $index->getName();
$index->addAlias($aliasName);
$type = new Type($index, 'test');
@@ -71,6 +75,9 @@ class IndexTest extends BaseTest
$this->assertEquals($mapping1, $mapping2);
}
+ /**
+ * @group functional
+ */
public function testParent()
{
$index = $this->_createIndex();
@@ -108,12 +115,15 @@ class IndexTest extends BaseTest
$this->assertEquals(array('title' => 'Foo bar'), $resultSet->current()->getData());
}
+ /**
+ * @group functional
+ */
public function testAddPdfFile()
{
$this->_checkAttachmentsPlugin();
- $indexMapping = array('file' => array('type' => 'attachment', 'store' => 'no'), 'text' => array('type' => 'string', 'store' => 'no'),);
+ $indexMapping = array('file' => array('type' => 'attachment', 'store' => 'no'), 'text' => array('type' => 'string', 'store' => 'no'));
- $indexParams = array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0),);
+ $indexParams = array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0));
$index = $this->_createIndex();
$type = new Type($index, 'test');
@@ -122,7 +132,7 @@ class IndexTest extends BaseTest
$type->setMapping($indexMapping);
$doc1 = new Document(1);
- $doc1->addFile('file', BASE_PATH . '/data/test.pdf', 'application/pdf');
+ $doc1->addFile('file', BASE_PATH.'/data/test.pdf', 'application/pdf');
$doc1->set('text', 'basel world');
$type->addDocument($doc1);
@@ -147,12 +157,15 @@ class IndexTest extends BaseTest
$this->assertEquals(0, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testAddPdfFileContent()
{
$this->_checkAttachmentsPlugin();
- $indexMapping = array('file' => array('type' => 'attachment', 'store' => 'no'), 'text' => array('type' => 'string', 'store' => 'no'),);
+ $indexMapping = array('file' => array('type' => 'attachment', 'store' => 'no'), 'text' => array('type' => 'string', 'store' => 'no'));
- $indexParams = array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0),);
+ $indexParams = array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0));
$index = $this->_createIndex();
$type = new Type($index, 'test');
@@ -161,7 +174,7 @@ class IndexTest extends BaseTest
$type->setMapping($indexMapping);
$doc1 = new Document(1);
- $doc1->addFileContent('file', file_get_contents(BASE_PATH . '/data/test.pdf'));
+ $doc1->addFileContent('file', file_get_contents(BASE_PATH.'/data/test.pdf'));
$doc1->set('text', 'basel world');
$type->addDocument($doc1);
@@ -186,12 +199,15 @@ class IndexTest extends BaseTest
$this->assertEquals(0, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testAddWordxFile()
{
$this->_checkAttachmentsPlugin();
- $indexMapping = array('file' => array('type' => 'attachment'), 'text' => array('type' => 'string', 'store' => 'no'),);
+ $indexMapping = array('file' => array('type' => 'attachment'), 'text' => array('type' => 'string', 'store' => 'no'));
- $indexParams = array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0),);
+ $indexParams = array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0));
$index = $this->_createIndex();
$type = new Type($index, 'content');
@@ -200,33 +216,40 @@ class IndexTest extends BaseTest
$type->setMapping($indexMapping);
$doc1 = new Document(1);
- $doc1->addFile('file', BASE_PATH . '/data/test.docx');
+ $doc1->addFile('file', BASE_PATH.'/data/test.docx');
$doc1->set('text', 'basel world');
$type->addDocument($doc1);
+ $index->optimize();
+ $index->refresh();
+
$doc2 = new Document(2);
$doc2->set('text', 'running in basel');
$type->addDocument($doc2);
$index->optimize();
-
- $resultSet = $type->search('xodoa');
- $this->assertEquals(1, $resultSet->count());
+ $index->refresh();
$resultSet = $type->search('basel');
$this->assertEquals(2, $resultSet->count());
$resultSet = $type->search('ruflin');
$this->assertEquals(0, $resultSet->count());
+
+ $resultSet = $type->search('xodoa');
+ $this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testExcludeFileSource()
{
$this->_checkAttachmentsPlugin();
$indexMapping = array('file' => array('type' => 'attachment', 'store' => 'yes'), 'text' => array('type' => 'string', 'store' => 'yes'),
'title' => array('type' => 'string', 'store' => 'yes'),);
- $indexParams = array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0),);
+ $indexParams = array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0));
$index = $this->_createIndex();
$type = new Type($index, 'content');
@@ -244,7 +267,7 @@ class IndexTest extends BaseTest
$title = 'No Title';
$doc1 = new Document($docId);
- $doc1->addFile('file', BASE_PATH . '/data/test.docx');
+ $doc1->addFile('file', BASE_PATH.'/data/test.docx');
$doc1->set('text', $text);
$doc1->set('title', $title);
$type->addDocument($doc1);
@@ -259,6 +282,7 @@ class IndexTest extends BaseTest
}
/**
+ * @group functional
* @expectedException \Elastica\Exception\ResponseException
*/
public function testAddRemoveAlias()
@@ -297,6 +321,9 @@ class IndexTest extends BaseTest
$client->getIndex($aliasName)->getType($typeName)->search('ruflin');
}
+ /**
+ * @group functional
+ */
public function testCount()
{
$index = $this->_createIndex();
@@ -309,7 +336,6 @@ class IndexTest extends BaseTest
$type->addDocument($doc1);
$type->addDocument($doc2);
-
$index->refresh();
$this->assertEquals(2, $index->count());
@@ -322,6 +348,123 @@ class IndexTest extends BaseTest
$this->assertEquals(1, $index->count($query));
}
+ /**
+ * @group functional
+ */
+ public function testDeleteByQueryWithQueryString()
+ {
+ $index = $this->_createIndex();
+ $type1 = new Type($index, 'test1');
+ $type1->addDocument(new Document(1, array('name' => 'ruflin nicolas')));
+ $type1->addDocument(new Document(2, array('name' => 'ruflin')));
+ $type2 = new Type($index, 'test2');
+ $type2->addDocument(new Document(1, array('name' => 'ruflin nicolas')));
+ $type2->addDocument(new Document(2, array('name' => 'ruflin')));
+ $index->refresh();
+
+ $response = $index->search('ruflin*');
+ $this->assertEquals(4, $response->count());
+
+ $response = $index->search('nicolas');
+ $this->assertEquals(2, $response->count());
+
+ // Delete first document
+ $response = $index->deleteByQuery('nicolas');
+ $this->assertTrue($response->isOk());
+
+ $index->refresh();
+
+ // Makes sure, document is deleted
+ $response = $index->search('ruflin*');
+ $this->assertEquals(2, $response->count());
+
+ $response = $index->search('nicolas');
+ $this->assertEquals(0, $response->count());
+ }
+
+ /**
+ * @group functional
+ */
+ public function testDeleteByQueryWithQuery()
+ {
+ $index = $this->_createIndex();
+ $type1 = new Type($index, 'test1');
+ $type1->addDocument(new Document(1, array('name' => 'ruflin nicolas')));
+ $type1->addDocument(new Document(2, array('name' => 'ruflin')));
+ $type2 = new Type($index, 'test2');
+ $type2->addDocument(new Document(1, array('name' => 'ruflin nicolas')));
+ $type2->addDocument(new Document(2, array('name' => 'ruflin')));
+ $index->refresh();
+
+ $response = $index->search('ruflin*');
+ $this->assertEquals(4, $response->count());
+
+ $response = $index->search('nicolas');
+ $this->assertEquals(2, $response->count());
+
+ // Delete first document
+ $response = $index->deleteByQuery(new SimpleQueryString('nicolas'));
+ $this->assertTrue($response->isOk());
+
+ $index->refresh();
+
+ // Makes sure, document is deleted
+ $response = $index->search('ruflin*');
+ $this->assertEquals(2, $response->count());
+
+ $response = $index->search('nicolas');
+ $this->assertEquals(0, $response->count());
+ }
+
+ /**
+ * @group functional
+ */
+ public function testDeleteByQueryWithQueryAndOptions()
+ {
+ $index = $this->_createIndex(null, true, 2);
+ $type1 = new Type($index, 'test1');
+ $type1->addDocument(new Document(1, array('name' => 'ruflin nicolas')));
+ $type1->addDocument(new Document(2, array('name' => 'ruflin')));
+ $type2 = new Type($index, 'test2');
+ $type2->addDocument(new Document(1, array('name' => 'ruflin nicolas')));
+ $type2->addDocument(new Document(2, array('name' => 'ruflin')));
+ $index->refresh();
+
+ $response = $index->search('ruflin*');
+ $this->assertEquals(4, $response->count());
+
+ $response = $index->search('nicolas');
+ $this->assertEquals(2, $response->count());
+
+ // Route to the wrong document id; should not delete
+ $response = $index->deleteByQuery(new SimpleQueryString('nicolas'), array('routing' => '2'));
+ $this->assertTrue($response->isOk());
+
+ $index->refresh();
+
+ $response = $index->search('ruflin*');
+ $this->assertEquals(4, $response->count());
+
+ $response = $index->search('nicolas');
+ $this->assertEquals(2, $response->count());
+
+ // Delete first document
+ $response = $index->deleteByQuery(new SimpleQueryString('nicolas'), array('routing' => '1'));
+ $this->assertTrue($response->isOk());
+
+ $index->refresh();
+
+ // Makes sure, document is deleted
+ $response = $index->search('ruflin*');
+ $this->assertEquals(2, $response->count());
+
+ $response = $index->search('nicolas');
+ $this->assertEquals(0, $response->count());
+ }
+
+ /**
+ * @group functional
+ */
public function testDeleteIndexDeleteAlias()
{
$indexName = 'test';
@@ -345,6 +488,9 @@ class IndexTest extends BaseTest
$this->assertFalse($status->aliasExists($aliasName));
}
+ /**
+ * @group functional
+ */
public function testAddAliasTwoIndices()
{
$indexName1 = 'test1';
@@ -356,8 +502,10 @@ class IndexTest extends BaseTest
$index2 = $client->getIndex($indexName2);
$index1->create(array(), true);
+ $this->_waitForAllocation($index1);
$index1->addAlias($aliasName);
$index2->create(array(), true);
+ $this->_waitForAllocation($index2);
$index1->refresh();
$index2->refresh();
@@ -366,7 +514,6 @@ class IndexTest extends BaseTest
$status = new Status($client);
-
$this->assertTrue($status->indexExists($indexName1));
$this->assertTrue($status->indexExists($indexName2));
@@ -379,6 +526,9 @@ class IndexTest extends BaseTest
$this->assertTrue($index2->getStatus()->hasAlias($aliasName));
}
+ /**
+ * @group functional
+ */
public function testReplaceAlias()
{
$indexName1 = 'test1';
@@ -409,6 +559,9 @@ class IndexTest extends BaseTest
$this->assertTrue($index2->getStatus()->hasAlias($aliasName));
}
+ /**
+ * @group functional
+ */
public function testAddDocumentVersion()
{
$client = $this->_getClient();
@@ -428,24 +581,29 @@ class IndexTest extends BaseTest
$this->assertEquals(2, $data['_version']);
}
+ /**
+ * @group functional
+ */
public function testClearCache()
{
- $client = $this->_getClient();
- $index1 = $client->getIndex('test1');
-
- $response = $index1->clearCache();
+ $index = $this->_createIndex();
+ $response = $index->clearCache();
$this->assertFalse($response->hasError());
}
+ /**
+ * @group functional
+ */
public function testFlush()
{
- $client = $this->_getClient();
- $index = $client->getIndex('test1');
-
+ $index = $this->_createIndex();
$response = $index->flush();
$this->assertFalse($response->hasError());
}
+ /**
+ * @group functional
+ */
public function testExists()
{
$index = $this->_createIndex();
@@ -458,11 +616,13 @@ class IndexTest extends BaseTest
}
/**
- * Test $index->delete() return value for unknown index
+ * Test $index->delete() return value for unknown index.
*
* Tests if deleting an index that does not exist in Elasticsearch,
* correctly returns a boolean true from the hasError() method of
* the \Elastica\Response object
+ *
+ * @group functional
*/
public function testDeleteMissingIndexHasError()
{
@@ -481,7 +641,9 @@ class IndexTest extends BaseTest
}
/**
- * Tests to see if the test type mapping exists when calling $index->getMapping()
+ * Tests to see if the test type mapping exists when calling $index->getMapping().
+ *
+ * @group functional
*/
public function testIndexGetMapping()
{
@@ -504,6 +666,8 @@ class IndexTest extends BaseTest
/**
* Tests to see if the index is empty when there are no types set.
+ *
+ * @group functional
*/
public function testEmptyIndexGetMapping()
{
@@ -514,7 +678,9 @@ class IndexTest extends BaseTest
}
/**
- * Test to see if search Default Limit works
+ * Test to see if search Default Limit works.
+ *
+ * @group functional
*/
public function testLimitDefaultIndex()
{
@@ -551,6 +717,8 @@ class IndexTest extends BaseTest
/**
* @expectedException \Elastica\Exception\InvalidException
+ *
+ * @group functional
*/
public function testCreateArray()
{
@@ -560,22 +728,28 @@ class IndexTest extends BaseTest
//Testing recreate (backward compatibility)
$index = $client->getIndex($indexName);
$index->create(array(), true);
+ $this->_waitForAllocation($index);
$status = new Status($client);
$this->assertTrue($status->indexExists($indexName));
//Testing create index with array options
$opts = array('recreate' => true, 'routing' => 'r1,r2');
$index->create(array(), $opts);
+ $this->_waitForAllocation($index);
$status = new Status($client);
$this->assertTrue($status->indexExists($indexName));
//Testing invalid options
$opts = array('recreate' => true, 'routing' => 'r1,r2', 'testing_invalid_option' => true);
$index->create(array(), $opts);
+ $this->_waitForAllocation($index);
$status = new Status($client);
$this->assertTrue($status->indexExists($indexName));
}
+ /**
+ * @group functional
+ */
public function testCreateSearch()
{
$client = $this->_getClient();
@@ -589,10 +763,10 @@ class IndexTest extends BaseTest
$expected = array(
'query' => array(
'query_string' => array(
- 'query' => 'test'
- )
+ 'query' => 'test',
+ ),
),
- 'size' => 5
+ 'size' => 5,
);
$this->assertEquals($expected, $search->getQuery()->toArray());
$this->assertEquals(array('test'), $search->getIndices());
@@ -607,6 +781,9 @@ class IndexTest extends BaseTest
$this->assertFalse($search->hasType($type));
}
+ /**
+ * @group functional
+ */
public function testSearch()
{
$index = $this->_createIndex();
@@ -636,6 +813,9 @@ class IndexTest extends BaseTest
$this->assertEquals(3, $count);
}
+ /**
+ * @group functional
+ */
public function testOptimize()
{
$index = $this->_createIndex();
@@ -663,9 +843,12 @@ class IndexTest extends BaseTest
$this->assertEquals(0, $stats['_all']['primaries']['docs']['deleted']);
}
+ /**
+ * @group functional
+ */
public function testAnalyze()
{
- $index = $this->_createIndex('analyze');
+ $index = $this->_createIndex();
$index->optimize();
sleep(2);
$returnedTokens = $index->analyze('foo');
@@ -677,13 +860,35 @@ class IndexTest extends BaseTest
'end_offset' => 3,
'type' => '<ALPHANUM>',
'position' => 1,
- )
+ ),
);
$this->assertEquals($tokens, $returnedTokens);
}
/**
+ * @group unit
+ * @expectedException \Elastica\Exception\InvalidException
+ */
+ public function testThrowExceptionIfNotScalar()
+ {
+ $client = $this->_getClient();
+ $client->getIndex(new \stdClass());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testConvertScalarsToString()
+ {
+ $client = $this->_getClient();
+ $index = $client->getIndex(1);
+
+ $this->assertEquals('1', $index->getName());
+ $this->assertInternalType('string', $index->getName());
+ }
+
+ /**
* Check for the presence of the mapper-attachments plugin and skip the current test if it is not found.
*/
protected function _checkAttachmentsPlugin()
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/LogTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/LogTest.php
index 188be933..fdfc5c00 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/LogTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/LogTest.php
@@ -1,8 +1,6 @@
<?php
-
namespace Elastica\Test;
-use Elastica\Client;
use Elastica\Log;
use Elastica\Test\Base as BaseTest;
use Psr\Log\LogLevel;
@@ -12,45 +10,63 @@ class LogTest extends BaseTest
private $_context = array();
private $_message = 'hello world';
- protected function setUp()
+ public static function setUpBeforeClass()
{
if (!class_exists('Psr\Log\AbstractLogger')) {
- $this->markTestSkipped('The Psr extension is not available.');
+ self::markTestSkipped('The Psr extension is not available.');
}
}
+ /**
+ * @group unit
+ */
public function testLogInterface()
{
$log = new Log();
$this->assertInstanceOf('Psr\Log\LoggerInterface', $log);
}
+ /**
+ * @group unit
+ */
public function testSetLogConfigPath()
{
$logPath = '/tmp/php.log';
- $client = new Client(array('log' => $logPath));
+ $client = $this->_getClient(array('log' => $logPath));
$this->assertEquals($logPath, $client->getConfig('log'));
}
+ /**
+ * @group unit
+ */
public function testSetLogConfigEnable()
{
- $client = new Client(array('log' => true));
+ $client = $this->_getClient(array('log' => true));
$this->assertTrue($client->getConfig('log'));
}
+ /**
+ * @group unit
+ */
public function testSetLogConfigEnable1()
{
- $client = new Client();
+ $client = $this->_getClient();
$client->setLogger(new Log());
$this->assertFalse($client->getConfig('log'));
}
+ /**
+ * @group unit
+ */
public function testEmptyLogConfig()
{
$client = $this->_getClient();
$this->assertEmpty($client->getConfig('log'));
}
+ /**
+ * @group unit
+ */
public function testGetLastMessage()
{
$log = new Log('/tmp/php.log');
@@ -63,14 +79,17 @@ class LogTest extends BaseTest
$this->assertEquals($message, $log->getLastMessage());
}
+ /**
+ * @group unit
+ */
public function testGetLastMessage2()
{
- $client = new Client(array('log' => true));
+ $client = $this->_getClient(array('log' => true));
$log = new Log($client);
// Set log path temp path as otherwise test fails with output
$errorLog = ini_get('error_log');
- ini_set('error_log', sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'php.log');
+ ini_set('error_log', sys_get_temp_dir().DIRECTORY_SEPARATOR.'php.log');
$this->_context['error_message'] = $this->_message;
$message = json_encode($this->_context);
@@ -81,6 +100,9 @@ class LogTest extends BaseTest
$this->assertEquals($message, $log->getLastMessage());
}
+ /**
+ * @group unit
+ */
public function testGetLastMessageInfo()
{
$log = $this->initLog();
@@ -88,6 +110,9 @@ class LogTest extends BaseTest
$this->assertEquals($this->getMessage(), $log->getLastMessage());
}
+ /**
+ * @group unit
+ */
public function testGetLastMessageCritical()
{
$log = $this->initLog();
@@ -95,6 +120,9 @@ class LogTest extends BaseTest
$this->assertEquals($this->getMessage(), $log->getLastMessage());
}
+ /**
+ * @group unit
+ */
public function testGetLastMessageAlert()
{
$log = $this->initLog();
@@ -102,6 +130,9 @@ class LogTest extends BaseTest
$this->assertEquals($this->getMessage(), $log->getLastMessage());
}
+ /**
+ * @group unit
+ */
public function testGetLastMessageDebug()
{
$log = $this->initLog();
@@ -109,6 +140,9 @@ class LogTest extends BaseTest
$this->assertEquals($this->getMessage(), $log->getLastMessage());
}
+ /**
+ * @group unit
+ */
public function testGetLastMessageEmergency()
{
$log = $this->initLog();
@@ -116,6 +150,9 @@ class LogTest extends BaseTest
$this->assertEquals($this->getMessage(), $log->getLastMessage());
}
+ /**
+ * @group unit
+ */
public function testGetLastMessageError()
{
$log = $this->initLog();
@@ -123,6 +160,9 @@ class LogTest extends BaseTest
$this->assertEquals($this->getMessage(), $log->getLastMessage());
}
+ /**
+ * @group unit
+ */
public function testGetLastMessageNotice()
{
$log = $this->initLog();
@@ -130,6 +170,9 @@ class LogTest extends BaseTest
$this->assertEquals($this->getMessage(), $log->getLastMessage());
}
+ /**
+ * @group unit
+ */
public function testGetLastMessageWarning()
{
$log = $this->initLog();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Multi/SearchTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Multi/SearchTest.php
index a62aaaad..765c8c1d 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Multi/SearchTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Multi/SearchTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Multi;
use Elastica\Document;
@@ -41,6 +40,9 @@ class SearchTest extends BaseTest
return $type;
}
+ /**
+ * @group unit
+ */
public function testConstruct()
{
$client = $this->_getClient();
@@ -50,6 +52,9 @@ class SearchTest extends BaseTest
$this->assertSame($client, $multiSearch->getClient());
}
+ /**
+ * @group unit
+ */
public function testSetSearches()
{
$client = $this->_getClient();
@@ -79,6 +84,9 @@ class SearchTest extends BaseTest
$this->assertCount(0, $searches);
}
+ /**
+ * @group unit
+ */
public function testSetSearchesByKeys()
{
$client = $this->_getClient();
@@ -108,6 +116,9 @@ class SearchTest extends BaseTest
$this->assertCount(0, $searches);
}
+ /**
+ * @group functional
+ */
public function testSearch()
{
$type = $this->_createType();
@@ -200,6 +211,9 @@ class SearchTest extends BaseTest
$this->assertEquals(6, $resultSets[1]->getTotalHits());
}
+ /**
+ * @group functional
+ */
public function testSearchWithKeys()
{
$type = $this->_createType();
@@ -217,7 +231,7 @@ class SearchTest extends BaseTest
$query1->setSize(2);
$search1->setQuery($query1);
- $multiSearch->addSearch($search1, "search1");
+ $multiSearch->addSearch($search1, 'search1');
$this->assertCount(1, $multiSearch->getSearches());
@@ -230,13 +244,13 @@ class SearchTest extends BaseTest
$query2->setSize(3);
$search2->setQuery($query2);
- $multiSearch->addSearch($search2, "search2");
+ $multiSearch->addSearch($search2, 'search2');
$this->assertCount(2, $multiSearch->getSearches());
$searches = $multiSearch->getSearches();
- $this->assertSame($search1, $searches["search1"]);
- $this->assertSame($search2, $searches["search2"]);
+ $this->assertSame($search1, $searches['search1']);
+ $this->assertSame($search2, $searches['search2']);
$multiResultSet = $multiSearch->search();
@@ -248,24 +262,24 @@ class SearchTest extends BaseTest
$this->assertInstanceOf('Elastica\ResultSet', $resultSet);
}
- $this->assertInstanceOf('Elastica\ResultSet', $multiResultSet["search1"]);
- $this->assertInstanceOf('Elastica\ResultSet', $multiResultSet["search2"]);
+ $this->assertInstanceOf('Elastica\ResultSet', $multiResultSet['search1']);
+ $this->assertInstanceOf('Elastica\ResultSet', $multiResultSet['search2']);
$resultSets = $multiResultSet->getResultSets();
$this->assertInternalType('array', $resultSets);
- $this->assertArrayHasKey("search1", $resultSets);
- $this->assertInstanceOf('Elastica\ResultSet', $resultSets["search1"]);
- $this->assertCount(2, $resultSets["search1"]);
- $this->assertSame($query1, $resultSets["search1"]->getQuery());
- $this->assertEquals(3, $resultSets["search1"]->getTotalHits());
+ $this->assertArrayHasKey('search1', $resultSets);
+ $this->assertInstanceOf('Elastica\ResultSet', $resultSets['search1']);
+ $this->assertCount(2, $resultSets['search1']);
+ $this->assertSame($query1, $resultSets['search1']->getQuery());
+ $this->assertEquals(3, $resultSets['search1']->getTotalHits());
- $this->assertArrayHasKey("search2", $resultSets);
- $this->assertInstanceOf('Elastica\ResultSet', $resultSets["search2"]);
- $this->assertCount(3, $resultSets["search2"]);
- $this->assertSame($query2, $resultSets["search2"]->getQuery());
- $this->assertEquals(6, $resultSets["search2"]->getTotalHits());
+ $this->assertArrayHasKey('search2', $resultSets);
+ $this->assertInstanceOf('Elastica\ResultSet', $resultSets['search2']);
+ $this->assertCount(3, $resultSets['search2']);
+ $this->assertSame($query2, $resultSets['search2']->getQuery());
+ $this->assertEquals(6, $resultSets['search2']->getTotalHits());
$this->assertFalse($multiResultSet->hasError());
@@ -282,19 +296,22 @@ class SearchTest extends BaseTest
$this->assertInternalType('array', $resultSets);
- $this->assertArrayHasKey("search1", $resultSets);
- $this->assertInstanceOf('Elastica\ResultSet', $resultSets["search1"]);
- $this->assertCount(0, $resultSets["search1"]);
- $this->assertSame($query1, $resultSets["search1"]->getQuery());
- $this->assertEquals(3, $resultSets["search1"]->getTotalHits());
-
- $this->assertArrayHasKey("search2", $resultSets);
- $this->assertInstanceOf('Elastica\ResultSet', $resultSets["search2"]);
- $this->assertCount(0, $resultSets["search2"]);
- $this->assertSame($query2, $resultSets["search2"]->getQuery());
- $this->assertEquals(6, $resultSets["search2"]->getTotalHits());
+ $this->assertArrayHasKey('search1', $resultSets);
+ $this->assertInstanceOf('Elastica\ResultSet', $resultSets['search1']);
+ $this->assertCount(0, $resultSets['search1']);
+ $this->assertSame($query1, $resultSets['search1']->getQuery());
+ $this->assertEquals(3, $resultSets['search1']->getTotalHits());
+
+ $this->assertArrayHasKey('search2', $resultSets);
+ $this->assertInstanceOf('Elastica\ResultSet', $resultSets['search2']);
+ $this->assertCount(0, $resultSets['search2']);
+ $this->assertSame($query2, $resultSets['search2']->getQuery());
+ $this->assertEquals(6, $resultSets['search2']->getTotalHits());
}
+ /**
+ * @group functional
+ */
public function testSearchWithError()
{
$type = $this->_createType();
@@ -340,6 +357,9 @@ class SearchTest extends BaseTest
$this->assertTrue($multiResultSet->hasError());
}
+ /**
+ * @group functional
+ */
public function testSearchWithErrorWithKeys()
{
$type = $this->_createType();
@@ -352,7 +372,7 @@ class SearchTest extends BaseTest
$searchGood->setQuery('bunny');
$searchGood->addIndex($index)->addType($type);
- $multiSearch->addSearch($searchGood, "search1");
+ $multiSearch->addSearch($searchGood, 'search1');
$searchBad = new Search($client);
$searchBadQuery = new Range();
@@ -369,11 +389,11 @@ class SearchTest extends BaseTest
$resultSets = $multiResultSet->getResultSets();
$this->assertInternalType('array', $resultSets);
- $this->assertArrayHasKey("search1", $resultSets);
- $this->assertInstanceOf('Elastica\ResultSet', $resultSets["search1"]);
- $this->assertSame($searchGood->getQuery(), $resultSets["search1"]->getQuery());
- $this->assertSame(6, $resultSets["search1"]->getTotalHits());
- $this->assertCount(6, $resultSets["search1"]);
+ $this->assertArrayHasKey('search1', $resultSets);
+ $this->assertInstanceOf('Elastica\ResultSet', $resultSets['search1']);
+ $this->assertSame($searchGood->getQuery(), $resultSets['search1']->getQuery());
+ $this->assertSame(6, $resultSets['search1']->getTotalHits());
+ $this->assertCount(6, $resultSets['search1']);
$this->assertArrayHasKey(0, $resultSets);
$this->assertInstanceOf('Elastica\ResultSet', $resultSets[0]);
@@ -385,6 +405,9 @@ class SearchTest extends BaseTest
$this->assertTrue($multiResultSet->hasError());
}
+ /**
+ * @group functional
+ */
public function testGlobalSearchTypeSearch()
{
$type = $this->_createType();
@@ -466,6 +489,9 @@ class SearchTest extends BaseTest
$this->assertEquals(6, $resultSets[1]->getTotalHits());
}
+ /**
+ * @group functional
+ */
public function testGlobalSearchTypeSearchWithKeys()
{
$type = $this->_createType();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Node/InfoTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Node/InfoTest.php
index 10886b2d..812f141e 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Node/InfoTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Node/InfoTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Node;
use Elastica\Node;
@@ -8,6 +7,9 @@ use Elastica\Test\Base as BaseTest;
class InfoTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testGet()
{
$client = $this->_getClient();
@@ -22,11 +24,14 @@ class InfoTest extends BaseTest
// Load os infos
$info = new NodeInfo($node, array('os'));
- $this->assertTrue(!is_null($info->get('os', 'mem', 'total_in_bytes')));
+ $this->assertNotNull($info->get('os', 'mem', 'total_in_bytes'));
$this->assertInternalType('array', $info->get('os', 'mem'));
$this->assertNull($info->get('test', 'notest', 'notexist'));
}
+ /**
+ * @group functional
+ */
public function testHasPlugin()
{
$client = $this->_getClient();
@@ -35,8 +40,40 @@ class InfoTest extends BaseTest
$info = $node->getInfo();
$pluginName = 'mapper-attachments';
-
+
$this->assertTrue($info->hasPlugin($pluginName));
$this->assertFalse($info->hasPlugin('foo'));
}
+
+ /**
+ * @group functional
+ */
+ public function testGetId()
+ {
+ $client = $this->_getClient();
+ $nodes = $client->getCluster()->getNodes();
+
+ $ids = array();
+
+ foreach ($nodes as $node) {
+ $id = $node->getInfo()->getId();
+
+ // Checks that the ids are unique
+ $this->assertFalse(in_array($id, $ids));
+ $ids[] = $id;
+ }
+ }
+
+ /**
+ * @group functional
+ */
+ public function testGetName()
+ {
+ $client = $this->_getClient();
+ $nodes = $client->getCluster()->getNodes();
+
+ foreach ($nodes as $node) {
+ $this->assertEquals('Elastica', $node->getInfo()->getName());
+ }
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/NodeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/NodeTest.php
index d70825d1..fbd2d297 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/NodeTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/NodeTest.php
@@ -1,14 +1,14 @@
<?php
-
namespace Elastica\Test;
-use Elastica\Client;
use Elastica\Node;
use Elastica\Test\Base as BaseTest;
class NodeTest extends BaseTest
{
-
+ /**
+ * @group functional
+ */
public function testCreateNode()
{
$client = $this->_getClient();
@@ -19,6 +19,9 @@ class NodeTest extends BaseTest
$this->assertInstanceOf('Elastica\Node', $node);
}
+ /**
+ * @group functional
+ */
public function testGetInfo()
{
$client = $this->_getClient();
@@ -32,6 +35,9 @@ class NodeTest extends BaseTest
$this->assertInstanceOf('Elastica\Node\Info', $info);
}
+ /**
+ * @group functional
+ */
public function testGetStats()
{
$client = $this->_getClient();
@@ -46,39 +52,24 @@ class NodeTest extends BaseTest
}
/**
- * Shuts one of two nodes down (if two available)
+ * @group functional
*/
- public function testShutdown()
+ public function testGetName()
{
- $this->markTestSkipped('At least two nodes have to be running, because 1 node is shutdown');
- $client = $this->_getClient();
- $nodes = $client->getCluster()->getNodes();
+ $nodes = $this->_getClient()->getCluster()->getNodes();
+ // At least 1 instance must exist
+ $this->assertGreaterThan(0, $nodes);
- $count = count($nodes);
- if ($count < 2) {
- $this->markTestSkipped('At least two nodes have to be running, because 1 node is shutdown');
+ foreach ($nodes as $node) {
+ $this->assertEquals($node->getName(), 'Elastica');
}
+ }
- // Store node info of node with port 9200 for later
- foreach ($nodes as $key => $node) {
- if ($node->getInfo()->getPort() == 9200) {
- $info = $node->getInfo();
- unset($nodes[$key]);
- }
- }
-
- // Select one of the not port 9200 nodes and shut it down
- $node = array_shift($nodes);
- $node->shutdown('2s');
-
- // Wait until node is shutdown
- sleep(5);
-
- // Use still existing node
- $client = new Client(array('host' => $info->getIp(), 'port' => $info->getPort()));
- $names = $client->getCluster()->getNodeNames();
-
- // One node less ...
- $this->assertEquals($count - 1, count($names));
+ /**
+ * @group functional
+ */
+ public function testGetId()
+ {
+ $node = new Node('Elastica', $this->_getClient());
}
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ParamTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ParamTest.php
index fab77600..eade8118 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/ParamTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ParamTest.php
@@ -1,13 +1,15 @@
<?php
-
namespace Elastica\Test;
use Elastica\Param;
-use Elastica\Util;
use Elastica\Test\Base as BaseTest;
+use Elastica\Util;
class ParamTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArrayEmpty()
{
$param = new Param();
@@ -15,6 +17,9 @@ class ParamTest extends BaseTest
$this->assertEquals(array($this->_getFilterName($param) => array()), $param->toArray());
}
+ /**
+ * @group unit
+ */
public function testSetParams()
{
$param = new Param();
@@ -25,6 +30,9 @@ class ParamTest extends BaseTest
$this->assertEquals(array($this->_getFilterName($param) => $params), $param->toArray());
}
+ /**
+ * @group unit
+ */
public function testSetGetParam()
{
$param = new Param();
@@ -39,6 +47,9 @@ class ParamTest extends BaseTest
$this->assertEquals($value, $param->getParam($key));
}
+ /**
+ * @group unit
+ */
public function testAddParam()
{
$param = new Param();
@@ -52,6 +63,9 @@ class ParamTest extends BaseTest
$this->assertEquals(array($value), $param->getParam($key));
}
+ /**
+ * @group unit
+ */
public function testAddParam2()
{
$param = new Param();
@@ -68,6 +82,7 @@ class ParamTest extends BaseTest
}
/**
+ * @group unit
* @expectedException \Elastica\Exception\InvalidException
*/
public function testGetParamInvalid()
@@ -77,6 +92,9 @@ class ParamTest extends BaseTest
$param->getParam('notest');
}
+ /**
+ * @group unit
+ */
public function testHasParam()
{
$param = new Param();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/PercolatorTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/PercolatorTest.php
index f4cfae0c..2a5a88c3 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/PercolatorTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/PercolatorTest.php
@@ -1,22 +1,24 @@
<?php
-
namespace Elastica\Test;
-use Elastica\Client;
use Elastica\Document;
use Elastica\Index;
use Elastica\Percolator;
-use Elastica\Query\Term;
use Elastica\Query;
+use Elastica\Query\Term;
use Elastica\Test\Base as BaseTest;
+use Elastica\Type;
class PercolatorTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testConstruct()
{
- $percolatorName = 'percotest';
+ $index = $this->_createIndex();
+ $percolatorName = $index->getName();
- $index = $this->_createIndex($percolatorName);
$percolator = new Percolator($index);
$query = new Term(array('field1' => 'value1'));
@@ -29,7 +31,7 @@ class PercolatorTest extends BaseTest
'_index' => $index->getName(),
'_id' => $percolatorName,
'_version' => 1,
- 'created' => 1
+ 'created' => 1,
);
$this->assertEquals($expectedArray, $data);
@@ -37,12 +39,16 @@ class PercolatorTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testMatchDoc()
{
$index = $this->_createIndex();
+
$percolator = new Percolator($index);
- $percolatorName = 'percotest';
+ $percolatorName = $index->getName();
$query = new Term(array('name' => 'ruflin'));
$response = $percolator->registerQuery($percolatorName, $query);
@@ -77,6 +83,8 @@ class PercolatorTest extends BaseTest
/**
* Test case for using filtered percolator queries based on the Elasticsearch documentation examples.
+ *
+ * @group functional
*/
public function testFilteredMatchDoc()
{
@@ -111,6 +119,8 @@ class PercolatorTest extends BaseTest
/**
* Test case for using filtered percolator queries based on the Elasticsearch documentation examples.
+ *
+ * @group functional
*/
public function testRegisterAndUnregisterPercolator()
{
@@ -140,7 +150,6 @@ class PercolatorTest extends BaseTest
$matches = $percolator->matchDoc($doc, new Term(array('color' => 'green')));
$this->assertCount(0, $matches, 'A registered query matched, although nothing should match at all.');
-
// unregister percolator query
$response = $percolator->unregisterQuery('kuku');
@@ -162,26 +171,31 @@ class PercolatorTest extends BaseTest
$percolator = new Percolator($index);
$query = new Term(array('name' => 'foobar'));
- $percolator->registerQuery($percolatorName, $query);
+ $percolator->registerQuery($percolatorName, $query, array('field1' => array('tag1', 'tag2')));
+
return $percolator;
}
- protected function _addDefaultDocuments($index, $type='testing')
+ protected function _addDefaultDocuments($index, $type = 'testing')
{
$type = $index->getType('testing');
- $doc1 = new Document(1, array('name' => 'foobar'));
- $doc2 = new Document(2, array('name' => 'barbaz'));
- $type->addDocument($doc1);
- $type->addDocument($doc2);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'foobar')),
+ new Document(2, array('name' => 'barbaz')),
+ ));
$index->refresh();
+
return $type;
}
+ /**
+ * @group functional
+ */
public function testPercolateExistingDocWithoutAnyParameter()
{
$percolator = $this->_getDefaultPercolator();
- $index = $percolator->getIndex();
- $type = $this->_addDefaultDocuments($index);
+ $index = $percolator->getIndex();
+ $type = $this->_addDefaultDocuments($index);
$matches = $percolator->matchExistingDoc(1, $type->getName());
@@ -190,28 +204,34 @@ class PercolatorTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testPercolateExistingDocWithPercolateFormatIds()
{
$percolator = $this->_getDefaultPercolator();
- $index = $percolator->getIndex();
- $type = $this->_addDefaultDocuments($index);
+ $index = $percolator->getIndex();
+ $type = $this->_addDefaultDocuments($index);
$parameter = array('percolate_format' => 'ids');
- $matches = $percolator->matchExistingDoc(1, $type->getName(), null, $parameter);
+ $matches = $percolator->matchExistingDoc(1, $type->getName(), null, $parameter);
$this->assertCount(1, $matches);
$this->assertEquals('existingDoc', $matches[0]);
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testPercolateExistingDocWithIdThatShouldBeUrlEncoded()
{
$percolator = $this->_getDefaultPercolator();
- $index = $percolator->getIndex();
- $type = $this->_addDefaultDocuments($index);
+ $index = $percolator->getIndex();
+ $type = $this->_addDefaultDocuments($index);
// id with whitespace, should be urlencoded
- $id = "foo bar 1";
+ $id = 'foo bar 1';
$type->addDocument(new Document($id, array('name' => 'foobar')));
$index->refresh();
@@ -221,4 +241,88 @@ class PercolatorTest extends BaseTest
$this->assertCount(1, $matches);
$index->delete();
}
+
+ /**
+ * @group functional
+ */
+ public function testPercolateWithAdditionalRequestBodyOptions()
+ {
+ $index = $this->_createIndex();
+ $percolator = new Percolator($index);
+
+ $query = new Term(array('name' => 'foo'));
+ $response = $percolator->registerQuery('percotest', $query, array('field1' => array('tag1', 'tag2')));
+
+ $this->assertTrue($response->isOk());
+ $this->assertFalse($response->hasError());
+
+ $query = new Term(array('name' => 'foo'));
+ $response = $percolator->registerQuery('percotest1', $query, array('field1' => array('tag2')));
+
+ $this->assertTrue($response->isOk());
+ $this->assertFalse($response->hasError());
+
+ $doc1 = new Document();
+ $doc1->set('name', 'foo');
+
+ $index->refresh();
+
+ $options = array(
+ 'track_scores' => true,
+ 'sort' => array('_score' => 'desc'),
+ 'size' => 1,
+ );
+
+ $matches = $percolator->matchDoc($doc1, new Term(array('field1' => 'tag2')), 'type', $options);
+
+ $this->assertCount(1, $matches);
+ $this->assertEquals('percotest1', $matches[0]['_id']);
+ $this->assertArrayHasKey('_score', $matches[0]);
+ }
+
+ /**
+ * @group functional
+ */
+ public function testPercolateExistingDocWithAdditionalRequestBodyOptions()
+ {
+ $percolatorName = 'existingDoc';
+ $percolator = $this->_getDefaultPercolator($percolatorName);
+
+ $query = new Term(array('name' => 'foobar'));
+ $percolator->registerQuery($percolatorName.'1', $query, array('field1' => array('tag2')));
+
+ $index = $percolator->getIndex();
+ $type = $this->_addDefaultDocuments($index);
+
+ $options = array(
+ 'track_scores' => true,
+ 'sort' => array('_score' => 'desc'),
+ 'size' => 1,
+ );
+
+ $matches = $percolator->matchExistingDoc(1, $type->getName(), new Term(array('field1' => 'tag2')), $options);
+
+ $this->assertCount(1, $matches);
+ $this->assertEquals('existingDoc1', $matches[0]['_id']);
+ $this->assertArrayHasKey('_score', $matches[0]);
+ $index->delete();
+ }
+
+ protected function _createIndex($name = null, $delete = true, $shards = 1)
+ {
+ $index = parent::_createIndex($name, $delete, $shards);
+ $type = $index->getType('.percolator');
+
+ $mapping = new Type\Mapping($type,
+ array(
+ 'name' => array('type' => 'string'),
+ 'field1' => array('type' => 'string'),
+ )
+ );
+ $mapping->disableSource();
+
+ $type->setMapping($mapping);
+
+ return $index;
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BoolTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BoolQueryTest.php
index d3bd90cd..211d0c23 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BoolTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BoolQueryTest.php
@@ -1,20 +1,22 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Document;
use Elastica\Index;
-use Elastica\Query\Bool;
+use Elastica\Query\BoolQuery;
use Elastica\Query\Ids;
use Elastica\Query\Term;
use Elastica\Test\Base as BaseTest;
use Elastica\Type;
-class BoolTest extends BaseTest
+class BoolQueryTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
- $query = new Bool();
+ $query = new BoolQuery();
$idsQuery1 = new Ids();
$idsQuery1->setIds(1);
@@ -41,20 +43,22 @@ class BoolTest extends BaseTest
'minimum_number_should_match' => $minMatch,
'must_not' => array($idsQuery2->toArray()),
'boost' => $boost,
- )
+ ),
);
$this->assertEquals($expectedArray, $query->toArray());
}
/**
- * Test to resolve the following issue
+ * Test to resolve the following issue.
+ *
+ * @link https://groups.google.com/forum/?fromgroups#!topic/elastica-php-client/zK_W_hClfvU
*
- * https://groups.google.com/forum/?fromgroups#!topic/elastica-php-client/zK_W_hClfvU
+ * @group unit
*/
public function testToArrayStructure()
{
- $boolQuery = new Bool();
+ $boolQuery = new BoolQuery();
$term1 = new Term();
$term1->setParam('interests', 84);
@@ -68,6 +72,9 @@ class BoolTest extends BaseTest
$this->assertEquals($jsonString, json_encode($boolQuery->toArray()));
}
+ /**
+ * @group functional
+ */
public function testSearch()
{
$client = $this->_getClient();
@@ -86,7 +93,7 @@ class BoolTest extends BaseTest
// Refresh index
$index->refresh();
- $boolQuery = new Bool();
+ $boolQuery = new BoolQuery();
$termQuery1 = new Term(array('test' => '2'));
$boolQuery->addMust($termQuery1);
$resultSet = $type->search($boolQuery);
@@ -111,4 +118,54 @@ class BoolTest extends BaseTest
$this->assertEquals(0, $resultSet->count());
}
+
+ /**
+ * @group functional
+ */
+ public function testEmptyBoolQuery()
+ {
+ $index = $this->_createIndex();
+ $type = new Type($index, 'test');
+
+ $docNumber = 3;
+ for ($i = 0; $i < $docNumber; $i++) {
+ $doc = new Document($i, array('email' => 'test@test.com'));
+ $type->addDocument($doc);
+ }
+
+ $index->refresh();
+
+ $boolQuery = new BoolQuery();
+
+ $resultSet = $type->search($boolQuery);
+
+ $this->assertEquals($resultSet->count(), $docNumber);
+ }
+
+ /**
+ * @group functional
+ */
+ public function testOldObject()
+ {
+ if (version_compare(phpversion(), 7, '>=')) {
+ self::markTestSkipped('These objects are not supported in PHP 7');
+ }
+
+ $index = $this->_createIndex();
+ $type = new Type($index, 'test');
+
+ $docNumber = 3;
+ for ($i = 0; $i < $docNumber; $i++) {
+ $doc = new Document($i, array('email' => 'test@test.com'));
+ $type->addDocument($doc);
+ }
+
+ $index->refresh();
+
+ $boolQuery = new \Elastica\Query\Bool();
+
+ $resultSet = $type->search($boolQuery);
+
+ $this->assertEquals($resultSet->count(), $docNumber);
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BoostingTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BoostingTest.php
index f5af8740..8133fd37 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BoostingTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BoostingTest.php
@@ -1,67 +1,54 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Document;
use Elastica\Query\Boosting;
+use Elastica\Query\Term;
use Elastica\Test\Base as BaseTest;
class BoostingTest extends BaseTest
{
/**
- * @var \Elastica\Index
- */
- protected $index;
-
- /**
- * @var \Elastica\Type
- */
- protected $type;
-
- /*
* @var array
*/
- protected $sampleData;
-
- protected function setUp()
+ protected $sampleData = array(
+ array('name' => 'Vital Lama', 'price' => 5.2),
+ array('name' => 'Vital Match', 'price' => 2.1),
+ array('name' => 'Mercury Vital', 'price' => 7.5),
+ array('name' => 'Fist Mercury', 'price' => 3.8),
+ array('name' => 'Lama Vital 2nd', 'price' => 3.2),
+ );
+
+ protected function _getTestIndex()
{
- parent::setUp();
- $this->index = $this->_createIndex('test_boostingquery');
- $this->type = $this->index->getType('test');
- $this->type->setMapping(array(
+ $index = $this->_createIndex();
+ $type = $index->getType('test');
+ $type->setMapping(array(
'name' => array('type' => 'string', 'index' => 'analyzed'),
- 'price' => array('type' => 'float')
+ 'price' => array('type' => 'float'),
));
-
- $this->sampleData = array(
- array("name" => "Vital Lama", "price" => 5.2),
- array("name" => "Vital Match", "price" => 2.1),
- array("name" => "Mercury Vital", "price" => 7.5),
- array("name" => "Fist Mercury", "price" => 3.8),
- array("name" => "Lama Vital 2nd", "price" => 3.2)
- );
-
- foreach($this->sampleData as $key => $value) {
- $this->type->addDocument(new Document($key, $value));
+ $docs = array();
+ foreach ($this->sampleData as $key => $value) {
+ $docs[] = new Document($key, $value);
}
+ $type->addDocuments($docs);
- $this->index->refresh();
- }
+ $index->refresh();
- protected function tearDown()
- {
- $this->index->delete();
- parent::tearDown();
+ return $index;
}
+ /**
+ * @group unit
+ */
public function testToArray()
{
- $keyword = "vital";
- $negativeKeyword = "Mercury";
+ $keyword = 'vital';
+ $negativeKeyword = 'Mercury';
$query = new Boosting();
- $positiveQuery = new \Elastica\Query\Term(array('name' => $keyword));
- $negativeQuery = new \Elastica\Query\Term(array('name' => $negativeKeyword));
+ $positiveQuery = new Term(array('name' => $keyword));
+ $negativeQuery = new Term(array('name' => $negativeKeyword));
$query->setPositiveQuery($positiveQuery);
$query->setNegativeQuery($negativeQuery);
$query->setNegativeBoost(0.3);
@@ -70,25 +57,28 @@ class BoostingTest extends BaseTest
'boosting' => array(
'positive' => $positiveQuery->toArray(),
'negative' => $negativeQuery->toArray(),
- 'negative_boost' => 0.3
- )
+ 'negative_boost' => 0.3,
+ ),
);
$this->assertEquals($expected, $query->toArray());
}
+ /**
+ * @group functional
+ */
public function testNegativeBoost()
{
- $keyword = "vital";
- $negativeKeyword = "mercury";
+ $keyword = 'vital';
+ $negativeKeyword = 'mercury';
$query = new Boosting();
- $positiveQuery = new \Elastica\Query\Term(array('name' => $keyword));
- $negativeQuery = new \Elastica\Query\Term(array('name' => $negativeKeyword));
+ $positiveQuery = new Term(array('name' => $keyword));
+ $negativeQuery = new Term(array('name' => $negativeKeyword));
$query->setPositiveQuery($positiveQuery);
$query->setNegativeQuery($negativeQuery);
$query->setNegativeBoost(0.2);
- $response = $this->type->search($query);
+ $response = $this->_getTestIndex()->search($query);
$results = $response->getResults();
$this->assertEquals($response->getTotalHits(), 4);
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BuilderTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BuilderTest.php
index 5875c4ba..a96e8b3a 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BuilderTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BuilderTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Query\Builder;
@@ -8,21 +7,7 @@ use Elastica\Test\Base as BaseTest;
class BuilderTest extends BaseTest
{
/**
- * @var \Elastica\Query\Builder
- */
- private $builder;
-
- public function setUp()
- {
- $this->builder = new Builder();
- }
-
- public function tearDown()
- {
- $this->builder = null;
- }
-
- /**
+ * @group unit
* @covers \Elastica\Query\Builder::factory
* @covers \Elastica\Query\Builder::__construct
*/
@@ -66,11 +51,12 @@ class BuilderTest extends BaseTest
array('size', 7, '{"size":"7"}'),
array('tieBreakerMultiplier', 7, '{"tie_breaker_multiplier":"7"}'),
array('matchAll', 1.1, '{"match_all":{"boost":"1.1"}}'),
- array('fields', array("age", "sex", "location"), '{"fields":["age","sex","location"]}'),
+ array('fields', array('age', 'sex', 'location'), '{"fields":["age","sex","location"]}'),
);
}
/**
+ * @group unit
* @dataProvider getQueryData
* @covers \Elastica\Query\Builder::__toString
* @covers \Elastica\Query\Builder::allowLeadingWildcard
@@ -99,8 +85,9 @@ class BuilderTest extends BaseTest
*/
public function testAllowLeadingWildcard($method, $argument, $result)
{
- $this->assertSame($this->builder, $this->builder->$method($argument));
- $this->assertSame($result, (string) $this->builder);
+ $builder = new Builder();
+ $this->assertSame($builder, $builder->$method($argument));
+ $this->assertSame($result, (string) $builder);
}
public function getQueryTypes()
@@ -127,11 +114,10 @@ class BuilderTest extends BaseTest
}
/**
+ * @group unit
* @dataProvider getQueryTypes
- *
* @covers \Elastica\Query\Builder::fieldClose
* @covers \Elastica\Query\Builder::close
- *
* @covers \Elastica\Query\Builder::bool
* @covers \Elastica\Query\Builder::boolClose
* @covers \Elastica\Query\Builder::constantScore
@@ -169,12 +155,14 @@ class BuilderTest extends BaseTest
*/
public function testQueryTypes($method, $queryType)
{
- $this->assertSame($this->builder, $this->builder->$method()); // open
- $this->assertSame($this->builder, $this->builder->{$method."Close"}()); // close
- $this->assertSame('{"' . $queryType . '":{}}', (string) $this->builder);
+ $builder = new Builder();
+ $this->assertSame($builder, $builder->$method()); // open
+ $this->assertSame($builder, $builder->{$method.'Close'}()); // close
+ $this->assertSame('{"'.$queryType.'":{}}', (string) $builder);
}
/**
+ * @group unit
* @covers \Elastica\Query\Builder::fieldOpen
* @covers \Elastica\Query\Builder::fieldClose
* @covers \Elastica\Query\Builder::open
@@ -182,44 +170,51 @@ class BuilderTest extends BaseTest
*/
public function testFieldOpenAndClose()
{
- $this->assertSame($this->builder, $this->builder->fieldOpen('someField'));
- $this->assertSame($this->builder, $this->builder->fieldClose());
- $this->assertSame('{"someField":{}}', (string) $this->builder);
+ $builder = new Builder();
+ $this->assertSame($builder, $builder->fieldOpen('someField'));
+ $this->assertSame($builder, $builder->fieldClose());
+ $this->assertSame('{"someField":{}}', (string) $builder);
}
/**
+ * @group unit
* @covers \Elastica\Query\Builder::sortField
*/
public function testSortField()
{
- $this->assertSame($this->builder, $this->builder->sortField('name', true));
- $this->assertSame('{"sort":{"name":{"reverse":"true"}}}', (string) $this->builder);
+ $builder = new Builder();
+ $this->assertSame($builder, $builder->sortField('name', true));
+ $this->assertSame('{"sort":{"name":{"reverse":"true"}}}', (string) $builder);
}
/**
+ * @group unit
* @covers \Elastica\Query\Builder::sortFields
*/
public function testSortFields()
{
- $this->assertSame($this->builder, $this->builder->sortFields(array('field1' => 'asc', 'field2' => 'desc', 'field3' => 'asc')));
- $this->assertSame('{"sort":[{"field1":"asc"},{"field2":"desc"},{"field3":"asc"}]}', (string) $this->builder);
+ $builder = new Builder();
+ $this->assertSame($builder, $builder->sortFields(array('field1' => 'asc', 'field2' => 'desc', 'field3' => 'asc')));
+ $this->assertSame('{"sort":[{"field1":"asc"},{"field2":"desc"},{"field3":"asc"}]}', (string) $builder);
}
/**
+ * @group unit
* @covers \Elastica\Query\Builder::queries
*/
public function testQueries()
{
$queries = array();
- $b1 = clone $this->builder;
- $b2 = clone $this->builder;
+ $builder = new Builder();
+ $b1 = clone $builder;
+ $b2 = clone $builder;
$queries[] = $b1->term()->field('age', 34)->termClose();
$queries[] = $b2->term()->field('name', 'christer')->termClose();
- $this->assertSame($this->builder, $this->builder->queries($queries));
- $this->assertSame('{"queries":[{"term":{"age":"34"}},{"term":{"name":"christer"}}]}', (string) $this->builder);
+ $this->assertSame($builder, $builder->queries($queries));
+ $this->assertSame('{"queries":[{"term":{"age":"34"}},{"term":{"name":"christer"}}]}', (string) $builder);
}
public function getFieldData()
@@ -234,37 +229,45 @@ class BuilderTest extends BaseTest
}
/**
+ * @group unit
* @dataProvider getFieldData
* @covers \Elastica\Query\Builder::field
*/
public function testField($name, $value, $result)
{
- $this->assertSame($this->builder, $this->builder->field($name, $value));
- $this->assertSame($result, (string) $this->builder);
+ $builder = new Builder();
+ $this->assertSame($builder, $builder->field($name, $value));
+ $this->assertSame($result, (string) $builder);
}
/**
+ * @group unit
* @expectedException \Elastica\Exception\InvalidException
+ * @expectedExceptionMessage The produced query is not a valid json string : "{{}"
* @covers \Elastica\Query\Builder::toArray
*/
public function testToArrayWithInvalidData()
{
- $this->builder->open('foo');
- $this->builder->toArray();
+ $builder = new Builder();
+ $builder->open('foo');
+ $builder->toArray();
}
/**
+ * @group unit
* @covers \Elastica\Query\Builder::toArray
*/
public function testToArray()
{
- $this->builder->query()->term()->field('category.id', array(1, 2, 3))->termClose()->queryClose();
- $this->assertEquals(array(
+ $builder = new Builder();
+ $builder->query()->term()->field('category.id', array(1, 2, 3))->termClose()->queryClose();
+ $expected = array(
'query' => array(
'term' => array(
- 'category.id' => array(1, 2, 3)
- )
- )
- ), $this->builder->toArray());
+ 'category.id' => array(1, 2, 3),
+ ),
+ ),
+ );
+ $this->assertEquals($expected, $builder->toArray());
}
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/CommonTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/CommonTest.php
index a84d6397..016213a8 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/CommonTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/CommonTest.php
@@ -1,12 +1,15 @@
<?php
-
namespace Elastica\Test\Query;
+use Elastica\Document;
use Elastica\Query\Common;
use Elastica\Test\Base as BaseTest;
class CommonTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$query = new Common('body', 'test query', .001);
@@ -17,29 +20,32 @@ class CommonTest extends BaseTest
'body' => array(
'query' => 'test query',
'cutoff_frequency' => .001,
- 'low_freq_operator' => 'and'
- )
- )
+ 'low_freq_operator' => 'and',
+ ),
+ ),
);
$this->assertEquals($expected, $query->toArray());
}
+ /**
+ * @group functional
+ */
public function testQuery()
{
- $index = $this->_createIndex('common_test');
+ $index = $this->_createIndex();
$type = $index->getType('test');
+ $docs = array(
+ new Document(1, array('body' => 'foo baz')),
+ new Document(2, array('body' => 'foo bar baz')),
+ new Document(3, array('body' => 'foo bar baz bat')),
+ );
//add documents to create common terms
- $docs = array();
- for ($i = 0; $i < 20; $i++) {
- $docs[] = new \Elastica\Document($i, array('body' => 'foo bar'));
+ for ($i = 4; $i < 24; $i++) {
+ $docs[] = new Document($i, array('body' => 'foo bar'));
}
$type->addDocuments($docs);
-
- $type->addDocument(new \Elastica\Document(20, array('body' => 'foo baz')));
- $type->addDocument(new \Elastica\Document(21, array('body' => 'foo bar baz')));
- $type->addDocument(new \Elastica\Document(22, array('body' => 'foo bar baz bat')));
$index->refresh();
$query = new Common('body', 'foo bar baz bat', .5);
@@ -53,7 +59,5 @@ class CommonTest extends BaseTest
//only the document containing both low frequency terms should match
$this->assertEquals(1, $results->count());
-
- $index->delete();
}
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/ConstantScoreTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/ConstantScoreTest.php
index 27143eb6..a3a213b9 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/ConstantScoreTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/ConstantScoreTest.php
@@ -1,15 +1,13 @@
<?php
-
namespace Elastica\Test\Query;
-use Elastica\Filter\Term;
+use Elastica\Document;
use Elastica\Filter\Ids;
+use Elastica\Filter\Term;
+use Elastica\Index;
use Elastica\Query\ConstantScore;
use Elastica\Query\MatchAll;
use Elastica\Test\Base as BaseTest;
-use Elastica\Index;
-use Elastica\Document;
-use Elastica\Type;
class ConstantScoreTest extends BaseTest
{
@@ -55,6 +53,7 @@ class ConstantScoreTest extends BaseTest
);
}
/**
+ * @group unit
* @dataProvider dataProviderSampleQueries
*/
public function testSimple($filter, $expected)
@@ -67,6 +66,9 @@ class ConstantScoreTest extends BaseTest
$this->assertEquals($expected, $query->toArray());
}
+ /**
+ * @group unit
+ */
public function testToArray()
{
$query = new ConstantScore();
@@ -81,13 +83,16 @@ class ConstantScoreTest extends BaseTest
$expectedArray = array(
'constant_score' => array(
'filter' => $filter->toArray(),
- 'boost' => $boost
- )
+ 'boost' => $boost,
+ ),
);
$this->assertEquals($expectedArray, $query->toArray());
}
+ /**
+ * @group unit
+ */
public function testConstruct()
{
$filter = new Ids();
@@ -98,28 +103,25 @@ class ConstantScoreTest extends BaseTest
$expectedArray = array(
'constant_score' => array(
'filter' => $filter->toArray(),
- )
+ ),
);
$this->assertEquals($expectedArray, $query->toArray());
-
}
+ /**
+ * @group functional
+ */
public function testQuery()
{
+ $index = $this->_createIndex();
- $client = $this->_getClient();
- $index = new Index($client, 'test');
- $index->create(array(), true);
-
- $type = new Type($index, 'constant_score');
-
- $doc = new Document(1, array('id' => 1, 'email' => 'hans@test.com', 'username' => 'hans'));
- $type->addDocument($doc);
- $doc = new Document(2, array('id' => 2, 'email' => 'emil@test.com', 'username' => 'emil'));
- $type->addDocument($doc);
- $doc = new Document(3, array('id' => 3, 'email' => 'ruth@test.com', 'username' => 'ruth'));
- $type->addDocument($doc);
+ $type = $index->getType('constant_score');
+ $type->addDocuments(array(
+ new Document(1, array('id' => 1, 'email' => 'hans@test.com', 'username' => 'hans')),
+ new Document(2, array('id' => 2, 'email' => 'emil@test.com', 'username' => 'emil')),
+ new Document(3, array('id' => 3, 'email' => 'ruth@test.com', 'username' => 'ruth')),
+ ));
// Refresh index
$index->refresh();
@@ -134,8 +136,8 @@ class ConstantScoreTest extends BaseTest
$expectedArray = array(
'constant_score' => array(
'query' => $query_match->toArray(),
- 'boost' => $boost
- )
+ 'boost' => $boost,
+ ),
);
$this->assertEquals($expectedArray, $query->toArray());
@@ -145,9 +147,11 @@ class ConstantScoreTest extends BaseTest
$this->assertEquals($resultSet->count(), 3);
$this->assertEquals($results[1]->getScore(), 1);
-
}
+ /**
+ * @group unit
+ */
public function testConstructEmpty()
{
$query = new ConstantScore();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/DisMaxTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/DisMaxTest.php
index 31c8437d..2c128018 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/DisMaxTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/DisMaxTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Document;
@@ -10,6 +9,9 @@ use Elastica\Test\Base as BaseTest;
class DisMaxTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$query = new DisMax();
@@ -39,29 +41,28 @@ class DisMaxTest extends BaseTest
'queries' => array(
$idsQuery1->toArray(),
$idsQuery2->toArray(),
- $idsQuery3->toArray()
- )
- )
+ $idsQuery3->toArray(),
+ ),
+ ),
);
$this->assertEquals($expectedArray, $query->toArray());
}
+ /**
+ * @group functional
+ */
public function testQuery()
{
- $client = $this->_getClient();
- $index = $client->getIndex('test');
- $index->create(array(), true);
+ $index = $this->_createIndex();
$type = $index->getType('test');
- $doc = new Document(1, array('name' => 'Basel-Stadt'));
- $type->addDocument($doc);
- $doc = new Document(2, array('name' => 'New York'));
- $type->addDocument($doc);
- $doc = new Document(3, array('name' => 'Baden'));
- $type->addDocument($doc);
- $doc = new Document(4, array('name' => 'Baden Baden'));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'Basel-Stadt')),
+ new Document(2, array('name' => 'New York')),
+ new Document(3, array('name' => 'Baden')),
+ new Document(4, array('name' => 'Baden Baden')),
+ ));
$index->refresh();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/EscapeStringTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/EscapeStringTest.php
new file mode 100644
index 00000000..536a7bb3
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/EscapeStringTest.php
@@ -0,0 +1,36 @@
+<?php
+namespace Elastica\Test\Query;
+
+use Elastica\Document;
+use Elastica\Index;
+use Elastica\Query\QueryString;
+use Elastica\Test\Base as BaseTest;
+use Elastica\Type;
+use Elastica\Util;
+
+class EscapeStringTest extends BaseTest
+{
+ /**
+ * @group functional
+ */
+ public function testSearch()
+ {
+ $index = $this->_createIndex();
+ $index->getSettings()->setNumberOfReplicas(0);
+
+ $type = new Type($index, 'helloworld');
+
+ $doc = new Document(1, array(
+ 'email' => 'test@test.com', 'username' => 'test 7/6 123', 'test' => array('2', '3', '5'), )
+ );
+ $type->addDocument($doc);
+
+ // Refresh index
+ $index->refresh();
+
+ $queryString = new QueryString(Util::escapeTerm('test 7/6'));
+ $resultSet = $type->search($queryString);
+
+ $this->assertEquals(1, $resultSet->count());
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FilteredTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FilteredTest.php
index c6bd9096..c4bea6f2 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FilteredTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FilteredTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Document;
@@ -10,15 +9,18 @@ use Elastica\Test\Base as BaseTest;
class FilteredTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testFilteredSearch()
{
$index = $this->_createIndex();
$type = $index->getType('helloworld');
- $doc = new Document(1, array('id' => 1, 'email' => 'test@test.com', 'username' => 'hanswurst', 'test' => array('2', '3', '5')));
- $type->addDocument($doc);
- $doc = new Document(2, array('id' => 2, 'email' => 'test@test.com', 'username' => 'peter', 'test' => array('2', '3', '5')));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('id' => 1, 'email' => 'test@test.com', 'username' => 'hanswurst', 'test' => array('2', '3', '5'))),
+ new Document(2, array('id' => 2, 'email' => 'test@test.com', 'username' => 'peter', 'test' => array('2', '3', '5'))),
+ ));
$queryString = new QueryString('test*');
@@ -42,6 +44,9 @@ class FilteredTest extends BaseTest
$this->assertEquals(0, $resultSet->count());
}
+ /**
+ * @group unit
+ */
public function testFilteredGetter()
{
$queryString = new QueryString('test*');
@@ -62,6 +67,7 @@ class FilteredTest extends BaseTest
}
/**
+ * @group unit
* @expectedException \Elastica\Exception\InvalidException
*/
public function testFilteredWithoutArgumentsShouldRaiseException()
@@ -69,27 +75,34 @@ class FilteredTest extends BaseTest
$query = new Filtered();
$query->toArray();
}
-
+
+ /**
+ * @group functional
+ */
public function testFilteredSearchNoQuery()
{
$index = $this->_createIndex();
$type = $index->getType('helloworld');
- $doc = new Document(1, array('id' => 1, 'email' => 'test@test.com', 'username' => 'hanswurst', 'test' => array('2', '3', '5')));
- $type->addDocument($doc);
- $doc = new Document(2, array('id' => 2, 'email' => 'test@test.com', 'username' => 'peter', 'test' => array('2', '3', '5')));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('id' => 1, 'email' => 'test@test.com', 'username' => 'hanswurst', 'test' => array('2', '3', '5'))),
+ new Document(2, array('id' => 2, 'email' => 'test@test.com', 'username' => 'peter', 'test' => array('2', '3', '5'))),
+ ));
+
+ $index->refresh();
$filter = new Term();
$filter->setTerm('username', 'peter');
$query = new Filtered(null, $filter);
- $index->refresh();
$resultSet = $type->search($query);
$this->assertEquals(1, $resultSet->count());
}
-
+
+ /**
+ * @group functional
+ */
public function testFilteredSearchNoFilter()
{
$index = $this->_createIndex();
@@ -108,5 +121,4 @@ class FilteredTest extends BaseTest
$resultSet = $type->search($query);
$this->assertEquals(1, $resultSet->count());
}
-
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FunctionScoreTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FunctionScoreTest.php
index 47d9dd2c..25600034 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FunctionScoreTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FunctionScoreTest.php
@@ -1,70 +1,56 @@
<?php
-/**
- * User: Joe Linn
- * Date: 9/16/13
- * Time: 5:05 PM
- */
-
namespace Elastica\Test\Query;
use Elastica\Document;
use Elastica\Filter\Term;
use Elastica\Query\FunctionScore;
+use Elastica\Query\MatchAll;
use Elastica\Script;
use Elastica\Test\Base as BaseTest;
class FunctionScoreTest extends BaseTest
{
- /**
- * @var \Elastica\Index
- */
- protected $index;
-
- /**
- * @var \Elastica\Type
- */
- protected $type;
-
- protected $locationOrigin = "32.804654, -117.242594";
+ protected $locationOrigin = '32.804654, -117.242594';
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->index = $this->_createIndex('test_functionscore');
- $this->type = $this->index->getType('test');
- $this->type->setMapping(array(
+ $index = $this->_createIndex();
+ $type = $index->getType('test');
+
+ $type->setMapping(array(
'name' => array('type' => 'string', 'index' => 'not_analyzed'),
'location' => array('type' => 'geo_point'),
- 'price' => array('type' => 'float')
+ 'price' => array('type' => 'float'),
));
- $this->type->addDocument(new Document(1, array(
- 'name' => "Mr. Frostie's",
- 'location' => array('lat' => 32.799605, 'lon' => -117.243027),
- 'price' => 4.5
- )));
- $this->type->addDocument(new Document(2, array(
- 'name' => "Miller's Field",
- 'location' => array('lat' => 32.795964, 'lon' => -117.255028),
- 'price' => 9.5
- )));
-
- $this->index->refresh();
- }
+ $type->addDocuments(array(
+ new Document(1, array(
+ 'name' => "Mr. Frostie's",
+ 'location' => array('lat' => 32.799605, 'lon' => -117.243027),
+ 'price' => 4.5,
+ )),
+ new Document(2, array(
+ 'name' => "Miller's Field",
+ 'location' => array('lat' => 32.795964, 'lon' => -117.255028),
+ 'price' => 9.5,
+ )),
+ ));
- protected function tearDown()
- {
- $this->index->delete();
- parent::tearDown();
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group unit
+ */
public function testToArray()
{
$priceOrigin = 0;
$locationScale = '2mi';
$priceScale = 9.25;
$query = new FunctionScore();
- $childQuery = new \Elastica\Query\MatchAll();
+ $childQuery = new MatchAll();
$query->setQuery($childQuery);
$query->addDecayFunction(FunctionScore::DECAY_GAUSS, 'location', $this->locationOrigin, $locationScale);
$query->addDecayFunction(FunctionScore::DECAY_GAUSS, 'price', $priceOrigin, $priceScale);
@@ -76,30 +62,82 @@ class FunctionScoreTest extends BaseTest
'gauss' => array(
'location' => array(
'origin' => $this->locationOrigin,
- 'scale' => $locationScale
- )
- )
+ 'scale' => $locationScale,
+ ),
+ ),
),
array(
'gauss' => array(
'price' => array(
'origin' => $priceOrigin,
- 'scale' => $priceScale
- )
- )
- )
- )
- )
+ 'scale' => $priceScale,
+ ),
+ ),
+ ),
+ ),
+ ),
);
$this->assertEquals($expected, $query->toArray());
}
+ /**
+ * @group unit
+ */
+ public function testDecayWeight()
+ {
+ $priceOrigin = 0;
+ $locationScale = '2mi';
+ $priceScale = 9.25;
+ $query = new FunctionScore();
+ $childQuery = new MatchAll();
+ $query->setQuery($childQuery);
+ $query->addDecayFunction(
+ FunctionScore::DECAY_GAUSS,
+ 'location',
+ $this->locationOrigin,
+ $locationScale,
+ null,
+ null,
+ .5
+ );
+ $query->addDecayFunction(FunctionScore::DECAY_GAUSS, 'price', $priceOrigin, $priceScale, null, null, 2);
+ $expected = array(
+ 'function_score' => array(
+ 'query' => $childQuery->toArray(),
+ 'functions' => array(
+ array(
+ 'gauss' => array(
+ 'location' => array(
+ 'origin' => $this->locationOrigin,
+ 'scale' => $locationScale,
+ ),
+ ),
+ 'weight' => .5,
+ ),
+ array(
+ 'gauss' => array(
+ 'price' => array(
+ 'origin' => $priceOrigin,
+ 'scale' => $priceScale,
+ ),
+ ),
+ 'weight' => 2,
+ ),
+ ),
+ ),
+ );
+ $this->assertEquals($expected, $query->toArray());
+ }
+
+ /**
+ * @group functional
+ */
public function testGauss()
{
$query = new FunctionScore();
- $query->addDecayFunction(FunctionScore::DECAY_GAUSS, 'location', $this->locationOrigin, "4mi");
+ $query->addDecayFunction(FunctionScore::DECAY_GAUSS, 'location', $this->locationOrigin, '4mi');
$query->addDecayFunction(FunctionScore::DECAY_GAUSS, 'price', 0, 10);
- $response = $this->type->search($query);
+ $response = $this->_getIndexForTest()->search($query);
$results = $response->getResults();
// the document with the closest location and lowest price should be scored highest
@@ -107,7 +145,10 @@ class FunctionScoreTest extends BaseTest
$this->assertEquals("Mr. Frostie's", $result0['name']);
}
- public function testBoostFactor()
+ /**
+ * @group functional
+ */
+ public function testWeight()
{
$filter = new Term(array('price' => 4.5));
$query = new FunctionScore();
@@ -116,20 +157,20 @@ class FunctionScoreTest extends BaseTest
'function_score' => array(
'functions' => array(
array(
- 'boost_factor' => 5.0,
+ 'weight' => 5.0,
'filter' => array(
'term' => array(
- 'price' => 4.5
- )
- )
- )
- )
- )
+ 'price' => 4.5,
+ ),
+ ),
+ ),
+ ),
+ ),
);
$this->assertEquals($expected, $query->toArray());
- $response = $this->type->search($query);
+ $response = $this->_getIndexForTest()->search($query);
$results = $response->getResults();
// the document with price = 4.5 should be scored highest
@@ -137,6 +178,9 @@ class FunctionScoreTest extends BaseTest
$this->assertEquals("Mr. Frostie's", $result0['name']);
}
+ /**
+ * @group functional
+ */
public function testRandomScore()
{
$filter = new Term(array('price' => 4.5));
@@ -147,39 +191,74 @@ class FunctionScoreTest extends BaseTest
'functions' => array(
array(
'random_score' => array(
- 'seed' => 2
+ 'seed' => 2,
),
'filter' => array(
'term' => array(
- 'price' => 4.5
- )
- )
- )
- )
- )
+ 'price' => 4.5,
+ ),
+ ),
+ ),
+ ),
+ ),
);
$this->assertEquals($expected, $query->toArray());
- $response = $this->type->search($query);
+ $response = $this->_getIndexForTest()->search($query);
$results = $response->getResults();
// the document with the random score should have a score > 1, means it is the first result
- $result0 = $results[1]->getData();
-
+ $result0 = $results[0]->getData();
+
$this->assertEquals("Miller's Field", $result0['name']);
}
+ /**
+ * @group unit
+ */
+ public function testRandomScoreWeight()
+ {
+ $filter = new Term(array('price' => 4.5));
+ $query = new FunctionScore();
+ $query->addRandomScoreFunction(2, $filter, 2);
+ $expected = array(
+ 'function_score' => array(
+ 'functions' => array(
+ array(
+ 'random_score' => array(
+ 'seed' => 2,
+ ),
+ 'filter' => array(
+ 'term' => array(
+ 'price' => 4.5,
+ ),
+ ),
+ 'weight' => 2,
+ ),
+ ),
+ ),
+ );
+
+ $this->assertEquals($expected, $query->toArray());
+ }
+
+ /**
+ * @group functional
+ */
public function testRandomScoreWithoutSeed()
{
$query = new FunctionScore();
$query->setRandomScore();
- $response = $this->type->search($query);
+ $response = $this->_getIndexForTest()->search($query);
$this->assertEquals(2, $response->count());
}
+ /**
+ * @group functional
+ */
public function testScriptScore()
{
$scriptString = "_score * doc['price'].value";
@@ -191,20 +270,55 @@ class FunctionScoreTest extends BaseTest
'functions' => array(
array(
'script_score' => array(
- 'script' => $scriptString
- )
- )
- )
- )
+ 'script' => $scriptString,
+ ),
+ ),
+ ),
+ ),
);
$this->assertEquals($expected, $query->toArray());
- $response = $this->type->search($query);
+ $response = $this->_getIndexForTest()->search($query);
$results = $response->getResults();
// the document the highest price should be scored highest
$result0 = $results[0]->getData();
$this->assertEquals("Miller's Field", $result0['name']);
}
+
+ /**
+ * @group functional
+ */
+ public function testSetMinScore()
+ {
+ $expected = array(
+ 'function_score' => array(
+ 'min_score' => 0.8,
+ 'functions' => array(
+ array(
+ 'gauss' => array(
+ 'price' => array(
+ 'origin' => 0,
+ 'scale' => 10,
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+
+ $query = new FunctionScore();
+ $query->addDecayFunction(FunctionScore::DECAY_GAUSS, 'price', 0, 10);
+ $returnedValue = $query->setMinScore(0.8);
+
+ $this->assertEquals($expected, $query->toArray());
+ $this->assertInstanceOf('Elastica\Query\FunctionScore', $returnedValue);
+
+ $response = $this->_getIndexForTest()->search($query);
+ $results = $response->getResults();
+
+ $this->assertCount(1, $results);
+ $this->assertEquals(1, $results[0]->getId());
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FuzzyLikeThisTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FuzzyLikeThisTest.php
index c842c1a8..fe11e788 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FuzzyLikeThisTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FuzzyLikeThisTest.php
@@ -1,16 +1,18 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Document;
use Elastica\Index;
use Elastica\Query\FuzzyLikeThis;
+use Elastica\Test\Base as BaseTest;
use Elastica\Type;
use Elastica\Type\Mapping;
-use Elastica\Test\Base as BaseTest;
class FuzzyLikeThisTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testSearch()
{
$client = $this->_getClient();
@@ -20,7 +22,7 @@ class FuzzyLikeThisTest extends BaseTest
//$index->getSettings()->setNumberOfShards(1);
$type = new Type($index, 'helloworldfuzzy');
- $mapping = new Mapping($type , array(
+ $mapping = new Mapping($type, array(
'email' => array('store' => 'yes', 'type' => 'string', 'index' => 'analyzed'),
'content' => array('store' => 'yes', 'type' => 'string', 'index' => 'analyzed'),
));
@@ -35,14 +37,17 @@ class FuzzyLikeThisTest extends BaseTest
$index->refresh();
$fltQuery = new FuzzyLikeThis();
- $fltQuery->setLikeText("sample gmail");
- $fltQuery->addFields(array("email","content"));
+ $fltQuery->setLikeText('sample gmail');
+ $fltQuery->addFields(array('email', 'content'));
$fltQuery->setMinSimilarity(0.3);
$fltQuery->setMaxQueryTerms(3);
$resultSet = $type->search($fltQuery);
$this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group unit
+ */
public function testSetPrefixLength()
{
$query = new FuzzyLikeThis();
@@ -55,6 +60,9 @@ class FuzzyLikeThisTest extends BaseTest
$this->assertEquals($length, $data['fuzzy_like_this']['prefix_length']);
}
+ /**
+ * @group unit
+ */
public function testAddFields()
{
$query = new FuzzyLikeThis();
@@ -67,6 +75,9 @@ class FuzzyLikeThisTest extends BaseTest
$this->assertEquals($fields, $data['fuzzy_like_this']['fields']);
}
+ /**
+ * @group unit
+ */
public function testSetLikeText()
{
$query = new FuzzyLikeThis();
@@ -79,6 +90,9 @@ class FuzzyLikeThisTest extends BaseTest
$this->assertEquals(trim($text), $data['fuzzy_like_this']['like_text']);
}
+ /**
+ * @group unit
+ */
public function testSetIgnoreTF()
{
$query = new FuzzyLikeThis();
@@ -94,6 +108,9 @@ class FuzzyLikeThisTest extends BaseTest
$this->assertEquals($ignoreTF, $data['fuzzy_like_this']['ignore_tf']);
}
+ /**
+ * @group unit
+ */
public function testSetIgnoreTFDefault()
{
$query = new FuzzyLikeThis();
@@ -104,6 +121,9 @@ class FuzzyLikeThisTest extends BaseTest
$this->assertEquals($defaultIgnoreTF, $data['fuzzy_like_this']['ignore_tf']);
}
+ /**
+ * @group unit
+ */
public function testSetMinSimilarity()
{
$query = new FuzzyLikeThis();
@@ -116,6 +136,9 @@ class FuzzyLikeThisTest extends BaseTest
$this->assertEquals($similarity, $data['fuzzy_like_this']['min_similarity']);
}
+ /**
+ * @group unit
+ */
public function testSetBoost()
{
$query = new FuzzyLikeThis();
@@ -128,6 +151,9 @@ class FuzzyLikeThisTest extends BaseTest
$this->assertEquals($boost, $data['fuzzy_like_this']['boost']);
}
+ /**
+ * @group unit
+ */
public function testAddAnalyzerViasetParam()
{
$analyzer = 'snowball';
@@ -139,6 +165,9 @@ class FuzzyLikeThisTest extends BaseTest
$this->assertEquals($analyzer, $data['fuzzy_like_this']['analyzer']);
}
+ /**
+ * @group unit
+ */
public function testSetAnalyzer()
{
$analyzer = 'snowball';
@@ -150,6 +179,9 @@ class FuzzyLikeThisTest extends BaseTest
$this->assertEquals($analyzer, $data['fuzzy_like_this']['analyzer']);
}
+ /**
+ * @group unit
+ */
public function testAnalyzerNotPresentInArrayToMaintainDefaultOfField()
{
$query = new FuzzyLikeThis();
@@ -158,6 +190,9 @@ class FuzzyLikeThisTest extends BaseTest
$this->assertArrayNotHasKey('analyzer', $data);
}
+ /**
+ * @group unit
+ */
public function testArgArrayFieldsOverwrittenBySetParams()
{
$query = new FuzzyLikeThis();
@@ -168,6 +203,9 @@ class FuzzyLikeThisTest extends BaseTest
$this->assertEquals(200, $data['fuzzy_like_this']['max_query_terms']);
}
+ /**
+ * @group functional
+ */
public function testSearchSetAnalyzer()
{
$client = $this->_getClient();
@@ -177,41 +215,40 @@ class FuzzyLikeThisTest extends BaseTest
'searchAnalyzer' => array(
'type' => 'custom',
'tokenizer' => 'standard',
- 'filter' => array('myStopWords')
- )
+ 'filter' => array('myStopWords'),
+ ),
),
'filter' => array(
'myStopWords' => array(
'type' => 'stop',
- 'stopwords' => array('The')
- )
- )
+ 'stopwords' => array('The'),
+ ),
+ ),
)), true);
$index->getSettings()->setNumberOfReplicas(0);
//$index->getSettings()->setNumberOfShards(1);
-
+
$type = new Type($index, 'helloworldfuzzy');
- $mapping = new Mapping($type , array(
+ $mapping = new Mapping($type, array(
'email' => array('store' => 'yes', 'type' => 'string', 'index' => 'analyzed'),
'content' => array('store' => 'yes', 'type' => 'string', 'index' => 'analyzed'),
));
-
+
$mapping->setSource(array('enabled' => false));
$type->setMapping($mapping);
- $doc = new Document(1000, array('email' => 'testemail@gmail.com', 'content' => 'The Fuzzy Test!'));
- $type->addDocument($doc);
-
- $doc = new Document(1001, array('email' => 'testemail@gmail.com', 'content' => 'Elastica Fuzzy Test'));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1000, array('email' => 'testemail@gmail.com', 'content' => 'The Fuzzy Test!')),
+ new Document(1001, array('email' => 'testemail@gmail.com', 'content' => 'Elastica Fuzzy Test')),
+ ));
// Refresh index
$index->refresh();
$fltQuery = new FuzzyLikeThis();
- $fltQuery->addFields(array("email","content"));
- $fltQuery->setLikeText("The");
+ $fltQuery->addFields(array('email', 'content'));
+ $fltQuery->setLikeText('The');
$fltQuery->setMinSimilarity(0.1);
$fltQuery->setMaxQueryTerms(3);
@@ -225,4 +262,39 @@ class FuzzyLikeThisTest extends BaseTest
$resultSet = $type->search($fltQuery);
$this->assertEquals(0, $resultSet->count());
}
+
+ /**
+ * @group functional
+ */
+ public function testNoLikeTextProvidedShouldReturnNoResults()
+ {
+ $client = $this->_getClient();
+ $index = new Index($client, 'test');
+ $index->create(array(), true);
+ $index->getSettings()->setNumberOfReplicas(0);
+
+ $type = new Type($index, 'helloworldfuzzy');
+ $mapping = new Mapping($type, array(
+ 'email' => array('store' => 'yes', 'type' => 'string', 'index' => 'analyzed'),
+ 'content' => array('store' => 'yes', 'type' => 'string', 'index' => 'analyzed'),
+ ));
+
+ $mapping->setSource(array('enabled' => false));
+ $type->setMapping($mapping);
+
+ $doc = new Document(1000, array('email' => 'testemail@gmail.com', 'content' => 'This is a sample post. Hello World Fuzzy Like This!'));
+ $type->addDocument($doc);
+
+ // Refresh index
+ $index->refresh();
+
+ $fltQuery = new FuzzyLikeThis();
+ $fltQuery->setLikeText('');
+ $fltQuery->addFields(array('email', 'content'));
+ $fltQuery->setMinSimilarity(0.3);
+ $fltQuery->setMaxQueryTerms(3);
+ $resultSet = $type->search($fltQuery);
+
+ $this->assertEquals(0, $resultSet->count());
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FuzzyTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FuzzyTest.php
index 57659293..e9107232 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FuzzyTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FuzzyTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Document;
@@ -8,6 +7,9 @@ use Elastica\Test\Base as BaseTest;
class FuzzyTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$fuzzy = new Fuzzy();
@@ -16,9 +18,9 @@ class FuzzyTest extends BaseTest
'fuzzy' => array(
'user' => array(
'value' => 'Nicolas',
- 'boost' => 1.0
- )
- )
+ 'boost' => 1.0,
+ ),
+ ),
);
$this->assertEquals($expectedArray, $fuzzy->toArray(), 'Deprecated method failed');
@@ -27,8 +29,8 @@ class FuzzyTest extends BaseTest
'fuzzy' => array(
'user' => array(
'value' => 'Nicolas',
- )
- )
+ ),
+ ),
);
$this->assertEquals($expectedArray, $fuzzy->toArray());
@@ -38,13 +40,16 @@ class FuzzyTest extends BaseTest
'fuzzy' => array(
'user' => array(
'value' => 'Nicolas',
- 'boost' => 1.0
- )
- )
+ 'boost' => 1.0,
+ ),
+ ),
);
$this->assertEquals($expectedArray, $fuzzy->toArray());
}
+ /**
+ * @group functional
+ */
public function testQuery()
{
$client = $this->_getClient();
@@ -52,14 +57,12 @@ class FuzzyTest extends BaseTest
$index->create(array(), true);
$type = $index->getType('test');
- $doc = new Document(1, array('name' => 'Basel-Stadt'));
- $type->addDocument($doc);
- $doc = new Document(2, array('name' => 'New York'));
- $type->addDocument($doc);
- $doc = new Document(3, array('name' => 'Baden'));
- $type->addDocument($doc);
- $doc = new Document(4, array('name' => 'Baden Baden'));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'Basel-Stadt')),
+ new Document(2, array('name' => 'New York')),
+ new Document(3, array('name' => 'Baden')),
+ new Document(4, array('name' => 'Baden Baden')),
+ ));
$index->refresh();
@@ -73,7 +76,10 @@ class FuzzyTest extends BaseTest
$this->assertEquals(2, $resultSet->count());
}
- public function testBadArguments ()
+ /**
+ * @group unit
+ */
+ public function testBadArguments()
{
$this->setExpectedException('Elastica\Exception\InvalidException');
$query = new Fuzzy();
@@ -88,20 +94,21 @@ class FuzzyTest extends BaseTest
$query->setField('name', 'value');
$query->setField('name1', 'value1');
}
-
- public function testFuzzyWithFacets() {
+ /**
+ * @group functional
+ */
+ public function testFuzzyWithFacets()
+ {
$index = $this->_createIndex();
$type = $index->getType('test');
- $doc = new Document(1, array('name' => 'Basel-Stadt'));
- $type->addDocument($doc);
- $doc = new Document(2, array('name' => 'New York'));
- $type->addDocument($doc);
- $doc = new Document(3, array('name' => 'Baden'));
- $type->addDocument($doc);
- $doc = new Document(4, array('name' => 'Baden Baden'));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'Basel-Stadt')),
+ new Document(2, array('name' => 'New York')),
+ new Document(3, array('name' => 'Baden')),
+ new Document(4, array('name' => 'Baden Baden')),
+ ));
$index->refresh();
@@ -109,21 +116,21 @@ class FuzzyTest extends BaseTest
$fuzzyQuery = new Fuzzy();
$fuzzyQuery->setField($field, 'Baden');
-
+
$facet = new \Elastica\Facet\Terms('test');
$facet->setField('name');
-
- $query = new \Elastica\Query($fuzzyQuery);
- $query->addFacet($facet);
+
+ $query = new \Elastica\Query($fuzzyQuery);
+ $query->addFacet($facet);
$resultSet = $index->search($query);
-
- // Assert query worked ok
+
+ // Assert query worked ok
$this->assertEquals(2, $resultSet->count());
-
- // Check Facets
- $this->assertTrue($resultSet->hasFacets());
- $facets = $resultSet->getFacets();
- $this->assertEquals(2, $facets['test']['total']);
- }
+
+ // Check Facets
+ $this->assertTrue($resultSet->hasFacets());
+ $facets = $resultSet->getFacets();
+ $this->assertEquals(2, $facets['test']['total']);
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HasChildTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HasChildTest.php
index bb1b5b96..a717b1ab 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HasChildTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HasChildTest.php
@@ -1,14 +1,19 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Document;
+use Elastica\Query;
use Elastica\Query\HasChild;
+use Elastica\Query\Match;
use Elastica\Query\MatchAll;
use Elastica\Test\Base as BaseTest;
+use Elastica\Type\Mapping;
class HasChildTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$q = new MatchAll();
@@ -20,13 +25,16 @@ class HasChildTest extends BaseTest
$expectedArray = array(
'has_child' => array(
'query' => $q->toArray(),
- 'type' => $type
- )
+ 'type' => $type,
+ ),
);
$this->assertEquals($expectedArray, $query->toArray());
}
+ /**
+ * @group unit
+ */
public function testSetScope()
{
$q = new MatchAll();
@@ -42,55 +50,56 @@ class HasChildTest extends BaseTest
'has_child' => array(
'query' => $q->toArray(),
'type' => $type,
- '_scope' => $scope
- )
+ '_scope' => $scope,
+ ),
);
$this->assertEquals($expectedArray, $query->toArray());
}
-
+
+ /**
+ * @group functional
+ */
public function testTypeInsideHasChildSearch()
{
- $index = $this->prepareSearchData();
-
- $f = new \Elastica\Query\Match();
+ $index = $this->_getTestIndex();
+
+ $f = new Match();
$f->setField('alt.name', 'testname');
$query = new HasChild($f, 'child');
-
- $searchQuery = new \Elastica\Query();
+
+ $searchQuery = new Query();
$searchQuery->setQuery($query);
$searchResults = $index->search($searchQuery);
-
+
$this->assertEquals(1, $searchResults->count());
-
+
$result = $searchResults->current()->getData();
$expected = array('id' => 'parent2', 'user' => 'parent2', 'email' => 'parent2@test.com');
-
+
$this->assertEquals($expected, $result);
- }
-
- private function prepareSearchData()
+ }
+
+ protected function _getTestIndex()
{
- $client = $this->_getClient();
- $index = $client->getIndex('has_child_test');
- $index->create(array(), true);
-
+ $index = $this->_createIndex('has_child_test');
+
$parentType = $index->getType('parent');
-
+
$childType = $index->getType('child');
- $childMapping = new \Elastica\Type\Mapping($childType);
+ $childMapping = new Mapping($childType);
$childMapping->setParent('parent');
$childMapping->send();
-
+
$altType = $index->getType('alt');
$altDoc = new Document('alt1', array('name' => 'altname'));
$altType->addDocument($altDoc);
-
+
$parent1 = new Document('parent1', array('id' => 'parent1', 'user' => 'parent1', 'email' => 'parent1@test.com'));
$parentType->addDocument($parent1);
$parent2 = new Document('parent2', array('id' => 'parent2', 'user' => 'parent2', 'email' => 'parent2@test.com'));
$parentType->addDocument($parent2);
-
+
$child1 = new Document('child1', array('id' => 'child1', 'user' => 'child1', 'email' => 'child1@test.com'));
$child1->setParent('parent1');
$childType->addDocument($child1);
@@ -100,8 +109,9 @@ class HasChildTest extends BaseTest
$child3 = new Document('child3', array('id' => 'child3', 'user' => 'child3', 'email' => 'child3@test.com', 'alt' => array(array('name' => 'testname'))));
$child3->setParent('parent2');
$childType->addDocument($child3);
-
+
$index->refresh();
+
return $index;
}
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HasParentTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HasParentTest.php
index d417c887..31a89852 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HasParentTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HasParentTest.php
@@ -1,13 +1,19 @@
<?php
-
namespace Elastica\Test\Query;
+use Elastica\Document;
use Elastica\Query\HasParent;
+use Elastica\Query\Match;
use Elastica\Query\MatchAll;
+use Elastica\Search;
use Elastica\Test\Base as BaseTest;
+use Elastica\Type\Mapping;
class HasParentTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$q = new MatchAll();
@@ -19,13 +25,16 @@ class HasParentTest extends BaseTest
$expectedArray = array(
'has_parent' => array(
'query' => $q->toArray(),
- 'type' => $type
- )
+ 'type' => $type,
+ ),
);
$this->assertEquals($expectedArray, $query->toArray());
}
+ /**
+ * @group unit
+ */
public function testSetScope()
{
$q = new MatchAll();
@@ -41,10 +50,59 @@ class HasParentTest extends BaseTest
'has_parent' => array(
'query' => $q->toArray(),
'type' => $type,
- '_scope' => $scope
- )
+ '_scope' => $scope,
+ ),
);
$this->assertEquals($expectedArray, $query->toArray());
}
+
+ /**
+ * @group functional
+ */
+ public function testHasParent()
+ {
+ $index = $this->_createIndex();
+
+ $shopType = $index->getType('shop');
+ $productType = $index->getType('product');
+ $mapping = new Mapping();
+ $mapping->setParent('shop');
+ $productType->setMapping($mapping);
+
+ $shopType->addDocuments(
+ array(
+ new Document('zurich', array('brand' => 'google')),
+ new Document('london', array('brand' => 'apple')),
+ )
+ );
+
+ $doc1 = new Document(1, array('device' => 'chromebook'));
+ $doc1->setParent('zurich');
+
+ $doc2 = new Document(2, array('device' => 'macmini'));
+ $doc2->setParent('london');
+
+ $productType->addDocument($doc1);
+ $productType->addDocument($doc2);
+
+ $index->refresh();
+
+ // All documents
+ $parentQuery = new HasParent(new MatchAll(), $shopType->getName());
+ $search = new Search($index->getClient());
+ $results = $search->search($parentQuery);
+ $this->assertEquals(2, $results->count());
+
+ $match = new Match();
+ $match->setField('brand', 'google');
+
+ $parentQuery = new HasParent($match, $shopType->getName());
+ $search = new Search($index->getClient());
+ $results = $search->search($parentQuery);
+ $this->assertEquals(1, $results->count());
+ $result = $results->current();
+ $data = $result->getData();
+ $this->assertEquals($data['device'], 'chromebook');
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HighlightTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HighlightTest.php
index 4b1b6c5e..c6850019 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HighlightTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HighlightTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Document;
@@ -9,19 +8,20 @@ use Elastica\Test\Base as BaseTest;
class HighlightTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testHightlightSearch()
{
- $client = $this->_getClient();
- $index = $client->getIndex('test');
- $index->create(array(), true);
+ $index = $this->_createIndex();
$type = $index->getType('helloworld');
$phrase = 'My name is ruflin';
- $doc = new Document(1, array('id' => 1, 'phrase' => $phrase, 'username' => 'hanswurst', 'test' => array('2', '3', '5')));
- $type->addDocument($doc);
- $doc = new Document(2, array('id' => 2, 'phrase' => $phrase, 'username' => 'peter', 'test' => array('2', '3', '5')));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('id' => 1, 'phrase' => $phrase, 'username' => 'hanswurst', 'test' => array('2', '3', '5'))),
+ new Document(2, array('id' => 2, 'phrase' => $phrase, 'username' => 'peter', 'test' => array('2', '3', '5'))),
+ ));
$queryString = new QueryString('rufl*');
$query = new Query($queryString);
@@ -44,6 +44,5 @@ class HighlightTest extends BaseTest
$this->assertEquals(array('phrase' => array(0 => 'My name is <em class="highlight">ruflin</em>')), $highlight);
}
$this->assertEquals(2, $resultSet->count());
-
}
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/IdsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/IdsTest.php
index d1bf901e..7b39020f 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/IdsTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/IdsTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Document;
@@ -11,11 +10,11 @@ class IdsTest extends BaseTest
protected $_index;
protected $_type;
- public function setUp()
+ protected function setUp()
{
- $client = $this->_getClient();
- $index = $client->getIndex('test');
- $index->create(array(), true);
+ parent::setUp();
+
+ $index = $this->_createIndex();
$type1 = $index->getType('helloworld1');
$type2 = $index->getType('helloworld2');
@@ -38,13 +37,9 @@ class IdsTest extends BaseTest
$this->_index = $index;
}
- public function tearDown()
- {
- $client = $this->_getClient();
- $index = $client->getIndex('test');
- $index->delete();
- }
-
+ /**
+ * @group functional
+ */
public function testSetIdsSearchSingle()
{
$query = new Ids();
@@ -55,6 +50,9 @@ class IdsTest extends BaseTest
$this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testSetIdsSearchArray()
{
$query = new Ids();
@@ -65,6 +63,9 @@ class IdsTest extends BaseTest
$this->assertEquals(2, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testAddIdsSearchSingle()
{
$query = new Ids();
@@ -75,6 +76,9 @@ class IdsTest extends BaseTest
$this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testComboIdsSearchArray()
{
$query = new Ids();
@@ -87,6 +91,9 @@ class IdsTest extends BaseTest
$this->assertEquals(3, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testSetTypeSingleSearchSingle()
{
$query = new Ids();
@@ -99,6 +106,9 @@ class IdsTest extends BaseTest
$this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testSetTypeSingleSearchArray()
{
$query = new Ids();
@@ -111,6 +121,9 @@ class IdsTest extends BaseTest
$this->assertEquals(2, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testSetTypeSingleSearchSingleDocInOtherType()
{
$query = new Ids();
@@ -125,6 +138,9 @@ class IdsTest extends BaseTest
$this->assertEquals(0, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testSetTypeSingleSearchArrayDocInOtherType()
{
$query = new Ids();
@@ -139,6 +155,9 @@ class IdsTest extends BaseTest
$this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testSetTypeArraySearchArray()
{
$query = new Ids();
@@ -151,6 +170,9 @@ class IdsTest extends BaseTest
$this->assertEquals(2, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testSetTypeArraySearchSingle()
{
$query = new Ids();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/ImageTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/ImageTest.php
new file mode 100644
index 00000000..989e4e4a
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/ImageTest.php
@@ -0,0 +1,159 @@
+<?php
+namespace Elastica\Test\Query;
+
+use Elastica\Document;
+use Elastica\Index;
+use Elastica\Query\Image;
+use Elastica\Test\Base as BaseTest;
+use Elastica\Type;
+use Elastica\Type\Mapping;
+
+class ImageTest extends BaseTest
+{
+ /**
+ * @var string
+ */
+ protected $_testFileContent;
+
+ protected function setUp()
+ {
+ parent::setUp();
+ $this->_testFileContent = base64_encode(file_get_contents(BASE_PATH.'/data/test.jpg'));
+ }
+
+ /**
+ * @group unit
+ */
+ public function testToArrayFromReference()
+ {
+ $client = $this->_getClient();
+ $index = new Index($client, 'test');
+ $type = new Type($index, 'helloworld');
+ $field = 'image';
+
+ $query = new Image();
+ $query->setFieldFeature($field, 'CEDD');
+ $query->setFieldHash($field, 'BIT_SAMPLING');
+ $query->setFieldBoost($field, 100);
+
+ $query->setImageByReference($field, $index->getName(), $type->getName(), 10);
+
+ $jsonString = '{"image":{"image":{"feature":"CEDD","hash":"BIT_SAMPLING","boost":100,"index":"test","type":"helloworld","id":10,"path":"image"}}}';
+ $this->assertEquals($jsonString, json_encode($query->toArray()));
+ }
+
+ /**
+ * @group unit
+ */
+ public function testToArrayFromImage()
+ {
+ $field = 'image';
+
+ $query = new Image();
+ $query->setFieldFeature($field, 'CEDD');
+ $query->setFieldHash($field, 'BIT_SAMPLING');
+ $query->setFieldBoost($field, 100);
+
+ $query->setFieldImage($field, BASE_PATH.'/data/test.jpg');
+
+ $jsonString = '{"image":{"image":{"feature":"CEDD","hash":"BIT_SAMPLING","boost":100,"image":"\/9j\/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP\/sABFEdWNreQABAAQAAAA8AAD\/4QN6aHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLwA8P3hwYWNrZXQgYmVnaW49Iu+7vyIgaWQ9Ilc1TTBNcENlaGlIenJlU3pOVGN6a2M5ZCI\/PiA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJBZG9iZSBYTVAgQ29yZSA1LjUtYzAyMSA3OS4xNTQ5MTEsIDIwMTMvMTAvMjktMTE6NDc6MTYgICAgICAgICI+IDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+IDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdFJlZj0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bXBNTTpPcmlnaW5hbERvY3VtZW50SUQ9InhtcC5kaWQ6OWQ4MjQ5N2MtNzViMS0wYzQ5LTg4ZjMtMDdiNmRhMjU0ZWRhIiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOjA4NjBGM0Y1QkJGQTExRTM4MjQ0QzMzNjU2MjUxOEJGIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjA4NjBGM0Y0QkJGQTExRTM4MjQ0QzMzNjU2MjUxOEJGIiB4bXA6Q3JlYXRvclRvb2w9IkFkb2JlIFBob3Rvc2hvcCBDQyAoV2luZG93cykiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo5ZDgyNDk3Yy03NWIxLTBjNDktODhmMy0wN2I2ZGEyNTRlZGEiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6OWQ4MjQ5N2MtNzViMS0wYzQ5LTg4ZjMtMDdiNmRhMjU0ZWRhIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+\/+4ADkFkb2JlAGTAAAAAAf\/bAIQABgQEBAUEBgUFBgkGBQYJCwgGBggLDAoKCwoKDBAMDAwMDAwQDA4PEA8ODBMTFBQTExwbGxscHx8fHx8fHx8fHwEHBwcNDA0YEBAYGhURFRofHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8f\/8AAEQgAZABkAwERAAIRAQMRAf\/EAKwAAAEFAQEBAQAAAAAAAAAAAAgAAwQFBwYCAQkBAQEAAwEBAAAAAAAAAAAAAAABAgQFAwYQAAEDAgMCBQwOCQQDAAAAAAIBAwQABRESBiEHMUFhExRRcYEisnPDNIQVRRaRodEyQlJikiOzVGYnCLFyo9NklKQlGIIzQ2VTdhcRAAIBAgQEBAYDAQAAAAAAAAABAhEDITESBEFRMgVhcZFCgaHR4SITsVJiFf\/aAAwDAQACEQMRAD8AJyHDhlDYImG1JWwVVUBVVVRTkqge6DC+ztfMH3KgF0GF9na+YPuUAugwvs7XzB9ygF0GF9na+YPuUBR6n1NpDTTAuXUmgdcTFmK22JvuYfFbRMcOVdnLXje3MLa\/JmEpqOZmty32GbiparFGaa24OS1QzXlyNoiJ85a50+5y9q9Tyd7kiva3v6jQ8xwraY\/E5gh9tDrBdxueBP2s6ax74rK6YtXq0DFx2LJjIjzafrAooaJ1sa2LfcU+pUM1eXE0i3nY7jEblwUjyYzqYg62gEK+wnDyV0IzUlVOqPVNMkdBhfZ2vmD7lZFF0GF9na+YPuUBD6JF88c3zIc30fNkyphjnwxwwqkJkHxKP3oO5SoUfoBUAqA47eXr5rSlqEY6C7eJuIwmC2iKJ755xE+AGPZXZWpu9z+qOHU8jzuXNK8Qe813vd2UlV243WaWJmvbOGqcarsQQHsCKVw4Qnclh+UmamLZ3dn3UKQCd1lkprwx42CCnIrpIqqvWSuva7Uve\/Q9la5l0W6rT6hgCSQPiLnlL2iTCth9ss+PqX9aOcv27W725spEEimsDtJpRyvoicaInan2NvJWjf7dKKrB6l8\/uYuDRWaT1fdNN3BJcIlNhxU6XCVcG3hTh\/VcT4Jdhdlali+7bqsiRk0ETZrvBvFsj3KCfORZI5wVdipxKJJxEK7FSu9bmpxTWRtJ1VSbWZSF6b8m8JVA9B8Sj96DuUqAfoDNdab+dKaZvDtnGPIuk6MqDMSNkRtolTHIpuEKKaIqYoOOHHtoCz3bb07frsriMO3yIPm7ms\/SCbLPz2bDLkIuDJx0Bh2u9SHf9VXG5kalHEyYhp8WOwqiOCfKXE+zXzO4u67jkaM5VdTSt3ulAtdrB54E84zBFyUfGIr2wMovUFOHqlX0Gy2ytQ\/08\/oe8I0R3LTIinBW6ZEphGxLthx61Ggiw6Mw8zwIQrXk20zMxXexpMLZLG7xRysSTyShRMERxdouf68MC5a5HcLCi9a45+fP4nhcjTEsdx2oTbuEywun9DIBZcUV4nAVBdRP1kUS7FTt12jcfiWzLgbJXWNghem\/JvCVQPQfEo\/eg7lKgH6AC1m2u6h3hnajeVty63h9hySqZlFDkGpHgvCqCi4VQEvp3dvYNA2a+yLI7KcclxlN1ZTgubY7ZqCjlEMPfLjXncdIvyI8gfbLGR+4W1hzaDzzAn1lMca+b28azinzRoxWISEIUwxw4Vxr642mTxSqQfbCowTI+IqvUVNtYSM4nI70GG39JXNC4W2VcFeoQEhItae9VbMjG50syPdfKNnXtmUOFxxxov1TZPH9FcfaOl2J423+SCVr6A2yF6b8m8JVA9B8Sj96DuUqAfoAOtGF+MtrT\/v3vrXaoDAmRhlRH4x+9fbJsusYqK\/prGSqqBgjgj9ul82YqMm3vZCBeHPHcwVOyoV8zGsJeMX\/AAaGQRdjlNTobctgkJl4BdbVOMTTH2uCvrIyUkmsmbWZbtJjtrMhKbGsWyj2wRxrBmSM73v3lqHpd+Pm+muBDHaHjUcUJxewKVz+43KW6cZYfUwuukfM4PczbHJuuor+XFm3tOyHC6iqPNB7Z1ztjGt1eB5WlWQRdd42yF6b8m8JVA9B8Sj96DuUqA5jeTvJtWhLSzMnMPSn5hmzBjsiioTwgpojhqqIA7Npe1QA2borLf77vMtFwYiOOMx5x3C5TEAkjtoucyTnFTLiRnlEccaoDBqAH7fhpB60X71jihjbLqSJLUU2NS8MMS6gvImxfjJypXG31jTLWsma16NHUh7ud4Q2VUt1wNUtxkqsv7V5kiXFUJE282q7dnvV5Kz2W9UFon08Hy+xjCdDaIdyYkNi82Ym04mIOAqEJIvGhJsrtp1VVkexYDLbRMcajZUVWotV2qzQilXGQLDSJ2grtM1+K2HCS14Xr0barJ\/V+RXJLMH7VWp52qr10lwVajtpzcONjjzbeOOK4cJku0q+d3O4c5apYcvBGpOdXU3XdTo0tPWJX5LeS43DK48K++BtE+jbXl2qq8q11e3bdwhql1S+S4GzZhRVZ21dA9SF6b8m8JVA9B8Sj96DuUqA5feRu0tOvLbGh3CVIhlCcJ+K7GUNjhAoduJiWYUx4NnXoAbdz+p9R6f3m2yyx5riwJVwdt1wgqZLGcwU2+dFtVwE0IEJCTbxLilUBg1AVmpVsnmKYF7Fpy1uN83IbfVEA0NUERxXjIlRE5axkk1R5ElSmIKWoLQ9Y7m9HUSSOhKraEqkQCq4oKl8LBNmbjrlbrt8oOsMY\/NGq7b4Huz6juduPC2z3IxLtVts+1XrguI+1WjC7KHS3EwToXbu8PWxt5EupgnxgFsS9lBr1e8vP3My1y5lCy1e7\/cubYGTd7ia4YBmePsrtQE66ola6UpvCsn6mGLZtu7XdAtoNu66gyOXAVQmIIKhtslxEZcBmnFh2qcvDXT23b6PVcz4I2LdmmLNTrqnuKgIXpvybwlUD0HxKP3oO5SoB+gAo0Qf43WlPvC\/9c9VAa9QGC79NZjcLoOnIp5oVtJHJypwHKVO1DlRoVxX5S8lcff39UtCyWZq35VwMrLUN3Pmbc235yJ0xYhxDxJxTNcoNtn75MVWvXbbqcaLqRhCbQTunN2OloOmIlquFriy3hHnJTjrYuKr57XMDVMcEXYmHEldCduM+pI29KeZIa3XbvWjQwsETMm3aGZPYVVSvJbS1\/VE\/XHkYlvp3zav3fa8LTWlQtsK2JDjyBZKIiqrjqmhe8NtPgJxV7xilkZJULrcV+Ya86v1H6ranjRxnyGnHrdPiCTYuKymZxpxsiPAsmJCQrhs4KpTfKAVAQvTfk3hKoHoPiUfvQdylQD9ABHoYvxxtP8A7E\/9c9VAW28PV7WltNPzhUSnO\/QW5lfhPmi5VVPignbFyJWvub6twb48DCc9KqChcZZqpm44rjpkRuOltIzJcxEvKSrjXz0at1ZpGk\/l10Ot0vD2sZ7eMO2kUe0iSYoclUwdewX\/AMQrkH5Sr1K7Gzte5nvZhxCMroGyKgOe1ToPR2o4stLzZ4cx6QwrBynGGykICIuXK8qZxUVXEcF2LQAafl6JR3zaYRSXY7KDMvCuEV5NvXwoA7KAVAQvTfk3hKoHoPiUfvQdylQD9AA9oUvx0tKfeN\/656qAjN48yyXqZJ09emnIc+P9JalLATNvKirJil71xMVyOBwphtTai15XbMbkaSMZxTWJiZ7utS3a+x7PazbkdKcQFliuVGWse3dMC29oO3BMcV2Vzf8Anzi+aNd2WFhp2w27T9jhWW3BzcKA0LLI8aonCRdUiXElXq11IxSVEbKVFQsayKKgESISKK7UXYqUAAmu7A9uz1+o2K\/xJsq2yykQXoh85IikJqoty21Hm0MUVRIcxIqcOHBQBhblNb3bW+7i16juwMNz5ZPg8MUSFr6F82kVBMjVMUDFdvDQHc0BC9N+TeEqgeg+JR+9B3KVAP0ADOgy\/Ha0J95H\/rnqoDT1Fpiwajt62+9wm50VVQxFxFQgNOA2zFUNs04iBUWoCn0Xu4tGkpEx+HMmTSlZRBZ7ovkyCYrkBzKJqir8dSXZw0B1dAKgFQHl1VFo1HhQVVOvhQH567obLA1XvYsNnvIrJhzpjzs0CVfpUaBx9RNeHAyDAuSgP0Et9ut9tiNwrdFZhQ2UwajR2xaaBFXHtQBEFNvUSgJFAQvTfk3hKoHoPiUfvQdylQD9AABrKPedG7y7o2RlBu1tujs6A+qIiqJPq8w+CFsICEk9tKoO2\/yy3qIiY+aNibV6M5t5f9+oD5\/lpvV\/6j+Wc\/f0B5X82u9Xi80fyzn7+gPJfm43qim3zR\/LOfv6AZP83+9ZODzP\/LO\/v6Ag3P8ANvvZm2+TC5y2xkktk0siPHNHQQ0wUm1N0xQuoqitARPyqafn3XfDbJ0dslhWRqRJmPInaijjJstipcGYzc2Jx4L1KAO2gFQEL035N4SqBmJ546KzzfR+byDkzZ8cMEwxwoQe\/vf8N+0oU5bWfqdjH9c\/V7NgvRfO3NZsMdvN8\/twx4cKA5j8BuP1K\/pKA+fgL9yv6OgF+An3J\/o6A8r\/APAOP1I7PQ6A8F\/j1x+o\/Z6FQHgv8deP1F7PQqA7rRnq\/wCal9S\/MfmrOubzRzfMc5gmObo\/a5sOrtoC\/wD73\/DftKAX97\/hv2lARP7p50\/4Of5j5eTJn9nHGhD\/2Q=="}}}';
+ $this->assertEquals($jsonString, json_encode($query->toArray()));
+ }
+
+ /**
+ * @group functional
+ */
+ public function testFromReference()
+ {
+ $this->markTestSkipped('Tests skipped as plugin not working properly with ES 1.6.0. See https://github.com/ruflin/Elastica/pull/881');
+ $field = 'image';
+
+ $client = $this->_getClient();
+ $index = $client->getIndex('test');
+ $index->create(array(), true);
+
+ $type = $index->getType('test');
+
+ $mapping = new Mapping($type, array(
+ $field => array(
+ 'type' => 'image',
+ 'store' => false,
+ 'include_in_all' => false,
+ 'feature' => array(
+ 'CEDD' => array(
+ 'hash' => 'BIT_SAMPLING',
+ ),
+ ),
+ ),
+ )
+ );
+
+ $type->setMapping($mapping);
+
+ $type->addDocuments(array(
+ new Document(1, array($field => $this->_testFileContent)),
+ new Document(2, array($field => $this->_testFileContent)),
+ new Document(3, array($field => $this->_testFileContent)),
+ ));
+
+ $index->refresh();
+
+ $query = new Image();
+ $query->setFieldFeature($field, 'CEDD');
+ $query->setFieldHash($field, 'BIT_SAMPLING');
+ $query->setFieldBoost($field, 100);
+ $query->setImageByReference($field, $index->getName(), $type->getName(), 1);
+
+ $resultSet = $index->search($query);
+ $this->assertEquals(3, $resultSet->count());
+ }
+
+ /**
+ * @group functional
+ */
+ public function testFromImage()
+ {
+ $this->markTestSkipped('Tests skipped as plugin not working properly with ES 1.6.0. See https://github.com/ruflin/Elastica/pull/881');
+
+ $field = 'image';
+
+ $client = $this->_getClient();
+ $index = $client->getIndex('test');
+ $index->create(array(), true);
+
+ $type = $index->getType('test');
+
+ $mapping = new Mapping($type, array(
+ $field => array(
+ 'type' => 'image',
+ 'store' => false,
+ 'include_in_all' => false,
+ 'feature' => array(
+ 'CEDD' => array(
+ 'hash' => 'BIT_SAMPLING',
+ ),
+ ),
+ ),
+ )
+ );
+
+ $type->setMapping($mapping);
+
+ $type->addDocuments(array(
+ new Document(1, array($field => $this->_testFileContent)),
+ new Document(2, array($field => $this->_testFileContent)),
+ new Document(3, array($field => $this->_testFileContent)),
+ ));
+
+ $index->refresh();
+
+ $query = new Image();
+ $query->setFieldFeature($field, 'CEDD');
+ $query->setFieldHash($field, 'BIT_SAMPLING');
+ $query->setFieldBoost($field, 100);
+ $query->setFieldImage($field, BASE_PATH.'/data/test.jpg');
+
+ $resultSet = $index->search($query);
+ $this->assertEquals(3, $resultSet->count());
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MatchAllTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MatchAllTest.php
index 3731e659..7eb0fae0 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MatchAllTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MatchAllTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Document;
@@ -9,6 +8,9 @@ use Elastica\Test\Base as BaseTest;
class MatchAllTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$query = new MatchAll();
@@ -18,10 +20,13 @@ class MatchAllTest extends BaseTest
$this->assertEquals($expectedArray, $query->toArray());
}
+ /**
+ * @group functional
+ */
public function testMatchAllIndicesTypes()
{
- $index1 = $this->_createIndex('test1');
- $index2 = $this->_createIndex('test2');
+ $index1 = $this->_createIndex();
+ $index2 = $this->_createIndex();
$client = $index1->getClient();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MatchTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MatchTest.php
index ed164663..98fdf26a 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MatchTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MatchTest.php
@@ -1,13 +1,17 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Document;
use Elastica\Query\Match;
+use Elastica\Query\MatchPhrase;
+use Elastica\Query\MatchPhrasePrefix;
use Elastica\Test\Base as BaseTest;
class MatchTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$field = 'test';
@@ -46,14 +50,17 @@ class MatchTest extends BaseTest
'fuzziness' => $fuzziness,
'fuzzy_rewrite' => $fuzzyRewrite,
'prefix_length' => $prefixLength,
- 'max_expansions' => $maxExpansions
- )
- )
+ 'max_expansions' => $maxExpansions,
+ ),
+ ),
);
$this->assertEquals($expectedArray, $query->toArray());
}
+ /**
+ * @group functional
+ */
public function testMatch()
{
$client = $this->_getClient();
@@ -61,14 +68,75 @@ class MatchTest extends BaseTest
$index->create(array(), true);
$type = $index->getType('test');
- $doc = new Document(1, array('name' => 'Basel-Stadt'));
- $type->addDocument($doc);
- $doc = new Document(2, array('name' => 'New York'));
- $type->addDocument($doc);
- $doc = new Document(3, array('name' => 'New Hampshire'));
- $type->addDocument($doc);
- $doc = new Document(4, array('name' => 'Basel Land'));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'Basel-Stadt')),
+ new Document(2, array('name' => 'New York')),
+ new Document(3, array('name' => 'New Hampshire')),
+ new Document(4, array('name' => 'Basel Land')),
+ ));
+
+ $index->refresh();
+
+ $field = 'name';
+ $operator = 'or';
+
+ $query = new Match();
+ $query->setFieldQuery($field, 'Basel New');
+ $query->setFieldOperator($field, $operator);
+
+ $resultSet = $index->search($query);
+
+ $this->assertEquals(4, $resultSet->count());
+ }
+
+ /**
+ * @group functional
+ */
+ public function testMatchSetFieldBoost()
+ {
+ $client = $this->_getClient();
+ $index = $client->getIndex('test');
+ $index->create(array(), true);
+ $type = $index->getType('test');
+
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'Basel-Stadt')),
+ new Document(2, array('name' => 'New York')),
+ new Document(3, array('name' => 'New Hampshire')),
+ new Document(4, array('name' => 'Basel Land')),
+ ));
+
+ $index->refresh();
+
+ $field = 'name';
+ $operator = 'or';
+
+ $query = new Match();
+ $query->setFieldQuery($field, 'Basel New');
+ $query->setFieldOperator($field, $operator);
+ $query->setFieldBoost($field, 1.2);
+
+ $resultSet = $index->search($query);
+
+ $this->assertEquals(4, $resultSet->count());
+ }
+
+ /**
+ * @group functional
+ */
+ public function testMatchSetFieldBoostWithString()
+ {
+ $client = $this->_getClient();
+ $index = $client->getIndex('test');
+ $index->create(array(), true);
+ $type = $index->getType('test');
+
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'Basel-Stadt')),
+ new Document(2, array('name' => 'New York')),
+ new Document(3, array('name' => 'New Hampshire')),
+ new Document(4, array('name' => 'Basel Land')),
+ ));
$index->refresh();
@@ -78,22 +146,28 @@ class MatchTest extends BaseTest
$query = new Match();
$query->setFieldQuery($field, 'Basel New');
$query->setFieldOperator($field, $operator);
+ $query->setFieldBoost($field, '1.2');
$resultSet = $index->search($query);
$this->assertEquals(4, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testMatchZeroTerm()
{
$client = $this->_getClient();
$index = $client->getIndex('test');
$index->create(array(), true);
$type = $index->getType('test');
- $doc = new Document(1, array('name' => 'Basel-Stadt'));
- $type->addDocument($doc);
- $doc = new Document(2, array('name' => 'New York'));
- $type->addDocument($doc);
+
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'Basel-Stadt')),
+ new Document(2, array('name' => 'New York')),
+ ));
+
$index->refresh();
$query = new Match();
@@ -105,6 +179,9 @@ class MatchTest extends BaseTest
$this->assertEquals(2, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testMatchPhrase()
{
$client = $this->_getClient();
@@ -112,14 +189,12 @@ class MatchTest extends BaseTest
$index->create(array(), true);
$type = $index->getType('test');
- $doc = new Document(1, array('name' => 'Basel-Stadt'));
- $type->addDocument($doc);
- $doc = new Document(2, array('name' => 'New York'));
- $type->addDocument($doc);
- $doc = new Document(3, array('name' => 'New Hampshire'));
- $type->addDocument($doc);
- $doc = new Document(4, array('name' => 'Basel Land'));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'Basel-Stadt')),
+ new Document(2, array('name' => 'New York')),
+ new Document(3, array('name' => 'New Hampshire')),
+ new Document(4, array('name' => 'Basel Land')),
+ ));
$index->refresh();
@@ -135,6 +210,38 @@ class MatchTest extends BaseTest
$this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group functional
+ */
+ public function testMatchPhraseAlias()
+ {
+ $client = $this->_getClient();
+ $index = $client->getIndex('test');
+ $index->create(array(), true);
+ $type = $index->getType('test');
+
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'Basel-Stadt')),
+ new Document(2, array('name' => 'New York')),
+ new Document(3, array('name' => 'New Hampshire')),
+ new Document(4, array('name' => 'Basel Land')),
+ ));
+
+ $index->refresh();
+
+ $field = 'name';
+
+ $query = new MatchPhrase();
+ $query->setFieldQuery($field, 'New York');
+
+ $resultSet = $index->search($query);
+
+ $this->assertEquals(1, $resultSet->count());
+ }
+
+ /**
+ * @group functional
+ */
public function testMatchPhrasePrefix()
{
$client = $this->_getClient();
@@ -142,14 +249,12 @@ class MatchTest extends BaseTest
$index->create(array(), true);
$type = $index->getType('test');
- $doc = new Document(1, array('name' => 'Basel-Stadt'));
- $type->addDocument($doc);
- $doc = new Document(2, array('name' => 'New York'));
- $type->addDocument($doc);
- $doc = new Document(3, array('name' => 'New Hampshire'));
- $type->addDocument($doc);
- $doc = new Document(4, array('name' => 'Basel Land'));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'Basel-Stadt')),
+ new Document(2, array('name' => 'New York')),
+ new Document(3, array('name' => 'New Hampshire')),
+ new Document(4, array('name' => 'Basel Land')),
+ ));
$index->refresh();
@@ -164,24 +269,71 @@ class MatchTest extends BaseTest
$this->assertEquals(2, $resultSet->count());
}
-
-
+
+ /**
+ * @group functional
+ */
+ public function testMatchPhrasePrefixAlias()
+ {
+ $client = $this->_getClient();
+ $index = $client->getIndex('test');
+ $index->create(array(), true);
+ $type = $index->getType('test');
+
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'Basel-Stadt')),
+ new Document(2, array('name' => 'New York')),
+ new Document(3, array('name' => 'New Hampshire')),
+ new Document(4, array('name' => 'Basel Land')),
+ ));
+
+ $index->refresh();
+
+ $field = 'name';
+
+ $query = new MatchPhrasePrefix();
+ $query->setFieldQuery($field, 'New');
+
+ $resultSet = $index->search($query);
+
+ $this->assertEquals(2, $resultSet->count());
+ }
+
+ /**
+ * @group unit
+ */
public function testMatchFuzzinessType()
{
$field = 'test';
$query = new Match();
-
- $fuzziness = "AUTO";
+
+ $fuzziness = 'AUTO';
$query->setFieldFuzziness($field, $fuzziness);
-
- $parameters = $query->getParam($field);
- $this->assertEquals($fuzziness, $parameters['fuzziness']);
-
-
+
+ $parameters = $query->getParam($field);
+ $this->assertEquals($fuzziness, $parameters['fuzziness']);
+
$fuzziness = 0.3;
$query->setFieldFuzziness($field, $fuzziness);
-
- $parameters = $query->getParam($field);
- $this->assertEquals($fuzziness, $parameters['fuzziness']);
+
+ $parameters = $query->getParam($field);
+ $this->assertEquals($fuzziness, $parameters['fuzziness']);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testConstruct()
+ {
+ $match = new Match(null, 'values');
+ $this->assertEquals(array('match' => array()), $match->toArray());
+
+ $match = new Match('field', null);
+ $this->assertEquals(array('match' => array()), $match->toArray());
+
+ $match1 = new Match('field', 'values');
+ $match2 = new Match();
+ $match2->setField('field', 'values');
+ $this->assertEquals($match1->toArray(), $match2->toArray());
}
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MoreLikeThisTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MoreLikeThisTest.php
index b352e23a..5dfe9379 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MoreLikeThisTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MoreLikeThisTest.php
@@ -1,17 +1,19 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Document;
use Elastica\Index;
use Elastica\Query;
use Elastica\Query\MoreLikeThis;
+use Elastica\Test\Base as BaseTest;
use Elastica\Type;
use Elastica\Type\Mapping;
-use Elastica\Test\Base as BaseTest;
class MoreLikeThisTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testSearch()
{
$client = $this->_getClient();
@@ -21,7 +23,7 @@ class MoreLikeThisTest extends BaseTest
//$index->getSettings()->setNumberOfShards(1);
$type = new Type($index, 'helloworldmlt');
- $mapping = new Mapping($type , array(
+ $mapping = new Mapping($type, array(
'email' => array('store' => 'yes', 'type' => 'string', 'index' => 'analyzed'),
'content' => array('store' => 'yes', 'type' => 'string', 'index' => 'analyzed'),
));
@@ -40,7 +42,7 @@ class MoreLikeThisTest extends BaseTest
$mltQuery = new MoreLikeThis();
$mltQuery->setLikeText('fake gmail sample');
- $mltQuery->setFields(array('email','content'));
+ $mltQuery->setFields(array('email', 'content'));
$mltQuery->setMaxQueryTerms(1);
$mltQuery->setMinDocFrequency(1);
$mltQuery->setMinTermFrequency(1);
@@ -54,6 +56,9 @@ class MoreLikeThisTest extends BaseTest
$this->assertEquals(2, $resultSet->count());
}
+ /**
+ * @group unit
+ */
public function testSetFields()
{
$query = new MoreLikeThis();
@@ -65,6 +70,22 @@ class MoreLikeThisTest extends BaseTest
$this->assertEquals($fields, $data['more_like_this']['fields']);
}
+ /**
+ * @group unit
+ */
+ public function testSetIds()
+ {
+ $query = new MoreLikeThis();
+ $ids = array(1, 2, 3);
+ $query->setIds($ids);
+
+ $data = $query->toArray();
+ $this->assertEquals($ids, $data['more_like_this']['ids']);
+ }
+
+ /**
+ * @group unit
+ */
public function testSetLikeText()
{
$query = new MoreLikeThis();
@@ -74,6 +95,9 @@ class MoreLikeThisTest extends BaseTest
$this->assertEquals('hello world', $data['more_like_this']['like_text']);
}
+ /**
+ * @group unit
+ */
public function testSetBoost()
{
$query = new MoreLikeThis();
@@ -84,6 +108,9 @@ class MoreLikeThisTest extends BaseTest
$this->assertEquals($boost, $query->getParam('boost'));
}
+ /**
+ * @group unit
+ */
public function testSetMaxQueryTerms()
{
$query = new MoreLikeThis();
@@ -94,6 +121,9 @@ class MoreLikeThisTest extends BaseTest
$this->assertEquals($max, $query->getParam('max_query_terms'));
}
+ /**
+ * @group unit
+ */
public function testSetPercentTermsToMatch()
{
$query = new MoreLikeThis();
@@ -104,6 +134,22 @@ class MoreLikeThisTest extends BaseTest
$this->assertEquals($match, $query->getParam('percent_terms_to_match'));
}
+ /**
+ * @group unit
+ */
+ public function testSetMinimumShouldMatch()
+ {
+ $query = new MoreLikeThis();
+
+ $match = '80%';
+ $query->setMinimumShouldMatch($match);
+
+ $this->assertEquals($match, $query->getParam('minimum_should_match'));
+ }
+
+ /**
+ * @group unit
+ */
public function testSetMinDocFrequency()
{
$query = new MoreLikeThis();
@@ -114,6 +160,9 @@ class MoreLikeThisTest extends BaseTest
$this->assertEquals($freq, $query->getParam('min_doc_freq'));
}
+ /**
+ * @group unit
+ */
public function testSetMaxDocFrequency()
{
$query = new MoreLikeThis();
@@ -124,6 +173,9 @@ class MoreLikeThisTest extends BaseTest
$this->assertEquals($freq, $query->getParam('max_doc_freq'));
}
+ /**
+ * @group unit
+ */
public function testSetMinWordLength()
{
$query = new MoreLikeThis();
@@ -134,6 +186,9 @@ class MoreLikeThisTest extends BaseTest
$this->assertEquals($length, $query->getParam('min_word_length'));
}
+ /**
+ * @group unit
+ */
public function testSetMaxWordLength()
{
$query = new MoreLikeThis();
@@ -144,6 +199,9 @@ class MoreLikeThisTest extends BaseTest
$this->assertEquals($length, $query->getParam('max_word_length'));
}
+ /**
+ * @group unit
+ */
public function testSetBoostTerms()
{
$query = new MoreLikeThis();
@@ -154,6 +212,9 @@ class MoreLikeThisTest extends BaseTest
$this->assertEquals($boost, $query->getParam('boost_terms'));
}
+ /**
+ * @group unit
+ */
public function testSetAnalyzer()
{
$query = new MoreLikeThis();
@@ -164,6 +225,9 @@ class MoreLikeThisTest extends BaseTest
$this->assertEquals($analyzer, $query->getParam('analyzer'));
}
+ /**
+ * @group unit
+ */
public function testSetStopWords()
{
$query = new MoreLikeThis();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MultiMatchTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MultiMatchTest.php
index 78a8a8fe..e32f91af 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MultiMatchTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MultiMatchTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Document;
@@ -22,114 +21,142 @@ class MultiMatchTest extends BaseTest
array('id' => 4, 'name' => 'John', 'last_name' => 'not Doe', 'full_name' => 'John not Doe'),
);
- protected function setUp()
- {
- $this->index = $this->_generateIndex();
- $this->multiMatch = new MultiMatch();
- }
-
+ /**
+ * @group functional
+ */
public function testMinimumShouldMatch()
{
- $this->multiMatch->setQuery('Tristan Maindron');
- $this->multiMatch->setFields(array('full_name', 'name'));
- $this->multiMatch->setMinimumShouldMatch(2);
- $resultSet = $this->_getResults();
+ $multiMatch = new MultiMatch();
+ $multiMatch->setQuery('Tristan Maindron');
+ $multiMatch->setFields(array('full_name', 'name'));
+ $multiMatch->setMinimumShouldMatch('2<100%');
+ $resultSet = $this->_getResults($multiMatch);
$this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testAndOperator()
{
- $this->multiMatch->setQuery('Monique Maindron');
- $this->multiMatch->setFields(array('full_name', 'name'));
- $this->multiMatch->setOperator(MultiMatch::OPERATOR_AND);
- $resultSet = $this->_getResults();
+ $multiMatch = new MultiMatch();
+ $multiMatch->setQuery('Monique Maindron');
+ $multiMatch->setFields(array('full_name', 'name'));
+ $multiMatch->setOperator(MultiMatch::OPERATOR_AND);
+ $resultSet = $this->_getResults($multiMatch);
$this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testType()
{
- $this->multiMatch->setQuery('Trist');
- $this->multiMatch->setFields(array('full_name', 'name'));
- $this->multiMatch->setType(MultiMatch::TYPE_PHRASE_PREFIX);
- $resultSet = $this->_getResults();
+ $multiMatch = new MultiMatch();
+ $multiMatch->setQuery('Trist');
+ $multiMatch->setFields(array('full_name', 'name'));
+ $multiMatch->setType(MultiMatch::TYPE_PHRASE_PREFIX);
+ $resultSet = $this->_getResults($multiMatch);
$this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testFuzzy()
{
- $this->multiMatch->setQuery('Tritsan'); // Mispell on purpose
- $this->multiMatch->setFields(array('full_name', 'name'));
- $this->multiMatch->setFuzziness(2);
- $resultSet = $this->_getResults();
+ $multiMatch = new MultiMatch();
+ $multiMatch->setQuery('Tritsan'); // Mispell on purpose
+ $multiMatch->setFields(array('full_name', 'name'));
+ $multiMatch->setFuzziness(2);
+ $resultSet = $this->_getResults($multiMatch);
$this->assertEquals(1, $resultSet->count());
- $this->multiMatch->setQuery('Tritsan'); // Mispell on purpose
- $this->multiMatch->setFields(array('full_name', 'name'));
- $this->multiMatch->setFuzziness(0);
- $resultSet = $this->_getResults();
+ $multiMatch = new MultiMatch();
+ $multiMatch->setQuery('Tritsan'); // Mispell on purpose
+ $multiMatch->setFields(array('full_name', 'name'));
+ $multiMatch->setFuzziness(0);
+ $resultSet = $this->_getResults($multiMatch);
$this->assertEquals(0, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testFuzzyWithOptions1()
{
// Here Elasticsearch will not accept mispells
// on the first 6 letters.
- $this->multiMatch->setQuery('Tritsan'); // Mispell on purpose
- $this->multiMatch->setFields(array('full_name', 'name'));
- $this->multiMatch->setFuzziness(2);
- $this->multiMatch->setPrefixLength(6);
- $resultSet = $this->_getResults();
+ $multiMatch = new MultiMatch();
+ $multiMatch->setQuery('Tritsan'); // Mispell on purpose
+ $multiMatch->setFields(array('full_name', 'name'));
+ $multiMatch->setFuzziness(2);
+ $multiMatch->setPrefixLength(6);
+ $resultSet = $this->_getResults($multiMatch);
- $this->assertEquals(0, $resultSet->count());
+ $this->assertEquals(0, $resultSet->count());
}
-
- public function testFuzzyWithOptions2() {
+ /**
+ * @group functional
+ */
+ public function testFuzzyWithOptions2()
+ {
// Here with a 'M' search we should hit 'Moraes' first
// and then stop because MaxExpansion = 1.
// If MaxExpansion was set to 2, we could hit "Maindron" too.
- $this->multiMatch->setQuery('M');
- $this->multiMatch->setFields(array('name'));
- $this->multiMatch->setType(MultiMatch::TYPE_PHRASE_PREFIX);
- $this->multiMatch->setPrefixLength(0);
- $this->multiMatch->setMaxExpansions(1);
- $resultSet = $this->_getResults();
+ $multiMatch = new MultiMatch();
+ $multiMatch->setQuery('M');
+ $multiMatch->setFields(array('name'));
+ $multiMatch->setType(MultiMatch::TYPE_PHRASE_PREFIX);
+ $multiMatch->setPrefixLength(0);
+ $multiMatch->setMaxExpansions(1);
+ $resultSet = $this->_getResults($multiMatch);
$this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testZeroTerm()
{
- $this->multiMatch->setQuery('not'); // This is a stopword.
- $this->multiMatch->setFields(array('full_name', 'last_name'));
- $this->multiMatch->setZeroTermsQuery(MultiMatch::ZERO_TERM_NONE);
- $this->multiMatch->setAnalyzer('stops');
- $resultSet = $this->_getResults();
+ $multiMatch = new MultiMatch();
+ $multiMatch->setQuery('not'); // This is a stopword.
+ $multiMatch->setFields(array('full_name', 'last_name'));
+ $multiMatch->setZeroTermsQuery(MultiMatch::ZERO_TERM_NONE);
+ $multiMatch->setAnalyzer('stops');
+ $resultSet = $this->_getResults($multiMatch);
$this->assertEquals(0, $resultSet->count());
- $this->multiMatch->setZeroTermsQuery(MultiMatch::ZERO_TERM_ALL);
- $resultSet = $this->_getResults();
+ $multiMatch->setZeroTermsQuery(MultiMatch::ZERO_TERM_ALL);
+ $resultSet = $this->_getResults($multiMatch);
$this->assertEquals(4, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testBaseMultiMatch()
{
- $this->multiMatch->setQuery('Rodolfo');
- $this->multiMatch->setFields(array('name', 'last_name'));
- $resultSet = $this->_getResults();
+ $multiMatch = new MultiMatch();
+ $multiMatch->setQuery('Rodolfo');
+ $multiMatch->setFields(array('name', 'last_name'));
+ $resultSet = $this->_getResults($multiMatch);
$this->assertEquals(1, $resultSet->count());
- $this->multiMatch->setQuery('Moraes');
- $this->multiMatch->setFields(array('name', 'last_name'));
- $resultSet = $this->_getResults();
+ $multiMatch = new MultiMatch();
+ $multiMatch->setQuery('Moraes');
+ $multiMatch->setFields(array('name', 'last_name'));
+ $resultSet = $this->_getResults($multiMatch);
$this->assertEquals(1, $resultSet->count());
}
@@ -137,9 +164,9 @@ class MultiMatchTest extends BaseTest
/**
* Executes the query with the current multimatch.
*/
- private function _getResults()
+ private function _getResults(MultiMatch $multiMatch)
{
- return $this->index->search(new Query($this->multiMatch));
+ return $this->_generateIndex()->search(new Query($multiMatch));
}
/**
@@ -154,21 +181,21 @@ class MultiMatchTest extends BaseTest
'analysis' => array(
'analyzer' => array(
'noStops' => array(
- 'type' => 'standard',
- 'stopwords' => '_none_'
+ 'type' => 'standard',
+ 'stopwords' => '_none_',
),
'stops' => array(
- 'type' => 'standard',
- 'stopwords' => array('not')
+ 'type' => 'standard',
+ 'stopwords' => array('not'),
),
),
- )
+ ),
), true);
$type = $index->getType('test');
$mapping = new Mapping($type, array(
- 'name' => array('type' => 'string', 'store' => 'no', 'analyzer' => 'noStops'),
+ 'name' => array('type' => 'string', 'store' => 'no', 'analyzer' => 'noStops'),
'last_name' => array('type' => 'string', 'store' => 'no', 'analyzer' => 'noStops'),
'full_name' => array('type' => 'string', 'store' => 'no', 'analyzer' => 'noStops'),
));
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/NestedTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/NestedTest.php
index 310a728b..1b5fc368 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/NestedTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/NestedTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Query\Nested;
@@ -8,6 +7,9 @@ use Elastica\Test\Base as BaseTest;
class NestedTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testSetQuery()
{
$nested = new Nested();
@@ -20,7 +22,7 @@ class NestedTest extends BaseTest
'nested' => array(
'query' => $queryString->toArray(),
'path' => $path,
- )
+ ),
);
$this->assertEquals($expected, $nested->toArray());
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/PostFilterTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/PostFilterTest.php
index 16b7e07b..178c803e 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/PostFilterTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/PostFilterTest.php
@@ -1,61 +1,48 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Document;
use Elastica\Filter\Term;
-use Elastica\Index;
-use Elastica\Query\Match;
use Elastica\Query;
+use Elastica\Query\Match;
use Elastica\Test\Base as BaseTest;
class PostFilterTest extends BaseTest
{
- /**
- * @var Index
- */
- protected $_index;
-
- protected function setUp()
+ protected function _getTestIndex()
{
- parent::setUp();
- $this->_index = $this->_createIndex("query");
+ $index = $this->_createIndex();
$docs = array(
- new Document("1", array("color" => "green", "make" => "ford")),
- new Document("2", array("color" => "blue", "make" => "volvo")),
- new Document("3", array("color" => "red", "make" => "ford")),
- new Document("4", array("color" => "green", "make" => "renault")),
+ new Document(1, array('color' => 'green', 'make' => 'ford')),
+ new Document(2, array('color' => 'blue', 'make' => 'volvo')),
+ new Document(3, array('color' => 'red', 'make' => 'ford')),
+ new Document(4, array('color' => 'green', 'make' => 'renault')),
);
- $this->_index->getType("test")->addDocuments($docs);
- $this->_index->refresh();
+ $index->getType('test')->addDocuments($docs);
+ $index->refresh();
+ return $index;
}
- protected function tearDown()
- {
- parent::tearDown();
- if ($this->_index instanceof Index) {
- $this->_index->delete();
- }
- }
-
+ /**
+ * @group unit
+ */
public function testToArray()
{
$query = new Query();
$post_filter = new Term(array('color' => 'green'));
- $query->setPostFilter($post_filter->toArray());
+ $query->setPostFilter($post_filter);
$data = $query->toArray();
$this->assertArrayHasKey('post_filter', $data);
$this->assertEquals(array('term' => array('color' => 'green')), $data['post_filter']);
-
- $query->setPostFilter(array());
-
- $this->assertArrayNotHasKey('post_filter', $query->toArray());
}
+ /**
+ * @group functional
+ */
public function testQuery()
{
$query = new Query();
@@ -68,16 +55,10 @@ class PostFilterTest extends BaseTest
$filter = new Term();
$filter->setTerm('color', 'green');
- $query->setPostFilter($filter->toArray());
+ $query->setPostFilter($filter);
- $results = $this->_index->search($query);
+ $results = $this->_getTestIndex()->search($query);
$this->assertEquals(1, $results->getTotalHits());
-
- }
-
- protected function _createIndex($name = 'test', $delete = true, $shards = 1)
- {
- return parent::_createIndex('test_postfilter_' . $name, $delete, $shards);
}
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/PrefixTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/PrefixTest.php
index e6852c2e..e12ead05 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/PrefixTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/PrefixTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Query\Prefix;
@@ -7,7 +6,9 @@ use Elastica\Test\Base as BaseTest;
class PrefixTest extends BaseTest
{
-
+ /**
+ * @group unit
+ */
public function testToArray()
{
$query = new Prefix();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/QueryStringTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/QueryStringTest.php
index 059bad2d..5b549a30 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/QueryStringTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/QueryStringTest.php
@@ -1,22 +1,22 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Document;
-use Elastica\Index;
-use Elastica\Type;
use Elastica\Query\QueryString;
use Elastica\Test\Base as BaseTest;
class QueryStringTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testSearchMultipleFields()
{
$str = md5(rand());
$query = new QueryString($str);
$expected = array(
- 'query' => $str
+ 'query' => $str,
);
$this->assertEquals(array('query_string' => $expected), $query->toArray());
@@ -39,20 +39,17 @@ class QueryStringTest extends BaseTest
}
}
+ /**
+ * @group functional
+ */
public function testSearch()
{
- $client = $this->_getClient();
- $index = new Index($client, 'test');
- $index->create(array(), true);
+ $index = $this->_createIndex();
$index->getSettings()->setNumberOfReplicas(0);
- //$index->getSettings()->setNumberOfShards(1);
-
- $type = new Type($index, 'helloworld');
+ $type = $index->getType('helloworld');
$doc = new Document(1, array('email' => 'test@test.com', 'username' => 'hanswurst', 'test' => array('2', '3', '5')));
$type->addDocument($doc);
-
- // Refresh index
$index->refresh();
$queryString = new QueryString('test*');
@@ -62,7 +59,9 @@ class QueryStringTest extends BaseTest
}
/**
- * Tests if search in multiple fields is possible
+ * Tests if search in multiple fields is possible.
+ *
+ * @group functional
*/
public function testSearchFields()
{
@@ -82,6 +81,9 @@ class QueryStringTest extends BaseTest
$this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group unit
+ */
public function testSetDefaultOperator()
{
$operator = 'AND';
@@ -93,6 +95,9 @@ class QueryStringTest extends BaseTest
$this->assertEquals($data['query_string']['default_operator'], $operator);
}
+ /**
+ * @group unit
+ */
public function testSetDefaultField()
{
$default = 'field1';
@@ -104,18 +109,22 @@ class QueryStringTest extends BaseTest
$this->assertEquals($data['query_string']['default_field'], $default);
}
+ /**
+ * @group unit
+ */
public function testSetRewrite()
{
- $rewrite = 'scoring_boolean';
- $query = new QueryString('test');
- $query->setRewrite($rewrite);
+ $rewrite = 'scoring_boolean';
+ $query = new QueryString('test');
+ $query->setRewrite($rewrite);
- $data = $query->toArray();
+ $data = $query->toArray();
- $this->assertEquals($data['query_string']['rewrite'], $rewrite);
+ $this->assertEquals($data['query_string']['rewrite'], $rewrite);
}
/**
+ * @group unit
* @expectedException \Elastica\Exception\InvalidException
*/
public function testSetQueryInvalid()
@@ -123,4 +132,58 @@ class QueryStringTest extends BaseTest
$query = new QueryString();
$query->setQuery(array());
}
+
+ /**
+ * @group unit
+ */
+ public function testSetTimezone()
+ {
+ $timezone = 'Europe/Paris';
+ $text = 'date:[2012 TO 2014]';
+
+ $query = new QueryString($text);
+ $query->setTimezone($timezone);
+
+ $expected = array(
+ 'query_string' => array(
+ 'query' => $text,
+ 'time_zone' => $timezone,
+ ),
+ );
+
+ $this->assertEquals($expected, $query->toArray());
+ $this->assertInstanceOf('Elastica\Query\QueryString', $query->setTimezone($timezone));
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetPhraseSlop()
+ {
+ $phraseSlop = 9;
+
+ $query = new QueryString('test');
+ $query->setPhraseSlop($phraseSlop);
+
+ $data = $query->toArray();
+ $this->assertEquals($phraseSlop, $data['query_string']['phrase_slop']);
+ }
+
+ /**
+ * @group functional
+ */
+ public function testSetBoost()
+ {
+ $index = $this->_createIndex();
+ $query = new QueryString('test');
+ $query->setBoost(9.3);
+
+ $doc = new Document('', array('name' => 'test'));
+ $index->getType('test')->addDocument($doc);
+ $index->refresh();
+
+ $resultSet = $index->search($query);
+
+ $this->assertEquals(1, $resultSet->count());
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RangeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RangeTest.php
index 4cd75bc8..108ef0c9 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RangeTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RangeTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Document;
@@ -8,6 +7,9 @@ use Elastica\Test\Base as BaseTest;
class RangeTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testQuery()
{
$client = $this->_getClient();
@@ -15,14 +17,12 @@ class RangeTest extends BaseTest
$index->create(array(), true);
$type = $index->getType('test');
- $doc = new Document(1, array('age' => 16, 'height' => 140));
- $type->addDocument($doc);
- $doc = new Document(2, array('age' => 21, 'height' => 155));
- $type->addDocument($doc);
- $doc = new Document(3, array('age' => 33, 'height' => 160));
- $type->addDocument($doc);
- $doc = new Document(4, array('age' => 68, 'height' => 160));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('age' => 16, 'height' => 140)),
+ new Document(2, array('age' => 21, 'height' => 155)),
+ new Document(3, array('age' => 33, 'height' => 160)),
+ new Document(4, array('age' => 68, 'height' => 160)),
+ ));
$index->optimize();
$index->refresh();
@@ -38,6 +38,9 @@ class RangeTest extends BaseTest
$this->assertEquals(2, $result);
}
+ /**
+ * @group unit
+ */
public function testToArray()
{
$range = new Range();
@@ -48,12 +51,15 @@ class RangeTest extends BaseTest
$expectedArray = array(
'range' => array(
'age' => $field,
- )
+ ),
);
$this->assertEquals($expectedArray, $range->toArray());
}
+ /**
+ * @group unit
+ */
public function testConstruct()
{
$ranges = array('from' => 20, 'to' => 40);
@@ -65,7 +71,7 @@ class RangeTest extends BaseTest
$expectedArray = array(
'range' => array(
'age' => $ranges,
- )
+ ),
);
$this->assertEquals($expectedArray, $range->toArray());
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RegexpTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RegexpTest.php
new file mode 100644
index 00000000..c67e6317
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RegexpTest.php
@@ -0,0 +1,31 @@
+<?php
+namespace Elastica\Test\Query;
+
+use Elastica\Query\Regexp;
+use Elastica\Test\Base as BaseTest;
+
+class RegexpTest extends BaseTest
+{
+ /**
+ * @group unit
+ */
+ public function testToArray()
+ {
+ $field = 'name';
+ $value = 'ruf';
+ $boost = 2;
+
+ $query = new Regexp($field, $value, $boost);
+
+ $expectedArray = array(
+ 'regexp' => array(
+ $field => array(
+ 'value' => $value,
+ 'boost' => $boost,
+ ),
+ ),
+ );
+
+ $this->assertequals($expectedArray, $query->toArray());
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RescoreTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RescoreTest.php
index 4396ceb4..87842b0f 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RescoreTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RescoreTest.php
@@ -1,27 +1,17 @@
<?php
-
namespace Elastica\Test\Query;
-use Elastica\Rescore\Query as QueryRescore;
-use Elastica\Query\Term;
-use Elastica\Query\Match;
use Elastica\Query;
+use Elastica\Query\Match;
+use Elastica\Query\Term;
+use Elastica\Rescore\Query as QueryRescore;
use Elastica\Test\Base as BaseTest;
class RescoreTest extends BaseTest
{
/**
- * @var Index
+ * @group unit
*/
- protected $_index;
-
- protected function setUp()
- {
- parent::setUp();
- $this->_index = $this->_createIndex("rescore_test");
- $this->_index->refresh();
- }
-
public function testToArray()
{
$query = new Query();
@@ -59,6 +49,9 @@ class RescoreTest extends BaseTest
$this->assertEquals($expected, $data);
}
+ /**
+ * @group unit
+ */
public function testSetSize()
{
$query = new Query();
@@ -98,6 +91,9 @@ class RescoreTest extends BaseTest
$this->assertEquals($expected, $data);
}
+ /**
+ * @group unit
+ */
public function testSetWeights()
{
$query = new Query();
@@ -133,7 +129,7 @@ class RescoreTest extends BaseTest
),
),
'query_weight' => 0.7,
- 'rescore_query_weight' => 1.2
+ 'rescore_query_weight' => 1.2,
),
),
);
@@ -141,6 +137,79 @@ class RescoreTest extends BaseTest
$this->assertEquals($expected, $data);
}
+ /**
+ * @group functional
+ */
+ public function testMultipleQueries()
+ {
+ $query = new Query();
+ $mainQuery = new Match();
+ $mainQuery = $mainQuery->setFieldQuery('test1', 'foo');
+
+ $secQuery1 = new Term();
+ $secQuery1 = $secQuery1->setTerm('test2', 'bar', 1);
+ $rescoreQuery1 = new QueryRescore();
+ $rescoreQuery1->setRescoreQuery($secQuery1);
+
+ $secQuery2 = new Term();
+ $secQuery2 = $secQuery2->setTerm('test2', 'tom', 2);
+ $rescoreQuery2 = new QueryRescore();
+ $rescoreQuery2->setRescoreQuery($secQuery2);
+
+ $query->setQuery($mainQuery);
+ $query->setRescore(array($rescoreQuery1, $rescoreQuery2));
+ $data = $query->toArray();
+
+ $expected = array(
+ 'query' => array(
+ 'match' => array(
+ 'test1' => array(
+ 'query' => 'foo',
+ ),
+ ),
+ ),
+ 'rescore' => array(
+ array(
+ 'query' => array(
+ 'rescore_query' => array(
+ 'term' => array(
+ 'test2' => array(
+ 'value' => 'bar',
+ 'boost' => 1,
+ ),
+ ),
+ ),
+ ),
+ ),
+ array(
+ 'query' => array(
+ 'rescore_query' => array(
+ 'term' => array(
+ 'test2' => array(
+ 'value' => 'tom',
+ 'boost' => 2,
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+
+ $this->assertEquals($expected, $data);
+
+ $index = $this->_createIndex();
+ $index->refresh();
+ $results = $index->search($query);
+ $response = $results->getResponse();
+
+ $this->assertEquals(true, $response->isOk());
+ $this->assertEquals(0, $results->getTotalHits());
+ }
+
+ /**
+ * @group functional
+ */
public function testQuery()
{
$query = new Query();
@@ -156,7 +225,9 @@ class RescoreTest extends BaseTest
$query->setRescore($queryRescore);
$data = $query->toArray();
- $results = $this->_index->search($query);
+ $index = $this->_createIndex();
+ $index->refresh();
+ $results = $index->search($query);
$response = $results->getResponse();
$this->assertEquals(true, $response->isOk());
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/SimpleQueryStringTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/SimpleQueryStringTest.php
index eff9b8a1..80316547 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/SimpleQueryStringTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/SimpleQueryStringTest.php
@@ -1,73 +1,103 @@
<?php
-
namespace Elastica\Test\Query;
-
use Elastica\Document;
-use Elastica\Index;
use Elastica\Query\SimpleQueryString;
use Elastica\Test\Base;
class SimpleQueryStringTest extends Base
{
/**
- * @var Index
+ * @group unit
*/
- protected $_index;
+ public function testToArray()
+ {
+ $string = 'this is a test';
+ $fields = array('field1', 'field2');
+ $query = new SimpleQueryString($string, $fields);
+ $query->setDefaultOperator(SimpleQueryString::OPERATOR_OR);
+ $query->setAnalyzer('whitespace');
+
+ $expected = array(
+ 'simple_query_string' => array(
+ 'query' => $string,
+ 'fields' => $fields,
+ 'analyzer' => 'whitespace',
+ 'default_operator' => SimpleQueryString::OPERATOR_OR,
+ ),
+ );
- protected function setUp()
+ $this->assertEquals($expected, $query->toArray());
+ }
+
+ /**
+ * @group functional
+ */
+ public function testQuery()
{
- parent::setUp();
- $this->_index = $this->_createIndex("simple_query_string_test");
+ $index = $this->_createIndex();
$docs = array(
new Document(1, array('make' => 'Gibson', 'model' => 'Les Paul')),
new Document(2, array('make' => 'Gibson', 'model' => 'SG Standard')),
new Document(3, array('make' => 'Gibson', 'model' => 'SG Supreme')),
new Document(4, array('make' => 'Gibson', 'model' => 'SG Faded')),
- new Document(5, array('make' => 'Fender', 'model' => 'Stratocaster'))
+ new Document(5, array('make' => 'Fender', 'model' => 'Stratocaster')),
);
- $this->_index->getType("guitars")->addDocuments($docs);
- $this->_index->refresh();
- }
+ $index->getType('guitars')->addDocuments($docs);
+ $index->refresh();
- protected function tearDown()
- {
- parent::tearDown();
- $this->_index->delete();
+ $query = new SimpleQueryString('gibson +sg +-faded', array('make', 'model'));
+ $results = $index->search($query);
+
+ $this->assertEquals(2, $results->getTotalHits());
+
+ $query->setFields(array('model'));
+ $results = $index->search($query);
+
+ // We should not get any hits, since the "make" field was not included in the query.
+ $this->assertEquals(0, $results->getTotalHits());
}
- public function testToArray()
+ /**
+ * @group unit
+ */
+ public function testSetMinimumShouldMatch()
{
- $string = "this is a test";
- $fields = array('field1', 'field2');
- $query = new SimpleQueryString($string, $fields);
- $query->setDefaultOperator(SimpleQueryString::OPERATOR_OR);
- $query->setAnalyzer("whitespace");
-
$expected = array(
- "simple_query_string" => array(
- "query" => $string,
- "fields" => $fields,
- "analyzer" => "whitespace",
- "default_operator" => SimpleQueryString::OPERATOR_OR
- )
+ 'simple_query_string' => array(
+ 'query' => 'DONT PANIC',
+ 'minimum_should_match' => '75%',
+ ),
);
+ $query = new SimpleQueryString($expected['simple_query_string']['query']);
+ $query->setMinimumShouldMatch($expected['simple_query_string']['minimum_should_match']);
+
$this->assertEquals($expected, $query->toArray());
+ $this->assertInstanceOf('Elastica\Query\SimpleQueryString', $query->setMinimumShouldMatch('75%'));
}
- public function testQuery()
+ /**
+ * @group functional
+ */
+ public function testSetMinimumShouldMatchWorks()
{
- $query = new SimpleQueryString("gibson +sg +-faded", array("make", "model"));
- $results = $this->_index->search($query);
+ $index = $this->_createIndex();
+ $type = $index->getType('foobars');
+ $type->addDocuments(array(
+ new Document(1, array('body' => 'foo')),
+ new Document(2, array('body' => 'bar')),
+ new Document(3, array('body' => 'foo bar')),
+ new Document(4, array('body' => 'foo baz bar')),
+ ));
+ $index->refresh();
- $this->assertEquals(2, $results->getTotalHits());
-
- $query->setFields(array("model"));
- $results = $this->_index->search($query);
+ $query = new SimpleQueryString('foo bar');
+ $query->setMinimumShouldMatch(2);
+ $results = $type->search($query);
- // We should not get any hits, since the "make" field was not included in the query.
- $this->assertEquals(0, $results->getTotalHits());
+ $this->assertCount(2, $results);
+ $this->assertEquals(3, $results[0]->getId());
+ $this->assertEquals(4, $results[1]->getId());
}
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/SimpleTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/SimpleTest.php
index 08a5f55d..b4f1dc8d 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/SimpleTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/SimpleTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Query\Simple;
@@ -7,6 +6,9 @@ use Elastica\Test\Base as BaseTest;
class SimpleTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$testQuery = array('hello' => array('world'), 'name' => 'ruflin');
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/TermTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/TermTest.php
index 887c3849..da15f0f2 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/TermTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/TermTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Query\Term;
@@ -7,7 +6,9 @@ use Elastica\Test\Base as BaseTest;
class TermTest extends BaseTest
{
-
+ /**
+ * @group unit
+ */
public function testToArray()
{
$query = new Term();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/TermsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/TermsTest.php
index 184f3ad6..f0c2b4b4 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/TermsTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/TermsTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Document;
@@ -8,19 +7,19 @@ use Elastica\Test\Base as BaseTest;
class TermsTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testFilteredSearch()
{
- $client = $this->_getClient();
- $index = $client->getIndex('test');
- $index->create(array(), true);
+ $index = $this->_createIndex();
$type = $index->getType('helloworld');
- $doc = new Document(1, array('name' => 'hello world'));
- $type->addDocument($doc);
- $doc = new Document(2, array('name' => 'nicolas ruflin'));
- $type->addDocument($doc);
- $doc = new Document(3, array('name' => 'ruflin'));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'hello world')),
+ new Document(2, array('name' => 'nicolas ruflin')),
+ new Document(3, array('name' => 'ruflin')),
+ ));
$query = new Terms();
$query->setTerms('name', array('nicolas', 'hello'));
@@ -37,6 +36,9 @@ class TermsTest extends BaseTest
$this->assertEquals(3, $resultSet->count());
}
+ /**
+ * @group unit
+ */
public function testSetMinimum()
{
$key = 'name';
@@ -51,6 +53,7 @@ class TermsTest extends BaseTest
}
/**
+ * @group unit
* @expectedException \Elastica\Exception\InvalidException
*/
public function testInvalidParams()
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/WildcardTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/WildcardTest.php
index 077e6d4f..7a0c379e 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/WildcardTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/WildcardTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Document;
@@ -9,12 +8,18 @@ use Elastica\Type\Mapping;
class WildcardTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testConstructEmpty()
{
$wildcard = new Wildcard();
$this->assertEmpty($wildcard->getParams());
}
+ /**
+ * @group unit
+ */
public function testToArray()
{
$key = 'name';
@@ -27,14 +32,17 @@ class WildcardTest extends BaseTest
'wildcard' => array(
$key => array(
'value' => $value,
- 'boost' => $boost
- )
- )
+ 'boost' => $boost,
+ ),
+ ),
);
$this->assertEquals($expectedArray, $wildcard->toArray());
}
+ /**
+ * @group functional
+ */
public function testSearchWithAnalyzer()
{
$client = $this->_getClient();
@@ -46,10 +54,10 @@ class WildcardTest extends BaseTest
'lw' => array(
'type' => 'custom',
'tokenizer' => 'keyword',
- 'filter' => array('lowercase')
- )
+ 'filter' => array('lowercase'),
+ ),
),
- )
+ ),
);
$index->create($indexParams, true);
@@ -61,16 +69,13 @@ class WildcardTest extends BaseTest
);
$type->setMapping($mapping);
- $doc = new Document(1, array('name' => 'Basel-Stadt'));
- $type->addDocument($doc);
- $doc = new Document(2, array('name' => 'New York'));
- $type->addDocument($doc);
- $doc = new Document(3, array('name' => 'Baden'));
- $type->addDocument($doc);
- $doc = new Document(4, array('name' => 'Baden Baden'));
- $type->addDocument($doc);
- $doc = new Document(5, array('name' => 'New Orleans'));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'Basel-Stadt')),
+ new Document(2, array('name' => 'New York')),
+ new Document(3, array('name' => 'Baden')),
+ new Document(4, array('name' => 'Baden Baden')),
+ new Document(5, array('name' => 'New Orleans')),
+ ));
$index->refresh();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/AbstractDSLTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/AbstractDSLTest.php
new file mode 100644
index 00000000..3e44f463
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/AbstractDSLTest.php
@@ -0,0 +1,97 @@
+<?php
+namespace Elastica\Test\QueryBuilder\DSL;
+
+use Elastica\Exception\NotImplementedException;
+use Elastica\QueryBuilder\DSL;
+use Elastica\Test\Base as BaseTest;
+
+abstract class AbstractDSLTest extends BaseTest
+{
+ /**
+ * @param DSL $dsl
+ * @param string $methodName
+ * @param string $className
+ * @param array $arguments
+ */
+ protected function _assertImplemented(DSL $dsl, $methodName, $className, $arguments)
+ {
+ // Check method existence
+ $this->assertTrue(method_exists($dsl, $methodName));
+
+ // Check returned value
+ $return = call_user_func_array(array($dsl, $methodName), $arguments);
+ $this->assertTrue(class_exists($className), 'Class not exists but NotImplementedException is not thrown');
+ $this->assertInstanceOf($className, $return);
+
+ // Check method signature
+ $class = new \ReflectionClass($className);
+ $method = new \ReflectionMethod(get_class($dsl), $methodName);
+ if (!$class->hasMethod('__construct')) {
+ $this->assertEmpty($method->getParameters(), 'Constructor is not defined, but method has some parameters');
+ } else {
+ $this->_assertParametersEquals($class->getMethod('__construct')->getParameters(), $method->getParameters());
+ }
+ }
+
+ /**
+ * @param DSL $dsl
+ * @param string $name
+ */
+ protected function _assertNotImplemented(DSL $dsl, $methodName, $arguments)
+ {
+ try {
+ call_user_func(array($dsl, $methodName), $arguments);
+ $this->fail('NotImplementedException is not thrown');
+ } catch (NotImplementedException $ex) {
+ // expected
+ }
+ }
+
+ /**
+ * @param \ReflectionParameter[] $left
+ * @param \ReflectionParameter[] $right
+ */
+ protected function _assertParametersEquals($left, $right)
+ {
+ $this->assertEquals(count($left), count($right), 'Parameters count mismatch');
+
+ for ($i = 0; $i < count($left); $i++) {
+ $this->assertEquals($left[$i]->getName(), $right[$i]->getName(), 'Parameters names mismatch');
+ $this->assertEquals($left[$i]->isOptional(), $right[$i]->isOptional(), 'Parameters optionality mismatch');
+ $this->assertEquals($this->_getHintName($left[$i]), $this->_getHintName($right[$i]), 'Parameters typehints mismatch');
+ $this->assertEquals($this->_getDefaultValue($left[$i]), $this->_getDefaultValue($right[$i]), 'Default values mismatch');
+ }
+ }
+
+ /**
+ * @param \ReflectionParameter $param
+ *
+ * @return string|null
+ */
+ protected function _getDefaultValue(\ReflectionParameter $param)
+ {
+ if ($param->isOptional()) {
+ return $param->getDefaultValue();
+ }
+ }
+
+ /**
+ * @param \ReflectionParameter $param
+ *
+ * @return string|null
+ */
+ protected function _getHintName(\ReflectionParameter $param)
+ {
+ if (version_compare(phpversion(), '5.4', '>=') && $param->isCallable()) {
+ return 'callable';
+ }
+
+ if ($param->isArray()) {
+ return 'array';
+ }
+
+ if ($class = $param->getClass()) {
+ return $class->getName();
+ }
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/AggregationTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/AggregationTest.php
new file mode 100644
index 00000000..67c70862
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/AggregationTest.php
@@ -0,0 +1,58 @@
+<?php
+namespace Elastica\Test\QueryBuilder\DSL;
+
+use Elastica\Filter\Exists;
+use Elastica\QueryBuilder\DSL;
+
+class AggregationTest extends AbstractDSLTest
+{
+ /**
+ * @group unit
+ */
+ public function testType()
+ {
+ $aggregationDSL = new DSL\Aggregation();
+
+ $this->assertInstanceOf('Elastica\QueryBuilder\DSL', $aggregationDSL);
+ $this->assertEquals(DSL::TYPE_AGGREGATION, $aggregationDSL->getType());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testInterface()
+ {
+ $aggregationDSL = new DSL\Aggregation();
+
+ $this->_assertImplemented($aggregationDSL, 'avg', 'Elastica\Aggregation\Avg', array('name'));
+ $this->_assertImplemented($aggregationDSL, 'cardinality', 'Elastica\Aggregation\Cardinality', array('name'));
+ $this->_assertImplemented($aggregationDSL, 'date_histogram', 'Elastica\Aggregation\DateHistogram', array('name', 'field', 1));
+ $this->_assertImplemented($aggregationDSL, 'date_range', 'Elastica\Aggregation\DateRange', array('name'));
+ $this->_assertImplemented($aggregationDSL, 'extended_stats', 'Elastica\Aggregation\ExtendedStats', array('name'));
+ $this->_assertImplemented($aggregationDSL, 'filter', 'Elastica\Aggregation\Filter', array('name', new Exists('field')));
+ $this->_assertImplemented($aggregationDSL, 'filters', 'Elastica\Aggregation\Filters', array('name'));
+ $this->_assertImplemented($aggregationDSL, 'geo_distance', 'Elastica\Aggregation\GeoDistance', array('name', 'field', 'origin'));
+ $this->_assertImplemented($aggregationDSL, 'geohash_grid', 'Elastica\Aggregation\GeohashGrid', array('name', 'field'));
+ $this->_assertImplemented($aggregationDSL, 'global_agg', 'Elastica\Aggregation\GlobalAggregation', array('name'));
+ $this->_assertImplemented($aggregationDSL, 'histogram', 'Elastica\Aggregation\Histogram', array('name', 'field', 1));
+ $this->_assertImplemented($aggregationDSL, 'ipv4_range', 'Elastica\Aggregation\IpRange', array('name', 'field'));
+ $this->_assertImplemented($aggregationDSL, 'max', 'Elastica\Aggregation\Max', array('name'));
+ $this->_assertImplemented($aggregationDSL, 'min', 'Elastica\Aggregation\Min', array('name'));
+ $this->_assertImplemented($aggregationDSL, 'missing', 'Elastica\Aggregation\Missing', array('name', 'field'));
+ $this->_assertImplemented($aggregationDSL, 'nested', 'Elastica\Aggregation\Nested', array('name', 'path'));
+ $this->_assertImplemented($aggregationDSL, 'percentiles', 'Elastica\Aggregation\Percentiles', array('name'));
+ $this->_assertImplemented($aggregationDSL, 'range', 'Elastica\Aggregation\Range', array('name'));
+ $this->_assertImplemented($aggregationDSL, 'reverse_nested', 'Elastica\Aggregation\ReverseNested', array('name'));
+ $this->_assertImplemented($aggregationDSL, 'scripted_metric', 'Elastica\Aggregation\ScriptedMetric', array('name'));
+ $this->_assertImplemented($aggregationDSL, 'significant_terms', 'Elastica\Aggregation\SignificantTerms', array('name'));
+ $this->_assertImplemented($aggregationDSL, 'stats', 'Elastica\Aggregation\Stats', array('name'));
+ $this->_assertImplemented($aggregationDSL, 'sum', 'Elastica\Aggregation\Sum', array('name'));
+ $this->_assertImplemented($aggregationDSL, 'terms', 'Elastica\Aggregation\Terms', array('name'));
+ $this->_assertImplemented($aggregationDSL, 'top_hits', 'Elastica\Aggregation\TopHits', array('name'));
+ $this->_assertImplemented($aggregationDSL, 'value_count', 'Elastica\Aggregation\ValueCount', array('name', 'field'));
+
+ $this->_assertNotImplemented($aggregationDSL, 'children', array('name'));
+ $this->_assertNotImplemented($aggregationDSL, 'geo_bounds', array('name'));
+ $this->_assertNotImplemented($aggregationDSL, 'percentile_ranks', array('name'));
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/FilterTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/FilterTest.php
new file mode 100644
index 00000000..755bd18a
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/FilterTest.php
@@ -0,0 +1,58 @@
+<?php
+namespace Elastica\Test\QueryBuilder\DSL;
+
+use Elastica\Filter\Exists;
+use Elastica\Query\Match;
+use Elastica\QueryBuilder\DSL;
+
+class FilterTest extends AbstractDSLTest
+{
+ /**
+ * @group unit
+ */
+ public function testType()
+ {
+ $filterDSL = new DSL\Filter();
+
+ $this->assertInstanceOf('Elastica\QueryBuilder\DSL', $filterDSL);
+ $this->assertEquals(DSL::TYPE_FILTER, $filterDSL->getType());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testInterface()
+ {
+ $filterDSL = new DSL\Filter();
+
+ $this->_assertImplemented($filterDSL, 'bool', 'Elastica\Filter\BoolFilter', array());
+ $this->_assertImplemented($filterDSL, 'bool_and', 'Elastica\Filter\BoolAnd', array(array(new Exists('field'))));
+ $this->_assertImplemented($filterDSL, 'bool_not', 'Elastica\Filter\BoolNot', array(new Exists('field')));
+ $this->_assertImplemented($filterDSL, 'bool_or', 'Elastica\Filter\BoolOr', array(array(new Exists('field'))));
+ $this->_assertImplemented($filterDSL, 'exists', 'Elastica\Filter\Exists', array('field'));
+ $this->_assertImplemented($filterDSL, 'geo_bounding_box', 'Elastica\Filter\GeoBoundingBox', array('field', array(1, 2)));
+ $this->_assertImplemented($filterDSL, 'geo_distance', 'Elastica\Filter\GeoDistance', array('key', 'location', 'distance'));
+ $this->_assertImplemented($filterDSL, 'geo_distance_range', 'Elastica\Filter\GeoDistanceRange', array('key', 'location'));
+ $this->_assertImplemented($filterDSL, 'geo_polygon', 'Elastica\Filter\GeoPolygon', array('key', array()));
+ $this->_assertImplemented($filterDSL, 'geo_shape_pre_indexed', 'Elastica\Filter\GeoShapePreIndexed', array('path', 'indexedId', 'indexedType', 'indexedIndex', 'indexedPath'));
+ $this->_assertImplemented($filterDSL, 'geo_shape_provided', 'Elastica\Filter\GeoShapeProvided', array('path', array()));
+ $this->_assertImplemented($filterDSL, 'geohash_cell', 'Elastica\Filter\GeohashCell', array('field', 'location'));
+ $this->_assertImplemented($filterDSL, 'has_child', 'Elastica\Filter\HasChild', array(new Match(), 'type'));
+ $this->_assertImplemented($filterDSL, 'has_parent', 'Elastica\Filter\HasParent', array(new Match(), 'type'));
+ $this->_assertImplemented($filterDSL, 'ids', 'Elastica\Filter\Ids', array('type', array()));
+ $this->_assertImplemented($filterDSL, 'indices', 'Elastica\Filter\Indices', array(new Exists('field'), array()));
+ $this->_assertImplemented($filterDSL, 'limit', 'Elastica\Filter\Limit', array(1));
+ $this->_assertImplemented($filterDSL, 'match_all', 'Elastica\Filter\MatchAll', array());
+ $this->_assertImplemented($filterDSL, 'missing', 'Elastica\Filter\Missing', array('field'));
+ $this->_assertImplemented($filterDSL, 'nested', 'Elastica\Filter\Nested', array());
+ $this->_assertImplemented($filterDSL, 'numeric_range', 'Elastica\Filter\NumericRange', array());
+ $this->_assertImplemented($filterDSL, 'prefix', 'Elastica\Filter\Prefix', array('field', 'prefix'));
+ $this->_assertImplemented($filterDSL, 'query', 'Elastica\Filter\Query', array(new Match()));
+ $this->_assertImplemented($filterDSL, 'range', 'Elastica\Filter\Range', array('field', array()));
+ $this->_assertImplemented($filterDSL, 'regexp', 'Elastica\Filter\Regexp', array('field', 'regex'));
+ $this->_assertImplemented($filterDSL, 'script', 'Elastica\Filter\Script', array('script'));
+ $this->_assertImplemented($filterDSL, 'term', 'Elastica\Filter\Term', array());
+ $this->_assertImplemented($filterDSL, 'terms', 'Elastica\Filter\Terms', array('field', array()));
+ $this->_assertImplemented($filterDSL, 'type', 'Elastica\Filter\Type', array('type'));
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/QueryTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/QueryTest.php
new file mode 100644
index 00000000..d4669119
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/QueryTest.php
@@ -0,0 +1,85 @@
+<?php
+namespace Elastica\Test\QueryBuilder\DSL;
+
+use Elastica\Filter\Exists;
+use Elastica\Query\Match;
+use Elastica\QueryBuilder\DSL;
+
+class QueryTest extends AbstractDSLTest
+{
+ /**
+ * @group unit
+ */
+ public function testType()
+ {
+ $queryDSL = new DSL\Query();
+
+ $this->assertInstanceOf('Elastica\QueryBuilder\DSL', $queryDSL);
+ $this->assertEquals(DSL::TYPE_QUERY, $queryDSL->getType());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testMatch()
+ {
+ $queryDSL = new DSL\Query();
+
+ $match = $queryDSL->match('field', 'match');
+ $this->assertEquals('match', $match->getParam('field'));
+ $this->assertInstanceOf('Elastica\Query\Match', $match);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testInterface()
+ {
+ $queryDSL = new DSL\Query();
+
+ $this->_assertImplemented($queryDSL, 'bool', 'Elastica\Query\BoolQuery', array());
+ $this->_assertImplemented($queryDSL, 'boosting', 'Elastica\Query\Boosting', array());
+ $this->_assertImplemented($queryDSL, 'common_terms', 'Elastica\Query\Common', array('field', 'query', 0.001));
+ $this->_assertImplemented($queryDSL, 'constant_score', 'Elastica\Query\ConstantScore', array(new Match()));
+ $this->_assertImplemented($queryDSL, 'dis_max', 'Elastica\Query\DisMax', array());
+ $this->_assertImplemented($queryDSL, 'filtered', 'Elastica\Query\Filtered', array(new Match(), new Exists('field')));
+ $this->_assertImplemented($queryDSL, 'function_score', 'Elastica\Query\FunctionScore', array());
+ $this->_assertImplemented($queryDSL, 'fuzzy', 'Elastica\Query\Fuzzy', array('field', 'type'));
+ $this->_assertImplemented($queryDSL, 'fuzzy_like_this', 'Elastica\Query\FuzzyLikeThis', array());
+ $this->_assertImplemented($queryDSL, 'has_child', 'Elastica\Query\HasChild', array(new Match()));
+ $this->_assertImplemented($queryDSL, 'has_parent', 'Elastica\Query\HasParent', array(new Match(), 'type'));
+ $this->_assertImplemented($queryDSL, 'ids', 'Elastica\Query\Ids', array('type', array()));
+ $this->_assertImplemented($queryDSL, 'match', 'Elastica\Query\Match', array('field', 'values'));
+ $this->_assertImplemented($queryDSL, 'match_all', 'Elastica\Query\MatchAll', array());
+ $this->_assertImplemented($queryDSL, 'more_like_this', 'Elastica\Query\MoreLikeThis', array());
+ $this->_assertImplemented($queryDSL, 'multi_match', 'Elastica\Query\MultiMatch', array());
+ $this->_assertImplemented($queryDSL, 'nested', 'Elastica\Query\Nested', array());
+ $this->_assertImplemented($queryDSL, 'prefix', 'Elastica\Query\Prefix', array());
+ $this->_assertImplemented($queryDSL, 'query_string', 'Elastica\Query\QueryString', array());
+ $this->_assertImplemented($queryDSL, 'range', 'Elastica\Query\Range', array('field', array()));
+ $this->_assertImplemented($queryDSL, 'regexp', 'Elastica\Query\Regexp', array('field', 'value', 1.0));
+ $this->_assertImplemented($queryDSL, 'simple_query_string', 'Elastica\Query\SimpleQueryString', array('query'));
+ $this->_assertImplemented($queryDSL, 'term', 'Elastica\Query\Term', array());
+ $this->_assertImplemented($queryDSL, 'terms', 'Elastica\Query\Terms', array('field', array()));
+ $this->_assertImplemented($queryDSL, 'top_children', 'Elastica\Query\TopChildren', array(new Match(), 'type'));
+ $this->_assertImplemented($queryDSL, 'wildcard', 'Elastica\Query\Wildcard', array());
+
+ $this->_assertNotImplemented($queryDSL, 'custom_boost_factor', array());
+ $this->_assertNotImplemented($queryDSL, 'custom_filters_score', array());
+ $this->_assertNotImplemented($queryDSL, 'custom_score', array());
+ $this->_assertNotImplemented($queryDSL, 'field', array());
+ $this->_assertNotImplemented($queryDSL, 'fuzzy_like_this_field', array());
+ $this->_assertNotImplemented($queryDSL, 'geo_shape', array());
+ $this->_assertNotImplemented($queryDSL, 'indices', array());
+ $this->_assertNotImplemented($queryDSL, 'minimum_should_match', array());
+ $this->_assertNotImplemented($queryDSL, 'more_like_this_field', array());
+ $this->_assertNotImplemented($queryDSL, 'span_first', array());
+ $this->_assertNotImplemented($queryDSL, 'span_multi_term', array());
+ $this->_assertNotImplemented($queryDSL, 'span_near', array());
+ $this->_assertNotImplemented($queryDSL, 'span_not', array());
+ $this->_assertNotImplemented($queryDSL, 'span_or', array());
+ $this->_assertNotImplemented($queryDSL, 'span_term', array());
+ $this->_assertNotImplemented($queryDSL, 'template', array());
+ $this->_assertNotImplemented($queryDSL, 'text', array());
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/SuggestTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/SuggestTest.php
new file mode 100644
index 00000000..b70e0ba7
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/SuggestTest.php
@@ -0,0 +1,32 @@
+<?php
+namespace Elastica\Test\QueryBuilder\DSL;
+
+use Elastica\QueryBuilder\DSL;
+
+class SuggestTest extends AbstractDSLTest
+{
+ /**
+ * @group unit
+ */
+ public function testType()
+ {
+ $suggestDSL = new DSL\Suggest();
+
+ $this->assertInstanceOf('Elastica\QueryBuilder\DSL', $suggestDSL);
+ $this->assertEquals(DSL::TYPE_SUGGEST, $suggestDSL->getType());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testInterface()
+ {
+ $suggestDSL = new DSL\Suggest();
+
+ $this->_assertImplemented($suggestDSL, 'completion', 'Elastica\Suggest\Completion', array('name', 'field'));
+ $this->_assertImplemented($suggestDSL, 'phrase', 'Elastica\Suggest\Phrase', array('name', 'field'));
+ $this->_assertImplemented($suggestDSL, 'term', 'Elastica\Suggest\Term', array('name', 'field'));
+
+ $this->_assertNotImplemented($suggestDSL, 'context', array());
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/VersionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/VersionTest.php
new file mode 100644
index 00000000..d92848a7
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/VersionTest.php
@@ -0,0 +1,67 @@
+<?php
+namespace Elastica\Test\QueryBuilder;
+
+use Elastica\QueryBuilder\DSL;
+use Elastica\QueryBuilder\Version;
+use Elastica\Test\Base as BaseTest;
+
+class VersionTest extends BaseTest
+{
+ /**
+ * @group unit
+ */
+ public function testVersions()
+ {
+ $dsl = array(
+ new DSL\Query(),
+ new DSL\Filter(),
+ new DSL\Aggregation(),
+ new DSL\Suggest(),
+ );
+
+ $versions = array(
+ new Version\Version090(),
+ new Version\Version100(),
+ new Version\Version110(),
+ new Version\Version120(),
+ new Version\Version130(),
+ new Version\Version140(),
+ new Version\Version150(),
+ );
+
+ foreach ($versions as $version) {
+ $this->assertVersions($version, $dsl);
+ }
+ }
+
+ private function assertVersions(Version $version, array $dsl)
+ {
+ foreach ($version->getQueries() as $query) {
+ $this->assertTrue(
+ method_exists($dsl[0], $query),
+ 'query "'.$query.'" in '.get_class($version).' must be defined in '.get_class($dsl[0])
+ );
+ }
+
+ foreach ($version->getFilters() as $filter) {
+ $this->assertTrue(
+ method_exists($dsl[1], $filter),
+ 'filter "'.$filter.'" in '.get_class($version).' must be defined in '.get_class($dsl[1])
+ );
+ }
+
+ foreach ($version->getAggregations() as $aggregation) {
+ $this->assertTrue(
+ method_exists($dsl[2], $aggregation),
+ 'aggregation "'.$aggregation.'" in '.get_class($version).' must be defined in '.get_class($dsl[2])
+ );
+ }
+
+ foreach ($version->getSuggesters() as $suggester) {
+ $this->assertTrue(
+ method_exists($dsl[3], $suggester),
+ 'suggester "'.$suggester.'" in '.get_class($version).' must be defined in '.get_class($dsl[3])
+ );
+ }
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilderTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilderTest.php
new file mode 100644
index 00000000..6cbfd37b
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilderTest.php
@@ -0,0 +1,88 @@
+<?php
+namespace Elastica\Test;
+
+use Elastica\Exception\QueryBuilderException;
+use Elastica\Query;
+use Elastica\QueryBuilder;
+use Elastica\Suggest;
+
+class QueryBuilderTest extends \PHPUnit_Framework_TestCase
+{
+ /**
+ * @group unit
+ */
+ public function testCustomDSL()
+ {
+ $qb = new QueryBuilder();
+
+ // test custom DSL
+ $qb->addDSL(new CustomDSL());
+
+ $this->assertTrue($qb->custom()->custom_method(), 'custom DSL execution failed');
+
+ // test custom DSL exception message
+ $exceptionMessage = '';
+ try {
+ $qb->invalid();
+ } catch (QueryBuilderException $exception) {
+ $exceptionMessage = $exception->getMessage();
+ }
+
+ $this->assertEquals('DSL "invalid" not supported', $exceptionMessage);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testFacade()
+ {
+ $qb = new QueryBuilder();
+
+ // test one example QueryBuilder flow for each default DSL type
+ $this->assertInstanceOf('Elastica\Query\AbstractQuery', $qb->query()->match());
+ $this->assertInstanceOf('Elastica\Filter\AbstractFilter', $qb->filter()->bool());
+ $this->assertInstanceOf('Elastica\Aggregation\AbstractAggregation', $qb->aggregation()->avg('name'));
+ $this->assertInstanceOf('Elastica\Suggest\AbstractSuggest', $qb->suggest()->term('name', 'field'));
+ }
+
+ /**
+ * @group unit
+ */
+ public function testFacadeException()
+ {
+ $qb = new QueryBuilder(new QueryBuilder\Version\Version100());
+
+ // undefined
+ $exceptionMessage = '';
+ try {
+ $qb->query()->invalid();
+ } catch (QueryBuilderException $exception) {
+ $exceptionMessage = $exception->getMessage();
+ }
+
+ $this->assertEquals('undefined query "invalid"', $exceptionMessage);
+
+ // unsupported
+ $exceptionMessage = '';
+ try {
+ $qb->aggregation()->top_hits('top_hits');
+ } catch (QueryBuilderException $exception) {
+ $exceptionMessage = $exception->getMessage();
+ }
+
+ $this->assertEquals('aggregation "top_hits" in Version100 not supported', $exceptionMessage);
+ }
+}
+
+class CustomDSL implements QueryBuilder\DSL
+{
+ public function getType()
+ {
+ return 'custom';
+ }
+
+ public function custom_method()
+ {
+ return true;
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryTest.php
index ece9f4c2..a39ab23a 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryTest.php
@@ -1,18 +1,24 @@
<?php
-
namespace Elastica\Test;
use Elastica\Document;
use Elastica\Exception\InvalidException;
+use Elastica\Facet\Terms;
+use Elastica\Query;
use Elastica\Query\Builder;
use Elastica\Query\Term;
use Elastica\Query\Text;
-use Elastica\Query;
-use Elastica\Facet\Terms;
+use Elastica\Script;
+use Elastica\ScriptFields;
+use Elastica\Suggest;
use Elastica\Test\Base as BaseTest;
+use Elastica\Type;
class QueryTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testStringConversion()
{
$queryString = '{
@@ -51,6 +57,9 @@ class QueryTest extends BaseTest
$this->assertEquals('2011-07-18 00:00:00', $queryArray['query']['filtered']['filter']['range']['due']['gte']);
}
+ /**
+ * @group unit
+ */
public function testRawQuery()
{
$textQuery = new Term(array('title' => 'test'));
@@ -63,14 +72,47 @@ class QueryTest extends BaseTest
$this->assertEquals($query1->toArray(), $query2->toArray());
}
+ /**
+ * @group unit
+ */
+ public function testSuggestShouldNotRemoveOtherParameters()
+ {
+ $query1 = new Query();
+ $query2 = new Query();
+
+ $suggest = new Suggest();
+ $suggest->setGlobalText('test');
+
+ $query1->setSize(40);
+ $query1->setSuggest($suggest);
+
+ $query2->setSuggest($suggest);
+ $query2->setSize(40);
+
+ $this->assertEquals($query1->toArray(), $query2->toArray());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetSuggestMustReturnQueryInstance()
+ {
+ $query = new Query();
+ $suggest = new Suggest();
+ $this->assertInstanceOf('Elastica\Query', $query->setSuggest($suggest));
+ }
+
+ /**
+ * @group unit
+ */
public function testArrayQuery()
{
$query = array(
'query' => array(
'text' => array(
- 'title' => 'test'
- )
- )
+ 'title' => 'test',
+ ),
+ ),
);
$query1 = Query::create($query);
@@ -81,17 +123,19 @@ class QueryTest extends BaseTest
$this->assertEquals($query1->toArray(), $query2->toArray());
}
+ /**
+ * @group functional
+ */
public function testSetSort()
{
$index = $this->_createIndex();
$type = $index->getType('test');
- $doc = new Document(1, array('name' => 'hello world'));
- $type->addDocument($doc);
- $doc = new Document(2, array('firstname' => 'guschti', 'lastname' => 'ruflin'));
- $type->addDocument($doc);
- $doc = new Document(3, array('firstname' => 'nicolas', 'lastname' => 'ruflin'));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'hello world')),
+ new Document(2, array('firstname' => 'guschti', 'lastname' => 'ruflin')),
+ new Document(3, array('firstname' => 'nicolas', 'lastname' => 'ruflin')),
+ ));
$queryTerm = new Term();
$queryTerm->setTerm('lastname', 'ruflin');
@@ -123,6 +167,9 @@ class QueryTest extends BaseTest
$this->assertEquals('guschti', $second['firstname']);
}
+ /**
+ * @group unit
+ */
public function testAddSort()
{
$query = new Query();
@@ -132,6 +179,9 @@ class QueryTest extends BaseTest
$this->assertEquals($query->getParam('sort'), array($sortParam));
}
+ /**
+ * @group unit
+ */
public function testSetRawQuery()
{
$query = new Query();
@@ -142,6 +192,9 @@ class QueryTest extends BaseTest
$this->assertEquals($params, $query->toArray());
}
+ /**
+ * @group unit
+ */
public function testSetFields()
{
$query = new Query();
@@ -154,9 +207,12 @@ class QueryTest extends BaseTest
$this->assertContains('firstname', $data['fields']);
$this->assertContains('lastname', $data['fields']);
- $this->assertEquals(2, count($data['fields']));
+ $this->assertCount(2, $data['fields']);
}
+ /**
+ * @group unit
+ */
public function testGetQuery()
{
$query = new Query();
@@ -175,6 +231,9 @@ class QueryTest extends BaseTest
$this->assertEquals($termQuery->toArray(), $query->getQuery());
}
+ /**
+ * @group unit
+ */
public function testSetFacets()
{
$query = new Query();
@@ -191,4 +250,209 @@ class QueryTest extends BaseTest
$this->assertArrayNotHasKey('facets', $query->toArray());
}
+
+ /**
+ * @group unit
+ */
+ public function testSetQueryToArrayCast()
+ {
+ $query = new Query();
+ $termQuery = new Term();
+ $termQuery->setTerm('text', 'value');
+ $query->setQuery($termQuery);
+
+ $termQuery->setTerm('text', 'another value');
+
+ $anotherQuery = new Query();
+ $anotherQuery->setQuery($termQuery);
+
+ $this->assertNotEquals($query->toArray(), $anotherQuery->toArray());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetQueryToArrayChangeQuery()
+ {
+ $query = new Query();
+ $termQuery = new Term();
+ $termQuery->setTerm('text', 'value');
+ $query->setQuery($termQuery);
+
+ $queryArray = $query->toArray();
+
+ $termQuery = $query->getQuery();
+ $termQuery['term']['text']['value'] = 'another value';
+
+ $this->assertEquals($queryArray, $query->toArray());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetScriptFieldsToArrayCast()
+ {
+ $query = new Query();
+ $scriptFields = new ScriptFields();
+ $scriptFields->addScript('script', new Script('script'));
+
+ $query->setScriptFields($scriptFields);
+
+ $scriptFields->addScript('another script', new Script('another script'));
+
+ $anotherQuery = new Query();
+ $anotherQuery->setScriptFields($scriptFields);
+
+ $this->assertNotEquals($query->toArray(), $anotherQuery->toArray());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testAddScriptFieldsToArrayCast()
+ {
+ $query = new Query();
+ $scriptField = new Script('script');
+
+ $query->addScriptField('script', $scriptField);
+
+ $scriptField->setScript('another script');
+
+ $anotherQuery = new Query();
+ $anotherQuery->addScriptField('script', $scriptField);
+
+ $this->assertNotEquals($query->toArray(), $anotherQuery->toArray());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testAddFacetToArrayCast()
+ {
+ $query = new Query();
+ $facet = new Terms('text');
+
+ $query->addFacet($facet);
+
+ $facet->setName('another text');
+
+ $anotherQuery = new Query();
+ $anotherQuery->addFacet($facet);
+
+ $this->assertNotEquals($query->toArray(), $anotherQuery->toArray());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testAddAggregationToArrayCast()
+ {
+ $query = new Query();
+ $aggregation = new \Elastica\Aggregation\Terms('text');
+
+ $query->addAggregation($aggregation);
+
+ $aggregation->setName('another text');
+
+ $anotherQuery = new Query();
+ $anotherQuery->addAggregation($aggregation);
+
+ $this->assertNotEquals($query->toArray(), $anotherQuery->toArray());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetSuggestToArrayCast()
+ {
+ $query = new Query();
+ $suggest = new Suggest();
+ $suggest->setGlobalText('text');
+
+ $query->setSuggest($suggest);
+
+ $suggest->setGlobalText('another text');
+
+ $anotherQuery = new Query();
+ $anotherQuery->setSuggest($suggest);
+
+ $this->assertNotEquals($query->toArray(), $anotherQuery->toArray());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetRescoreToArrayCast()
+ {
+ $query = new Query();
+ $rescore = new \Elastica\Rescore\Query();
+ $rescore->setQueryWeight(1);
+
+ $query->setRescore($rescore);
+
+ $rescore->setQueryWeight(2);
+
+ $anotherQuery = new Query();
+ $anotherQuery->setRescore($rescore);
+
+ $this->assertNotEquals($query->toArray(), $anotherQuery->toArray());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetPostFilterToArrayCast()
+ {
+ $query = new Query();
+ $postFilter = new \Elastica\Filter\Terms();
+ $postFilter->setTerms('key', array('term'));
+ $query->setPostFilter($postFilter);
+
+ $postFilter->setTerms('another key', array('another term'));
+
+ $anotherQuery = new Query();
+ $anotherQuery->setPostFilter($postFilter);
+
+ $this->assertNotEquals($query->toArray(), $anotherQuery->toArray());
+ }
+
+ /**
+ * @group functional
+ */
+ public function testNoSource()
+ {
+ $index = $this->_createIndex();
+
+ $type = new Type($index, 'user');
+
+ // Adds 1 document to the index
+ $doc1 = new Document(1,
+ array('username' => 'ruflin', 'test' => array('2', '3', '5'))
+ );
+ $type->addDocument($doc1);
+
+ // To update index
+ $index->refresh();
+
+ $query = Query::create('ruflin');
+ $resultSet = $type->search($query);
+
+ // Disable source
+ $query->setSource(false);
+
+ $resultSetNoSource = $type->search($query);
+
+ $this->assertEquals(1, $resultSet->count());
+ $this->assertEquals(1, $resultSetNoSource->count());
+
+ // Tests if no source is in response except id
+ $result = $resultSetNoSource->current();
+ $this->assertEquals(1, $result->getId());
+ $this->assertEmpty($result->getData());
+
+ // Tests if source is in response except id
+ $result = $resultSet->current();
+ $this->assertEquals(1, $result->getId());
+ $this->assertNotEmpty($result->getData());
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/RequestTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/RequestTest.php
index 8896adeb..987f2391 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/RequestTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/RequestTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test;
use Elastica\Connection;
@@ -8,7 +7,9 @@ use Elastica\Test\Base as BaseTest;
class RequestTest extends BaseTest
{
-
+ /**
+ * @group unit
+ */
public function testConstructor()
{
$path = 'test';
@@ -25,6 +26,7 @@ class RequestTest extends BaseTest
}
/**
+ * @group unit
* @expectedException \Elastica\Exception\InvalidException
*/
public function testInvalidConnection()
@@ -33,10 +35,13 @@ class RequestTest extends BaseTest
$request->send();
}
+ /**
+ * @group functional
+ */
public function testSend()
{
$connection = new Connection();
- $connection->setHost('localhost');
+ $connection->setHost($this->_getHost());
$connection->setPort('9200');
$request = new Request('_status', Request::GET, array(), array(), $connection);
@@ -46,6 +51,9 @@ class RequestTest extends BaseTest
$this->assertInstanceOf('Elastica\Response', $response);
}
+ /**
+ * @group unit
+ */
public function testToString()
{
$path = 'test';
@@ -54,7 +62,7 @@ class RequestTest extends BaseTest
$data = array('key' => 'value');
$connection = new Connection();
- $connection->setHost('localhost');
+ $connection->setHost($this->_getHost());
$connection->setPort('9200');
$request = new Request($path, $method, $data, $query, $connection);
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ResponseTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ResponseTest.php
index 1e026eae..e7b83ade 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/ResponseTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ResponseTest.php
@@ -1,16 +1,20 @@
<?php
-
namespace Elastica\Test;
+
use Elastica\Document;
use Elastica\Facet\DateHistogram;
use Elastica\Query;
use Elastica\Query\MatchAll;
use Elastica\Request;
-use Elastica\Type\Mapping;
+use Elastica\Response;
use Elastica\Test\Base as BaseTest;
+use Elastica\Type\Mapping;
class ResponseTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testClassHierarchy()
{
$facet = new DateHistogram('dateHist1');
@@ -19,25 +23,26 @@ class ResponseTest extends BaseTest
unset($facet);
}
+ /**
+ * @group functional
+ */
public function testResponse()
{
$index = $this->_createIndex();
$type = $index->getType('helloworld');
$mapping = new Mapping($type, array(
- 'name' => array('type' => 'string', 'store' => 'no'),
- 'dtmPosted' => array('type' => 'date', 'store' => 'no', 'format' => 'yyyy-MM-dd HH:mm:ss')
- ));
+ 'name' => array('type' => 'string', 'store' => 'no'),
+ 'dtmPosted' => array('type' => 'date', 'store' => 'no', 'format' => 'yyyy-MM-dd HH:mm:ss'),
+ ));
$type->setMapping($mapping);
- $doc = new Document(1, array('name' => 'nicolas ruflin', 'dtmPosted' => "2011-06-23 21:53:00"));
- $type->addDocument($doc);
- $doc = new Document(2, array('name' => 'raul martinez jr', 'dtmPosted' => "2011-06-23 09:53:00"));
- $type->addDocument($doc);
- $doc = new Document(3, array('name' => 'rachelle clemente', 'dtmPosted' => "2011-07-08 08:53:00"));
- $type->addDocument($doc);
- $doc = new Document(4, array('name' => 'elastica search', 'dtmPosted' => "2011-07-08 01:53:00"));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'nicolas ruflin', 'dtmPosted' => '2011-06-23 21:53:00')),
+ new Document(2, array('name' => 'raul martinez jr', 'dtmPosted' => '2011-06-23 09:53:00')),
+ new Document(3, array('name' => 'rachelle clemente', 'dtmPosted' => '2011-07-08 08:53:00')),
+ new Document(4, array('name' => 'elastica search', 'dtmPosted' => '2011-07-08 01:53:00')),
+ ));
$query = new Query();
$query->setQuery(new MatchAll());
@@ -54,6 +59,9 @@ class ResponseTest extends BaseTest
$this->assertArrayHasKey('successful', $shardsStats);
}
+ /**
+ * @group functional
+ */
public function testIsOk()
{
$index = $this->_createIndex();
@@ -65,6 +73,9 @@ class ResponseTest extends BaseTest
$this->assertTrue($response->isOk());
}
+ /**
+ * @group functional
+ */
public function testIsOkMultiple()
{
$index = $this->_createIndex();
@@ -72,13 +83,114 @@ class ResponseTest extends BaseTest
$docs = array(
new Document(1, array('name' => 'ruflin')),
- new Document(2, array('name' => 'ruflin'))
+ new Document(2, array('name' => 'ruflin')),
);
$response = $type->addDocuments($docs);
$this->assertTrue($response->isOk());
}
+ /**
+ * @group unit
+ */
+ public function testIsOkBulkWithErrorsField()
+ {
+ $response = new Response(json_encode(array(
+ 'took' => 213,
+ 'errors' => false,
+ 'items' => array(
+ array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707891', '_version' => 4, 'status' => 200)),
+ array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707893', '_version' => 4, 'status' => 200)),
+ ),
+ )));
+
+ $this->assertTrue($response->isOk());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testIsNotOkBulkWithErrorsField()
+ {
+ $response = new Response(json_encode(array(
+ 'took' => 213,
+ 'errors' => true,
+ 'items' => array(
+ array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707891', '_version' => 4, 'status' => 200)),
+ array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707893', '_version' => 4, 'status' => 200)),
+ ),
+ )));
+
+ $this->assertFalse($response->isOk());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testIsOkBulkItemsWithOkField()
+ {
+ $response = new Response(json_encode(array(
+ 'took' => 213,
+ 'items' => array(
+ array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707891', '_version' => 4, 'ok' => true)),
+ array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707893', '_version' => 4, 'ok' => true)),
+ ),
+ )));
+
+ $this->assertTrue($response->isOk());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testIsNotOkBulkItemsWithOkField()
+ {
+ $response = new Response(json_encode(array(
+ 'took' => 213,
+ 'items' => array(
+ array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707891', '_version' => 4, 'ok' => true)),
+ array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707893', '_version' => 4, 'ok' => false)),
+ ),
+ )));
+
+ $this->assertFalse($response->isOk());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testIsOkBulkItemsWithStatusField()
+ {
+ $response = new Response(json_encode(array(
+ 'took' => 213,
+ 'items' => array(
+ array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707891', '_version' => 4, 'status' => 200)),
+ array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707893', '_version' => 4, 'status' => 200)),
+ ),
+ )));
+
+ $this->assertTrue($response->isOk());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testIsNotOkBulkItemsWithStatusField()
+ {
+ $response = new Response(json_encode(array(
+ 'took' => 213,
+ 'items' => array(
+ array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707891', '_version' => 4, 'status' => 200)),
+ array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707893', '_version' => 4, 'status' => 301)),
+ ),
+ )));
+
+ $this->assertFalse($response->isOk());
+ }
+
+ /**
+ * @group functional
+ */
public function testGetDataEmpty()
{
$index = $this->_createIndex();
@@ -90,5 +202,4 @@ class ResponseTest extends BaseTest
$this->assertEquals(0, count($response));
}
-
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultSetTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultSetTest.php
index 2a62111d..be76d4a2 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultSetTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultSetTest.php
@@ -1,27 +1,25 @@
<?php
-
namespace Elastica\Test;
-use Elastica\Client;
use Elastica\Document;
-use Elastica\Query;
-use Elastica\Query\Match;
use Elastica\Result;
use Elastica\Test\Base as BaseTest;
class ResultSetTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testGetters()
{
$index = $this->_createIndex();
$type = $index->getType('test');
- $doc = new Document(1, array('name' => 'elastica search'));
- $type->addDocument($doc);
- $doc = new Document(2, array('name' => 'elastica library'));
- $type->addDocument($doc);
- $doc = new Document(3, array('name' => 'elastica test'));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'elastica search')),
+ new Document(2, array('name' => 'elastica library')),
+ new Document(3, array('name' => 'elastica test')),
+ ));
$index->refresh();
$resultSet = $type->search('elastica search');
@@ -33,17 +31,19 @@ class ResultSetTest extends BaseTest
$this->assertEquals(3, count($resultSet));
}
+ /**
+ * @group functional
+ */
public function testArrayAccess()
{
$index = $this->_createIndex();
$type = $index->getType('test');
- $doc = new Document(1, array('name' => 'elastica search'));
- $type->addDocument($doc);
- $doc = new Document(2, array('name' => 'elastica library'));
- $type->addDocument($doc);
- $doc = new Document(3, array('name' => 'elastica test'));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'elastica search')),
+ new Document(2, array('name' => 'elastica library')),
+ new Document(3, array('name' => 'elastica test')),
+ ));
$index->refresh();
$resultSet = $type->search('elastica search');
@@ -57,6 +57,7 @@ class ResultSetTest extends BaseTest
}
/**
+ * @group functional
* @expectedException \Elastica\Exception\InvalidException
*/
public function testInvalidOffsetCreation()
@@ -75,6 +76,7 @@ class ResultSetTest extends BaseTest
}
/**
+ * @group functional
* @expectedException \Elastica\Exception\InvalidException
*/
public function testInvalidOffsetGet()
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultTest.php
index 54d3ce55..a905fcc5 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultTest.php
@@ -1,15 +1,16 @@
<?php
-
namespace Elastica\Test;
-use Elastica\Client;
use Elastica\Document;
use Elastica\Result;
-use Elastica\Type\Mapping;
use Elastica\Test\Base as BaseTest;
+use Elastica\Type\Mapping;
class ResultTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testGetters()
{
// Creates a new index 'xodoa' and a type 'user' inside this index
@@ -42,6 +43,9 @@ class ResultTest extends BaseTest
$this->assertEquals('hans', $result->username);
}
+ /**
+ * @group functional
+ */
public function testGetIdNoSource()
{
// Creates a new index 'xodoa' and a type 'user' inside this index
@@ -80,6 +84,9 @@ class ResultTest extends BaseTest
$this->assertInternalType('array', $result->getData());
}
+ /**
+ * @group functional
+ */
public function testGetTotalTimeReturnsExpectedResults()
{
$typeName = 'user';
@@ -103,17 +110,20 @@ class ResultTest extends BaseTest
'Total Time should be an integer'
);
}
-
+
+ /**
+ * @group unit
+ */
public function testHasFields()
{
$data = array('value set');
$result = new Result(array());
$this->assertFalse($result->hasFields());
-
+
$result = new Result(array('_source' => $data));
$this->assertFalse($result->hasFields());
-
+
$result = new Result(array('fields' => $data));
$this->assertTrue($result->hasFields());
$this->assertEquals($data, $result->getFields());
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ScanAndScrollTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ScanAndScrollTest.php
index a64670bb..9f06f9e6 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/ScanAndScrollTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ScanAndScrollTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test;
use Elastica\Document;
@@ -9,102 +8,66 @@ use Elastica\ScanAndScroll;
use Elastica\Search;
use Elastica\Test\Base as BaseTest;
-class ScanAndScrollTest extends BaseTest {
-
- public function testConstruct() {
- $scanAndScroll = $this->_prepareScanAndScroll();
-
- $this->assertInstanceOf('Elastica\ScanAndScroll', $scanAndScroll);
- }
-
- public function testDefaultProperties() {
- $scanAndScroll = $this->_prepareScanAndScroll();
+class ScanAndScrollTest extends BaseTest
+{
+ /**
+ * Full foreach test.
+ *
+ * @gropu functional
+ */
+ public function testForeach()
+ {
+ $scanAndScroll = new ScanAndScroll($this->_prepareSearch(), '1m', 2);
+ $docCount = 0;
+
+ /** @var ResultSet $resultSet */
+ foreach ($scanAndScroll as $scrollId => $resultSet) {
+ $docCount += $resultSet->count();
+ }
- $this->assertEquals('1m', $scanAndScroll->expiryTime);
- $this->assertEquals(1000, $scanAndScroll->sizePerShard);
+ /*
+ * number of loops and documents per iteration may fluctuate
+ * => only test end results
+ */
+ $this->assertEquals(12, $docCount);
}
- public function testQuerySizeOverride() {
- $query = new Query();
- $query->setSize(100);
-
- $index = $this->_createIndex('test_1');
- $index->refresh(); // Waits for the index to be fully created.
- $type = $index->getType('scanAndScrollTest');
-
- $search = new Search($this->_getClient());
- $search->addIndex($index)->addType($type);
- $search->setQuery($query);
+ /**
+ * query size revert options.
+ *
+ * @group functional
+ */
+ public function testQuerySizeRevert()
+ {
+ $search = $this->_prepareSearch();
+ $search->getQuery()->setSize(9);
$scanAndScroll = new ScanAndScroll($search);
- $scanAndScroll->sizePerShard = 10;
- $scanAndScroll->rewind();
-
- $this->assertEquals(10, $query->getParam('size'));
- }
-
- public function testSizePerShard() {
- $search = $this->_prepareSearch('test_2', 2, 20);
- $scanAndScroll = new ScanAndScroll($search);
- $scanAndScroll->sizePerShard = 5;
$scanAndScroll->rewind();
+ $this->assertEquals(9, $search->getQuery()->getParam('size'));
- $this->assertEquals(10, $scanAndScroll->current()->count());
- }
-
- public function testScrollId() {
- $search = $this->_prepareSearch('test_3', 1, 2);
-
- $scanAndScroll = new ScanAndScroll($search);
- $scanAndScroll->sizePerShard = 1;
-
- $scanAndScroll->rewind();
- $this->assertEquals(
- $scanAndScroll->current()->getResponse()->getScrollId(),
- $scanAndScroll->key()
- );
+ $scanAndScroll->next();
+ $this->assertEquals(9, $search->getQuery()->getParam('size'));
}
- public function testForeach() {
- $search = $this->_prepareSearch('test_4', 2, 11);
-
- $scanAndScroll = new ScanAndScroll($search);
- $scanAndScroll->sizePerShard = 5;
-
- // We expect 2 scrolls:
- // 1. with 10 hits,
- // 2. with 1 hit
- // Note: there is a 3. scroll with 0 hits
-
- $count = 0;
- foreach($scanAndScroll as $resultSet) {
- /** @var ResultSet $resultSet */
- $count++;
+ /**
+ * index: 12 docs, 2 shards.
+ *
+ * @return Search
+ */
+ private function _prepareSearch()
+ {
+ $index = $this->_createIndex('', true, 2);
+ $index->refresh();
- switch(true) {
- case $count == 1: $this->assertEquals(10, $resultSet->count()); break;
- case $count == 2: $this->assertEquals(1, $resultSet->count()); break;
- }
+ $docs = array();
+ for ($x = 1; $x <= 12; $x++) {
+ $docs[] = new Document($x, array('id' => $x, 'key' => 'value'));
}
- $this->assertEquals(2, $count);
- }
-
- private function _prepareScanAndScroll() {
- return new ScanAndScroll(new Search($this->_getClient()));
- }
-
- private function _prepareSearch($indexName, $indexShards, $docs) {
- $index = $this->_createIndex($indexName, true, $indexShards);
$type = $index->getType('scanAndScrollTest');
-
- $insert = array();
- for ($x = 1; $x <= $docs; $x++) {
- $insert[] = new Document($x, array('id' => $x, 'key' => 'value'));
- }
-
- $type->addDocuments($insert);
+ $type->addDocuments($docs);
$index->refresh();
$search = new Search($this->_getClient());
@@ -112,4 +75,4 @@ class ScanAndScrollTest extends BaseTest {
return $search;
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ScriptFieldsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ScriptFieldsTest.php
index a3dd0d51..5448209d 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/ScriptFieldsTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ScriptFieldsTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test;
use Elastica\Document;
@@ -10,59 +9,54 @@ use Elastica\Test\Base as BaseTest;
class ScriptFieldsTest extends BaseTest
{
- protected $index;
-
- public function setUp()
- {
- $this->index = $this->_createIndex();
- }
-
- public function tearDown()
- {
- $this->index->delete();
- }
-
+ /**
+ * @group unit
+ */
public function testNewScriptFields()
{
$script = new Script('1 + 2');
// addScript
- $scriptFields = new ScriptFields;
+ $scriptFields = new ScriptFields();
$scriptFields->addScript('test', $script);
$this->assertEquals($scriptFields->getParam('test'), $script->toArray());
// setScripts
- $scriptFields = new ScriptFields;
+ $scriptFields = new ScriptFields();
$scriptFields->setScripts(array(
- 'test' => $script
+ 'test' => $script,
));
$this->assertEquals($scriptFields->getParam('test'), $script->toArray());
// Constructor
$scriptFields = new ScriptFields(array(
- 'test' => $script
+ 'test' => $script,
));
$this->assertEquals($scriptFields->getParam('test'), $script->toArray());
}
+ /**
+ * @group unit
+ */
public function testSetScriptFields()
{
- $query = new Query;
+ $query = new Query();
$script = new Script('1 + 2');
$scriptFields = new ScriptFields(array(
- 'test' => $script
+ 'test' => $script,
));
$query->setScriptFields($scriptFields);
$this->assertEquals($query->getParam('script_fields'), $scriptFields->toArray());
$query->setScriptFields(array(
- 'test' => $script
+ 'test' => $script,
));
$this->assertEquals($query->getParam('script_fields'), $scriptFields->toArray());
}
/**
+ * @group unit
* @expectedException \Elastica\Exception\InvalidException
*/
public function testNameException()
@@ -71,18 +65,22 @@ class ScriptFieldsTest extends BaseTest
$scriptFields = new ScriptFields(array($script));
}
+ /**
+ * @group functional
+ */
public function testQuery()
{
- $type = $this->index->getType('test');
+ $index = $this->_createIndex();
+ $type = $index->getType('test');
$doc = new Document(1, array('firstname' => 'guschti', 'lastname' => 'ruflin'));
$type->addDocument($doc);
- $this->index->refresh();
+ $index->refresh();
$query = new Query();
$script = new Script('1 + 2');
$scriptFields = new ScriptFields(array(
- 'test' => $script
+ 'test' => $script,
));
$query->setScriptFields($scriptFields);
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ScriptTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ScriptTest.php
index 0a11d118..b42d8646 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/ScriptTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ScriptTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test;
use Elastica\Script;
@@ -7,6 +6,9 @@ use Elastica\Test\Base as BaseTest;
class ScriptTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testConstructor()
{
$value = "_score * doc['my_numeric_field'].value";
@@ -50,6 +52,9 @@ class ScriptTest extends BaseTest
$this->assertEquals($expected, $script->toArray());
}
+ /**
+ * @group unit
+ */
public function testCreateString()
{
$string = '_score * 2.0';
@@ -65,6 +70,9 @@ class ScriptTest extends BaseTest
$this->assertEquals($expected, $script->toArray());
}
+ /**
+ * @group unit
+ */
public function testCreateScript()
{
$data = new Script('_score * 2.0');
@@ -75,6 +83,9 @@ class ScriptTest extends BaseTest
$this->assertSame($data, $script);
}
+ /**
+ * @group unit
+ */
public function testCreateArray()
{
$string = '_score * 2.0';
@@ -101,6 +112,7 @@ class ScriptTest extends BaseTest
}
/**
+ * @group unit
* @dataProvider dataProviderCreateInvalid
* @expectedException \Elastica\Exception\InvalidException
*/
@@ -116,14 +128,42 @@ class ScriptTest extends BaseTest
{
return array(
array(
- new \stdClass
+ new \stdClass(),
),
array(
array('params' => array('param1' => 'one')),
),
array(
array('script' => '_score * 2.0', 'params' => 'param'),
- )
+ ),
);
}
+
+ /**
+ * @group unit
+ */
+ public function testSetLang()
+ {
+ $script = new Script('foo', array(), Script::LANG_GROOVY);
+ $this->assertEquals(Script::LANG_GROOVY, $script->getLang());
+
+ $script->setLang(Script::LANG_PYTHON);
+ $this->assertEquals(Script::LANG_PYTHON, $script->getLang());
+
+ $this->assertInstanceOf('Elastica\Script', $script->setLang(Script::LANG_PYTHON));
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetScript()
+ {
+ $script = new Script('foo');
+ $this->assertEquals('foo', $script->getScript());
+
+ $script->setScript('bar');
+ $this->assertEquals('bar', $script->getScript());
+
+ $this->assertInstanceOf('Elastica\Script', $script->setScript('foo'));
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ScrollTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ScrollTest.php
new file mode 100644
index 00000000..df5b0317
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ScrollTest.php
@@ -0,0 +1,105 @@
+<?php
+namespace Elastica\Test;
+
+use Elastica\Document;
+use Elastica\Query;
+use Elastica\ResultSet;
+use Elastica\Scroll;
+use Elastica\Search;
+
+class ScrollTest extends Base
+{
+ /**
+ * Full foreach test.
+ *
+ * @group functional
+ */
+ public function testForeach()
+ {
+ $scroll = new Scroll($this->_prepareSearch());
+ $count = 1;
+
+ /** @var ResultSet $resultSet */
+ foreach ($scroll as $scrollId => $resultSet) {
+ $this->assertNotEmpty($scrollId);
+
+ $results = $resultSet->getResults();
+ switch (true) {
+ case $count === 1:
+ // hits: 1 - 5
+ $this->assertEquals(5, $resultSet->count());
+ $this->assertEquals('1', $results[0]->getId());
+ $this->assertEquals('5', $results[4]->getId());
+ break;
+ case $count === 2:
+ // hits: 6 - 10
+ $this->assertEquals(5, $resultSet->count());
+ $this->assertEquals('6', $results[0]->getId());
+ $this->assertEquals('10', $results[4]->getId());
+ break;
+ case $count === 3:
+ // hit: 11
+ $this->assertEquals(1, $resultSet->count());
+ $this->assertEquals('11', $results[0]->getId());
+ break;
+ case $count === 4:
+ $this->assertEquals(0, $resultSet->count());
+ break;
+ default:
+ $this->fail('too many iterations');
+ }
+
+ $count++;
+ }
+ }
+
+ /**
+ * Scroll must not overwrite options.
+ *
+ * @group functional
+ */
+ public function testSearchRevert()
+ {
+ $search = $this->_prepareSearch();
+
+ $search->setOption(Search::OPTION_SCROLL, 'must');
+ $search->setOption(Search::OPTION_SCROLL_ID, 'not');
+ $search->setOption(Search::OPTION_SEARCH_TYPE, 'change');
+ $old = $search->getOptions();
+
+ $scroll = new Scroll($search);
+
+ $scroll->rewind();
+ $this->assertEquals($old, $search->getOptions());
+
+ $scroll->next();
+ $this->assertEquals($old, $search->getOptions());
+ }
+
+ /**
+ * index: 11 docs
+ * query size: 5.
+ *
+ * @return Search
+ */
+ private function _prepareSearch()
+ {
+ $index = $this->_createIndex();
+ $index->refresh();
+
+ $docs = array();
+ for ($x = 1; $x <= 11; $x++) {
+ $docs[] = new Document($x, array('id' => $x, 'key' => 'value'));
+ }
+
+ $type = $index->getType('scrollTest');
+ $type->addDocuments($docs);
+ $index->refresh();
+
+ $search = new Search($this->_getClient());
+ $search->addIndex($index)->addType($type);
+ $search->getQuery()->setSize(5);
+
+ return $search;
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/SearchTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/SearchTest.php
index e08d2d60..905f8462 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/SearchTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/SearchTest.php
@@ -1,15 +1,14 @@
<?php
-
namespace Elastica\Test;
-use Elastica\Client;
+use Elastica\Aggregation;
use Elastica\Document;
+use Elastica\Exception\ResponseException;
use Elastica\Index;
-use Elastica\Query\Builder;
+use Elastica\Query;
+use Elastica\Query\FunctionScore;
use Elastica\Query\MatchAll;
use Elastica\Query\QueryString;
-use Elastica\Query\FunctionScore;
-use Elastica\Query;
use Elastica\Script;
use Elastica\Search;
use Elastica\Test\Base as BaseTest;
@@ -17,6 +16,9 @@ use Elastica\Type;
class SearchTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testConstruct()
{
$client = $this->_getClient();
@@ -26,13 +28,16 @@ class SearchTest extends BaseTest
$this->assertSame($client, $search->getClient());
}
+ /**
+ * @group functional
+ */
public function testAddIndex()
{
$client = $this->_getClient();
$search = new Search($client);
- $index1 = $this->_createIndex('test1');
- $index2 = $this->_createIndex('test2');
+ $index1 = $this->_createIndex();
+ $index2 = $this->_createIndex();
$search->addIndex($index1);
$indices = $search->getIndices();
@@ -55,6 +60,9 @@ class SearchTest extends BaseTest
$this->assertTrue(in_array('test3', $indices));
}
+ /**
+ * @group unit
+ */
public function testAddIndices()
{
$client = $this->_getClient();
@@ -69,6 +77,9 @@ class SearchTest extends BaseTest
$this->assertEquals(2, count($search->getIndices()));
}
+ /**
+ * @group functional
+ */
public function testAddType()
{
$client = $this->_getClient();
@@ -102,12 +113,15 @@ class SearchTest extends BaseTest
$this->assertTrue(in_array('test3', $types));
}
+ /**
+ * @group unit
+ */
public function testAddTypes()
{
$client = $this->_getClient();
$search = new Search($client);
- $index = $this->_createIndex();
+ $index = $client->getIndex('foo');
$types = array();
$types[] = $index->getType('type1');
@@ -119,6 +133,7 @@ class SearchTest extends BaseTest
}
/**
+ * @group unit
* @expectedException \Elastica\Exception\InvalidException
*/
public function testAddTypeInvalid()
@@ -130,6 +145,7 @@ class SearchTest extends BaseTest
}
/**
+ * @group unit
* @expectedException \Elastica\Exception\InvalidException
*/
public function testAddIndexInvalid()
@@ -140,14 +156,30 @@ class SearchTest extends BaseTest
$search->addIndex(new \stdClass());
}
+ /**
+ * @group unit
+ */
+ public function testAddNumericIndex()
+ {
+ $client = $this->_getClient();
+ $search = new Search($client);
+
+ $search->addIndex(1);
+
+ $this->assertContains('1', $search->getIndices(), 'Make sure it has been added and converted to string');
+ }
+
+ /**
+ * @group functional
+ */
public function testGetPath()
{
$client = $this->_getClient();
$search1 = new Search($client);
$search2 = new Search($client);
- $index1 = $this->_createIndex('test1');
- $index2 = $this->_createIndex('test2');
+ $index1 = $this->_createIndex();
+ $index2 = $this->_createIndex();
$type1 = $index1->getType('type1');
$type2 = $index1->getType('type2');
@@ -157,32 +189,35 @@ class SearchTest extends BaseTest
// Only index
$search1->addIndex($index1);
- $this->assertEquals($index1->getName() . '/_search', $search1->getPath());
+ $this->assertEquals($index1->getName().'/_search', $search1->getPath());
// MUltiple index, no types
$search1->addIndex($index2);
- $this->assertEquals($index1->getName() . ',' . $index2->getName() . '/_search', $search1->getPath());
+ $this->assertEquals($index1->getName().','.$index2->getName().'/_search', $search1->getPath());
// Single type, no index
$search2->addType($type1);
- $this->assertEquals('_all/' . $type1->getName() . '/_search', $search2->getPath());
+ $this->assertEquals('_all/'.$type1->getName().'/_search', $search2->getPath());
// Multiple types
$search2->addType($type2);
- $this->assertEquals('_all/' . $type1->getName() . ',' . $type2->getName() . '/_search', $search2->getPath());
+ $this->assertEquals('_all/'.$type1->getName().','.$type2->getName().'/_search', $search2->getPath());
// Combine index and types
$search2->addIndex($index1);
- $this->assertEquals($index1->getName() . '/' . $type1->getName() . ',' . $type2->getName() . '/_search', $search2->getPath());
+ $this->assertEquals($index1->getName().'/'.$type1->getName().','.$type2->getName().'/_search', $search2->getPath());
}
+ /**
+ * @group functional
+ */
public function testSearchRequest()
{
$client = $this->_getClient();
$search1 = new Search($client);
- $index1 = $this->_createIndex('test1');
- $index2 = $this->_createIndex('test2');
+ $index1 = $this->_createIndex();
+ $index2 = $this->_createIndex();
$type1 = $index1->getType('hello1');
@@ -205,11 +240,14 @@ class SearchTest extends BaseTest
$this->assertFalse($result->getResponse()->hasError());
}
+ /**
+ * @group functional
+ */
public function testSearchScrollRequest()
{
$client = $this->_getClient();
- $index = $this->_createIndex('test');
+ $index = $this->_createIndex();
$type = $index->getType('scrolltest');
$docs = array();
@@ -265,7 +303,9 @@ class SearchTest extends BaseTest
}
/**
- * Default Limit tests for \Elastica\Search
+ * Default Limit tests for \Elastica\Search.
+ *
+ * @group functional
*/
public function testLimitDefaultSearch()
{
@@ -275,20 +315,20 @@ class SearchTest extends BaseTest
$index = $client->getIndex('zero');
$index->create(array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0)), true);
- $docs = array();
- $docs[] = new Document(1, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(2, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(3, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(4, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(5, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(6, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(7, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(8, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(9, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(10, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(11, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
$type = $index->getType('zeroType');
- $type->addDocuments($docs);
+ $type->addDocuments(array(
+ new Document(1, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(2, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(3, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(4, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(5, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(6, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(7, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(8, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(9, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(10, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(11, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ ));
$index->refresh();
$search->addIndex($index)->addType($type);
@@ -303,6 +343,7 @@ class SearchTest extends BaseTest
}
/**
+ * @group functional
* @expectedException \Elastica\Exception\InvalidException
*/
public function testArrayConfigSearch()
@@ -357,6 +398,13 @@ class SearchTest extends BaseTest
$this->assertTrue(($resultSet->count() === 0) && $resultSet->getTotalHits() === 11);
//Timeout - this one is a bit more tricky to test
+ $mockResponse = new \Elastica\Response(json_encode(array('timed_out' => true)));
+ $client = $this->getMockBuilder('Elastica\\Client')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $client->method('request')
+ ->will($this->returnValue($mockResponse));
+ $search = new Search($client);
$script = new Script('Thread.sleep(100); return _score;');
$query = new FunctionScore();
$query->addScriptScoreFunction($script);
@@ -367,9 +415,12 @@ class SearchTest extends BaseTest
$resultSet = $search->search('test', array('invalid_option' => 'invalid_option_value'));
}
+ /**
+ * @group functional
+ */
public function testSearchWithVersionOption()
{
- $index = $this->_createIndex('test1');
+ $index = $this->_createIndex();
$doc = new Document(1, array('id' => 1, 'email' => 'test@test.com', 'username' => 'ruflin'));
$index->getType('test')->addDocument($doc);
$index->refresh();
@@ -388,6 +439,9 @@ class SearchTest extends BaseTest
$this->assertEquals(1, $hit->getParam('_version'));
}
+ /**
+ * @group functional
+ */
public function testCountRequest()
{
$client = $this->_getClient();
@@ -396,21 +450,20 @@ class SearchTest extends BaseTest
$index = $client->getIndex('zero');
$index->create(array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0)), true);
- $docs = array();
- $docs[] = new Document(1, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(2, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(3, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(4, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(5, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(6, array('id' => 1, 'email' => 'test@test.com', 'username' => 'marley'));
- $docs[] = new Document(7, array('id' => 1, 'email' => 'test@test.com', 'username' => 'marley'));
- $docs[] = new Document(8, array('id' => 1, 'email' => 'test@test.com', 'username' => 'marley'));
- $docs[] = new Document(9, array('id' => 1, 'email' => 'test@test.com', 'username' => 'marley'));
- $docs[] = new Document(10, array('id' => 1, 'email' => 'test@test.com', 'username' => 'marley'));
- $docs[] = new Document(11, array('id' => 1, 'email' => 'test@test.com', 'username' => 'marley'));
-
$type = $index->getType('zeroType');
- $type->addDocuments($docs);
+ $type->addDocuments(array(
+ new Document(1, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(2, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(3, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(4, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(5, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(6, array('id' => 1, 'email' => 'test@test.com', 'username' => 'marley')),
+ new Document(7, array('id' => 1, 'email' => 'test@test.com', 'username' => 'marley')),
+ new Document(8, array('id' => 1, 'email' => 'test@test.com', 'username' => 'marley')),
+ new Document(9, array('id' => 1, 'email' => 'test@test.com', 'username' => 'marley')),
+ new Document(10, array('id' => 1, 'email' => 'test@test.com', 'username' => 'marley')),
+ new Document(11, array('id' => 1, 'email' => 'test@test.com', 'username' => 'marley')),
+ ));
$index->refresh();
$search->addIndex($index)->addType($type);
@@ -431,6 +484,9 @@ class SearchTest extends BaseTest
$this->assertEquals(0, $count);
}
+ /**
+ * @group functional
+ */
public function testEmptySearch()
{
$client = $this->_getClient();
@@ -438,20 +494,20 @@ class SearchTest extends BaseTest
$index = $client->getIndex('zero');
$index->create(array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0)), true);
- $docs = array();
- $docs[] = new Document(1, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(2, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(3, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(4, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(5, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(6, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(7, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(8, array('id' => 1, 'email' => 'test@test.com', 'username' => 'bunny'));
- $docs[] = new Document(9, array('id' => 1, 'email' => 'test@test.com', 'username' => 'bunny'));
- $docs[] = new Document(10, array('id' => 1, 'email' => 'test@test.com', 'username' => 'bunny'));
- $docs[] = new Document(11, array('id' => 1, 'email' => 'test@test.com', 'username' => 'bunny'));
$type = $index->getType('zeroType');
- $type->addDocuments($docs);
+ $type->addDocuments(array(
+ new Document(1, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(2, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(3, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(4, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(5, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(6, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(7, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(8, array('id' => 1, 'email' => 'test@test.com', 'username' => 'bunny')),
+ new Document(9, array('id' => 1, 'email' => 'test@test.com', 'username' => 'bunny')),
+ new Document(10, array('id' => 1, 'email' => 'test@test.com', 'username' => 'bunny')),
+ new Document(11, array('id' => 1, 'email' => 'test@test.com', 'username' => 'bunny')),
+ ));
$index->refresh();
$search->addIndex($index)->addType($type);
@@ -470,31 +526,122 @@ class SearchTest extends BaseTest
$source = $resultSet->current()->getSource();
$this->assertEquals('bunny', $source['username']);
}
-
- public function testCount() {
- $index = $this->_createIndex('eeee');
+
+ /**
+ * @group functional
+ */
+ public function testCount()
+ {
+ $index = $this->_createIndex();
$search = new Search($index->getClient());
- $type = $index->getType('test');
-
+ $type = $index->getType('test');
+
$doc = new Document(1, array('id' => 1, 'username' => 'ruflin'));
-
- $type->addDocument($doc);
- $index->refresh();
-
- $search->addIndex($index);
- $search->addType($type);
-
- $result1 = $search->count(new \Elastica\Query\MatchAll());
- $this->assertEquals(1, $result1);
-
-
- $result2 = $search->count(new \Elastica\Query\MatchAll(), true);
- $this->assertInstanceOf('\Elastica\ResultSet', $result2);
- $this->assertEquals(1, $result2->getTotalHits());
- }
-
- public function testScanAndScroll() {
+
+ $type->addDocument($doc);
+ $index->refresh();
+
+ $search->addIndex($index);
+ $search->addType($type);
+
+ $result1 = $search->count(new \Elastica\Query\MatchAll());
+ $this->assertEquals(1, $result1);
+
+ $result2 = $search->count(new \Elastica\Query\MatchAll(), true);
+ $this->assertInstanceOf('\Elastica\ResultSet', $result2);
+ $this->assertEquals(1, $result2->getTotalHits());
+ }
+
+ /**
+ * @group functional
+ */
+ public function testScanAndScroll()
+ {
$search = new Search($this->_getClient());
$this->assertInstanceOf('Elastica\ScanAndScroll', $search->scanAndScroll());
}
+
+ /**
+ * @group functional
+ */
+ public function testIgnoreUnavailableOption()
+ {
+ $client = $this->_getClient();
+ $index = $client->getIndex('elastica_7086b4c2ee585bbb6740ece5ed7ece01');
+ $query = new MatchAll();
+
+ $search = new Search($client);
+ $search->addIndex($index);
+
+ $exception = null;
+ try {
+ $search->search($query);
+ } catch (ResponseException $e) {
+ $exception = $e;
+ }
+ $this->assertEquals('IndexMissingException', $exception->getElasticsearchException()->getExceptionName());
+
+ $results = $search->search($query, array(Search::OPTION_SEARCH_IGNORE_UNAVAILABLE => true));
+ $this->assertInstanceOf('\Elastica\ResultSet', $results);
+ }
+
+ /**
+ * @group functional
+ */
+ public function testQueryCacheOption()
+ {
+ $client = $this->_getClient();
+
+ $index = $client->getIndex('zero');
+ $index->create(array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0)), true);
+ $type = $index->getType('zeroType');
+ $type->addDocuments(array(
+ new Document(1, array('id' => 1, 'username' => 'farrelley')),
+ new Document(2, array('id' => 2, 'username' => 'bunny')),
+ ));
+ $index->refresh();
+
+ $aggregation = new Aggregation\Terms('username');
+ $aggregation->setField('username');
+
+ $query = new Query();
+ $query->addAggregation($aggregation);
+
+ $search = new Search($client);
+ $search->addIndex($index);
+ $search->setQuery($query);
+ $search->setOption(Search::OPTION_SEARCH_TYPE, Search::OPTION_SEARCH_TYPE_COUNT);
+ $search->setOption(Search::OPTION_QUERY_CACHE, true);
+
+ // before search query cache should be empty
+ $statsData = $index->getStats()->getData();
+ $queryCache = $statsData['_all']['primaries']['query_cache'];
+
+ $this->assertEquals(0, $queryCache['memory_size_in_bytes']);
+ $this->assertEquals(0, $queryCache['evictions']);
+ $this->assertEquals(0, $queryCache['hit_count']);
+ $this->assertEquals(0, $queryCache['miss_count']);
+
+ // first search should result in cache miss and save data to cache
+ $search->search();
+ $index->getStats()->refresh();
+ $statsData = $index->getStats()->getData();
+ $queryCache = $statsData['_all']['primaries']['query_cache'];
+
+ $this->assertNotEquals(0, $queryCache['memory_size_in_bytes']);
+ $this->assertEquals(0, $queryCache['evictions']);
+ $this->assertEquals(0, $queryCache['hit_count']);
+ $this->assertEquals(1, $queryCache['miss_count']);
+
+ // next search should result in cache hit
+ $search->search();
+ $index->getStats()->refresh();
+ $statsData = $index->getStats()->getData();
+ $queryCache = $statsData['_all']['primaries']['query_cache'];
+
+ $this->assertNotEquals(0, $queryCache['memory_size_in_bytes']);
+ $this->assertEquals(0, $queryCache['evictions']);
+ $this->assertEquals(1, $queryCache['hit_count']);
+ $this->assertEquals(1, $queryCache['miss_count']);
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ShutdownTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ShutdownTest.php
new file mode 100644
index 00000000..93d6e32b
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ShutdownTest.php
@@ -0,0 +1,74 @@
+<?php
+
+use Elastica\Test\Base as BaseTest;
+
+/**
+ * These tests shuts down node/cluster, so can't be executed with rest testsuite
+ * Please use `sudo service elasticsearch restart` after every run of these tests.
+ */
+class ShutdownTest extends BaseTest
+{
+ /**
+ * @group shutdown
+ */
+ public function testNodeShutdown()
+ {
+ // Get cluster nodes
+ $client = $this->_getClient();
+ $cluster = $client->getCluster();
+ $nodes = $cluster->getNodes();
+
+ $nodesCount = count($nodes);
+
+ if ($nodesCount < 2) {
+ $this->markTestIncomplete('At least two nodes have to be running, because 1 node is shutdown');
+ }
+
+ $portFound = false;
+ // sayonara, wolverine, we'd never love you
+ foreach ($nodes as $node) {
+ if ((int) $node->getInfo()->getPort() === 9201) {
+ $portFound = true;
+ $node->shutdown('1s');
+ break;
+ }
+ }
+
+ if (!$portFound) {
+ $this->markTestSkipped('This test was skipped as in the new docker environment all elasticsearch instances run on the same port');
+ }
+
+ // Wait until node is shutdown
+ sleep(5);
+
+ // Get nodes again
+ $client = $this->_getClient();
+ $cluster = $client->getCluster();
+ $nodes = $cluster->getNodes();
+
+ // Only one left
+ $this->assertCount($nodesCount - 1, $nodes);
+ }
+
+ /**
+ * @group shutdown
+ * @depends testNodeShutdown
+ * @expectedException \Elastica\Exception\Connection\HttpException
+ */
+ public function testClusterShutdown()
+ {
+ // Get cluster nodes
+ $client = $this->_getClient();
+ $cluster = $client->getCluster();
+ $nodes = $cluster->getNodes();
+
+ // Shutdown cluster
+ $cluster->shutdown('1s');
+
+ // Wait...
+ sleep(5);
+
+ // Now exception must be thrown
+ $client->getStatus();
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/SnapshotTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/SnapshotTest.php
index 3ac5bfe2..fa190e8c 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/SnapshotTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/SnapshotTest.php
@@ -1,8 +1,6 @@
<?php
-
namespace Elastica\Test;
-
use Elastica\Document;
use Elastica\Index;
use Elastica\Snapshot;
@@ -29,62 +27,62 @@ class SnapshotTest extends Base
parent::setUp();
$this->_snapshot = new Snapshot($this->_getClient());
- $this->_index = $this->_createIndex("test_snapshot");
+ $this->_index = $this->_createIndex();
$this->_docs = array(
- new Document("1", array("city" => "San Diego")),
- new Document("2", array("city" => "San Luis Obispo")),
- new Document("3", array("city" => "San Francisco")),
+ new Document('1', array('city' => 'San Diego')),
+ new Document('2', array('city' => 'San Luis Obispo')),
+ new Document('3', array('city' => 'San Francisco')),
);
- $this->_index->getType("test")->addDocuments($this->_docs);
+ $this->_index->getType('test')->addDocuments($this->_docs);
$this->_index->refresh();
}
- protected function tearDown()
- {
- parent::tearDown();
- $this->_index->delete();
- }
-
+ /**
+ * @group functional
+ */
public function testRegisterRepository()
{
- $name = "test_register";
- $location = "/tmp/test_register";
+ $name = 'test_register';
+ $location = '/tmp/test_register';
- $response = $this->_snapshot->registerRepository($name, "fs", array("location" => $location));
+ $response = $this->_snapshot->registerRepository($name, 'fs', array('location' => $location));
$this->assertTrue($response->isOk());
$response = $this->_snapshot->getRepository($name);
- $this->assertEquals($location, $response["settings"]["location"]);
+ $this->assertEquals($location, $response['settings']['location']);
// attempt to retrieve a repository which does not exist
$this->setExpectedException('Elastica\Exception\NotFoundException');
- $this->_snapshot->getRepository("foobar");
+ $this->_snapshot->getRepository('foobar');
}
+ /**
+ * @group functional
+ */
public function testSnapshotAndRestore()
{
- $repositoryName = "test_repository";
+ $repositoryName = 'test_repository';
$location = "/tmp/{$repositoryName}";
// register the repository
- $response = $this->_snapshot->registerRepository($repositoryName, "fs", array("location" => $location));
+ $response = $this->_snapshot->registerRepository($repositoryName, 'fs', array('location' => $location));
$this->assertTrue($response->isOk());
// create a snapshot of our test index
- $snapshotName = "test_snapshot_1";
- $response = $this->_snapshot->createSnapshot($repositoryName, $snapshotName, array("indices" => $this->_index->getName()), true);
+ $snapshotName = 'test_snapshot_1';
+ $response = $this->_snapshot->createSnapshot($repositoryName, $snapshotName, array('indices' => $this->_index->getName()), true);
// ensure that the snapshot was created properly
$this->assertTrue($response->isOk());
- $this->assertArrayHasKey("snapshot", $response->getData());
+ $this->assertArrayHasKey('snapshot', $response->getData());
$data = $response->getData();
- $this->assertContains($this->_index->getName(), $data["snapshot"]["indices"]);
- $this->assertEquals(1, sizeof($data["snapshot"]["indices"])); // only the specified index should be present
- $this->assertEquals($snapshotName, $data["snapshot"]["snapshot"]);
+ $this->assertContains($this->_index->getName(), $data['snapshot']['indices']);
+ $this->assertEquals(1, sizeof($data['snapshot']['indices'])); // only the specified index should be present
+ $this->assertEquals($snapshotName, $data['snapshot']['snapshot']);
// retrieve data regarding the snapshot
$response = $this->_snapshot->getSnapshot($repositoryName, $snapshotName);
- $this->assertContains($this->_index->getName(), $response["indices"]);
+ $this->assertContains($this->_index->getName(), $response['indices']);
// delete our test index
$this->_index->delete();
@@ -97,7 +95,7 @@ class SnapshotTest extends Base
$this->_index->optimize();
// ensure that the index has been restored
- $count = $this->_index->getType("test")->count();
+ $count = $this->_index->getType('test')->count();
$this->assertEquals(sizeof($this->_docs), $count);
// delete the snapshot
@@ -109,4 +107,3 @@ class SnapshotTest extends Base
$this->_snapshot->getSnapshot($repositoryName, $snapshotName);
}
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/StatusTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/StatusTest.php
index 14d7950a..fe6bb091 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/StatusTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/StatusTest.php
@@ -1,13 +1,15 @@
<?php
-
namespace Elastica\Test;
-use Elastica\Client;
+
use Elastica\Exception\ResponseException;
use Elastica\Status;
use Elastica\Test\Base as BaseTest;
class StatusTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testGetResponse()
{
$index = $this->_createIndex();
@@ -15,6 +17,9 @@ class StatusTest extends BaseTest
$this->assertInstanceOf('Elastica\Response', $status->getResponse());
}
+ /**
+ * @group functional
+ */
public function testGetIndexStatuses()
{
$index = $this->_createIndex();
@@ -29,6 +34,9 @@ class StatusTest extends BaseTest
}
}
+ /**
+ * @group functional
+ */
public function testGetIndexNames()
{
$indexName = 'test';
@@ -36,8 +44,8 @@ class StatusTest extends BaseTest
$index = $client->getIndex($indexName);
$index->create(array(), true);
$index = $this->_createIndex();
- $index->refresh();
- $index->optimize();
+ $index->refresh();
+ $index->optimize();
$status = new Status($index->getClient());
$names = $status->getIndexNames();
@@ -50,6 +58,9 @@ class StatusTest extends BaseTest
}
}
+ /**
+ * @group functional
+ */
public function testIndexExists()
{
$indexName = 'elastica_test';
@@ -72,12 +83,15 @@ class StatusTest extends BaseTest
$this->assertTrue($status->indexExists($indexName));
}
+ /**
+ * @group functional
+ */
public function testAliasExists()
{
- $indexName = 'test';
$aliasName = 'elastica_test-alias';
$index1 = $this->_createIndex();
+ $indexName = $index1->getName();
$status = new Status($index1->getClient());
@@ -92,19 +106,22 @@ class StatusTest extends BaseTest
$this->assertTrue($status->aliasExists($aliasName));
$indicesWithAlias = $status->getIndicesWithAlias($aliasName);
- $this->assertEquals(array("elastica_$indexName"), array_map(
- function($index) {
+ $this->assertEquals(array($indexName), array_map(
+ function ($index) {
return $index->getName();
}, $indicesWithAlias));
}
+ /**
+ * @group functional
+ */
public function testServerStatus()
{
$client = $this->_getClient();
$status = $client->getStatus();
$serverStatus = $status->getServerStatus();
- $this->assertTrue(!empty($serverStatus) );
+ $this->assertTrue(!empty($serverStatus));
$this->assertTrue('array' == gettype($serverStatus));
$this->assertArrayHasKey('status', $serverStatus);
$this->assertTrue($serverStatus['status'] == 200);
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/CompletionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/CompletionTest.php
new file mode 100644
index 00000000..6120743c
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/CompletionTest.php
@@ -0,0 +1,140 @@
+<?php
+namespace Elastica\Test\Suggest;
+
+use Elastica\Document;
+use Elastica\Index;
+use Elastica\Query;
+use Elastica\Suggest\Completion;
+use Elastica\Test\Base as BaseTest;
+
+class CompletionTest extends BaseTest
+{
+ /**
+ * @return Index
+ */
+ protected function _getIndexForTest()
+ {
+ $index = $this->_createIndex();
+ $type = $index->getType('song');
+
+ $type->setMapping(array(
+ 'fieldName' => array(
+ 'type' => 'completion',
+ 'payloads' => true,
+ ),
+ ));
+
+ $type->addDocuments(array(
+ new Document(1, array(
+ 'fieldName' => array(
+ 'input' => array('Nevermind', 'Nirvana'),
+ 'output' => 'Nevermind - Nirvana',
+ 'payload' => array(
+ 'year' => 1991,
+ ),
+ ),
+ )),
+ new Document(2, array(
+ 'fieldName' => array(
+ 'input' => array('Bleach', 'Nirvana'),
+ 'output' => 'Bleach - Nirvana',
+ 'payload' => array(
+ 'year' => 1989,
+ ),
+ ),
+ )),
+ new Document(3, array(
+ 'fieldName' => array(
+ 'input' => array('Incesticide', 'Nirvana'),
+ 'output' => 'Incesticide - Nirvana',
+ 'payload' => array(
+ 'year' => 1992,
+ ),
+ ),
+ )),
+ ));
+
+ $index->refresh();
+
+ return $index;
+ }
+
+ /**
+ * @group unit
+ */
+ public function testToArray()
+ {
+ $suggest = new Completion('suggestName', 'fieldName');
+ $suggest->setText('foo');
+ $suggest->setSize(10);
+ $expected = array(
+ 'text' => 'foo',
+ 'completion' => array(
+ 'size' => 10,
+ 'field' => 'fieldName',
+ ),
+ );
+ $this->assertEquals($expected, $suggest->toArray());
+ }
+
+ /**
+ * @group functional
+ */
+ public function testSuggestWorks()
+ {
+ $suggest = new Completion('suggestName', 'fieldName');
+ $suggest->setText('Never');
+
+ $index = $this->_getIndexForTest();
+ $resultSet = $index->search(Query::create($suggest));
+
+ $this->assertTrue($resultSet->hasSuggests());
+
+ $suggests = $resultSet->getSuggests();
+ $options = $suggests['suggestName'][0]['options'];
+
+ $this->assertCount(1, $options);
+ $this->assertEquals('Nevermind - Nirvana', $options[0]['text']);
+ $this->assertEquals(1991, $options[0]['payload']['year']);
+ }
+
+ /**
+ * @group functional
+ */
+ public function testFuzzySuggestWorks()
+ {
+ $suggest = new Completion('suggestName', 'fieldName');
+ $suggest->setFuzzy(array('fuzziness' => 2));
+ $suggest->setText('Neavermint');
+
+ $index = $this->_getIndexForTest();
+ $resultSet = $index->search(Query::create($suggest));
+
+ $this->assertTrue($resultSet->hasSuggests());
+
+ $suggests = $resultSet->getSuggests();
+ $options = $suggests['suggestName'][0]['options'];
+
+ $this->assertCount(1, $options);
+ $this->assertEquals('Nevermind - Nirvana', $options[0]['text']);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetFuzzy()
+ {
+ $suggest = new Completion('suggestName', 'fieldName');
+
+ $fuzzy = array(
+ 'unicode_aware' => true,
+ 'fuzziness' => 3,
+ );
+
+ $suggest->setFuzzy($fuzzy);
+
+ $this->assertEquals($fuzzy, $suggest->getParam('fuzzy'));
+
+ $this->assertInstanceOf('Elastica\\Suggest\\Completion', $suggest->setFuzzy($fuzzy));
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/PhraseTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/PhraseTest.php
index eda08ba0..9ce345d4 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/PhraseTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/PhraseTest.php
@@ -1,44 +1,37 @@
<?php
-
namespace Elastica\Test\Suggest;
+use Elastica\Document;
+use Elastica\Index;
use Elastica\Suggest;
use Elastica\Suggest\CandidateGenerator\DirectGenerator;
use Elastica\Suggest\Phrase;
use Elastica\Test\Base as BaseTest;
-use Elastica\Query;
-use Elastica\Document;
-use Elastica\Index;
class PhraseTest extends BaseTest
{
- const TEST_TYPE = 'testSuggestType';
-
/**
- * @var Index
+ * @return Index
*/
- protected $_index;
-
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex('test_suggest_phrase');
- $docs = array();
- $docs[] = new Document(1, array('text' => 'Github is pretty cool'));
- $docs[] = new Document(2, array('text' => 'Elasticsearch is bonsai cool'));
- $docs[] = new Document(3, array('text' => 'This is a test phrase'));
- $docs[] = new Document(4, array('text' => 'Another sentence for testing'));
- $docs[] = new Document(5, array('text' => 'Some more words here'));
- $type = $this->_index->getType(self::TEST_TYPE);
- $type->addDocuments($docs);
- $this->_index->refresh();
- }
+ $index = $this->_createIndex();
+ $type = $index->getType('testSuggestType');
+ $type->addDocuments(array(
+ new Document(1, array('text' => 'Github is pretty cool')),
+ new Document(2, array('text' => 'Elasticsearch is bonsai cool')),
+ new Document(3, array('text' => 'This is a test phrase')),
+ new Document(4, array('text' => 'Another sentence for testing')),
+ new Document(5, array('text' => 'Some more words here')),
+ ));
+ $index->refresh();
- protected function tearDown()
- {
- $this->_index->delete();
+ return $index;
}
+ /**
+ * @group unit
+ */
public function testToArray()
{
$suggest = new Suggest();
@@ -55,31 +48,35 @@ class PhraseTest extends BaseTest
'text' => 'elasticsearch is bansai coor',
'phrase' => array(
'field' => 'text',
- 'analyzer' => 'simple'
- )
- )
- )
+ 'analyzer' => 'simple',
+ ),
+ ),
+ ),
);
$this->assertEquals($expected, $suggest->toArray());
}
+ /**
+ * @group functional
+ */
public function testPhraseSuggest()
{
$suggest = new Suggest();
$phraseSuggest = new Phrase('suggest1', 'text');
- $phraseSuggest->setText("elasticsearch is bansai coor");
- $phraseSuggest->setAnalyzer("simple")->setHighlight("<suggest>", "</suggest>")->setStupidBackoffSmoothing(0.4);
- $phraseSuggest->addCandidateGenerator(new DirectGenerator("text"));
+ $phraseSuggest->setText('elasticsearch is bansai coor');
+ $phraseSuggest->setAnalyzer('simple')->setHighlight('<suggest>', '</suggest>')->setStupidBackoffSmoothing(0.4);
+ $phraseSuggest->addCandidateGenerator(new DirectGenerator('text'));
$suggest->addSuggestion($phraseSuggest);
- $result = $this->_index->search($suggest);
+ $index = $this->_getIndexForTest();
+ $result = $index->search($suggest);
$suggests = $result->getSuggests();
// 3 suggestions should be returned: One in which both misspellings are corrected, and two in which only one misspelling is corrected.
$this->assertEquals(3, sizeof($suggests['suggest1'][0]['options']));
- $this->assertEquals("elasticsearch is <suggest>bonsai cool</suggest>", $suggests['suggest1'][0]['options'][0]['highlighted']);
- $this->assertEquals("elasticsearch is bonsai cool", $suggests['suggest1'][0]['options'][0]['text']);
+ $this->assertEquals('elasticsearch is <suggest>bonsai cool</suggest>', $suggests['suggest1'][0]['options'][0]['highlighted']);
+ $this->assertEquals('elasticsearch is bonsai cool', $suggests['suggest1'][0]['options'][0]['text']);
}
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/TermTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/TermTest.php
index 7765f1bb..f1250e6f 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/TermTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/TermTest.php
@@ -1,44 +1,37 @@
<?php
-
namespace Elastica\Test\Suggest;
+use Elastica\Document;
+use Elastica\Index;
use Elastica\Suggest;
use Elastica\Suggest\Term;
use Elastica\Test\Base as BaseTest;
-use Elastica\Query;
-use Elastica\Document;
-use Elastica\Index;
class TermTest extends BaseTest
{
- const TEST_TYPE = 'testSuggestType';
-
/**
- * @var Index
+ * @return Index
*/
- protected $_index;
-
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex('test_suggest');
- $docs = array();
- $docs[] = new Document(1, array('id' => 1, 'text' => 'GitHub'));
- $docs[] = new Document(2, array('id' => 1, 'text' => 'Elastic'));
- $docs[] = new Document(3, array('id' => 1, 'text' => 'Search'));
- $docs[] = new Document(4, array('id' => 1, 'text' => 'Food'));
- $docs[] = new Document(5, array('id' => 1, 'text' => 'Flood'));
- $docs[] = new Document(6, array('id' => 1, 'text' => 'Folks'));
- $type = $this->_index->getType(self::TEST_TYPE);
- $type->addDocuments($docs);
- $this->_index->refresh();
- }
-
- protected function tearDown()
- {
- $this->_index->delete();
+ $index = $this->_createIndex();
+ $type = $index->getType('testSuggestType');
+ $type->addDocuments(array(
+ new Document(1, array('id' => 1, 'text' => 'GitHub')),
+ new Document(2, array('id' => 1, 'text' => 'Elastic')),
+ new Document(3, array('id' => 1, 'text' => 'Search')),
+ new Document(4, array('id' => 1, 'text' => 'Food')),
+ new Document(5, array('id' => 1, 'text' => 'Flood')),
+ new Document(6, array('id' => 1, 'text' => 'Folks')),
+ ));
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group unit
+ */
public function testToArray()
{
$suggest = new Suggest();
@@ -51,22 +44,25 @@ class TermTest extends BaseTest
'suggest' => array(
'suggest1' => array(
'term' => array(
- 'field' => '_all'
+ 'field' => '_all',
),
- 'text' => 'Foor'
+ 'text' => 'Foor',
),
'suggest2' => array(
'term' => array(
- 'field' => '_all'
+ 'field' => '_all',
),
- 'text' => 'Girhub'
- )
- )
+ 'text' => 'Girhub',
+ ),
+ ),
);
$this->assertEquals($expected, $suggest->toArray());
}
+ /**
+ * @group functional
+ */
public function testSuggestResults()
{
$suggest = new Suggest();
@@ -75,7 +71,8 @@ class TermTest extends BaseTest
$suggest2 = new Term('suggest2', '_all');
$suggest->addSuggestion($suggest2->setText('Girhub'));
- $result = $this->_index->search($suggest);
+ $index = $this->_getIndexForTest();
+ $result = $index->search($suggest);
$this->assertEquals(2, $result->countSuggests());
@@ -88,12 +85,16 @@ class TermTest extends BaseTest
$this->assertEquals('food', $suggests['suggest1'][0]['options'][0]['text']);
}
+ /**
+ * @group functional
+ */
public function testSuggestNoResults()
{
$termSuggest = new Term('suggest1', '_all');
$termSuggest->setText('Foobar')->setSize(4);
- $result = $this->_index->search($termSuggest);
+ $index = $this->_getIndexForTest();
+ $result = $index->search($termSuggest);
$this->assertEquals(1, $result->countSuggests());
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Tool/CrossIndexTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Tool/CrossIndexTest.php
new file mode 100644
index 00000000..f8fbf280
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Tool/CrossIndexTest.php
@@ -0,0 +1,135 @@
+<?php
+namespace Elastica\Test\Tool;
+
+use Elastica\Document;
+use Elastica\Test\Base;
+use Elastica\Tool\CrossIndex;
+use Elastica\Type;
+
+class CrossIndexTest extends Base
+{
+ /**
+ * Test default reindex.
+ */
+ public function testReindex()
+ {
+ $oldIndex = $this->_createIndex(null, true, 2);
+ $this->_addDocs($oldIndex->getType('crossIndexTest'), 10);
+
+ $newIndex = $this->_createIndex(null, true, 2);
+
+ $this->assertInstanceOf(
+ 'Elastica\Index',
+ CrossIndex::reindex($oldIndex, $newIndex)
+ );
+
+ $this->assertEquals(10, $newIndex->count());
+ }
+
+ /**
+ * Test reindex type option.
+ */
+ public function testReindexTypeOption()
+ {
+ $oldIndex = $this->_createIndex('', true, 2);
+ $type1 = $oldIndex->getType('crossIndexTest_1');
+ $type2 = $oldIndex->getType('crossIndexTest_2');
+
+ $docs1 = $this->_addDocs($type1, 10);
+ $docs2 = $this->_addDocs($type2, 10);
+
+ $newIndex = $this->_createIndex(null, true, 2);
+
+ // \Elastica\Type
+ CrossIndex::reindex($oldIndex, $newIndex, array(
+ CrossIndex::OPTION_TYPE => $type1,
+ ));
+ $this->assertEquals(10, $newIndex->count());
+ $newIndex->deleteDocuments($docs1);
+
+ // string
+ CrossIndex::reindex($oldIndex, $newIndex, array(
+ CrossIndex::OPTION_TYPE => 'crossIndexTest_2',
+ ));
+ $this->assertEquals(10, $newIndex->count());
+ $newIndex->deleteDocuments($docs2);
+
+ // array
+ CrossIndex::reindex($oldIndex, $newIndex, array(
+ CrossIndex::OPTION_TYPE => array(
+ 'crossIndexTest_1',
+ $type2,
+ ),
+ ));
+ $this->assertEquals(20, $newIndex->count());
+ }
+
+ /**
+ * Test default copy.
+ */
+ public function testCopy()
+ {
+ $oldIndex = $this->_createIndex(null, true, 2);
+ $newIndex = $this->_createIndex(null, true, 2);
+
+ $oldType = $oldIndex->getType('copy_test');
+ $oldMapping = array(
+ 'name' => array(
+ 'type' => 'string',
+ 'store' => true,
+ ),
+ );
+ $oldType->setMapping($oldMapping);
+ $docs = $this->_addDocs($oldType, 10);
+
+ // mapping
+ $this->assertInstanceOf(
+ 'Elastica\Index',
+ CrossIndex::copy($oldIndex, $newIndex)
+ );
+
+ $newMapping = $newIndex->getType('copy_test')->getMapping();
+ if (!isset($newMapping['copy_test']['properties']['name'])) {
+ $this->fail('could not request new mapping');
+ }
+
+ $this->assertEquals(
+ $oldMapping['name'],
+ $newMapping['copy_test']['properties']['name']
+ );
+
+ // document copy
+ $this->assertEquals(10, $newIndex->count());
+ $newIndex->deleteDocuments($docs);
+
+ // ignore mapping
+ $ignoredType = $oldIndex->getType('copy_test_1');
+ $this->_addDocs($ignoredType, 10);
+
+ CrossIndex::copy($oldIndex, $newIndex, array(
+ CrossIndex::OPTION_TYPE => $oldType,
+ ));
+
+ $this->assertFalse($newIndex->getType($ignoredType->getName())->exists());
+ $this->assertEquals(10, $newIndex->count());
+ }
+
+ /**
+ * @param Type $type
+ * @param int $docs
+ *
+ * @return array
+ */
+ private function _addDocs(Type $type, $docs)
+ {
+ $insert = array();
+ for ($i = 1; $i <= $docs; $i++) {
+ $insert[] = new Document($i, array('_id' => $i, 'key' => 'value'));
+ }
+
+ $type->addDocuments($insert);
+ $type->getIndex()->refresh();
+
+ return $insert;
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/AbstractTransportTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/AbstractTransportTest.php
index 4f1c7114..20573cc7 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/AbstractTransportTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/AbstractTransportTest.php
@@ -1,16 +1,14 @@
<?php
-
namespace Elastica\Test\Transport;
+use Elastica\Connection;
use Elastica\Transport\AbstractTransport;
use Elastica\Transport\Http;
-use Elastica\Connection;
-use Elastica\Exception\InvalidException;
class AbstractTransportTest extends \PHPUnit_Framework_TestCase
{
/**
- * Return transport configuration and the expected HTTP method
+ * Return transport configuration and the expected HTTP method.
*
* @return array[]
*/
@@ -27,6 +25,7 @@ class AbstractTransportTest extends \PHPUnit_Framework_TestCase
}
/**
+ * @group unit
* @dataProvider getValidDefinitions
*/
public function testCanCreateTransportInstances($transport)
@@ -47,6 +46,7 @@ class AbstractTransportTest extends \PHPUnit_Framework_TestCase
}
/**
+ * @group unit
* @dataProvider getInvalidDefinitions
* @expectedException Elastica\Exception\InvalidException
* @expectedExceptionMessage Invalid transport
@@ -56,6 +56,9 @@ class AbstractTransportTest extends \PHPUnit_Framework_TestCase
AbstractTransport::create($transport, new Connection());
}
+ /**
+ * @group unit
+ */
public function testCanInjectParamsWhenUsingArray()
{
$connection = new Connection();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/GuzzleTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/GuzzleTest.php
index b2e385bb..04e7ee2d 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/GuzzleTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/GuzzleTest.php
@@ -1,13 +1,10 @@
<?php
-
namespace Elastica\Test\Transport;
-use Elastica\Client;
use Elastica\Document;
use Elastica\Query;
use Elastica\ResultSet;
use Elastica\Test\Base as BaseTest;
-use Elastica\Exception\ResponseException;
class GuzzleTest extends BaseTest
{
@@ -18,19 +15,8 @@ class GuzzleTest extends BaseTest
}
}
- public function setUp()
- {
- if (defined('DEBUG') && !DEBUG) {
- $this->markTestSkipped('The DEBUG constant must be set to true for this test to run');
- }
-
- if (!defined('DEBUG')) {
- define('DEBUG', true);
- }
- }
-
/**
- * Return transport configuration and the expected HTTP method
+ * Return transport configuration and the expected HTTP method.
*
* @return array[]
*/
@@ -38,26 +24,27 @@ class GuzzleTest extends BaseTest
{
return array(
array(
- array('transport' => 'Guzzle'),
- 'GET'
+ array('persistent' => false, 'transport' => 'Guzzle'),
+ 'GET',
),
array(
- array('transport' => array('type' => 'Guzzle', 'postWithRequestBody' => false)),
- 'GET'
+ array('persistent' => false, 'transport' => array('type' => 'Guzzle', 'postWithRequestBody' => false)),
+ 'GET',
),
array(
- array('transport' => array('type' => 'Guzzle', 'postWithRequestBody' => true)),
- 'POST'
+ array('persistent' => false, 'transport' => array('type' => 'Guzzle', 'postWithRequestBody' => true)),
+ 'POST',
),
);
}
/**
+ * @group functional
* @dataProvider getConfig
*/
public function testDynamicHttpMethodBasedOnConfigParameter(array $config, $httpMethod)
{
- $client = new Client($config);
+ $client = $this->_getClient($config);
$index = $client->getIndex('dynamic_http_method_test');
$index->create(array(), true);
@@ -70,22 +57,26 @@ class GuzzleTest extends BaseTest
}
/**
+ * @group functional
* @dataProvider getConfig
*/
public function testDynamicHttpMethodOnlyAffectsRequestsWithBody(array $config, $httpMethod)
{
- $client = new Client($config);
+ $client = $this->_getClient($config);
$status = $client->getStatus();
$info = $status->getResponse()->getTransferInfo();
$this->assertStringStartsWith('GET', $info['request_header']);
}
+ /**
+ * @group functional
+ */
public function testWithEnvironmentalProxy()
{
- putenv('http_proxy=http://127.0.0.1:12345/');
+ putenv('http_proxy='.$this->_getProxyUrl().'/');
- $client = new \Elastica\Client(array('transport' => 'Guzzle'));
+ $client = $this->_getClient(array('transport' => 'Guzzle', 'persistent' => false));
$transferInfo = $client->request('/_nodes')->getTransferInfo();
$this->assertEquals(200, $transferInfo['http_code']);
@@ -96,16 +87,18 @@ class GuzzleTest extends BaseTest
putenv('http_proxy=');
}
+ /**
+ * @group functional
+ */
public function testWithEnabledEnvironmentalProxy()
{
- putenv('http_proxy=http://127.0.0.1:12346/');
-
- $client = new \Elastica\Client(array('transport' => 'Guzzle'));
+ putenv('http_proxy='.$this->_getProxyUrl403().'/');
+ $client = $this->_getClient(array('transport' => 'Guzzle', 'persistent' => false));
$transferInfo = $client->request('/_nodes')->getTransferInfo();
$this->assertEquals(403, $transferInfo['http_code']);
- $client = new \Elastica\Client();
+ $client = $this->_getClient(array('transport' => 'Guzzle', 'persistent' => false));
$client->getConnection()->setProxy('');
$transferInfo = $client->request('/_nodes')->getTransferInfo();
$this->assertEquals(200, $transferInfo['http_code']);
@@ -113,31 +106,40 @@ class GuzzleTest extends BaseTest
putenv('http_proxy=');
}
+ /**
+ * @group functional
+ */
public function testWithProxy()
{
- $client = new \Elastica\Client(array('transport' => 'Guzzle'));
- $client->getConnection()->setProxy('http://127.0.0.1:12345');
+ $client = $this->_getClient(array('transport' => 'Guzzle', 'persistent' => false));
+ $client->getConnection()->setProxy($this->_getProxyUrl());
$transferInfo = $client->request('/_nodes')->getTransferInfo();
$this->assertEquals(200, $transferInfo['http_code']);
}
+ /**
+ * @group functional
+ */
public function testWithoutProxy()
{
- $client = new \Elastica\Client(array('transport' => 'Guzzle'));
+ $client = $this->_getClient(array('transport' => 'Guzzle', 'persistent' => false));
$client->getConnection()->setProxy('');
$transferInfo = $client->request('/_nodes')->getTransferInfo();
$this->assertEquals(200, $transferInfo['http_code']);
}
+ /**
+ * @group functional
+ */
public function testBodyReuse()
{
- $client = new Client(array('transport' => 'Guzzle'));
+ $client = $this->_getClient(array('transport' => 'Guzzle', 'persistent' => false));
$index = $client->getIndex('elastica_body_reuse_test');
-
$index->create(array(), true);
+ $this->_waitForAllocation($index);
$type = $index->getType('test');
$type->addDocument(new Document(1, array('test' => 'test')));
@@ -160,4 +162,19 @@ class GuzzleTest extends BaseTest
$this->assertEquals(1, $resultSet->getTotalHits());
}
+ /**
+ * @group unit
+ * @expectedException Elastica\Exception\Connection\GuzzleException
+ */
+ public function testInvalidConnection()
+ {
+ $client = $this->_getClient(array('transport' => 'Guzzle', 'port' => 4500, 'persistent' => false));
+ $response = $client->request('_status', 'GET');
+ }
+
+ protected function tearDown()
+ {
+ parent::tearDown();
+ putenv('http_proxy=');
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/HttpTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/HttpTest.php
index 88c93bea..53ee105f 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/HttpTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/HttpTest.php
@@ -1,29 +1,15 @@
<?php
-
namespace Elastica\Test\Transport;
-use Elastica\Client;
use Elastica\Document;
use Elastica\Query;
use Elastica\ResultSet;
use Elastica\Test\Base as BaseTest;
-use Elastica\Exception\ResponseException;
class HttpTest extends BaseTest
{
- public function setUp()
- {
- if (defined('DEBUG') && !DEBUG) {
- $this->markTestSkipped('The DEBUG constant must be set to true for this test to run');
- }
-
- if (!defined('DEBUG')) {
- define('DEBUG', true);
- }
- }
-
/**
- * Return transport configuration and the expected HTTP method
+ * Return transport configuration and the expected HTTP method.
*
* @return array[]
*/
@@ -31,30 +17,31 @@ class HttpTest extends BaseTest
{
return array(
array(
- array('transport' => 'Http'),
- 'GET'
+ array('transport' => 'Http', 'curl' => array(CURLINFO_HEADER_OUT => true)),
+ 'GET',
),
array(
- array('transport' => array('type' => 'Http', 'postWithRequestBody' => false)),
- 'GET'
+ array('transport' => array('type' => 'Http', 'postWithRequestBody' => false, 'curl' => array(CURLINFO_HEADER_OUT => true))),
+ 'GET',
),
array(
- array('transport' => array('type' => 'Http', 'postWithRequestBody' => true)),
- 'POST'
+ array('transport' => array('type' => 'Http', 'postWithRequestBody' => true, 'curl' => array(CURLINFO_HEADER_OUT => true))),
+ 'POST',
),
);
}
/**
+ * @group functional
* @dataProvider getConfig
*/
public function testDynamicHttpMethodBasedOnConfigParameter(array $config, $httpMethod)
{
- $client = new Client($config);
+ $client = $this->_getClient($config);
$index = $client->getIndex('dynamic_http_method_test');
-
$index->create(array(), true);
+ $this->_waitForAllocation($index);
$type = $index->getType('test');
$type->addDocument(new Document(1, array('test' => 'test')));
@@ -68,23 +55,29 @@ class HttpTest extends BaseTest
}
/**
+ * @group functional
* @dataProvider getConfig
*/
public function testDynamicHttpMethodOnlyAffectsRequestsWithBody(array $config, $httpMethod)
{
- $client = new Client($config);
+ $client = $this->_getClient($config);
$status = $client->getStatus();
$info = $status->getResponse()->getTransferInfo();
$this->assertStringStartsWith('GET', $info['request_header']);
}
+ /**
+ * @group functional
+ */
public function testCurlNobodyOptionIsResetAfterHeadRequest()
{
- $client = new \Elastica\Client();
+ $client = $this->_getClient();
$index = $client->getIndex('curl_test');
- $type = $index->getType('item');
+ $index->create(array(), true);
+ $this->_waitForAllocation($index);
+ $type = $index->getType('item');
// Force HEAD request to set CURLOPT_NOBODY = true
$index->exists();
@@ -103,10 +96,16 @@ class HttpTest extends BaseTest
$this->assertEquals($id, $doc->getId());
}
+ /**
+ * @group functional
+ */
public function testUnicodeData()
{
- $client = new \Elastica\Client();
+ $client = $this->_getClient();
$index = $client->getIndex('curl_test');
+ $index->create(array(), true);
+ $this->_waitForAllocation($index);
+
$type = $index->getType('item');
// Force HEAD request to set CURLOPT_NOBODY = true
@@ -132,11 +131,14 @@ class HttpTest extends BaseTest
$this->assertEquals($id, $doc->getId());
}
+ /**
+ * @group functional
+ */
public function testWithEnvironmentalProxy()
{
- putenv('http_proxy=http://127.0.0.1:12345/');
+ putenv('http_proxy='.$this->_getProxyUrl().'/');
- $client = new \Elastica\Client();
+ $client = $this->_getClient();
$transferInfo = $client->request('/_nodes')->getTransferInfo();
$this->assertEquals(200, $transferInfo['http_code']);
@@ -147,48 +149,56 @@ class HttpTest extends BaseTest
putenv('http_proxy=');
}
+ /**
+ * @group functional
+ */
public function testWithEnabledEnvironmentalProxy()
{
- putenv('http_proxy=http://127.0.0.1:12346/');
-
- $client = new \Elastica\Client();
-
+ putenv('http_proxy='.$this->_getProxyUrl403().'/');
+ $client = $this->_getClient();
$transferInfo = $client->request('/_nodes')->getTransferInfo();
$this->assertEquals(403, $transferInfo['http_code']);
-
- $client = new \Elastica\Client();
+ $client = $this->_getClient();
$client->getConnection()->setProxy('');
$transferInfo = $client->request('/_nodes')->getTransferInfo();
$this->assertEquals(200, $transferInfo['http_code']);
-
putenv('http_proxy=');
}
+ /**
+ * @group functional
+ */
public function testWithProxy()
{
- $client = new \Elastica\Client();
- $client->getConnection()->setProxy('http://127.0.0.1:12345');
+ $client = $this->_getClient();
+ $client->getConnection()->setProxy($this->_getProxyUrl());
$transferInfo = $client->request('/_nodes')->getTransferInfo();
$this->assertEquals(200, $transferInfo['http_code']);
}
+ /**
+ * @group functional
+ */
public function testWithoutProxy()
{
- $client = new \Elastica\Client();
+ $client = $this->_getClient();
$client->getConnection()->setProxy('');
$transferInfo = $client->request('/_nodes')->getTransferInfo();
$this->assertEquals(200, $transferInfo['http_code']);
}
+ /**
+ * @group functional
+ */
public function testBodyReuse()
{
- $client = new Client();
+ $client = $this->_getClient();
$index = $client->getIndex('elastica_body_reuse_test');
-
$index->create(array(), true);
+ $this->_waitForAllocation($index);
$type = $index->getType('test');
$type->addDocument(new Document(1, array('test' => 'test')));
@@ -211,12 +221,16 @@ class HttpTest extends BaseTest
$this->assertEquals(1, $resultSet->getTotalHits());
}
+ /**
+ * @group functional
+ */
public function testPostWith0Body()
{
- $client = new Client();
+ $client = $this->_getClient();
$index = $client->getIndex('elastica_0_body');
$index->create(array(), true);
+ $this->_waitForAllocation($index);
$index->refresh();
$tokens = $index->analyze('0');
@@ -224,4 +238,9 @@ class HttpTest extends BaseTest
$this->assertNotEmpty($tokens);
}
+ protected function tearDown()
+ {
+ parent::tearDown();
+ putenv('http_proxy=');
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/MemcacheTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/MemcacheTest.php
index 17d46d88..30897073 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/MemcacheTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/MemcacheTest.php
@@ -1,51 +1,176 @@
<?php
-
namespace Elastica\Test\Transport;
-use Elastica\Client;
use Elastica\Document;
+use Elastica\Query;
+use Elastica\Query\QueryString;
+use Elastica\Request;
use Elastica\Test\Base as BaseTest;
class MemcacheTest extends BaseTest
{
- public function setUp()
+ public static function setUpBeforeClass()
{
if (!extension_loaded('Memcache')) {
- $this->markTestSkipped('pecl/memcache must be installed to run this test case');
+ self::markTestSkipped('pecl/memcache must be installed to run this test case');
}
}
- public function testExample()
+ protected function _getMemcacheClient()
{
- // Creates a new index 'xodoa' and a type 'user' inside this index
- $host = 'localhost';
- $port = 11211;
- $client = new Client(array('host' => $host, 'port' => $port, 'transport' => 'Memcache'));
+ return $this->_getClient(array(
+ 'host' => $this->_getHost(),
+ 'port' => 11211,
+ 'transport' => 'Memcache',
+ ));
+ }
- $index = $client->getIndex('elastica_test1');
- $index->create(array(), true);
+ /**
+ * @group functional
+ */
+ public function testConstruct()
+ {
+ $client = $this->_getMemcacheClient();
+ $this->assertEquals($this->_getHost(), $client->getConnection()->getHost());
+ $this->assertEquals(11211, $client->getConnection()->getPort());
+ }
- $type = $index->getType('user');
+ /**
+ * @group functional
+ */
+ public function testCreateDocument()
+ {
+ $index = $this->_createIndex();
+ $this->_waitForAllocation($index);
+ $type = $index->getType('foo');
- // Adds 1 document to the index
- $doc1 = new Document(1,
- array('username' => 'hans', 'test' => array('2', '3', '5'))
- );
- $type->addDocument($doc1);
+ // Create document
+ $document = new Document(1, array('username' => 'John Doe'));
+ $type->addDocument($document);
+ $index->refresh();
- // Adds a list of documents with _bulk upload to the index
- $docs = array();
- $docs[] = new Document(2,
- array('username' => 'john', 'test' => array('1', '3', '6'))
- );
- $docs[] = new Document(3,
- array('username' => 'rolf', 'test' => array('2', '3', '7'))
+ // Check it was saved
+ $document = $type->getDocument(1);
+ $this->assertEquals('John Doe', $document->get('username'));
+ }
+
+ /**
+ * @group functional
+ * @expectedException Elastica\Exception\NotFoundException
+ */
+ public function testDeleteDocument()
+ {
+ $index = $this->_createIndex();
+ $this->_waitForAllocation($index);
+ $type = $index->getType('foo');
+
+ // Create document
+ $document = new Document(1, array('username' => 'John Doe'));
+ $type->addDocument($document);
+ $index->refresh();
+
+ // Delete document
+ $type->deleteById(1);
+
+ // Check if document is not exists
+ $document = $type->getDocument(1);
+ }
+
+ /**
+ * @group functional
+ */
+ public function testUpdateDocument()
+ {
+ $index = $this->_createIndex();
+ $this->_waitForAllocation($index);
+ $type = $index->getType('foo');
+
+ // Create document
+ $document = new Document(1, array('username' => 'John Doe'));
+ $type->addDocument($document);
+ $index->refresh();
+
+ // Check it was saved
+ $savedDocument = $type->getDocument(1);
+ $this->assertEquals('John Doe', $savedDocument->get('username'));
+
+ // Update document
+ $newDocument = new Document(1, array('username' => 'Doe John'));
+ $type->updateDocument($newDocument);
+ $index->refresh();
+
+ // Check it was updated
+ $newSavedDocument = $type->getDocument(1);
+ $this->assertEquals('Doe John', $newSavedDocument->get('username'));
+ }
+
+ /**
+ * @group functional
+ */
+ public function testSearchDocument()
+ {
+ $index = $this->_createIndex();
+ $this->_waitForAllocation($index);
+ $type = $index->getType('fruits');
+
+ // Create documents
+ $docs = array(
+ new Document(1, array('name' => 'banana')),
+ new Document(2, array('name' => 'apple')),
+ new Document(3, array('name' => 'orange')),
);
$type->addDocuments($docs);
-
- // Refresh index
$index->refresh();
- $this->markTestIncomplete('Memcache implementation is not finished yet');
- $resultSet = $type->search('rolf');
+
+ // Search documents
+ $queryString = new QueryString('orange');
+ $query = new Query($queryString);
+ $resultSet = $type->search($query);
+
+ // Check if correct document was found
+ $this->assertEquals(1, $resultSet->getTotalHits());
+ $this->assertEquals(3, $resultSet[0]->getId());
+ $data = $resultSet[0]->getData();
+ $this->assertEquals('orange', $data['name']);
+ }
+
+ /**
+ * @group functional
+ * @expectedException Elastica\Exception\InvalidException
+ * @expectedExceptionMessage is not supported in memcache transport
+ */
+ public function testHeadRequest()
+ {
+ $client = $this->_getMemcacheClient();
+ $client->request('foo', Request::HEAD);
+ }
+
+ /**
+ * @group functional
+ * @expectedException Elastica\Exception\InvalidException
+ * @expectedExceptionMessage is not supported in memcache transport
+ */
+ public function testInvalidRequest()
+ {
+ $client = $this->_getMemcacheClient();
+ $client->request('foo', 'its_fail');
+ }
+
+ /**
+ * @group functional
+ * @expectedException Elastica\Exception\Connection\MemcacheException
+ * @expectedExceptionMessage is too long
+ */
+ public function testRequestWithLongPath()
+ {
+ $client = $this->_getMemcacheClient();
+ $index = $client->getIndex('memcache-test');
+ $index->create();
+
+ $this->_waitForAllocation($index);
+
+ $queryString = new QueryString(str_repeat('z', 300));
+ $query = new Query($queryString);
+ $index->search($query);
}
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/NullTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/NullTest.php
deleted file mode 100644
index c07f5da1..00000000
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/NullTest.php
+++ /dev/null
@@ -1,59 +0,0 @@
-<?php
-
-namespace Elastica\Test\Transport;
-
-use Elastica\Client;
-use Elastica\Connection;
-use Elastica\Query;
-use Elastica\Test\Base as BaseTest;
-
-/**
- * Elastica Null Transport Test
- *
- * @package Elastica
- * @author James Boehmer <james.boehmer@jamesboehmer.com>
- */
-class NullTest extends BaseTest
-{
-
- public function testEmptyResult()
- {
- // Creates a client with any destination, and verify it returns a response object when executed
- $client = $this->_getClient();
- $connection = new Connection(array('transport' => 'Null'));
- $client->setConnections(array($connection));
-
- $index = $client->getIndex('elasticaNullTransportTest1');
-
- $resultSet = $index->search(new Query());
- $this->assertNotNull($resultSet);
-
- $response = $resultSet->getResponse();
- $this->assertNotNull($response);
-
- // Validate most of the expected fields in the response data. Consumers of the response
- // object have a reasonable expectation of finding "hits", "took", etc
- $responseData = $response->getData();
- $this->assertContains("took", $responseData);
- $this->assertEquals(0, $responseData["took"]);
- $this->assertContains("_shards", $responseData);
- $this->assertContains("hits", $responseData);
- $this->assertContains("total", $responseData["hits"]);
- $this->assertEquals(0, $responseData["hits"]["total"]);
- $this->assertContains("params", $responseData);
-
- $took = $response->getEngineTime();
- $this->assertEquals(0, $took);
-
- $errorString = $response->getError();
- $this->assertEmpty($errorString);
-
- $shards = $response->getShardsStatistics();
- $this->assertContains("total", $shards);
- $this->assertEquals(0, $shards["total"]);
- $this->assertContains("successful", $shards);
- $this->assertEquals(0, $shards["successful"]);
- $this->assertContains("failed", $shards);
- $this->assertEquals(0, $shards["failed"]);
- }
-}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/NullTransportTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/NullTransportTest.php
new file mode 100644
index 00000000..cea3e3ba
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/NullTransportTest.php
@@ -0,0 +1,96 @@
+<?php
+namespace Elastica\Test\Transport;
+
+use Elastica\Connection;
+use Elastica\Query;
+use Elastica\Request;
+use Elastica\Test\Base as BaseTest;
+use Elastica\Transport\NullTransport;
+
+/**
+ * Elastica Null Transport Test.
+ *
+ * @author James Boehmer <james.boehmer@jamesboehmer.com>
+ */
+class NullTransportTest extends BaseTest
+{
+ /**
+ * @group functional
+ */
+ public function testEmptyResult()
+ {
+ // Creates a client with any destination, and verify it returns a response object when executed
+ $client = $this->_getClient();
+ $connection = new Connection(array('transport' => 'NullTransport'));
+ $client->setConnections(array($connection));
+
+ $index = $client->getIndex('elasticaNullTransportTest1');
+
+ $resultSet = $index->search(new Query());
+ $this->assertNotNull($resultSet);
+
+ $response = $resultSet->getResponse();
+ $this->assertNotNull($response);
+
+ // Validate most of the expected fields in the response data. Consumers of the response
+ // object have a reasonable expectation of finding "hits", "took", etc
+ $responseData = $response->getData();
+ $this->assertContains('took', $responseData);
+ $this->assertEquals(0, $responseData['took']);
+ $this->assertContains('_shards', $responseData);
+ $this->assertContains('hits', $responseData);
+ $this->assertContains('total', $responseData['hits']);
+ $this->assertEquals(0, $responseData['hits']['total']);
+ $this->assertContains('params', $responseData);
+
+ $took = $response->getEngineTime();
+ $this->assertEquals(0, $took);
+
+ $errorString = $response->getError();
+ $this->assertEmpty($errorString);
+
+ $shards = $response->getShardsStatistics();
+ $this->assertContains('total', $shards);
+ $this->assertEquals(0, $shards['total']);
+ $this->assertContains('successful', $shards);
+ $this->assertEquals(0, $shards['successful']);
+ $this->assertContains('failed', $shards);
+ $this->assertEquals(0, $shards['failed']);
+ }
+
+ /**
+ * @group functional
+ */
+ public function testExec()
+ {
+ $request = new Request('/test');
+ $params = array('name' => 'ruflin');
+ $transport = new NullTransport();
+ $response = $transport->exec($request, $params);
+
+ $this->assertInstanceOf('\Elastica\Response', $response);
+
+ $data = $response->getData();
+ $this->assertEquals($params, $data['params']);
+ }
+
+ /**
+ * @group functional
+ */
+ public function testOldObject()
+ {
+ if (version_compare(phpversion(), 7, '>=')) {
+ self::markTestSkipped('These objects are not supported in PHP 7');
+ }
+
+ $request = new Request('/test');
+ $params = array('name' => 'ruflin');
+ $transport = new \Elastica\Transport\Null();
+ $response = $transport->exec($request, $params);
+
+ $this->assertInstanceOf('\Elastica\Response', $response);
+
+ $data = $response->getData();
+ $this->assertEquals($params, $data['params']);
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/ThriftTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/ThriftTest.php
index f1698ff6..b73ef4f7 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/ThriftTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/ThriftTest.php
@@ -1,12 +1,9 @@
<?php
-
namespace Elastica\Test\Transport;
-use Elastica\Client;
use Elastica\Connection;
use Elastica\Document;
use Elastica\Index;
-use Elastica\Query;
use Elastica\Test\Base as BaseTest;
class ThriftTest extends BaseTest
@@ -18,17 +15,21 @@ class ThriftTest extends BaseTest
}
}
+ /**
+ * @group unit
+ */
public function testConstruct()
{
- $host = 'localhost';
+ $host = $this->_getHost();
$port = 9500;
- $client = new Client(array('host' => $host, 'port' => $port, 'transport' => 'Thrift'));
+ $client = $this->_getClient(array('host' => $host, 'port' => $port, 'transport' => 'Thrift'));
$this->assertEquals($host, $client->getConnection()->getHost());
$this->assertEquals($port, $client->getConnection()->getPort());
}
/**
+ * @group functional
* @dataProvider configProvider
*/
public function testSearchRequest($config)
@@ -36,7 +37,7 @@ class ThriftTest extends BaseTest
$this->_checkPlugin();
// Creates a new index 'xodoa' and a type 'user' inside this index
- $client = new Client($config);
+ $client = $this->_getClient($config);
$index = $client->getIndex('elastica_test1');
$index->create(array(), true);
@@ -68,17 +69,19 @@ class ThriftTest extends BaseTest
}
/**
+ * @group unit
* @expectedException \Elastica\Exception\ConnectionException
*/
public function testInvalidHostRequest()
{
$this->_checkPlugin();
- $client = new Client(array('host' => 'unknown', 'port' => 9555, 'transport' => 'Thrift'));
+ $client = $this->_getClient(array('host' => 'unknown', 'port' => 9555, 'transport' => 'Thrift'));
$client->getStatus();
}
/**
+ * @group functional
* @expectedException \Elastica\Exception\ResponseException
*/
public function testInvalidElasticRequest()
@@ -86,11 +89,11 @@ class ThriftTest extends BaseTest
$this->_checkPlugin();
$connection = new Connection();
- $connection->setHost('localhost');
+ $connection->setHost($this->_getHost());
$connection->setPort(9500);
$connection->setTransport('Thrift');
- $client = new Client();
+ $client = $this->_getClient();
$client->addConnection($connection);
$index = new Index($client, 'missing_index');
@@ -102,23 +105,23 @@ class ThriftTest extends BaseTest
return array(
array(
array(
- 'host' => 'localhost',
+ 'host' => $this->_getHost(),
'port' => 9500,
- 'transport' => 'Thrift'
- )
+ 'transport' => 'Thrift',
+ ),
),
array(
array(
- 'host' => 'localhost',
+ 'host' => $this->_getHost(),
'port' => 9500,
'transport' => 'Thrift',
'config' => array(
'framedTransport' => false,
'sendTimeout' => 10000,
'recvTimeout' => 20000,
- )
- )
- )
+ ),
+ ),
+ ),
);
}
@@ -126,7 +129,7 @@ class ThriftTest extends BaseTest
{
$nodes = $this->_getClient()->getCluster()->getNodes();
if (!$nodes[0]->getInfo()->hasPlugin('transport-thrift')) {
- $this->markTestSkipped("transport-thrift plugin not installed.");
+ $this->markTestSkipped('transport-thrift plugin not installed.');
}
}
}
diff --git a/vendor/ruflin/elastica/test/benchmark/TransportTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/TransportBenchmarkTest.php
index 42d6ac0c..11a16a34 100644
--- a/vendor/ruflin/elastica/test/benchmark/TransportTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/TransportBenchmarkTest.php
@@ -1,29 +1,18 @@
<?php
+namespace Elastica\Test\Transport;
-use Elastica\Client;
-use Elastica\Request;
use Elastica\Document;
+use Elastica\Index;
use Elastica\Query;
-use Elastica\Type\Mapping;
-use Elastica\Query\MatchAll as MatchAllQuery;
-use Elastica\Filter\Term as TermFilter;
+use Elastica\Test\Base as BaseTest;
-class TransportTest extends \PHPUnit_Framework_TestCase
+class TransportBenchmarkTest extends BaseTest
{
protected $_max = 1000;
protected $_maxData = 20;
- static protected $_results = array();
-
- public static function setUpBeforeClass()
- {
- if (!defined('DEBUG')) {
- define('DEBUG', true);
- } else if (false == DEBUG) {
- self::markTestIncomplete('DEBUG const is set to false, it prevents query time measuring.');
- }
- }
+ protected static $_results = array();
public static function tearDownAfterClass()
{
@@ -32,20 +21,26 @@ class TransportTest extends \PHPUnit_Framework_TestCase
/**
* @param array $config
+ *
* @return \Elastica\Type
*/
protected function getType(array $config)
{
- $client = new Client($config);
- $index = $client->getIndex('test');
- return $index->getType('test');
+ $client = $this->_getClient($config);
+ $index = $client->getIndex('benchmark'.uniqid());
+ $index->create(array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0)), true);
+
+ return $index->getType('benchmark');
}
/**
* @dataProvider providerTransport
+ * @group benchmark
*/
public function testAddDocument(array $config, $transport)
{
+ $this->_checkThrift($transport);
+
$type = $this->getType($config);
$index = $type->getIndex();
$index->create(array(), true);
@@ -67,9 +62,12 @@ class TransportTest extends \PHPUnit_Framework_TestCase
/**
* @depends testAddDocument
* @dataProvider providerTransport
+ * @group benchmark
*/
public function testRandomRead(array $config, $transport)
{
+ $this->_checkThrift($transport);
+
$type = $this->getType($config);
$type->search('test');
@@ -78,8 +76,8 @@ class TransportTest extends \PHPUnit_Framework_TestCase
for ($i = 0; $i < $this->_max; $i++) {
$test = rand(1, $this->_max);
$query = new Query();
- $query->setQuery(new MatchAllQuery());
- $query->setFilter(new TermFilter(array('test' => $test)));
+ $query->setQuery(new \Elastica\Query\MatchAll());
+ $query->setPostFilter(new \Elastica\Filter\Term(array('test' => $test)));
$result = $type->search($query);
$times[] = $result->getResponse()->getQueryTime();
}
@@ -90,6 +88,7 @@ class TransportTest extends \PHPUnit_Framework_TestCase
/**
* @depends testAddDocument
* @dataProvider providerTransport
+ * @group benchmark
*/
public function testBulk(array $config, $transport)
{
@@ -99,7 +98,7 @@ class TransportTest extends \PHPUnit_Framework_TestCase
for ($i = 0; $i < $this->_max; $i++) {
$docs = array();
for ($j = 0; $j < 10; $j++) {
- $data = $this->getData($i . $j);
+ $data = $this->getData($i.$j);
$docs[] = new Document($i, $data);
}
@@ -112,30 +111,31 @@ class TransportTest extends \PHPUnit_Framework_TestCase
/**
* @dataProvider providerTransport
+ * @group benchmark
*/
public function testGetMapping(array $config, $transport)
{
- $client = new Client($config);
- $index = $client->getIndex('test');
+ $client = $this->_getClient($config);
+ $index = $client->getIndex('benchmark');
$index->create(array(), true);
$type = $index->getType('mappingTest');
// Define mapping
- $mapping = new Mapping();
+ $mapping = new \Elastica\Type\Mapping();
$mapping->setParam('_boost', array('name' => '_boost', 'null_value' => 1.0));
$mapping->setProperties(array(
- 'id' => array('type' => 'integer', 'include_in_all' => FALSE),
+ 'id' => array('type' => 'integer', 'include_in_all' => false),
'user' => array(
'type' => 'object',
'properties' => array(
- 'name' => array('type' => 'string', 'include_in_all' => TRUE),
- 'fullName' => array('type' => 'string', 'include_in_all' => TRUE)
+ 'name' => array('type' => 'string', 'include_in_all' => true),
+ 'fullName' => array('type' => 'string', 'include_in_all' => true),
),
),
- 'msg' => array('type' => 'string', 'include_in_all' => TRUE),
- 'tstamp' => array('type' => 'date', 'include_in_all' => FALSE),
- 'location'=> array('type' => 'geo_point', 'include_in_all' => FALSE),
- '_boost' => array('type' => 'float', 'include_in_all' => FALSE)
+ 'msg' => array('type' => 'string', 'include_in_all' => true),
+ 'tstamp' => array('type' => 'date', 'include_in_all' => false),
+ 'location' => array('type' => 'geo_point', 'include_in_all' => false),
+ '_boost' => array('type' => 'float', 'include_in_all' => false),
));
$type->setMapping($mapping);
@@ -143,7 +143,7 @@ class TransportTest extends \PHPUnit_Framework_TestCase
$times = array();
for ($i = 0; $i < $this->_max; $i++) {
- $response = $type->request('_mapping', Request::GET);
+ $response = $type->request('_mapping', \Elastica\Request::GET);
$times[] = $response->getQueryTime();
}
self::logResults('get mapping', $transport, $times);
@@ -155,37 +155,38 @@ class TransportTest extends \PHPUnit_Framework_TestCase
array(
array(
'transport' => 'Http',
- 'host' => 'localhost',
- 'port' => 9200,
+ 'host' => $this->_getHost(),
+ 'port' => $this->_getPort(),
'persistent' => false,
),
- 'Http:NotPersistent'
+ 'Http:NotPersistent',
),
array(
array(
'transport' => 'Http',
- 'host' => 'localhost',
- 'port' => 9200,
+ 'host' => $this->_getHost(),
+ 'port' => $this->_getPort(),
'persistent' => true,
),
- 'Http:Persistent'
+ 'Http:Persistent',
),
array(
array(
'transport' => 'Thrift',
- 'host' => 'localhost',
+ 'host' => $this->_getHost(),
'port' => 9500,
'config' => array(
'framedTransport' => false,
),
),
- 'Thrift:Buffered'
+ 'Thrift:Buffered',
),
);
}
/**
* @param string $test
+ *
* @return array
*/
protected function getData($test)
@@ -197,6 +198,7 @@ class TransportTest extends \PHPUnit_Framework_TestCase
for ($i = 0; $i < $this->_maxData; $i++) {
$data['name'][] = uniqid();
}
+
return $data;
}
@@ -209,9 +211,9 @@ class TransportTest extends \PHPUnit_Framework_TestCase
{
self::$_results[$name][$transport] = array(
'count' => count($times),
- 'max' => max($times) * 1000,
- 'min' => min($times) * 1000,
- 'mean' => (array_sum($times) / count($times)) * 1000,
+ 'max' => max($times) * 1000,
+ 'min' => min($times) * 1000,
+ 'mean' => (array_sum($times) / count($times)) * 1000,
);
}
@@ -249,4 +251,11 @@ class TransportTest extends \PHPUnit_Framework_TestCase
echo "\n";
}
}
+
+ protected function _checkThrift($transport)
+ {
+ if (strpos($transport, 'Thrift') !== false && !class_exists('Elasticsearch\\RestClient')) {
+ self::markTestSkipped('munkie/elasticsearch-thrift-php package should be installed to run thrift transport tests');
+ }
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Type/MappingTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Type/MappingTest.php
index 796bfb8d..925c23bb 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Type/MappingTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Type/MappingTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Type;
use Elastica\Document;
@@ -11,6 +10,9 @@ use Elastica\Type\Mapping;
class MappingTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testMappingStoreFields()
{
$client = $this->_getClient();
@@ -34,7 +36,7 @@ class MappingTest extends BaseTest
$doc = new Document(1,
array(
'firstname' => $firstname,
- 'lastname' => 'Ruflin'
+ 'lastname' => 'Ruflin',
)
);
@@ -61,6 +63,9 @@ class MappingTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testEnableAllField()
{
$index = $this->_createIndex();
@@ -79,6 +84,9 @@ class MappingTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testEnableTtl()
{
$client = $this->_getClient();
@@ -97,6 +105,9 @@ class MappingTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testNestedMapping()
{
$client = $this->_getClient();
@@ -105,7 +116,7 @@ class MappingTest extends BaseTest
$index->create(array(), true);
$type = $index->getType('test');
- $this->markTestIncomplete('nested mapping is not set right yet');
+ //$this->markTestIncomplete('nested mapping is not set right yet');
$mapping = new Mapping($type,
array(
'test' => array(
@@ -115,20 +126,21 @@ class MappingTest extends BaseTest
'firstname' => array('type' => 'string', 'store' => 'yes'),
'lastname' => array('type' => 'string', 'store' => 'yes'),
'age' => array('type' => 'integer', 'store' => 'yes'),
- )
+ ),
),
),
),
)
);
- $type->setMapping($mapping);
+ $response = $type->setMapping($mapping);
+ $this->assertFalse($response->hasError());
$doc = new Document(1, array(
'user' => array(
'firstname' => 'Nicolas',
'lastname' => 'Ruflin',
- 'age' => 9
+ 'age' => 9,
),
));
@@ -136,17 +148,21 @@ class MappingTest extends BaseTest
$index->refresh();
$resultSet = $type->search('ruflin');
+ $this->assertEquals($resultSet->count(), 1);
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testParentMapping()
{
$index = $this->_createIndex();
$parenttype = new Type($index, 'parenttype');
$parentmapping = new Mapping($parenttype,
array(
- 'name' => array('type' => 'string', 'store' => 'yes')
+ 'name' => array('type' => 'string', 'store' => 'yes'),
)
);
@@ -168,6 +184,9 @@ class MappingTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testMappingExample()
{
$index = $this->_createIndex();
@@ -177,10 +196,10 @@ class MappingTest extends BaseTest
array(
'note' => array(
'store' => 'yes', 'properties' => array(
- 'titulo' => array('type' => 'string', 'store' => 'no', 'include_in_all' => true, 'boost' => 1.0),
- 'contenido' => array('type' => 'string', 'store' => 'no', 'include_in_all' => true, 'boost' => 1.0)
- )
- )
+ 'titulo' => array('type' => 'string', 'store' => 'no', 'include_in_all' => true, 'boost' => 1.0),
+ 'contenido' => array('type' => 'string', 'store' => 'no', 'include_in_all' => true, 'boost' => 1.0),
+ ),
+ ),
)
);
@@ -189,14 +208,14 @@ class MappingTest extends BaseTest
$doc = new Document(1, array(
'note' => array(
array(
- 'titulo' => 'nota1',
- 'contenido' => 'contenido1'
+ 'titulo' => 'nota1',
+ 'contenido' => 'contenido1',
),
array(
- 'titulo' => 'nota2',
- 'contenido' => 'contenido2'
- )
- )
+ 'titulo' => 'nota2',
+ 'contenido' => 'contenido2',
+ ),
+ ),
)
);
@@ -206,36 +225,38 @@ class MappingTest extends BaseTest
}
/**
+ * @group functional
+ *
* Test setting a dynamic template and validate whether the right mapping is applied after adding a document which
* should match the dynamic template. The example is the template_1 from the Elasticsearch documentation.
- *
- * @link http://www.elasticsearch.org/guide/reference/mapping/root-object-type/
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-root-object-type.html
*/
public function testDynamicTemplate()
{
$index = $this->_createIndex();
- $type = $index->getType('person');
-
- // set a dynamic template "template_1" which creates a multi field for multi* matches.
+ $type = $index->getType('person');
+
+ // set a dynamic template "template_1" which creates a multi field for multi* matches.
$mapping = new Mapping($type);
$mapping->setParam('dynamic_templates', array(
array('template_1' => array(
- 'match' => 'multi*',
+ 'match' => 'multi*',
'mapping' => array(
- 'type' => 'multi_field',
+ 'type' => 'multi_field',
'fields' => array(
'{name}' => array('type' => '{dynamic_type}', 'index' => 'analyzed'),
- 'org' => array('type' => '{dynamic_type}', 'index' => 'not_analyzed')
- )
- )
- ))
+ 'org' => array('type' => '{dynamic_type}', 'index' => 'not_analyzed'),
+ ),
+ ),
+ )),
));
-
+
$mapping->send();
-
+
// when running the tests, the mapping sometimes isn't available yet. Optimize index to enforce reload mapping.
$index->optimize();
-
+
// create a document which should create a mapping for the field: multiname.
$testDoc = new Document('person1', array('multiname' => 'Jasper van Wanrooy'), $type);
$index->addDocuments(array($testDoc));
@@ -260,13 +281,16 @@ class MappingTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testSetMeta()
{
$index = $this->_createIndex();
$type = $index->getType('test');
$mapping = new Mapping($type, array(
'firstname' => array('type' => 'string', 'store' => 'yes'),
- 'lastname' => array('type' => 'string')
+ 'lastname' => array('type' => 'string'),
));
$mapping->setMeta(array('class' => 'test'));
$type->setMapping($mapping);
@@ -277,18 +301,21 @@ class MappingTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testGetters()
{
$index = $this->_createIndex();
$type = $index->getType('test');
$properties = array(
'firstname' => array('type' => 'string', 'store' => 'yes'),
- 'lastname' => array('type' => 'string')
+ 'lastname' => array('type' => 'string'),
);
$mapping = new Mapping($type, $properties);
$all = array(
- "enabled" => true,
- "store" => "yes"
+ 'enabled' => true,
+ 'store' => 'yes',
);
$mapping->setParam('_all', $all);
$get_all = $mapping->getParam('_all');
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/TypeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/TypeTest.php
index 40e56c3b..dcb74ac5 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/TypeTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/TypeTest.php
@@ -1,24 +1,25 @@
<?php
-
namespace Elastica\Test;
-use Elastica\Client;
use Elastica\Document;
use Elastica\Exception\NotFoundException;
use Elastica\Exception\ResponseException;
+use Elastica\Filter\Term;
+use Elastica\Index;
use Elastica\Query;
use Elastica\Query\MatchAll;
use Elastica\Query\SimpleQueryString;
use Elastica\Script;
use Elastica\Search;
-use Elastica\Filter\Term;
+use Elastica\Test\Base as BaseTest;
use Elastica\Type;
-use Elastica\Index;
use Elastica\Type\Mapping;
-use Elastica\Test\Base as BaseTest;
class TypeTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testSearch()
{
$index = $this->_createIndex();
@@ -55,6 +56,9 @@ class TypeTest extends BaseTest
$this->assertEquals('rolf', $data['username']);
}
+ /**
+ * @group functional
+ */
public function testCreateSearch()
{
$client = $this->_getClient();
@@ -72,11 +76,11 @@ class TypeTest extends BaseTest
$expected = array(
'query' => array(
'query_string' => array(
- 'query' => 'test'
- )
+ 'query' => 'test',
+ ),
),
'size' => 5,
- 'explain' => true
+ 'explain' => true,
);
$this->assertEquals($expected, $search->getQuery()->toArray());
$this->assertEquals(array('test_index'), $search->getIndices());
@@ -91,6 +95,9 @@ class TypeTest extends BaseTest
$this->assertFalse($search->hasType('test_type2'));
}
+ /**
+ * @group functional
+ */
public function testCreateSearchWithArray()
{
$client = $this->_getClient();
@@ -100,9 +107,9 @@ class TypeTest extends BaseTest
$query = array(
'query' => array(
'query_string' => array(
- 'query' => 'test'
- )
- )
+ 'query' => 'test',
+ ),
+ ),
);
$options = array(
@@ -115,11 +122,11 @@ class TypeTest extends BaseTest
$expected = array(
'query' => array(
'query_string' => array(
- 'query' => 'test'
- )
+ 'query' => 'test',
+ ),
),
'size' => 5,
- 'explain' => true
+ 'explain' => true,
);
$this->assertEquals($expected, $search->getQuery()->toArray());
$this->assertEquals(array('test_index'), $search->getIndices());
@@ -134,6 +141,9 @@ class TypeTest extends BaseTest
$this->assertFalse($search->hasType('test_type2'));
}
+ /**
+ * @group functional
+ */
public function testNoSource()
{
$index = $this->_createIndex();
@@ -183,6 +193,9 @@ class TypeTest extends BaseTest
$this->assertEmpty($result->getData());
}
+ /**
+ * @group functional
+ */
public function testDeleteById()
{
$index = $this->_createIndex();
@@ -281,6 +294,9 @@ class TypeTest extends BaseTest
$this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testDeleteDocument()
{
$index = $this->_createIndex();
@@ -314,6 +330,7 @@ class TypeTest extends BaseTest
}
/**
+ * @group functional
* @expectedException \Elastica\Exception\NotFoundException
*/
public function testGetDocumentNotExist()
@@ -329,17 +346,21 @@ class TypeTest extends BaseTest
}
/**
- * @expectedException \Elastica\Exception\NotFoundException
+ * @group functional
+ * @expectedException \Elastica\Exception\ResponseException
*/
public function testGetDocumentNotExistingIndex()
{
- $client = new Client();
+ $client = $this->_getClient();
$index = new Index($client, 'index');
$type = new Type($index, 'type');
$type->getDocument(1);
}
+ /**
+ * @group functional
+ */
public function testDeleteByQueryWithQueryString()
{
$index = $this->_createIndex();
@@ -368,6 +389,9 @@ class TypeTest extends BaseTest
$this->assertEquals(0, $response->count());
}
+ /**
+ * @group functional
+ */
public function testDeleteByQueryWithQuery()
{
$index = $this->_createIndex();
@@ -396,9 +420,12 @@ class TypeTest extends BaseTest
$this->assertEquals(0, $response->count());
}
+ /**
+ * @group functional
+ */
public function testDeleteByQueryWithQueryAndOptions()
{
- $index = $this->_createIndex('test', true, 2);
+ $index = $this->_createIndex(null, true, 2);
$type = new Type($index, 'test');
$type->addDocument(new Document(1, array('name' => 'ruflin nicolas')));
$type->addDocument(new Document(2, array('name' => 'ruflin')));
@@ -411,7 +438,7 @@ class TypeTest extends BaseTest
$this->assertEquals(1, $response->count());
// Route to the wrong document id; should not delete
- $response = $type->deleteByQuery(new SimpleQueryString('nicolas'), array('routing'=>'2'));
+ $response = $type->deleteByQuery(new SimpleQueryString('nicolas'), array('routing' => '2'));
$this->assertTrue($response->isOk());
$index->refresh();
@@ -423,7 +450,7 @@ class TypeTest extends BaseTest
$this->assertEquals(1, $response->count());
// Delete first document
- $response = $type->deleteByQuery(new SimpleQueryString('nicolas'), array('routing'=>'1'));
+ $response = $type->deleteByQuery(new SimpleQueryString('nicolas'), array('routing' => '1'));
$this->assertTrue($response->isOk());
$index->refresh();
@@ -438,7 +465,9 @@ class TypeTest extends BaseTest
/**
* Test to see if Elastica_Type::getDocument() is properly using
- * the fields array when available instead of _source
+ * the fields array when available instead of _source.
+ *
+ * @group functional
*/
public function testGetDocumentWithFieldsSelection()
{
@@ -456,7 +485,9 @@ class TypeTest extends BaseTest
}
/**
- * Test to see if search Default Limit works
+ * Test to see if search Default Limit works.
+ *
+ * @group functional
*/
public function testLimitDefaultType()
{
@@ -492,34 +523,47 @@ class TypeTest extends BaseTest
/**
* Test Delete of index type. After delete will check for type mapping.
+ *
+ * @group functional
*/
public function testDeleteType()
{
$index = $this->_createIndex();
$type = new Type($index, 'test');
- $type->addDocument(new Document(1, array('name' => 'ruflin nicolas')));
- $type->addDocument(new Document(2, array('name' => 'ruflin')));
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'ruflin nicolas')),
+ new Document(2, array('name' => 'ruflin')),
+ ));
$index->refresh();
+ // sleep a moment to be sure that all nodes in cluster has new type
+ sleep(5);
+
$type->delete();
+ $index->optimize();
+
$this->assertFalse($type->exists());
}
+ /**
+ * @group functional
+ */
public function testMoreLikeThisApi()
{
- $client = new Client(array('persistent' => false));
+ $client = $this->_getClient(array('persistent' => false));
$index = $client->getIndex('elastica_test');
$index->create(array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0)), true);
$type = new Type($index, 'mlt_test');
- $type->addDocument(new Document(1, array('visible' => true, 'name' => 'bruce wayne batman')));
- $type->addDocument(new Document(2, array('visible' => true, 'name' => 'bruce wayne')));
- $type->addDocument(new Document(3, array('visible' => false, 'name' => 'bruce wayne')));
- $type->addDocument(new Document(4, array('visible' => true, 'name' => 'batman')));
- $type->addDocument(new Document(5, array('visible' => false, 'name' => 'batman')));
- $type->addDocument(new Document(6, array('visible' => true, 'name' => 'superman')));
- $type->addDocument(new Document(7, array('visible' => true, 'name' => 'spiderman')));
-
+ $type->addDocuments(array(
+ new Document(1, array('visible' => true, 'name' => 'bruce wayne batman')),
+ new Document(2, array('visible' => true, 'name' => 'bruce wayne')),
+ new Document(3, array('visible' => false, 'name' => 'bruce wayne')),
+ new Document(4, array('visible' => true, 'name' => 'batman')),
+ new Document(5, array('visible' => false, 'name' => 'batman')),
+ new Document(6, array('visible' => true, 'name' => 'superman')),
+ new Document(7, array('visible' => true, 'name' => 'spiderman')),
+ ));
$index->refresh();
$document = $type->getDocument(1);
@@ -529,15 +573,18 @@ class TypeTest extends BaseTest
$this->assertEquals(4, $resultSet->count());
// Return just the visible similar
- $query = new Query();
- $filterTerm = new Term();
+ $query = new Query();
+ $filterTerm = new Term();
$filterTerm->setTerm('visible', true);
- $query->setFilter($filterTerm);
+ $query->setPostFilter($filterTerm);
$resultSet = $type->moreLikeThis($document, array('min_term_freq' => '1', 'min_doc_freq' => '1'), $query);
$this->assertEquals(2, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testUpdateDocument()
{
$client = $this->_getClient();
@@ -549,7 +596,37 @@ class TypeTest extends BaseTest
$document = new Document();
$script = new Script(
- "ctx._source.name = name; ctx._source.counter += count",
+ 'ctx._source.name = name; ctx._source.counter += count',
+ array(
+ 'name' => $newName,
+ 'count' => 2,
+ ),
+ null,
+ $id
+ );
+ $script->setUpsert($document);
+
+ $type->updateDocument($script, array('refresh' => true));
+ $updatedDoc = $type->getDocument($id)->getData();
+ $this->assertEquals($newName, $updatedDoc['name'], 'Name was not updated');
+ $this->assertEquals(3, $updatedDoc['counter'], 'Counter was not incremented');
+ }
+
+ /**
+ * @group functional
+ */
+ public function testUpdateDocumentWithIdForwardSlashes()
+ {
+ $client = $this->_getClient();
+ $index = $client->getIndex('elastica_test');
+ $type = $index->getType('update_type');
+ $id = '/id/with/forward/slashes';
+ $type->addDocument(new Document($id, array('name' => 'bruce wayne batman', 'counter' => 1)));
+ $newName = 'batman';
+
+ $document = new Document();
+ $script = new Script(
+ 'ctx._source.name = name; ctx._source.counter += count',
array(
'name' => $newName,
'count' => 2,
@@ -561,10 +638,47 @@ class TypeTest extends BaseTest
$type->updateDocument($script, array('refresh' => true));
$updatedDoc = $type->getDocument($id)->getData();
- $this->assertEquals($newName, $updatedDoc['name'], "Name was not updated");
- $this->assertEquals(3, $updatedDoc['counter'], "Counter was not incremented");
+ $this->assertEquals($newName, $updatedDoc['name'], 'Name was not updated');
+ $this->assertEquals(3, $updatedDoc['counter'], 'Counter was not incremented');
+ }
+
+ /**
+ * @group functional
+ */
+ public function testUpdateDocumentWithParameter()
+ {
+ $client = $this->_getClient();
+ $index = $client->getIndex('elastica_test');
+ $type = $index->getType('update_type');
+ $id = 1;
+ $type->addDocument(new Document($id, array('name' => 'bruce wayne batman', 'counter' => 1)));
+ $newName = 'batman';
+
+ $document = new Document();
+ $script = new Script(
+ 'ctx._source.name = name; ctx._source.counter += count',
+ array(
+ 'name' => $newName,
+ 'count' => 2,
+ ),
+ null,
+ $id
+ );
+ $script->setUpsert($document);
+
+ try {
+ $type->updateDocument($script, array('version' => 999)); // Wrong version number to make the update fail
+ } catch (ResponseException $e) {
+ $this->assertContains('VersionConflictEngineException', $e->getMessage());
+ }
+ $updatedDoc = $type->getDocument($id)->getData();
+ $this->assertNotEquals($newName, $updatedDoc['name'], 'Name was updated');
+ $this->assertNotEquals(3, $updatedDoc['counter'], 'Counter was incremented');
}
+ /**
+ * @group functional
+ */
public function testUpdateDocumentWithFieldsSource()
{
$client = $this->_getClient();
@@ -612,11 +726,13 @@ class TypeTest extends BaseTest
}
/**
+ * @group functional
* @expectedException \Elastica\Exception\InvalidException
*/
public function testUpdateDocumentWithoutId()
{
$index = $this->_createIndex();
+ $this->_waitForAllocation($index);
$type = $index->getType('elastica_type');
$document = new Document();
@@ -624,6 +740,9 @@ class TypeTest extends BaseTest
$type->updateDocument($document);
}
+ /**
+ * @group functional
+ */
public function testUpdateDocumentWithoutSource()
{
$index = $this->_createIndex();
@@ -633,10 +752,10 @@ class TypeTest extends BaseTest
$mapping->setProperties(array(
'name' => array(
'type' => 'string',
- 'store' => 'yes'),
+ 'store' => 'yes', ),
'counter' => array(
'type' => 'integer',
- 'store' => 'no'
+ 'store' => 'no',
),
));
$mapping->disableSource();
@@ -673,6 +792,9 @@ class TypeTest extends BaseTest
}
}
+ /**
+ * @group functional
+ */
public function testAddDocumentHashId()
{
$index = $this->_createIndex();
@@ -694,6 +816,9 @@ class TypeTest extends BaseTest
$this->assertEquals($hashId, $doc->getId());
}
+ /**
+ * @group functional
+ */
public function testAddDocumentAutoGeneratedId()
{
$index = $this->_createIndex();
@@ -719,23 +844,28 @@ class TypeTest extends BaseTest
}
/**
+ * @group functional
* @expectedException \Elastica\Exception\RuntimeException
*/
public function testAddDocumentWithoutSerializer()
{
$index = $this->_createIndex();
+ $this->_waitForAllocation($index);
$type = new Type($index, 'user');
$type->addObject(new \stdClass());
}
+ /**
+ * @group functional
+ */
public function testAddObject()
{
$index = $this->_createIndex();
$type = new Type($index, 'user');
- $type->setSerializer(array(new SerializerMock(), 'serialize'));
+ $type->setSerializer('get_object_vars');
$userObject = new \stdClass();
$userObject->username = 'hans';
@@ -754,6 +884,20 @@ class TypeTest extends BaseTest
$this->assertEquals('hans', $data['username']);
}
+ /**
+ * @group unit
+ */
+ public function testSetSerializer()
+ {
+ $index = $this->_getClient()->getIndex('foo');
+ $type = $index->getType('user');
+ $ret = $type->setSerializer('get_object_vars');
+ $this->assertInstanceOf('Elastica\Type', $ret);
+ }
+
+ /**
+ * @group functional
+ */
public function testExists()
{
$index = $this->_createIndex();
@@ -765,6 +909,9 @@ class TypeTest extends BaseTest
$type->addDocument(new Document(1, array('name' => 'test name')));
$index->optimize();
+ // sleep a moment to be sure that all nodes in cluster has new type
+ sleep(5);
+
//Test if type exists
$this->assertTrue($type->exists());
@@ -772,15 +919,18 @@ class TypeTest extends BaseTest
$this->assertFalse($index->exists());
}
- public function testGetMapping() {
- $indexName = 'test';
+ /**
+ * @group functional
+ */
+ public function testGetMapping()
+ {
$typeName = 'test-type';
- $index = $this->_createIndex($indexName);
+ $index = $this->_createIndex();
$indexName = $index->getName();
$type = new Type($index, $typeName);
$mapping = new Mapping($type, $expect = array(
- 'id' => array('type' => 'integer', 'store' => true)
+ 'id' => array('type' => 'integer', 'store' => true),
));
$type->setMapping($mapping);
@@ -792,16 +942,19 @@ class TypeTest extends BaseTest
);
}
- public function testGetMappingAlias() {
- $indexName = 'test';
+ /**
+ * @group functional
+ */
+ public function testGetMappingAlias()
+ {
$aliasName = 'test-alias';
$typeName = 'test-alias-type';
- $index = $this->_createIndex($indexName);
+ $index = $this->_createIndex();
$index->addAlias($aliasName);
$type = new Type($index, $typeName);
$mapping = new Mapping($type, $expect = array(
- 'id' => array('type' => 'integer', 'store' => true)
+ 'id' => array('type' => 'integer', 'store' => true),
));
$type->setMapping($mapping);
@@ -813,11 +966,3 @@ class TypeTest extends BaseTest
);
}
}
-
-class SerializerMock
-{
- public function serialize($object)
- {
- return get_object_vars($object);
- }
-}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/UtilTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/UtilTest.php
index 09d4b5b1..a5b0f42e 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/UtilTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/UtilTest.php
@@ -1,15 +1,15 @@
<?php
-
namespace Elastica\Test;
-use Elastica\Util;
-use Elastica\Request;
use Elastica\Connection;
+use Elastica\Request;
use Elastica\Test\Base as BaseTest;
+use Elastica\Util;
class UtilTest extends BaseTest
{
/**
+ * @group unit
* @dataProvider getEscapeTermPairs
*/
public function testEscapeTerm($unescaped, $escaped)
@@ -25,18 +25,45 @@ class UtilTest extends BaseTest
array('oh yeah!', 'oh yeah\\!'),
// Seperate test below because phpunit seems to have some problems
//array('\\+-&&||!(){}[]^"~*?:', '\\\\\\+\\-\\&&\\||\\!\\(\\)\\{\\}\\[\\]\\^\\"\\~\\*\\?\\:'),
- array('some signs, can stay.', 'some signs, can stay.')
+ array('some signs, can stay.', 'some signs, can stay.'),
);
}
+ /**
+ * @group unit
+ * @dataProvider getReplaceBooleanWordsPairs
+ */
+ public function testReplaceBooleanWords($before, $after)
+ {
+ $this->assertEquals($after, Util::replaceBooleanWords($before));
+ }
+
+ public function getReplaceBooleanWordsPairs()
+ {
+ return array(
+ array('to be OR not to be', 'to be || not to be'),
+ array('ORIGINAL GIFTS', 'ORIGINAL GIFTS'),
+ array('Black AND White', 'Black && White'),
+ array('TIMBERLAND Men`s', 'TIMBERLAND Men`s'),
+ array('hello NOT kitty', 'hello !kitty'),
+ array('SEND NOTIFICATION', 'SEND NOTIFICATION'),
+ );
+ }
+
+ /**
+ * @group unit
+ */
public function testEscapeTermSpecialCharacters()
{
- $before = '\\+-&&||!(){}[]^"~*?:/';
- $after = '\\\\\\+\\-\\&&\\||\\!\\(\\)\\{\\}\\[\\]\\^\\"\\~\\*\\?\\:\\\\/';
+ $before = '\\+-&&||!(){}[]^"~*?:/<>';
+ $after = '\\\\\\+\\-\\&&\\||\\!\\(\\)\\{\\}\\[\\]\\^\\"\\~\\*\\?\\:\\/\<\>';
$this->assertEquals(Util::escapeTerm($before), $after);
}
+ /**
+ * @group unit
+ */
public function testToCamelCase()
{
$string = 'hello_world';
@@ -46,6 +73,9 @@ class UtilTest extends BaseTest
$this->assertEquals('HowAreYouToday', Util::toCamelCase($string));
}
+ /**
+ * @group unit
+ */
public function testToSnakeCase()
{
$string = 'HelloWorld';
@@ -55,6 +85,9 @@ class UtilTest extends BaseTest
$this->assertEquals('how_are_you_today', Util::toSnakeCase($string));
}
+ /**
+ * @group unit
+ */
public function testConvertRequestToCurlCommand()
{
$path = 'test';
@@ -63,15 +96,44 @@ class UtilTest extends BaseTest
$data = array('key' => 'value');
$connection = new Connection();
- $connection->setHost('localhost');
+ $connection->setHost($this->_getHost());
$connection->setPort('9200');
$request = new Request($path, $method, $data, $query, $connection);
$curlCommand = Util::convertRequestToCurlCommand($request);
- $expected = 'curl -XPOST \'http://localhost:9200/test?no=params\' -d \'{"key":"value"}\'';
+ $expected = 'curl -XPOST \'http://'.$this->_getHost().':9200/test?no=params\' -d \'{"key":"value"}\'';
$this->assertEquals($expected, $curlCommand);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testConvertDateTimeObjectWithTimezone()
+ {
+ $dateTimeObject = new \DateTime();
+ $timestamp = $dateTimeObject->getTimestamp();
+
+ $convertedString = Util::convertDateTimeObject($dateTimeObject);
+
+ $date = date('Y-m-d\TH:i:sP', $timestamp);
+
+ $this->assertEquals($convertedString, $date);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testConvertDateTimeObjectWithoutTimezone()
+ {
+ $dateTimeObject = new \DateTime();
+ $timestamp = $dateTimeObject->getTimestamp();
+
+ $convertedString = Util::convertDateTimeObject($dateTimeObject, false);
+
+ $date = date('Y-m-d\TH:i:s\Z', $timestamp);
+ $this->assertEquals($convertedString, $date);
}
}
diff --git a/vendor/ruflin/elastica/test/nginx/nginx.conf b/vendor/ruflin/elastica/test/nginx/nginx.conf
deleted file mode 100644
index 97f45fbc..00000000
--- a/vendor/ruflin/elastica/test/nginx/nginx.conf
+++ /dev/null
@@ -1,24 +0,0 @@
-events {
- worker_connections 1024;
-}
-
-http {
- access_log logs/access.log;
- error_log logs/error.log;
-
- server {
- listen 127.0.0.1:12345;
-
- location / {
- proxy_pass http://127.0.0.1:9201;
- }
- }
-
- server {
- listen 127.0.0.1:12346;
-
- location / {
- return 403;
- }
- }
-}
diff --git a/vendor/ruflin/elastica/test/benchmark/phpunit.xhprof.xml b/vendor/ruflin/elastica/test/phpunit.xhprof.xml
index 2293155a..59878cc2 100644
--- a/vendor/ruflin/elastica/test/benchmark/phpunit.xhprof.xml
+++ b/vendor/ruflin/elastica/test/phpunit.xhprof.xml
@@ -4,7 +4,7 @@
colors="true">
<testsuites>
<testsuite name="Transport">
- <file>TransportTest.php</file>
+ <file>lib/Elastica/Test/Transport/TransportBenchmarkTest.php</file>
</testsuite>
</testsuites>
<listeners>
@@ -36,4 +36,4 @@
</arguments>
</listener>
</listeners>
-</phpunit> \ No newline at end of file
+</phpunit>
diff --git a/vendor/ruflin/elastica/test/phpunit.xml.dist b/vendor/ruflin/elastica/test/phpunit.xml.dist
index a863692c..51993e0a 100644
--- a/vendor/ruflin/elastica/test/phpunit.xml.dist
+++ b/vendor/ruflin/elastica/test/phpunit.xml.dist
@@ -1,32 +1,27 @@
-<phpunit
- bootstrap="./bootstrap.php"
+<?xml version="1.0"?>
+<phpunit
backupGlobals="false"
backupStaticAttributes="false"
+ bootstrap="./bootstrap.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
+ processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
syntaxCheck="false"
- processIsolation="false">
-
- <testsuites>
- <testsuite name="Elastica">
- <directory>./lib/Elastica/</directory>
- </testsuite>
- </testsuites>
- <filter>
- <whitelist>
- <directory suffix=".php">../lib/</directory>
- </whitelist>
- </filter>
- <logging>
- <log type="coverage-html" target="../build/coverage" title="Elastica"
- charset="UTF-8" yui="true" highlight="true"
- lowUpperBound="35" highLowerBound="70"/>
- <log type="coverage-clover" target="../build/logs/clover.xml"/>
- <log type="junit" target="../build/logs/junit.xml" logIncompleteSkipped="false"/>
- </logging>
+ verbose="true"
+ >
+ <filter>
+ <whitelist>
+ <directory suffix=".php">../lib/</directory>
+ </whitelist>
+ </filter>
+ <testsuites>
+ <testsuite name="default">
+ <directory>./lib/Elastica/</directory>
+ </testsuite>
+ </testsuites>
</phpunit>