BREAKING_CHANGES.md 0000644 00000011145 14373463016 0007411 0 ustar 00 # 8.0
This major release is a complete new PHP client for Elasticsearch. We build it from scratch!
We tried to reduce the BC breaks as much as possible but there are some (big) differences:
## Architectural changes:
- we changed the namespace, now everything is under `Elastic\Elasticsearch`
- we used the [elastic-transport-php](https://github.com/elastic/elastic-transport-php) library for HTTP communications;
- we changed the `Exception` model, using the namespace `Elastic\Elasticsearch\Exception`. All the exceptions extends the
`ElasticsearchException` interface, as in 7.x
- we changed the response type of each endpoints using an [Elasticsearch](src/Response/Elasticsearch.php) response class.
This class wraps a a [PSR-7](https://www.php-fig.org/psr/psr-7/) response allowing the access of the body response
as array or object. This means you can access the API response as in 7.x, no BC break here! :angel:
- we changed the `ConnectionPool` in `NodePool`. The `connection` naming was ambigous since the objects are nodes (hosts)
## Specific changes:
The following functions has been removed:
- `ClientBuilder::getEndpoint()`
- `ClientBuilder::getRegisteredNamespacesBuilders()`
- `ClientBuilder::getRegisteredNamespacesBuilders()`
- `ClientBuilder::defaultHandler()`
- `ClientBuilder::multiHandler()`
- `ClientBuilder::singleHandler()`
- `ClientBuilder::setConnectionFactory()`
- `ClientBuilder::setConnectionPool()`, you can use `ClientBuilder::setNodePool` instead
- `ClientBuilder::setEndpoint()`
- `ClientBuilder::registerNamespace()`
- `ClientBuilder::setTransport()`, you can specify an HTTP PSR-18 client using `ClientBuilder::setHttpClient()`
- `ClientBuilder::setHandler()`
- `ClientBuilder::setTracer()`, you can only set a Logger using `ClientBuilder::setLogger()`
- `ClientBuilder::setSerializer()`
- `ClientBuilder::setConnectionParams()`, you can use `ClientBuilder::setHttpClientOptions()` instead
- `ClientBuilder::setSelector()`, you can set a `Selector` using the `setNodePool`, see [here](https://github.com/elastic/elastic-transport-php/blob/8.x/README.md#use-a-custom-selector) for more information
- `ClientBuilder::setSniffOnStart()`
- `ClientBuilder::includePortInHostHeader()`
We removed the special `client` parameter passed in `$params` endpoints. In details:
- `$params['client']['never_retry']`
- `$params['client']['verbose']`
- `$params['client']['port_in_header']`
- `$params['client']['future']`, you can set HTTP async using `Client::setAsync(true)`
- `$params['client']['ignore']`, you can disable the Exception using `Client::setResponseException(false)`
# 7.17
- We changed the signature of `Elasticsearch\Common\EmptyLogger::log` adding the `void` return type.
This change has been needed to support psr/log v3.
# 7.4
- Using a deprecated parameter is notified triggering a [E_USER_DEPRECATED](https://www.php.net/manual/en/errorfunc.constants.php)
error (e.g. using the `type` parameter will generate a `Specifying types in urls has been deprecated`
deprecation message).
- When `delete` with an empty `id` an `Elasticsearch\Common\Exceptions\RuntimeException\Missing404Exception`
exception is thrown. Previously it was a `Elasticsearch\Common\Exceptions\RuntimeException\InvalidArgumentException`.
# 7.0
- Requirement of PHP 7.1 instead of 7.0 that is not supported since 1 Jan 2019.
See [PHP supported version](https://www.php.net/supported-versions.php) for
more information.
- Elasticsearch 7.0 deprecated APIs that accept types, introduced new typeless
APIs, and removed support for the _default_ mapping. Read [this](https://www.elastic.co/blog/moving-from-types-to-typeless-apis-in-elasticsearch-7-0)
blog post for more information.
- Added type hints and return type declarations where possible
[#897](https://github.com/elastic/elasticsearch-php/pull/897)
# 6.8
- Method taskList() renamed to list() in TasksNamespace
# 6.7
- `{type}` part in `indices.put_mapping` API is not required anymore, see new specification [here](https://github.com/elastic/elasticsearch/blob/v6.7.0/rest-api-spec/src/main/resources/rest-api-spec/api/indices.put_mapping.json)
# 6.0
- [Search Templates]: PutTemplate endpoint has been removed (see [Elasticsearch Breaking Changes](https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking_60_scripting_changes.html#_stored_search_template_apis_removed)),
use PutScript instead.
- [#674](https://github.com/elastic/elasticsearch-php/pull/674) `ClientBuilder::defaultLogger()` method was removed. It is recommended to [create the logger object manually](https://github.com/elastic/elasticsearch-php/blob/master/docs/configuration.asciidoc#enabling-the-logger).
CHANGELOG.md 0000644 00000076563 14373463016 0006405 0 ustar 00 ## Release 8.4.0
- Added a `ClientInterface` to simplify the mock of the Client,
this is a fix for [#1227](https://github.com/elastic/elasticsearch-php/issues/1227)
[#1249](https://github.com/elastic/elasticsearch-php/pull/1249)
- Added the support of Symfony HTTP client, fixing the issue [#1241](https://github.com/elastic/elasticsearch-php/issues/1241)
[#1243](https://github.com/elastic/elasticsearch-php/pull/1243)
- Added the API compatibility header
[#1233](https://github.com/elastic/elasticsearch-php/pull/1233)
- Updated APIs for [Elasticsearch 8.4](https://github.com/elastic/elasticsearch/releases/tag/v8.4.0)
[7815caa](https://github.com/elastic/elasticsearch-php/commit/7815caac3d9342f13555481bd03ceb8d9c49a881)
## Release 8.3.0
- Updated APIs for [Elasticsearch 8.3](https://github.com/elastic/elasticsearch/releases/tag/v8.3.0)
[fb117a8](https://github.com/elastic/elasticsearch-php/commit/fb117a813cd28e8c0b9f4350896b66c068bfd072)
## Release 8.2.0
- Updated APIs for [Elasticsearch 8.2](https://github.com/elastic/elasticsearch/releases/tag/v8.2.0)
[630cb0b](https://github.com/elastic/elasticsearch-php/commit/630cb0bdcd4b864d2ed8cef380665cdb90429eec)
- Added the array support for `text/plain`
[#1220](https://github.com/elastic/elasticsearch-php/pull/1220)
## Release 8.1.0
- Updated APIs for [Elasticsearch 8.1](https://github.com/elastic/elasticsearch/releases/tag/v8.1.0)
[e4c2ac9](https://github.com/elastic/elasticsearch-php/commit/e4c2ac9b2c71e06c99b7a43712ccd83711fe6510)
## Release 8.0.1
- Fixed `NoNodeAvailableException` exception in endpoints
[e7d448d](https://github.com/elastic/elasticsearch-php/commit/e7d448d540f120eb3a3e3fe0d5866bf62fb67f3a)
## Release 8.0.0
- Finally released 8.0.0 GA.
## Release 8.0.0-rc2
- Added the common parameters in all the endpoints
[6427f8c](https://github.com/elastic/elasticsearch-php/commit/6427f8c42ba2afbe82c00adffdf93dd60b439432)
## Release 8.0.0-rc1
- Fixed query string in API endpoints + added a first integration test
[e404235](https://github.com/elastic/elasticsearch-php/commit/e404235890b53a99242f7fc5ddea6ee6b2459e8f)
- Added AdapterOptions class and setNodePool() in ClientBuilder
[9150f71](https://github.com/elastic/elasticsearch-php/commit/9150f717488ddb74d83a119d215c0584aa98c95a)
- Fixed urlencode in params, Exception in test code generation
[142327b](https://github.com/elastic/elasticsearch-php/commit/142327b3cb730042ec0b21b7c6076164bb0721ed)
- Improved client/server response exception messages
[50de3e6](https://github.com/elastic/elasticsearch-php/commit/50de3e60fc9b0167a948a992fda78bc5e1a42152)
## Release 8.0.0-alpha
First alpha release of elasticsearch-php 8.0.0.
This major release is a complete new PHP client for Elasticsearch. We build it from scratch!
We tried to reduce the BC breaks as much as possible but there are some (big) differences:
### Architectural changes:
- we changed the namespace, now everything is under `Elastic\Elasticsearch`
- we used the [elastic-transport-php](https://github.com/elastic/elastic-transport-php) library for HTTP communications;
- we changed the `Exception` model, using the namespace `Elastic\Elasticsearch\Exception`. All the exceptions extends the
`ElasticsearchException` interface, as in 7.x
- we changed the response type of each endpoints using an [Elasticsearch](src/Response/Elasticsearch.php) response class.
This class wraps a a [PSR-7](https://www.php-fig.org/psr/psr-7/) response allowing the access of the body response
as array or object. This means you can access the API response as in 7.x, no BC break here! :angel:
- we changed the `ConnectionPool` in `NodePool`. The `connection` naming was ambigous since the objects are nodes (hosts)
You can have a look at the [BREAKING_CHANGES](BREAKING_CHANGES.md) file for more information.
## Release 7.17.0
- Allow psr/log v3
[#1184](https://github.com/elastic/elasticsearch-php/pull/1184)
## Release 7.16.0
- Added support of includePortInHostHeader in ClientBuilder::fromConfig
[#1181](https://github.com/elastic/elasticsearch-php/pull/1181)
- Fixed UTF-16 issue in SmartSerializer with single unpaired surrogate in unicode escape
[#1179](https://github.com/elastic/elasticsearch-php/pull/1179)
- Replace trait with abstract class to avoid Deprecated Functionality issue in PHP 8.1
[#1175](https://github.com/elastic/elasticsearch-php/pull/1175)
## Release 7.15.0
- Updated endpoints for Elasticsearch 7.15.0
[995f6d4](https://github.com/elastic/elasticsearch-php/commit/995f6d4bde7de76004e95d7a434b1d59da7a7e75)
## Release 7.14.0
- Usage of psr/log version 2
[#1154](https://github.com/elastic/elasticsearch-php/pull/1154)
- Update search iterators to send `scroll_id` inside the request body
[#1134](https://github.com/elastic/elasticsearch-php/pull/1134)
- Added the `ingest.geoip.downloader.enabled=false` setting for ES
[5867351](https://github.com/elastic/elasticsearch-php/commit/586735109dc18f22bfdf3b73ab0621b37e857be1)
- Removed phpcs for autogenerated files (endpoints)
[651c57b](https://github.com/elastic/elasticsearch-php/commit/651c57b2e6bf98a0fd48220949966e630e5a804a)
## Release 7.13.1
- Added port in url for trace and logger messages
[#1126](https://github.com/elastic/elasticsearch-php/pull/1126)
## Release 7.13.0
- (DOCS) Added the HTTP meta data section
[#1143](https://github.com/elastic/elasticsearch-php/pull/1143)
- Added support for API Compatibility Header
[#1142](https://github.com/elastic/elasticsearch-php/pull/1142)
- (DOCS) Added Helpers section to PHP book
[#1129](https://github.com/elastic/elasticsearch-php/pull/1129)
- Added the API description in phpdoc section for each endpoint
[9e05c81](https://github.com/elastic/elasticsearch-php/commit/9e05c8108b638b60cc676b6a4f4be97c7df9eb64)
- Usage of PHPUnit 9 only + migrated xml configurations
[038b5dd](https://github.com/elastic/elasticsearch-php/commit/038b5dd043dc76b20b9f5f265ea914a38d33568d)
## Release 7.12.0
- Updated the endpoints for ES 7.12 + removed cpliakas/git-wrapper
in favor of symplify/git-wrapper
[136d5b9](https://github.com/elastic/elasticsearch-php/commit/136d5b9717b3806c6b34ef8a5076bfe7cee8b46e)
- Fixed warning header as array in YAML tests generator
[0d81be1](https://github.com/elastic/elasticsearch-php/commit/0d81be131bfc7eff6ef82468e61c16077a892aab)
- Refactored TEST_SUITE with free, platinum + removed old YamlRunnerTest
[f69d96f](https://github.com/elastic/elasticsearch-php/commit/f69d96fc283580177002b4088c279c3d0c07befe)
## Release 7.11.0
- Added the `X-Elastic-Client-Meta` header which is used by Elastic Cloud
and can be disabled with `ClientBuilder::setElasticMetaHeader(false)`
[#1089](https://github.com/elastic/elasticsearch-php/pull/1089)
- Replaced `array_walk` with `array_map` in `Connection::getURI` for PHP 8
compatibility
[#1075](https://github.com/elastic/elasticsearch-php/pull/1075)
- Remove unnecessary `InvalidArgumentExceptions`
[#1069](https://github.com/elastic/elasticsearch-php/pull/1069)
- Introducing PHP 8 compatibility
[#1063](https://github.com/elastic/elasticsearch-php/pull/1063)
- Replace Sami by Doctum and fix `.gitignore`
[#1062](https://github.com/elastic/elasticsearch-php/pull/1062)
## Release 7.10.0
- Updated endpoints and namespaces for Elasticsearch 7.10
[3ceb748](https://github.com/elastic/elasticsearch-php/commit/3ceb7484a111aa20126168460c79f098c4fe0792)
- Fixed ClientBuilder::fromConfig allowing multiple function
parameters (e.g. setApiKey)
[#1076](https://github.com/elastic/elasticsearch-php/pull/1076)
- Refactored the YAML tests using generated PHPUnit code
[85fadc2](https://github.com/elastic/elasticsearch-php/commit/85fadc2bd4b2b309b19761a50ff13010d43a524d)
## Release 7.9.1
- Fixed using object instead of array in onFailure transport event
[#1066](https://github.com/elastic/elasticsearch-php/pull/1066)
- Fixed reset custom header after endpoint call
[#1065](https://github.com/elastic/elasticsearch-php/pull/1065)
- Show generic error messages when server returns no response
[#1056](https://github.com/elastic/elasticsearch-php/pull/1056)
## Release 7.9.0
- Updated endpoints and namespaces for Elasticsearch 7.9
[28bf0ed](https://github.com/elastic/elasticsearch-php/commit/28bf0ed6df6bc95f83f369509431d97907bfdeb0)
- Moved `scroll_id` into `body` for search operations in the documentation
[#1052](https://github.com/elastic/elasticsearch-php/pull/1052)
- Fixed PHP 7.4 preloading feature for autoload.php
[#1051](https://github.com/elastic/elasticsearch-php/pull/1051)
- Improved message of JSON errors using `json_last_error_msg()`
[#1045](https://github.com/elastic/elasticsearch-php/pull/1045)
## Release 7.8.0
- Updated endpoints and namespaces for Elasticsearch 7.8
[f2a0828](https://github.com/elastic/elasticsearch-php/commit/f2a0828d5ee9d126ad63e2a1d43f70b4013845e2)
- Improved documentation
[#1038](https://github.com/elastic/elasticsearch-php/pull/1038)
[#1027](https://github.com/elastic/elasticsearch-php/pull/1027)
[#1025](https://github.com/elastic/elasticsearch-php/pull/1025)
## Release 7.7.0
- Removed setId() into endpoints, fixed `util/GenerateEndpoints.php`
[#1026](https://github.com/elastic/elasticsearch-php/pull/1026)
- Fixes JsonErrorException with code instead of message
[#1022](https://github.com/elastic/elasticsearch-php/pull/1022)
- Better exception message for Could not parse URI
[#1016](https://github.com/elastic/elasticsearch-php/pull/1016)
- Added JUnit log for PHPUnit
[88b7e1c](https://github.com/elastic/elasticsearch-php/commit/88b7e1ce80a5a52c1d64d00c55fef77097bbd8a9)
- Added the XPack endpoints
[763d91a](https://github.com/elastic/elasticsearch-php/commit/763d91a3d506075316b84a38b2bed7a098da5028)
## Release 7.6.1
- Fixed issue with `guzzlehttp/ringphp` and `guzzle/streams`
using forks `ezimuel/ringphp` and `ezimuel/guzzlestreams`
[92a6a4a](https://github.com/elastic/elasticsearch-php/commit/92a6a4adda5eafd1823c7c9c386e2c7e5e75cd08)
## Release 7.6.0
- Generated the new endpoints for Elasticsearch 7.6.0
[be31f31](https://github.com/elastic/elasticsearch-php/commit/be31f317af704f333b43bbcc7c01ddc7c91ec6f8)
## Release 7.5.1
- Fixes port missing in log [#925](https://github.com/elastic/elasticsearch-php/issues/925)
[75e0888](https://github.com/elastic/elasticsearch-php/commit/125594b40d167ef1509b3ee49a3f93426390c426)
- Added `ClientBuilder::includePortInHostHeader()` to add the
`port` in the `Host` header. This fixes [#993](https://github.com/elastic/elasticsearch-php/issues/993).
By default the `port` is not included in the `Host` header.
[#997](https://github.com/elastic/elasticsearch-php/pull/997)
- Replace abandoned packages: ringphp, streams and phpstan-shim
[#996](https://github.com/elastic/elasticsearch-php/pull/996)
- Fixed gzip compression when setting Cloud Id
[#986](https://github.com/elastic/elasticsearch-php/pull/986)
## Release 7.5.0
- Fixed `Client::extractArgument` iterable casting to array;
this allows passing a `Traversable` body for some endpoints
(e.g. Bulk, Msearch, MsearchTemplate)
[#983](https://github.com/elastic/elasticsearch-php/pull/983)
- Fixed the Response Exception if the `reason` field is null
[#980](https://github.com/elastic/elasticsearch-php/pull/980)
- Added support for PHP 7.4
[#976](https://github.com/elastic/elasticsearch-php/pull/976)
## Release 7.4.1
- We added the suppress operator `@` for the deprecation messages `@trigger_error()`.
With this approach we don't break existing application that convert PHP errors in Exception
(e.g. using Laravel with issue https://github.com/babenkoivan/scout-elasticsearch-driver/issues/297)
Using the `@` operator is still possible to intercept the deprecation message using
a custom error handler.
[#973](https://github.com/elastic/elasticsearch-php/pull/973)
- Add missing leading slash in the URL of put mapping endpoint
[#970](https://github.com/elastic/elasticsearch-php/pull/970)
- Fix pre 7.2 endpoint class name with aliases + reapply fix #947.
This PR solved the unexpected BC break introduce in 7.4.0 with the code
generation tool
[#968](https://github.com/elastic/elasticsearch-php/pull/968)
## Release 7.4.0
- Added the code generation for endpoints and namespaces based on
the [REST API specification](https://github.com/elastic/elasticsearch/tree/v7.4.2/rest-api-spec/src/main/resources/rest-api-spec/api)
of Elasticsearch. This tool is available in `util/GenerateEndpoints.php`.
[#966](https://github.com/elastic/elasticsearch-php/pull/966)
- Fixed the asciidoc [endpoints documentation](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/ElasticsearchPHP_Endpoints.html) based on the code generation
using [Sami](https://github.com/FriendsOfPHP/Sami) project
[#966](https://github.com/elastic/elasticsearch-php/pull/966)
- All the `experimental` and `beta` APIs are now signed with
a `@note` tag in the phpdoc section (e.g. [$client->rankEval()](https://github.com/elastic/elasticsearch-php/blob/master/src/Elasticsearch/Client.php)). For more information read the [experimental and beta APIs](docs/experimental-beta-apis.asciidoc)
section in the documentation.
[#966](https://github.com/elastic/elasticsearch-php/pull/966)
- Removed `AlreadyExpiredException` since it has been removed
from Elasticsearch with https://github.com/elastic/elasticsearch/pull/24857
[#954](https://github.com/elastic/elasticsearch-php/pull/954)
## Release 7.3.0
- Added support for simplified access to the `X-Opaque-Id` header
[#952](https://github.com/elastic/elasticsearch-php/pull/952)
- Added the HTTP port in the log messages
[#950](https://github.com/elastic/elasticsearch-php/pull/950)
- Fixed hostname with underscore (ClientBuilder::prependMissingScheme)
[#949](https://github.com/elastic/elasticsearch-php/pull/949)
- Removed unused Monolog in ClientBuilder
[#948](https://github.com/elastic/elasticsearch-php/pull/948)
## Release 7.2.2
- Reintroduced the optional parameter in `Elasticsearch\Namespaces\IndicesNamespace::getAliases()`.
This fixes the BC break introduced in 7.2.0 and 7.2.1.
[#947](https://github.com/elastic/elasticsearch-php/pull/)
## Release 7.2.1
- Reintroduced `Elasticsearch\Namespaces\IndicesNamespace::getAliases()` as proxy
to `IndicesNamespace::getAlias()` to prevent BC breaks. The `getAliases()` is
marked as deprecated and it will be removed from `elasticsearch-php 8.0`
[#943](https://github.com/elastic/elasticsearch-php/pull/943)
### Docs
- Fixed missing put mapping code snippet in code examples
[#938](https://github.com/elastic/elasticsearch-php/pull/938)
# Release 7.2.0
- Updated the API endpoints for working with Elasticsearch 7.2.0:
- added `wait_for_active_shards` parameter to `indices.close` API;
- added `expand_wildcards` parameter to `cluster.health` API;
- added include_unloaded_segments`, `expand_wildcards`, `forbid_closed_indices`
parameters to `indices.stats` API.
[[27d721b]](https://github.com/elastic/elasticsearch-php/pull/933/commits/27d721ba44b8c199388650c5a1c8bd69757229aa)
- Updated the phpdoc parameters for all the API endpoints
[[27d721b]](https://github.com/elastic/elasticsearch-php/pull/933/commits/27d721ba44b8c199388650c5a1c8bd69757229aa)
- Improved the Travis CI speed using cache feature with composer
[#929](https://github.com/elastic/elasticsearch-php/pull/929)
- Fixed `php_uname()` usage checking if it is disabled
[#927](https://github.com/elastic/elasticsearch-php/pull/927)
- Added support of Elastic Cloud ID and API key authentication
[#923](https://github.com/elastic/elasticsearch-php/pull/923)
## Release 7.1.1
- Fixed `ClientBuilder::setSSLVerification()` to accept string or boolean
[#917](https://github.com/elastic/elasticsearch-php/pull/917)
- Fix type hinting for `setBody` in `Elasticsearch\Endpoints\Ingest\Pipeline\Put`
[#913](https://github.com/elastic/elasticsearch-php/pull/913)
## Release 7.1.0
- Added warning log for Elasticsearch response containing the `Warning` header
[#911](https://github.com/elastic/elasticsearch-php/pull/911)
- Fixed #838 hosting company is blocking ports because of `YamlRunnerTest.php`
[#844](https://github.com/elastic/elasticsearch-php/pull/844)
- Specialized inheritance of `NoNodesAvailableException` to extend `ServerErrorResponseException`
instead of the generic `\Exception`
[#607](https://github.com/elastic/elasticsearch-php/pull/607)
- Fixed scroll TTL is extracted but not set as a body param
[#907](https://github.com/elastic/elasticsearch-php/pull/907)
### Testing
- Improved the speed of integration tests removing snapshots delete from `YamlRunnerTest::clean`
[#911](https://github.com/elastic/elasticsearch-php/pull/911)
- Reduced the number of skipping YAML integration tests from 20 to 6
[#911](https://github.com/elastic/elasticsearch-php/pull/911)
### Docs
- Documentation updated for Elasticsearch 7
[#904](https://github.com/elastic/elasticsearch-php/pull/904)
## Release 7.0.2
- Fixed incorrect return type hint when using async requests/futures
[#905](https://github.com/elastic/elasticsearch-php/pull/905)
## Release 7.0.1
- Fixed SniffingConnectionPool removing the return type of Connection::sniff()
[#899](https://github.com/elastic/elasticsearch-php/pull/899)
## Release 7.0.0
- Requirement of PHP 7.1 instead of 7.0 that is not supported since 1 Jan 2019.
[#897](https://github.com/elastic/elasticsearch-php/pull/897)
- Code refactoring using type hints and return type declarations where possible
[#897](https://github.com/elastic/elasticsearch-php/pull/897)
- Update vendor libraries (PHPUnit 7.5, Symfony YAML 4.3, etc)
[#897](https://github.com/elastic/elasticsearch-php/pull/897)
- Updated all the API endpoints using the [latest 7.0.0 specs](https://github.com/elastic/elasticsearch/tree/v7.0.0/rest-api-spec/src/main/resources/rest-api-spec/api) of Elasticsearch [#897](https://github.com/elastic/elasticsearch-php/pull/897)
- Added the `User-Agent` in each HTTP request [#898](https://github.com/elastic/elasticsearch-php/pull/898)
- Simplified the logging methods `logRequestFail($request, $response, $exception)`
and `logRequestSuccess($request, $response)` in `Elasticsearch\Connections\Connection`
[#876](https://github.com/elastic/elasticsearch-php/pull/876)
- Fix `json_encode` for unicode(emoji) characters [856](https://github.com/elastic/elasticsearch-php/pull/856)
- Fix HTTP port specification using CURLOPT_PORT, not anymore in the host [782](https://github.com/elastic/elasticsearch-php/pull/782)
## Release 6.7.1
- Added `track_total_hits` in `search` endpoint [0c9ff47](https://github.com/elastic/elasticsearch-php/commit/9f4f0dfa331c4f50d2c88c0068afd3062e6ea353)
## Release 6.7.0
- Removed requirement of `{type}` part in `indices.put_mapping`, see new API specification [here](https://github.com/elastic/elasticsearch/blob/v6.7.0/rest-api-spec/src/main/resources/rest-api-spec/api/indices.put_mapping.json)
- Added `seq_no_primary_term` parameter in `bulk` endpoint [#884](https://github.com/elastic/elasticsearch-php/pull/884)
- Added `include_type_name`, `if_primary_term`, `if_seq_no` in `delete` endpoint [#884](https://github.com/elastic/elasticsearch-php/pull/884)
- Added `include_type_name` in `get`, `index`, `indices.create`, `indices.field.get`, `indices.get`, `indices.mapping.get`, `indices.mapping.getfield`, `indices.mapping.put`, `indices.rollover`, `indices.template.get`, `indices.template.put` endpoints [#884](https://github.com/elastic/elasticsearch-php/pull/884)
- Added `seq_no_primary_term` in `search` endpoint [#884](https://github.com/elastic/elasticsearch-php/pull/884)
- Added `if_primary_term', 'if_seq_no`in `update` endpoint [#884](https://github.com/elastic/elasticsearch-php/pull/884)
### Testing
- Fix tests for PHP 7 with ES 6.7 [[5401479](https://github.com/elastic/elasticsearch-php/pull/884/commits/5401479)
### Docs
- [DOCS] Fix doc links in README [[5a1782d]](https://github.com/elastic/elasticsearch-php/pull/884/commits/5a1782d)
## Release 6.5.0
- Remove `_suggest` endpoint, which has disappeared from ES6 [#763](https://github.com/elastic/elasticsearch-php/pull/763)
- Fix `SearchHitIterator` key duplicates [#872](https://github.com/elastic/elasticsearch-php/pull/872)
- Fixing script get and delete by removing `lang` from endpoint url [#814](https://github.com/elastic/elasticsearch-php/pull/814)
- Fix `SearchResponseIterator` is scrolling the first page twice [#871](https://github.com/elastic/elasticsearch-php/pull/871), issue [#595](https://github.com/elastic/elasticsearch-php/issues/595)
### Docs
- [DOCS] Add reference to `parse_url()` for Extended Host Configuration [#778](https://github.com/elastic/elasticsearch-php/pull/778)
- [DOCS] Update php version requirement [#757](https://github.com/elastic/elasticsearch-php/pull/757)
- [DOCS] Update `community.asciidoc`, added `ElasticSearchQueryDSL` project [#749](https://github.com/elastic/elasticsearch-php/pull/749)
- [DOCS] Proper return type array for get method for `IndicesNamespace` [#651](https://github.com/elastic/elasticsearch-php/pull/651)
- [DOCS] Fix full docs link [#862](https://github.com/elastic/elasticsearch-php/pull/862)
- [DOCS] Update breaking-changes.asciidoc, removal of ClientBuilder::defaultLogger() [879](https://github.com/elastic/elasticsearch-php/pull/879)
### Testing
- Fix integration tests using docker [#867](https://github.com/elastic/elasticsearch-php/pull/867)
## Release 6.1.0
- Add 'wait_for_no_initializing_shards' to Cluster\Health whitelist [[98a372c]](http://github.com/elasticsearch/elasticsearch-php/commit/98a372c)
- Add 'wait_for_active_shards' to Indices\Open whitelist [[0275fe5]](http://github.com/elasticsearch/elasticsearch-php/commit/0275fe5)
- Add 'max_concurrent_searches' to msearch whitelist [[5624123]](http://github.com/elasticsearch/elasticsearch-php/commit/5624123)
- Add 'max_concurrent_shard_requests' param to MSearch endpoint [[00800c1]](http://github.com/elasticsearch/elasticsearch-php/commit/00800c1)
- Add ReloadSecureSettings endpoint [[75b32b2]](http://github.com/elasticsearch/elasticsearch-php/commit/75b32b2)
- Remove obsolete Shutdown API [[c75d690]](http://github.com/elasticsearch/elasticsearch-php/commit/c75d690)
- Fix: Restore::setBody() does not throw exceptions (#828) [[a96bb9c]](http://github.com/elasticsearch/elasticsearch-php/commit/a96bb9c)
- Fixed php 7.3 compatibility for elasticsearch 6 (#827) [[77916b2]](http://github.com/elasticsearch/elasticsearch-php/commit/77916b2)
- Fix issue with getting status of respository and snapshots. (#719) [[2d11682]](http://github.com/elasticsearch/elasticsearch-php/commit/2d11682)
- fix DeleteByQuery param white list (#748) [[8d963c6]](http://github.com/elasticsearch/elasticsearch-php/commit/8d963c6)
### Docs
- [Docs] Update elasticsearch version (#743) [[043ad4f]](http://github.com/elasticsearch/elasticsearch-php/commit/043ad4f)
- [DOCS] reuqest → request typo fix (#728) [[68db9f0]](http://github.com/elasticsearch/elasticsearch-php/commit/68db9f0)
- [DOCS] Fix documentation example of upsert (#730) [[805329b]](http://github.com/elasticsearch/elasticsearch-php/commit/805329b)
- [DOCS] Replace deprecated string type with keyword type for index operations (#736) [[a550507]](http://github.com/elasticsearch/elasticsearch-php/commit/a550507)
### Testing
- [TEST] Fix travis untarring [[0106351]](http://github.com/elasticsearch/elasticsearch-php/commit/0106351)
- [TEST] Download artifacts directly, migrate off esvm [[1e9f06c]](http://github.com/elasticsearch/elasticsearch-php/commit/1e9f06c)
- Update Travis Matrix [[aa32b12]](http://github.com/elasticsearch/elasticsearch-php/commit/aa32b12)
- [TEST] Fix teardown in yaml runner [[098030e]](http://github.com/elasticsearch/elasticsearch-php/commit/098030e)
- Add Indices/Split endpoint [[46d5a7a]](http://github.com/elasticsearch/elasticsearch-php/commit/46d5a7a)
- [TEST] Blacklist some bad yml tests [[d5edab7]](http://github.com/elasticsearch/elasticsearch-php/commit/d5edab7)
## Release 6.0.1
- Fix imports [[0106351]](http://github.com/elasticsearch/elasticsearch-php/commit/0106351)
- ClientBuilder: setLogger() and setTracer() only accept \Psr\Log\LoggerInterface (#673) [[0270c4f]](http://github.com/elasticsearch/elasticsearch-php/commit/0270c4f)
- fix for invalid GET /_aliases route. (#663) [[6d467fa]](http://github.com/elasticsearch/elasticsearch-php/commit/6d467fa)
- Remove PutTemplate endpoint, lang param of PutScript no longer used [[a13544f]](http://github.com/elasticsearch/elasticsearch-php/commit/a13544f)
Note: I'm considering PutTemplate removal a bugfix, since the API doesn't exist in ES Core anymore. Using the endpoint throws an error,
so the removal is just fixing an existing bug, hence `6.0.1` instead of `6.1.0`
### Docs
- [DOCS] Add note about separate X-Pack library to README (#694) [[6ffdef8]](http://github.com/elasticsearch/elasticsearch-php/commit/6ffdef8)
- [DOCS] add link to community index helper (#681) [[644f7f7]](http://github.com/elasticsearch/elasticsearch-php/commit/644f7f7)
- [DOCS] Add missing content for breaking changes page [[5a515ac]](http://github.com/elasticsearch/elasticsearch-php/commit/5a515ac)
- [DOCS] update autogenerated api docs [[7f2cd0b]](http://github.com/elasticsearch/elasticsearch-php/commit/7f2cd0b)
- [DOCS] Update version tables [[b824bb7]](http://github.com/elasticsearch/elasticsearch-php/commit/b824bb7)
## Release 6.0.0
- Add Ingest\ProcessorGrok endpoint [[800b1ec]](http://github.com/elasticsearch/elasticsearch-php/commit/800b1ec)
- Add Cluster\RemoteInfo endoint [[dfd8c3c]](http://github.com/elasticsearch/elasticsearch-php/commit/dfd8c3c)
- Add Unauthorized401Exception [[cc68efd]](http://github.com/elasticsearch/elasticsearch-php/commit/cc68efd)
- Add verify as acceptable query string parameter for createRepository (#665) [[885bfea]](http://github.com/elasticsearch/elasticsearch-php/commit/885bfea)
- Fix parsing of NodesInfo for Sniffing [[e22f67f]](http://github.com/elasticsearch/elasticsearch-php/commit/e22f67f)
- Do not schedule connection pool checks on 4xx level errors [[fd75e99]](http://github.com/elasticsearch/elasticsearch-php/commit/fd75e99)
- Add 'terminate_after' to Count endpoint whitelist (#634) [[c3cacd7]](http://github.com/elasticsearch/elasticsearch-php/commit/c3cacd7)
### Docs
- [DOCS] Flip Branch / PHP Version table (#656) [[fa7bfb3]](http://github.com/elasticsearch/elasticsearch-php/commit/fa7bfb3)
### Testing
- [TEST] use proper TestCase parent clsas [[766b440]](http://github.com/elasticsearch/elasticsearch-php/commit/766b440)
- [TEST] add PHPStan to build (#628) [[946cd65]](http://github.com/elasticsearch/elasticsearch-php/commit/946cd65)
- [TEST] Fix some PHPCS violations in tests [[18a38dd]](http://github.com/elasticsearch/elasticsearch-php/commit/18a38dd)
- [src] add PHP_CodeSniffer (#647) [[24900ef]](http://github.com/elasticsearch/elasticsearch-php/commit/24900ef)
- [TEST] add PHP_CodeSniffer to build (#638) [[088a509]](http://github.com/elasticsearch/elasticsearch-php/commit/088a509)
- [TEST] Use tests from corresponding ES version (#649) [[75c6680]](http://github.com/elasticsearch/elasticsearch-php/commit/75c6680)
- [TEST] Add support for `bad_request` in yaml runner [[ad86f91]](http://github.com/elasticsearch/elasticsearch-php/commit/ad86f91)
- [TEST] `max_compilations_per_minute` is now `max_compilations_rate` [[ebdba06]](http://github.com/elasticsearch/elasticsearch-php/commit/ebdba06)
- [TEST] print elasticsearch.log if cluster fails to start [[fe796aa]](http://github.com/elasticsearch/elasticsearch-php/commit/fe796aa)
- [TEST] move integration test to dedicated test file [[71ccfc1]](http://github.com/elasticsearch/elasticsearch-php/commit/71ccfc1)
- [TEST] Client does not support accepting Yaml format responses [[fc9a9f9]](http://github.com/elasticsearch/elasticsearch-php/commit/fc9a9f9)
## Release 6.0.0-beta1
Woo!
- Use upper-case "Host" header [[045aac4]](http://github.com/elasticsearch/elasticsearch-php/commit/045aac4)
- Add 'allow_no_indices' param to Indices\Delete whitelist [[3a3a5ab]](http://github.com/elasticsearch/elasticsearch-php/commit/3a3a5ab)
- Add 'verbose' param to Snapshot\Get whitelist [[b70b933]](http://github.com/elasticsearch/elasticsearch-php/commit/b70b933)
- Add 'pre_filter_shard_size' param to Search whitelist [[f708d9d]](http://github.com/elasticsearch/elasticsearch-php/commit/f708d9d)
- Add 'ignore_unavailable' param to Indices\Delete whitelist [[8133021]](http://github.com/elasticsearch/elasticsearch-php/commit/8133021)
- Add 'include_defaults' param to Cluster\Settings\Get whitelist [[8e5ab38]](http://github.com/elasticsearch/elasticsearch-php/commit/8e5ab38)
### Docs
- [DOCS] Remove Sami from composer.json and update docs (#619) [[fcd5ff1]](http://github.com/elasticsearch/elasticsearch-php/commit/fcd5ff1)
- [Docs] recommend composer/ca-bundle instead of Kdyby/CurlCaBundle (#613) [[7f43b2e]](http://github.com/elasticsearch/elasticsearch-php/commit/7f43b2e)
### Testing
- [TEST] Fix content-type assertions in test to match case [[5b37117]](http://github.com/elasticsearch/elasticsearch-php/commit/5b37117)
- Capitalize 'Content-Type' for maximum compatibility [[b8ad96c]](http://github.com/elasticsearch/elasticsearch-php/commit/b8ad96c)
- [TEST] Use percentage watermarks to be compatible with default flood [[95d2f89]](http://github.com/elasticsearch/elasticsearch-php/commit/95d2f89)
- [TEST] remove watermark flood from static config [[9b71940]](http://github.com/elasticsearch/elasticsearch-php/commit/9b71940)
- Shrink API was not setting body correctly [[e0f0985]](http://github.com/elasticsearch/elasticsearch-php/commit/e0f0985)
- [TEST] Add some missing and required static configs [[38febbe]](http://github.com/elasticsearch/elasticsearch-php/commit/38febbe)
- [TEST] Allow skipping individual tests inside of test file [[51b9b9b]](http://github.com/elasticsearch/elasticsearch-php/commit/51b9b9b)
- Travis: add PHP 7.2 + ES 6.0 to build matrix (#622) [[061f100]](http://github.com/elasticsearch/elasticsearch-php/commit/061f100)
- [TEST] tests code cleanup (#618) [[dc5d18c]](http://github.com/elasticsearch/elasticsearch-php/commit/dc5d18c)
- [TEST] Fix RoundRobinSelector Tests (#617) [[23a0ba8]](http://github.com/elasticsearch/elasticsearch-php/commit/23a0ba8)
- [TEST] skip new percentile tests for now [[b5d9613]](http://github.com/elasticsearch/elasticsearch-php/commit/b5d9613)
- [TEST] drop HHVM from build [#611] (#616) [[21a2d24]](http://github.com/elasticsearch/elasticsearch-php/commit/21a2d24)
- [TEST] Skip cat.aliases/20_headers.yml [[c83ca74]](http://github.com/elasticsearch/elasticsearch-php/commit/c83ca74)
- [TEST] YamlRunnerTest should run both .yml and .yaml files [[98c2646]](http://github.com/elasticsearch/elasticsearch-php/commit/98c2646)
- [TEST] build against ES 6 on Travis [[b5886a8]](http://github.com/elasticsearch/elasticsearch-php/commit/b5886a8)
- [TEST] drop HHVM from build [#611] [[0a7b402]](http://github.com/elasticsearch/elasticsearch-php/commit/0a7b402)
- [TEST] test tweaks to appease stricter types [[51f189e]](http://github.com/elasticsearch/elasticsearch-php/commit/51f189e)
- Fix ClientBuilder - pass correct argument for Elasticsearch\Endpoints\MsearchTemplate::__construct. (#605) [[5f83b52]](http://github.com/elasticsearch/elasticsearch-php/commit/5f83b52)
- [TEST] improve code quality of tests (#610) [[9ea2156]](http://github.com/elasticsearch/elasticsearch-php/commit/9ea2156)
- [TEST] Support headers in yaml runner, do some bad-comment cleaning [[57b5489]](http://github.com/elasticsearch/elasticsearch-php/commit/57b5489)
- [TEST] fix handling of format for Cat tests [[a24b7d1]](http://github.com/elasticsearch/elasticsearch-php/commit/a24b7d1)
- [TEST] test files are now .yml instead of .yaml [[ceac5bd]](http://github.com/elasticsearch/elasticsearch-php/commit/ceac5bd)
LICENSE 0000644 00000002071 14373463016 0005560 0 ustar 00 Copyright 2022 Elasticsearch B.V (https://www.elastic.co)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. README.md 0000644 00000034103 14373463016 0006033 0 ustar 00
Elasticsearch PHP client
========================
[![Build status](https://github.com/elastic/elasticsearch-php/workflows/PHP%20test/badge.svg)](https://github.com/elastic/elasticsearch-php/actions) [![Latest Stable Version](https://poser.pugx.org/elasticsearch/elasticsearch/v/stable)](https://packagist.org/packages/elasticsearch/elasticsearch) [![Total Downloads](https://poser.pugx.org/elasticsearch/elasticsearch/downloads)](https://packagist.org/packages/elasticsearch/elasticsearch)
This is the official PHP client for
[Elasticsearch](https://www.elastic.co/elasticsearch/).
## Contents
- [Getting started](#getting-started-)
- [Configuration](#configuration)
- [Use Elastic Cloud](#use-elastic-cloud)
- [Usage](#usage)
- [Index a document](#index-a-document)
- [Search a document](#search-a-document)
- [Delete a document](#delete-a-document)
- [Versioning](#versioning)
- [Backward Incompatible Changes](#backward-incompatible-changes-boom)
- [Mock the Elasticsearch client](#mock-the-elasticsearch-client)
- [FAQ](#faq-)
- [Contribute](#contribute-)
- [License](#license-)
***
## Getting started 🐣
Using this client assumes that you have an
[Elasticsearch](https://www.elastic.co/elasticsearch/) server installed and
running.
You can install the client in your PHP project using
[composer](https://getcomposer.org/):
```bash
composer require elasticsearch/elasticsearch
```
After the installation you can connect to Elasticsearch using the
`ClientBuilder` class. For instance, if your Elasticsearch is running on
`localhost:9200` you can use the following code:
```php
use Elastic\Elasticsearch\ClientBuilder;
$client = ClientBuilder::create()
->setHosts(['localhost:9200'])
->build();
// Info API
$response = $client->info();
echo $response['version']['number']; // 8.0.0
```
The `$response` is an object of `Elastic\Elasticsearch\Response\Elasticsearch`
class that implements `ElasticsearchInterface`, PSR-7
[ResponseInterface](https://www.php-fig.org/psr/psr-7/#33-psrhttpmessageresponseinterface)
and [ArrayAccess](https://www.php.net/manual/en/class.arrayaccess.php).
This means the `$response` is a [PSR-7](https://www.php-fig.org/psr/psr-7/)
object:
```php
echo $response->getStatusCode(); // 200
echo (string) $response->getBody(); // Response body in JSON
```
and also an "array", meaning you can access the response body as an
associative array, as follows:
```php
echo $response['version']['number']; // 8.0.0
var_dump($response->asArray()); // response body content as array
```
Moreover, you can access the response body as object, string or bool:
```php
echo $response->version->number; // 8.0.0
var_dump($response->asObject()); // response body content as object
var_dump($response->asString()); // response body as string (JSON)
var_dump($response->asBool()); // true if HTTP response code between 200 and 300
```
## Configuration
Elasticsearch 8.0 offers
[security by default](https://www.elastic.co/blog/introducing-simplified-elastic-stack-security),
that means it uses [TLS](https://en.wikipedia.org/wiki/Transport_Layer_Security)
for protect the communication between client and server.
In order to configure `elasticsearch-php` for connecting to Elasticsearch 8.0 we
need to have the certificate authority file (CA).
You can install Elasticsearch in different ways, for instance using
[Docker](https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html)
you need to execute the followind command:
```bash
docker pull docker.elastic.co/elasticsearch/elasticsearch:8.0.1
```
Once you have the docker image installed, you can execute Elasticsearch, for
instance using a single-node cluster configuration, as follows:
```bash
docker network create elastic
docker run --name es01 --net elastic -p 9200:9200 -p 9300:9300 -it docker.elastic.co/elasticsearch/elasticsearch:8.0.1
```
This command creates an `elastic` Docker network and start Elasticsearch
using the port `9200` (default).
When you run the docker image a password is generated for the `elastic` user
and it's printed to the terminal (you might need to scroll back a bit in the
terminal to view it). You have to copy it since we will need to connect to
Elasticsearch.
Now that Elasticsearch is running we can get the `http_ca.crt` file certificate.
We need to copy it from the docker instance, using the following command:
```bash
docker cp es01:/usr/share/elasticsearch/config/certs/http_ca.crt .
```
Once we have the `http_ca.crt` certificate and the `password`, copied during the
start of Elasticsearch, we can use it to connect with `elasticsearch-php` as
follows:
```php
$client = ClientBuilder::create()
->setHosts(['https://localhost:9200'])
->setBasicAuthentication('elastic', 'password copied during Elasticsearch start')
->setCABundle('path/to/http_ca.crt')
->build();
```
For more information about the Docker configuration of Elasticsearch you can
read the official documentation
[here](https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html).
### Use Elastic Cloud
You can use [Elastic Cloud](https://www.elastic.co/cloud/) as server with
`elasticsearch-php`. Elastic Cloud is the PaaS solution offered by
[Elastic](https://www.elastic.co).
For connecting to Elastic Cloud you just need the `Cloud ID` and the `API key`.
You can get the `Cloud ID` from the `My deployment` page of your dashboard (see
the red rectangle reported in the screenshot).
![Cloud ID](docs/images/cloud_id.png)
You can generate an `API key` in the `Management` page under the section
`Security`.
![Security](docs/images/create_api_key.png)
When you click on `Create API key` button you can choose a name and set the
other options (for example, restrict privileges, expire after time, and so on).
![Choose an API name](docs/images/api_key_name.png)
After this step you will get the `API key`in the API keys page.
![API key](docs/images/cloud_api_key.png)
**IMPORTANT**: you need to copy and store the `API key`in a secure place, since
you will not be able to view it again in Elastic Cloud.
Once you have collected the `Cloud ID` and the `API key`, you can use
`elasticsearch-php` to connect to your Elastic Cloud instance, as follows:
```php
$client = ClientBuilder::create()
->setElasticCloudId('insert here the Cloud ID')
->setApiKey('insert here the API key')
->build();
```
## Usage
The `elasticsearch-php` client offers 400+ endpoints for interacting with
Elasticsearch. A list of all these endpoints is available in the
[official documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/rest-apis.html)
of Elasticsearch APIs.
Here we reported the basic operation that you can perform with the client:
index, search and delete.
### Index a document
You can store (index) a JSON document in Elasticsearch using the following code:
```php
use Elastic\Elasticsearch\Exception\ClientResponseException;
use Elastic\Elasticsearch\Exception\ServerResponseException;
$params = [
'index' => 'my_index',
'body' => [ 'testField' => 'abc']
];
try {
$response = $client->index($params);
} catch (ClientResponseException $e) {
// manage the 4xx error
} catch (ServerResponseException $e) {
// manage the 5xx error
} catch (Exception $e) {
// eg. network error like NoNodeAvailableException
}
print_r($response->asArray()); // response body content as array
```
Elasticsearch stores the `{"testField":"abc"}` JSON document in the `my_index`
index. The `ID` of the document is created automatically by Elasticsearch and
stored in `$response['_id']` field value. If you want to specify an `ID` for the
document you need to store it in `$params['id']`.
You can manage errors using `ClientResponseException` and
`ServerResponseException`. The PSR-7 response is available using
`$e->getResponse()` and the HTTP status code is available using `$e->getCode()`.
### Search a document
Elasticsearch provides many different way to search documents. The simplest
search that you can perform is a
[match query](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html),
as follows:
```php
$params = [
'index' => 'my_index',
'body' => [
'query' => [
'match' => [
'testField' => 'abc'
]
]
]
];
$response = $client->search($params);
printf("Total docs: %d\n", $response['hits']['total']['value']);
printf("Max score : %.4f\n", $response['hits']['max_score']);
printf("Took : %d ms\n", $response['took']);
print_r($response['hits']['hits']); // documents
```
Using Elasticsearch you can perform different query search, for more information
we suggest toread the official documention reported
[here](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-your-data.html).
### Delete a document
You can delete a document specifing the `index` name and the `ID` of the
document, as follows:
```php
use Elastic\Elasticsearch\Exception\ClientResponseException;
try {
$response = $client->delete([
'index' => 'my_index',
'id' => 'my_id'
]);
} catch (ClientResponseException $e) {
if ($e->getCode() === 404) {
// the document does not exist
}
}
if ($response['acknowledge'] === 1) {
// the document has been delete
}
```
For more information about the Elasticsearch REST API you can read the official
documentation [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/rest-apis.html).
### Versioning
This client is versioned and released alongside Elasticsearch server.
To guarantee compatibility, use the most recent version of this library within
the major version of the corresponding Enterprise Search implementation.
For example, for Elasticsearch `7.16`, use `7.16` of this library or above, but
not `8.0`.
## Backward Incompatible Changes :boom:
The 8.0.0 version of `elasticsearch-php` contains a new implementation compared
with 7.x. It supports [PSR-7](https://www.php-fig.org/psr/psr-7/) for HTTP
messages and [PSR-18](https://www.php-fig.org/psr/psr-18/) for HTTP client
communications.
We tried to reduce the BC breaks as much as possible with `7.x` but there are
some (big) differences:
- we changed the namespace, now everything is under `Elastic\Elasticsearch`
- we used the
[elastic-transport-php](https://github.com/elastic/elastic-transport-php)
library for HTTP communications;
- we changed the `Exception` model, using the namespace
`Elastic\Elasticsearch\Exception`. All the exceptions extends the
`ElasticsearchException` interface, as in 7.x
- we changed the response type of each endpoints using an
[Elasticsearch](src/Response/Elasticsearch.php) response class. This class
wraps a a [PSR-7](https://www.php-fig.org/psr/psr-7/) response allowing the
access of the body response as array or object. This means you can access the
API response as in 7.x, no BC break here! :angel:
- we changed the `ConnectionPool` in `NodePool`. The `connection` naming was
ambigous since the objects are nodes (hosts)
You can have a look at the [BREAKING_CHANGES](BREAKING_CHANGES.md) file for more
information.
## Mock the Elasticsearch client
If you need to mock the Elasticsearch client you just need to mock a
[PSR-18](https://www.php-fig.org/psr/psr-18/) HTTP Client.
For instance, you can use the
[php-http/mock-client](https://github.com/php-http/mock-client) as follows:
```php
use Elastic\Elasticsearch\ClientBuilder;
use Elastic\Elasticsearch\Response\Elasticsearch;
use Http\Mock\Client;
use Nyholm\Psr7\Response;
$mock = new Client(); // This is the mock client
$client = ClientBuilder::create()
->setHttpClient($mock)
->build();
// This is a PSR-7 response
$response = new Response(
200,
[Elasticsearch::HEADER_CHECK => Elasticsearch::PRODUCT_NAME],
'This is the body!'
);
$mock->addResponse($response);
$result = $client->info(); // Just calling an Elasticsearch endpoint
echo $result->asString(); // This is the body!
```
We are using the `ClientBuilder::setHttpClient()` to set the mock client.
You can specify the response that you want to have using the
`addResponse($response)` function. As you can see the `$response` is a PSR-7
response object. In this example we used the `Nyholm\Psr7\Response` object from
the [nyholm/psr7](https://github.com/Nyholm/psr7) project. If you are using
[PHPUnit](https://phpunit.de/) you can even mock the `ResponseInterface` as
follows:
```php
$response = $this->createMock('Psr\Http\Message\ResponseInterface');
```
**Notice**: we added a special header in the HTTP response. This is the product
check header, and it is required for guarantee that `elasticsearch-php` is
communicating with an Elasticsearch server 8.0+.
For more information you can read the
[Mock client](https://docs.php-http.org/en/latest/clients/mock-client.html)
section of PHP-HTTP documentation.
## FAQ 🔮
### Where do I report issues with the client?
If something is not working as expected, please open an
[issue](https://github.com/elastic/elasticsearch-php/issues/new).
### Where else can I go to get help?
You can checkout the
[Elastic community discuss forums](https://discuss.elastic.co/).
## Contribute 🚀
We welcome contributors to the project. Before you begin, some useful info...
+ If you want to contribute to this project you need to subscribe to a
[Contributor Agreement](https://www.elastic.co/contributor-agreement).
+ Before opening a pull request, please create an issue to
[discuss the scope of your proposal](https://github.com/elastic/elasticsearch-php/issues).
+ If you want to send a PR for version `8.0` please use the `8.0` branch, for
`8.1` use the `8.1` branch and so on.
+ Never send PR to `master` unless you want to contribute to the development
version of the client (`master` represents the next major version).
+ Each PR should include a **unit test** using [PHPUnit](https://phpunit.de/).
If you are not familiar with PHPUnit you can have a look at the
[reference](https://phpunit.readthedocs.io/en/9.5/).
Thanks in advance for your contribution! :heart:
## License 📗
[MIT](LICENSE) © [Elastic](https://www.elastic.co/)
composer.json 0000644 00000002425 14373463016 0007300 0 ustar 00 {
"name": "elasticsearch/elasticsearch",
"description": "PHP Client for Elasticsearch",
"keywords": [
"search",
"client",
"elasticsearch",
"elastic"
],
"type": "library",
"license": "MIT",
"require": {
"php": "^7.4 || ^8.0",
"elastic/transport": "^8.5",
"psr/http-client": "^1.0",
"psr/http-message": "^1.0",
"psr/log": "^1|^2|^3",
"guzzlehttp/guzzle": "^7.0"
},
"require-dev": {
"ext-yaml": "*",
"ext-zip": "*",
"mockery/mockery": "^1.5",
"phpstan/phpstan": "^1.4",
"phpunit/phpunit": "^9.5",
"symfony/finder": "~4.0",
"nyholm/psr7": "^1.5",
"php-http/mock-client": "^1.5",
"symfony/http-client": "^5.0|^6.0"
},
"autoload": {
"psr-4": {
"Elastic\\Elasticsearch\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Elastic\\Elasticsearch\\Tests\\": "tests/",
"Elastic\\Elasticsearch\\Util\\": "util/"
}
},
"scripts": {
"test" : [
"vendor/bin/phpunit --testdox"
],
"integration-test" : [
"vendor/bin/phpunit --testdox -c phpunit-integration-tests.xml"
],
"cloud-test" : [
"vendor/bin/phpunit --testdox -c phpunit-integration-cloud-tests.xml"
],
"phpstan": [
"phpstan analyse src --level 2 --no-progress"
]
}
}
docs/breaking-changes.asciidoc 0000644 00000005247 14373463016 0012403 0 ustar 00 [[breaking_changes]]
=== Breaking changes from 7.x
This major release is a complete new PHP client for {es}. We build it from scratch!
We tried to reduce the BC breaks as much as possible but there are some (big) differences:
[discrete]
==== Architectural changes
- we changed the namespace, now everything is under `Elastic\Elasticsearch`
- we used the https://github.com/elastic/elastic-transport-php[elastic-transport-php] library for HTTP communications;
- we changed the `Exception` model, using the namespace `Elastic\Elasticsearch\Exception`. All the exceptions extends the
`ElasticsearchException` interface, as in 7.x
- we changed the response type of each endpoint using an https://github.com/elastic/elasticsearch-php/blob/master/src/Response/Elasticsearch.php[Elasticsearch] response class.
This class wraps a https://www.php-fig.org/psr/psr-7/[PSR-7] response allowing the access of the body response
as array or object. This means you can access the API response as in 7.x, no BC break here! :angel:
- we changed the `ConnectionPool` in `NodePool`. The `connection` naming was ambigous since the objects are nodes (hosts)
[discrete]
==== Specific changes
The following functions has been removed:
- `ClientBuilder::getEndpoint()`
- `ClientBuilder::getRegisteredNamespacesBuilders()`
- `ClientBuilder::getRegisteredNamespacesBuilders()`
- `ClientBuilder::defaultHandler()`
- `ClientBuilder::multiHandler()`
- `ClientBuilder::singleHandler()`
- `ClientBuilder::setConnectionFactory()`
- `ClientBuilder::setConnectionPool()`, you can use `ClientBuilder::setNodePool` instead
- `ClientBuilder::setEndpoint()`
- `ClientBuilder::registerNamespace()`
- `ClientBuilder::setTransport()`, you can specify an HTTP PSR-18 client using `ClientBuilder::setHttpClient()`
- `ClientBuilder::setHandler()`
- `ClientBuilder::setTracer()`, you can only set a Logger using `ClientBuilder::setLogger()`
- `ClientBuilder::setSerializer()`
- `ClientBuilder::setConnectionParams()`, you can use `ClientBuilder::setHttpClientOptions()` instead
- `ClientBuilder::setSelector()`, you can set a `Selector` using the `setNodePool`, see [here](https://github.com/elastic/elastic-transport-php/blob/8.x/README.md#use-a-custom-selector) for more information
- `ClientBuilder::setSniffOnStart()`
- `ClientBuilder::includePortInHostHeader()`
We removed the special `client` parameter passed in `$params` endpoints. In details:
- `$params['client']['never_retry']`
- `$params['client']['verbose']`
- `$params['client']['port_in_header']`
- `$params['client']['future']`, you can set HTTP async using `Client::setAsync(true)`
- `$params['client']['ignore']`, you can disable the Exception using `Client::setResponseException(false)`
docs/config-hash.asciidoc 0000644 00000002167 14373463016 0011377 0 ustar 00 [discrete]
[[config-hash]]
=== Building the client from a configuration hash
To help ease automated building of the client, all configurations can be
provided in a setting hash instead of calling the individual methods directly.
This functionality is exposed through the `ClientBuilder::fromConfig()` static
method, which accepts an array of configurations and returns a fully built
client.
Array keys correspond to the method name, for example `retries` key corresponds
to `setRetries()` method.
[source,php]
----
$params = [
'hosts' => [
'localhost:9200'
],
'retries' => 2
];
$client = ClientBuilder::fromConfig($params);
----
Unknown parameters throw an exception, to help the user find potential problems.
If this behavior is not desired (for example, you are using the hash for other
purposes), you can set `$quiet = true` in fromConfig() to silence the exceptions.
[source,php]
----
$params = [
'hosts' => [
'localhost:9200'
],
'retries' => 2,
'imNotReal' => 5
];
// Set $quiet to true to ignore the unknown `imNotReal` key
$client = ClientBuilder::fromConfig($params, true);
---- docs/configuration.asciidoc 0000644 00000001706 14373463016 0012056 0 ustar 00 [[configuration]]
== Configuration
Almost every aspect of the client is configurable. Most users only need to
configure a few parameters to suit their needs, but it is possible to completely
replace much of the internals if required.
Custom configuration is accomplished before the client is instantiated, through
the `ClientBuilder` class. You can find all the configuration options and
check sample code that helps you replace the various components.
To learn more about JSON in PHP, read <>.
* <>
* <>
* <>
* <>
* <>
* <>
* <>
* <>
include::php_json_objects.asciidoc[]
include::host-config.asciidoc[]
include::set-retries.asciidoc[]
include::http-meta-data.asciidoc[]
include::logger.asciidoc[]
include::http-client.asciidoc[]
include::namespaces.asciidoc[]
include::node-pool.asciidoc[]
include::config-hash.asciidoc[]
docs/connecting.asciidoc 0000644 00000007301 14373463016 0011333 0 ustar 00 [[connecting]]
== Connecting
This page contains the information you need to connect and use the Client with
{es}.
**On this page**
* <>
* <>
[discrete]
[[auth-ec]]
=== Elastic Cloud
You can connect to https://www.elastic.co/cloud/[Elastic Cloud] using an **API key**
and a **Cloud ID**:
[source,php]
----
$client = ClientBuilder::create()
->setElasticCloudId('')
->setApiKey('')
->build();
----
Where and can be retrieved using the Elastic Cloud web UI.
You can get the `Cloud ID` from the `My deployment` page of your dashboard (see the red
rectangle reported in the screenshot).
image::images/cloud_id.png[alt="Elastic Cloud ID",align="center"]
You can generate an `API key` in the `Management` page under the section `Security`.
image::images/create_api_key.png[alt="Create API key",align="center"]
When you click on `Create API key` button you can choose a name and set the other
options (eg. restrict privileges, expire after time, etc).
image::images/api_key_name.png[alt="Choose an API name",align="center"]
After this step you will get the `API key`in the API keys page.
image::images/cloud_api_key.png[alt="Cloud API key",align="center"]
**IMPORTANT**: you need to copy and store the `API key`in a secure place, since you will not
be able to view it again in Elastic Cloud.
[discrete]
[[auth-http]]
=== Security by default (HTTPS)
{es} 8.0 offers https://www.elastic.co/blog/introducing-simplified-elastic-stack-security[security by default],
that means it uses https://en.wikipedia.org/wiki/Transport_Layer_Security[TLS]
for protect the communication between client and server.
In order to configure `elasticsearch-php` for connecting to {es} 8.0 we
need to have the certificate authority file (CA).
You can install {es} in different ways, for instance using https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html[Docker]
you need to execute the followind command:
[source,shell]
--------------------------
docker pull docker.elastic.co/elasticsearch/elasticsearch:8.0.1
--------------------------
Once you have the docker image installed you can execute {es},
for instance using a single-node cluster configuration, as follows:
[source,shell]
--------------------------
docker network create elastic
docker run --name es01 --net elastic -p 9200:9200 -p 9300:9300 -it docker.elastic.co/elasticsearch/elasticsearch:8.0.1
--------------------------
This command creates an `elastic` Docker network and start {es}
using the port `9200` (default).
When you run the docker imnage a password is generated for the `elastic` user
and it's printed to the terminal (you might need to scroll back a bit in the terminal
to view it). You have to copy it since we will need to connect to {es}.
Now that {es} is running we can get the `http_ca.crt` file certificate.
We need to copy it from the docker instance, using the following command:
[source,shell]
--------------------------
docker cp es01:/usr/share/elasticsearch/config/certs/http_ca.crt .
--------------------------
Once we have the `http_ca.crt` certificate and the `password`, copied during the
start of {es} , we can use it to connect with `elasticsearch-php`
as follows:
[source,php]
--------------------------
$client = ClientBuilder::create()
->setHosts(['https://localhost:9200'])
->setBasicAuthentication('elastic', 'password copied during Elasticsearch start')
->setCABundle('path/to/http_ca.crt')
->build();
--------------------------
For more information about the Docker configuration of Elasticsearch you can
read the official documentation https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html[here].
docs/crud.asciidoc 0000644 00000013512 14373463016 0010142 0 ustar 00 [[indexing_documents]]
=== Indexing documents
When you add documents to {es}, you index JSON documents. This maps naturally to
PHP associative arrays, since they can easily be encoded in JSON. Therefore, in
Elasticsearch-PHP you create and pass associative arrays to the client for
indexing. There are several methods of ingesting data into {es} which we cover
here.
[discrete]
==== Single document indexing
When indexing a document, you can either provide an ID or let {es} generate one
for you.
{zwsp} +
.Providing an ID value
[source,php]
----
$params = [
'index' => 'my_index',
'id' => 'my_id',
'body' => [ 'testField' => 'abc']
];
// Document will be indexed to my_index/_doc/my_id
$response = $client->index($params);
----
{zwsp} +
.Omitting an ID value
[source,php]
----
$params = [
'index' => 'my_index',
'body' => [ 'testField' => 'abc']
];
// Document will be indexed to my_index/_doc/
$response = $client->index($params);
----
{zwsp} +
If you need to set other parameters, such as a `routing` value, you specify
those in the array alongside the `index`, and others. For example, let's set the
routing and timestamp of this new document:
.Additional parameters
[source,php]
----
$params = [
'index' => 'my_index',
'id' => 'my_id',
'routing' => 'company_xyz',
'timestamp' => strtotime("-1d"),
'body' => [ 'testField' => 'abc']
];
$response = $client->index($params);
----
{zwsp} +
[discrete]
==== Bulk Indexing
{es} also supports bulk indexing of documents. The bulk API expects JSON
action/metadata pairs, separated by newlines. When constructing your documents
in PHP, the process is similar. You first create an action array object (for
example, an `index` object), then you create a document body object. This
process repeats for all your documents.
A simple example might look like this:
.Bulk indexing with PHP arrays
[source,php]
----
for($i = 0; $i < 100; $i++) {
$params['body'][] = [
'index' => [
'_index' => 'my_index',
]
];
$params['body'][] = [
'my_field' => 'my_value',
'second_field' => 'some more values'
];
}
$responses = $client->bulk($params);
----
In practice, you'll likely have more documents than you want to send in a single
bulk request. In that case, you need to batch up the requests and periodically
send them:
.Bulk indexing with batches
[source,php]
----
$params = ['body' => []];
for ($i = 1; $i <= 1234567; $i++) {
$params['body'][] = [
'index' => [
'_index' => 'my_index',
'_id' => $i
]
];
$params['body'][] = [
'my_field' => 'my_value',
'second_field' => 'some more values'
];
// Every 1000 documents stop and send the bulk request
if ($i % 1000 == 0) {
$responses = $client->bulk($params);
// erase the old bulk request
$params = ['body' => []];
// unset the bulk response when you are done to save memory
unset($responses);
}
}
// Send the last batch if it exists
if (!empty($params['body'])) {
$responses = $client->bulk($params);
}
----
[[getting_documents]]
=== Getting documents
{es} provides realtime GETs of documents. This means that as soon as the
document is indexed and your client receives an acknowledgement, you can
immediately retrieve the document from any shard. Get operations are performed
by requesting a document by its full `index/type/id` path:
[source,php]
----
$params = [
'index' => 'my_index',
'id' => 'my_id'
];
// Get doc at /my_index/_doc/my_id
$response = $client->get($params);
----
{zwsp} +
[[updating_documents]]
=== Updating documents
Updating a document allows you to either completely replace the contents of the
existing document, or perform a partial update to just some fields (either
changing an existing field or adding new fields).
[discrete]
==== Partial document update
If you want to partially update a document (for example, change an existing
field or add a new one) you can do so by specifying the `doc` in the `body`
parameter. This merges the fields in `doc` with the existing document.
[source,php]
----
$params = [
'index' => 'my_index',
'id' => 'my_id',
'body' => [
'doc' => [
'new_field' => 'abc'
]
]
];
// Update doc at /my_index/_doc/my_id
$response = $client->update($params);
----
{zwsp} +
[discrete]
==== Scripted document update
Sometimes you need to perform a scripted update, such as incrementing a counter
or appending a new value to an array. To perform a scripted update, you need to
provide a script and usually a set of parameters:
[source,php]
----
$params = [
'index' => 'my_index',
'id' => 'my_id',
'body' => [
'script' => 'ctx._source.counter += count',
'params' => [
'count' => 4
]
]
];
$response = $client->update($params);
----
{zwsp} +
[discrete]
==== Upserts
Upserts are "Update or Insert" operations. This means an upsert attempts to run
your update script, but if the document does not exist (or the field you are
trying to update doesn't exist), default values are inserted instead.
[source,php]
----
$params = [
'index' => 'my_index',
'id' => 'my_id',
'body' => [
'script' => [
'source' => 'ctx._source.counter += params.count',
'params' => [
'count' => 4
],
],
'upsert' => [
'counter' => 1
],
]
];
$response = $client->update($params);
----
{zwsp} +
[[deleting_documents]]
=== Deleting documents
Finally, you can delete documents by specifying their full `/index/_doc_/id`
path:
[source,php]
----
$params = [
'index' => 'my_index',
'id' => 'my_id'
];
// Delete doc at /my_index/_doc_/my_id
$response = $client->delete($params);
----
{zwsp} +
docs/examples/014b788c879e4aaa1020672e45e25473.asciidoc 0000644 00000000366 14373463016 0015104 0 ustar 00 // search.asciidoc:72
[source, php]
----
$params = [
'body' => [
'transient' => [
'cluster.routing.use_adaptive_replica_selection' => false,
],
],
];
$response = $client->cluster()->putSettings($params);
----
docs/examples/015294a400986295039e52ebc62033be.asciidoc 0000644 00000000411 14373463016 0015004 0 ustar 00 // docs/update.asciidoc:251
[source, php]
----
$params = [
'index' => 'test',
'id' => '1',
'body' => [
'doc' => [
'name' => 'new_name',
],
'detect_noop' => false,
],
];
$response = $client->update($params);
----
docs/examples/025b54db0edc50c24ea48a2bd94366ad.asciidoc 0000644 00000000215 14373463016 0015514 0 ustar 00 // docs/update-by-query.asciidoc:606
[source, php]
----
$params = [
'index' => 'twitter',
];
$response = $client->search($params);
----
docs/examples/028f6d6ac2594e20b78b8a8f8cbad49d.asciidoc 0000644 00000002230 14373463016 0015551 0 ustar 00 // aggregations/bucket/terms-aggregation.asciidoc:336
[source, php]
----
$params = [
'body' => [
'aggs' => [
'countries' => [
'terms' => [
'field' => 'artist.country',
'order' => [
[
'rock>playback_stats.avg' => 'desc',
],
[
'_count' => 'desc',
],
],
],
'aggs' => [
'rock' => [
'filter' => [
'term' => [
'genre' => 'rock',
],
],
'aggs' => [
'playback_stats' => [
'stats' => [
'field' => 'play_count',
],
],
],
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/033778305d52746f5ce0a2a922c8e521.asciidoc 0000644 00000000666 14373463016 0015104 0 ustar 00 // aggregations/bucket/terms-aggregation.asciidoc:410
[source, php]
----
$params = [
'body' => [
'aggs' => [
'genres' => [
'terms' => [
'script' => [
'source' => 'doc[\'genre\'].value',
'lang' => 'painless',
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/047266b0d20fdb62ebc72d51952c8f6d.asciidoc 0000644 00000000713 14373463016 0015376 0 ustar 00 // query-dsl/multi-match-query.asciidoc:341
[source, php]
----
$params = [
'body' => [
'query' => [
'multi_match' => [
'query' => 'Will Smith',
'type' => 'cross_fields',
'fields' => [
'first_name',
'last_name',
],
'operator' => 'and',
],
],
],
];
$response = $client->search($params);
----
docs/examples/048d8abd42d094bbdcf4452a58ccb35b.asciidoc 0000644 00000000447 14373463016 0015613 0 ustar 00 // docs/index_.asciidoc:531
[source, php]
----
$params = [
'index' => 'twitter',
'id' => '1',
'body' => [
'user' => 'kimchy',
'post_date' => '2009-11-15T14:12:12',
'message' => 'trying out Elasticsearch',
],
];
$response = $client->create($params);
----
docs/examples/04f5dd677c777bcb15d7d5fa63275fc8.asciidoc 0000644 00000000141 14373463016 0015477 0 ustar 00 // cluster/health.asciidoc:36
[source, php]
----
$response = $client->cluster()->health();
----
docs/examples/04fe1e3a0047b0cdb10987b79fc3f3f3.asciidoc 0000644 00000001215 14373463016 0015447 0 ustar 00 // search/request/sort.asciidoc:568
[source, php]
----
$params = [
'body' => [
'query' => [
'term' => [
'user' => 'kimchy',
],
],
'sort' => [
'_script' => [
'type' => 'number',
'script' => [
'lang' => 'painless',
'source' => 'doc[\'field_name\'].value * params.factor',
'params' => [
'factor' => 1.1,
],
],
'order' => 'asc',
],
],
],
];
$response = $client->search($params);
----
docs/examples/06afce2955f9094d96d27067ebca32e8.asciidoc 0000644 00000002244 14373463016 0015422 0 ustar 00 // query-dsl/bool-query.asciidoc:36
[source, php]
----
$params = [
'body' => [
'query' => [
'bool' => [
'must' => [
'term' => [
'user' => 'kimchy',
],
],
'filter' => [
'term' => [
'tag' => 'tech',
],
],
'must_not' => [
'range' => [
'age' => [
'gte' => 10,
'lte' => 20,
],
],
],
'should' => [
[
'term' => [
'tag' => 'wow',
],
],
[
'term' => [
'tag' => 'elasticsearch',
],
],
],
'minimum_should_match' => 1,
'boost' => 1,
],
],
],
];
$response = $client->search($params);
----
docs/examples/073539a7e38be3cdf13008330b6a536a.asciidoc 0000644 00000000211 14373463016 0015216 0 ustar 00 // cat/indices.asciidoc:100
[source, php]
----
$params = [
'index' => 'twi*',
];
$response = $client->cat()->indices($params);
----
docs/examples/0989cc65d8924f666ce3eb0820d2d244.asciidoc 0000644 00000000473 14373463016 0015262 0 ustar 00 // indices/put-mapping.asciidoc:435
[source, php]
----
$params = [
'index' => 'users',
'body' => [
'user_id' => 12345,
],
];
$response = $client->index($params);
$params = [
'index' => 'users',
'body' => [
'user_id' => 12346,
],
];
$response = $client->index($params);
----
docs/examples/09d617863a103c82fb4101e6165ea7fe.asciidoc 0000644 00000000332 14373463016 0015231 0 ustar 00 // query-dsl/match-all-query.asciidoc:11
[source, php]
----
$params = [
'body' => [
'query' => [
'match_all' => [
],
],
],
];
$response = $client->search($params);
----
docs/examples/09dbd90c5e22ea4a17b4cf9aa72e08ae.asciidoc 0000644 00000000130 14373463016 0015660 0 ustar 00 // api-conventions.asciidoc:231
[source, php]
----
$response = $client->search();
----
docs/examples/09ecba5814d71e4c44468575eada9878.asciidoc 0000644 00000000633 14373463016 0015346 0 ustar 00 // aggregations/bucket/datehistogram-aggregation.asciidoc:214
[source, php]
----
$params = [
'index' => 'sales',
'body' => [
'aggs' => [
'sales_over_time' => [
'date_histogram' => [
'field' => 'date',
'fixed_interval' => '30d',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/0a958e486ede3f519d48431ab689eded.asciidoc 0000644 00000000657 14373463016 0015520 0 ustar 00 // docs/update.asciidoc:271
[source, php]
----
$params = [
'index' => 'test',
'id' => '1',
'body' => [
'script' => [
'source' => 'ctx._source.counter += params.count',
'lang' => 'painless',
'params' => [
'count' => 4,
],
],
'upsert' => [
'counter' => 1,
],
],
];
$response = $client->update($params);
----
docs/examples/0ac9916f47a2483b89c1416684af322a.asciidoc 0000644 00000000624 14373463016 0015165 0 ustar 00 // query-dsl/match-query.asciidoc:241
[source, php]
----
$params = [
'body' => [
'query' => [
'match' => [
'message' => [
'query' => 'to be or not to be',
'operator' => 'and',
'zero_terms_query' => 'all',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/0afaf1cad692e6201aa574c8feb6e622.asciidoc 0000644 00000000623 14373463016 0015606 0 ustar 00 // aggregations/bucket/terms-aggregation.asciidoc:492
[source, php]
----
$params = [
'body' => [
'aggs' => [
'tags' => [
'terms' => [
'field' => 'tags',
'include' => '.*sport.*',
'exclude' => 'water_.*',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/0ba0b2db24852abccb7c0fc1098d566e.asciidoc 0000644 00000000364 14373463016 0015577 0 ustar 00 // docs/get.asciidoc:366
[source, php]
----
$params = [
'index' => 'twitter',
'id' => '2',
'body' => [
'counter' => 1,
'tags' => [
'white',
],
],
];
$response = $client->index($params);
----
docs/examples/0bbd30b9be3e54ff3028b9f4459634d2.asciidoc 0000644 00000000625 14373463016 0015404 0 ustar 00 // indices/put-mapping.asciidoc:171
[source, php]
----
$params = [
'index' => 'my_index',
'body' => [
'properties' => [
'name' => [
'properties' => [
'last' => [
'type' => 'text',
],
],
],
],
],
];
$response = $client->indices()->putMapping($params);
----
docs/examples/0bd3923424a20a4ba860b0774b9991b1.asciidoc 0000644 00000002211 14373463016 0015133 0 ustar 00 // query-dsl/nested-query.asciidoc:206
[source, php]
----
$params = [
'index' => 'drivers',
'body' => [
'query' => [
'nested' => [
'path' => 'driver',
'query' => [
'nested' => [
'path' => 'driver.vehicle',
'query' => [
'bool' => [
'must' => [
[
'match' => [
'driver.vehicle.make' => 'Powell Motors',
],
],
[
'match' => [
'driver.vehicle.model' => 'Canyonero',
],
],
],
],
],
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/0be2c28ee65384774b1e479b47dc3d92.asciidoc 0000644 00000000377 14373463016 0015345 0 ustar 00 // indices/update-settings.asciidoc:120
[source, php]
----
$params = [
'index' => 'twitter',
'body' => [
'index' => [
'refresh_interval' => '1s',
],
],
];
$response = $client->indices()->putSettings($params);
----
docs/examples/0c4ad860a485fe53d8140ad3ccd11dcf.asciidoc 0000644 00000000542 14373463016 0015602 0 ustar 00 // query-dsl/terms-query.asciidoc:19
[source, php]
----
$params = [
'body' => [
'query' => [
'terms' => [
'user' => [
'kimchy',
'elasticsearch',
],
'boost' => 1,
],
],
],
];
$response = $client->search($params);
----
docs/examples/0cc991e3f7f8511a34730e154b3c5edc.asciidoc 0000644 00000000412 14373463016 0015372 0 ustar 00 // docs/reindex.asciidoc:25
[source, php]
----
$params = [
'body' => [
'source' => [
'index' => 'twitter',
],
'dest' => [
'index' => 'new_twitter',
],
],
];
$response = $client->reindex($params);
----
docs/examples/0ce3606f1dba490eef83c4317b315b62.asciidoc 0000644 00000000414 14373463016 0015363 0 ustar 00 // search/request-body.asciidoc:7
[source, php]
----
$params = [
'index' => 'twitter',
'body' => [
'query' => [
'term' => [
'user' => 'kimchy',
],
],
],
];
$response = $client->search($params);
----
docs/examples/0d664883151008b1051ef2c9ab2d0373.asciidoc 0000644 00000001162 14373463016 0015056 0 ustar 00 // docs/update-by-query.asciidoc:537
[source, php]
----
$params = [
'index' => 'twitter',
'body' => [
'slice' => [
'id' => 0,
'max' => 2,
],
'script' => [
'source' => 'ctx._source[\'extra\'] = \'test\'',
],
],
];
$response = $client->updateByQuery($params);
$params = [
'index' => 'twitter',
'body' => [
'slice' => [
'id' => 1,
'max' => 2,
],
'script' => [
'source' => 'ctx._source[\'extra\'] = \'test\'',
],
],
];
$response = $client->updateByQuery($params);
----
docs/examples/0e118857b815b62118a30c042f079db1.asciidoc 0000644 00000000645 14373463016 0015066 0 ustar 00 // query-dsl/multi-match-query.asciidoc:259
[source, php]
----
$params = [
'body' => [
'query' => [
'multi_match' => [
'query' => 'quick brown f',
'type' => 'phrase_prefix',
'fields' => [
'subject',
'message',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/1027ab1ca767ac1428176ef4f84bfbcf.asciidoc 0000644 00000001221 14373463016 0015527 0 ustar 00 // search/request/scroll.asciidoc:206
[source, php]
----
$params = [
'index' => 'twitter',
'body' => [
'slice' => [
'id' => 0,
'max' => 2,
],
'query' => [
'match' => [
'title' => 'elasticsearch',
],
],
],
];
$response = $client->search($params);
$params = [
'index' => 'twitter',
'body' => [
'slice' => [
'id' => 1,
'max' => 2,
],
'query' => [
'match' => [
'title' => 'elasticsearch',
],
],
],
];
$response = $client->search($params);
----
docs/examples/1216f8f7367df3aa823012cef310c08a.asciidoc 0000644 00000000553 14373463016 0015305 0 ustar 00 // docs/reindex.asciidoc:716
[source, php]
----
$params = [
'body' => [
'source' => [
'index' => 'test',
],
'dest' => [
'index' => 'test2',
],
'script' => [
'source' => 'ctx._source.tag = ctx._source.remove("flag")',
],
],
];
$response = $client->reindex($params);
----
docs/examples/12433d2b637d002e8d5c9a1adce69d3b.asciidoc 0000644 00000000233 14373463016 0015442 0 ustar 00 // indices/put-mapping.asciidoc:89
[source, php]
----
$params = [
'index' => 'publications',
];
$response = $client->indices()->create($params);
----
docs/examples/1252fa45847edba5ec2b2f33da70ec5b.asciidoc 0000644 00000000142 14373463016 0015600 0 ustar 00 // api-conventions.asciidoc:282
[source, php]
----
$response = $client->cluster()->state();
----
docs/examples/138ccd89f72aa7502dd9578403dcc589.asciidoc 0000644 00000000216 14373463016 0015341 0 ustar 00 // docs/get.asciidoc:53
[source, php]
----
$params = [
'index' => 'twitter',
'id' => '0',
];
$response = $client->get($params);
----
docs/examples/14701dcc0cca9665fce2aace0cb62af7.asciidoc 0000644 00000000474 14373463016 0015742 0 ustar 00 // docs/delete-by-query.asciidoc:511
[source, php]
----
$params = [
'index' => 'twitter',
'body' => [
'query' => [
'range' => [
'likes' => [
'lt' => 10,
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/1577e6e806b3283c9e99f1596d310754.asciidoc 0000644 00000000343 14373463016 0015052 0 ustar 00 // docs/reindex.asciidoc:704
[source, php]
----
$params = [
'index' => 'test',
'id' => '1',
'body' => [
'text' => 'words words',
'flag' => 'foo',
],
];
$response = $client->index($params);
----
docs/examples/15dad5338065baaaa7d475abe85f4c22.asciidoc 0000644 00000001052 14373463016 0015522 0 ustar 00 // search/request/sort.asciidoc:515
[source, php]
----
$params = [
'body' => [
'sort' => [
[
'_geo_distance' => [
'pin.location' => [
-70,
40,
],
'order' => 'asc',
'unit' => 'km',
],
],
],
'query' => [
'term' => [
'user' => 'kimchy',
],
],
],
];
$response = $client->search($params);
----
docs/examples/162b5b693b713f0bfab1209d59443c46.asciidoc 0000644 00000000561 14373463016 0015232 0 ustar 00 // query-dsl/bool-query.asciidoc:130
[source, php]
----
$params = [
'body' => [
'query' => [
'constant_score' => [
'filter' => [
'term' => [
'status' => 'active',
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/179f0a3e84ff4bbac18787a018eabf89.asciidoc 0000644 00000000735 14373463016 0015561 0 ustar 00 // query-dsl/multi-match-query.asciidoc:472
[source, php]
----
$params = [
'body' => [
'query' => [
'multi_match' => [
'query' => 'Jon',
'type' => 'cross_fields',
'analyzer' => 'standard',
'fields' => [
'first',
'last',
'*.edge',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/17de0020b228df961ad3c6b06233c948.asciidoc 0000644 00000000516 14373463016 0015226 0 ustar 00 // indices/put-mapping.asciidoc:351
[source, php]
----
$params = [
'index' => 'my_index',
'body' => [
'properties' => [
'user_id' => [
'type' => 'keyword',
'ignore_above' => 100,
],
],
],
];
$response = $client->indices()->putMapping($params);
----
docs/examples/189a921df2f5b1fe580937210ce9c1c2.asciidoc 0000644 00000000423 14373463016 0015320 0 ustar 00 // search.asciidoc:96
[source, php]
----
$params = [
'body' => [
'query' => [
'match_all' => [
],
],
'stats' => [
'group1',
'group2',
],
],
];
$response = $client->search($params);
----
docs/examples/18ddb7e7a4bcafd449df956e828ed7a8.asciidoc 0000644 00000000255 14373463016 0015734 0 ustar 00 // docs/update-by-query.asciidoc:498
[source, php]
----
$params = [
'task_id' => 'r1A2WoRbTwKZ516z6NEs5A:36619',
];
$response = $client->tasks()->cancel($params);
----
docs/examples/1aa91d3d48140d6367b6cabca8737b8f.asciidoc 0000644 00000001371 14373463016 0015460 0 ustar 00 // docs/bulk.asciidoc:567
[source, php]
----
$params = [
'body' => [
[
'update' => [
'_id' => '5',
'_index' => 'index1',
],
],
[
'doc' => [
'my_field' => 'foo',
],
],
[
'update' => [
'_id' => '6',
'_index' => 'index1',
],
],
[
'doc' => [
'my_field' => 'foo',
],
],
[
'create' => [
'_id' => '7',
'_index' => 'index1',
],
],
[
'my_field' => 'foo',
],
],
];
$response = $client->bulk($params);
----
docs/examples/1b542e3ea87a742f95641d64dcfb1bdb.asciidoc 0000644 00000000202 14373463016 0015530 0 ustar 00 // search/count.asciidoc:7
[source, php]
----
$params = [
'index' => 'twitter',
];
$response = $client->count($params);
----
docs/examples/1b8655e6ba99fe39933c6eafe78728b7.asciidoc 0000644 00000001236 14373463016 0015446 0 ustar 00 // docs/reindex.asciidoc:204
[source, php]
----
$params = [
'body' => [
'source' => [
'index' => 'twitter',
'slice' => [
'id' => 0,
'max' => 2,
],
],
'dest' => [
'index' => 'new_twitter',
],
],
];
$response = $client->reindex($params);
$params = [
'body' => [
'source' => [
'index' => 'twitter',
'slice' => [
'id' => 1,
'max' => 2,
],
],
'dest' => [
'index' => 'new_twitter',
],
],
];
$response = $client->reindex($params);
----
docs/examples/1b8caf0a6741126c6d0ad83b56fce290.asciidoc 0000644 00000001226 14373463016 0015445 0 ustar 00 // indices/templates.asciidoc:146
[source, php]
----
$params = [
'name' => 'template_1',
'body' => [
'index_patterns' => [
'te*',
],
'settings' => [
'number_of_shards' => 1,
],
'aliases' => [
'alias1' => [
],
'alias2' => [
'filter' => [
'term' => [
'user' => 'kimchy',
],
],
'routing' => 'kimchy',
],
'{index}-alias' => [
],
],
],
];
$response = $client->indices()->putTemplate($params);
----
docs/examples/1bc731a4df952228af6dfa6b48627332.asciidoc 0000644 00000000760 14373463016 0015322 0 ustar 00 // docs/reindex.asciidoc:819
[source, php]
----
$params = [
'body' => [
'max_docs' => 10,
'source' => [
'index' => 'twitter',
'query' => [
'function_score' => [
'random_score' => [
],
'min_score' => 0.9,
],
],
],
'dest' => [
'index' => 'random_twitter',
],
],
];
$response = $client->reindex($params);
----
docs/examples/1c23507edd7a3c18538b68223378e4ab.asciidoc 0000644 00000000227 14373463016 0015237 0 ustar 00 // indices/create-index.asciidoc:10
[source, php]
----
$params = [
'index' => 'twitter',
];
$response = $client->indices()->create($params);
----
docs/examples/1d65cb6d055c46a1bde809687d835b71.asciidoc 0000644 00000000216 14373463016 0015326 0 ustar 00 // docs/get.asciidoc:86
[source, php]
----
$params = [
'index' => 'twitter',
'id' => '2',
];
$response = $client->get($params);
----
docs/examples/1da77e114459e0b77d78a3dcc8fae429.asciidoc 0000644 00000000751 14373463016 0015475 0 ustar 00 // indices/put-mapping.asciidoc:114
[source, php]
----
$params = [
'index' => 'twitter-1',
];
$response = $client->indices()->create($params);
$params = [
'index' => 'twitter-2',
];
$response = $client->indices()->create($params);
$params = [
'index' => 'twitter-1,twitter-2',
'body' => [
'properties' => [
'user_name' => [
'type' => 'text',
],
],
],
];
$response = $client->indices()->putMapping($params);
----
docs/examples/1dbb8cf17fbc45c87c7d2f75f15f9778.asciidoc 0000644 00000000142 14373463016 0015570 0 ustar 00 // api-conventions.asciidoc:259
[source, php]
----
$response = $client->cluster()->state();
----
docs/examples/1e18a67caf8f06ff2710ec4a8b30f625.asciidoc 0000644 00000000142 14373463016 0015453 0 ustar 00 // api-conventions.asciidoc:326
[source, php]
----
$response = $client->cluster()->state();
----
docs/examples/1e49eba5b9042c1900a608fe5105ba43.asciidoc 0000644 00000001346 14373463016 0015301 0 ustar 00 // docs/delete-by-query.asciidoc:421
[source, php]
----
$params = [
'index' => 'twitter',
'body' => [
'slice' => [
'id' => 0,
'max' => 2,
],
'query' => [
'range' => [
'likes' => [
'lt' => 10,
],
],
],
],
];
$response = $client->deleteByQuery($params);
$params = [
'index' => 'twitter',
'body' => [
'slice' => [
'id' => 1,
'max' => 2,
],
'query' => [
'range' => [
'likes' => [
'lt' => 10,
],
],
],
],
];
$response = $client->deleteByQuery($params);
----
docs/examples/1e50d993bd6517e6c381e82d09f0389e.asciidoc 0000644 00000000450 14373463016 0015261 0 ustar 00 // search/request/from-size.asciidoc:22
[source, php]
----
$params = [
'body' => [
'from' => 5,
'size' => 20,
'query' => [
'term' => [
'user.id' => '8a4f500d',
],
],
],
];
$response = $client->search($params);
----
docs/examples/1f336ecc62480c1d56351cc2f82d0d08.asciidoc 0000644 00000000372 14373463016 0015310 0 ustar 00 // docs/index_.asciidoc:440
[source, php]
----
$params = [
'index' => 'twitter',
'id' => '1',
'body' => [
'message' => 'elasticsearch now has versioning support, double cool!',
],
];
$response = $client->index($params);
----
docs/examples/1f6fe6833686e38c3711c6f2aa00a078.asciidoc 0000644 00000000604 14373463016 0015242 0 ustar 00 // indices/put-mapping.asciidoc:332
[source, php]
----
$params = [
'index' => 'my_index',
'body' => [
'mappings' => [
'properties' => [
'user_id' => [
'type' => 'keyword',
'ignore_above' => 20,
],
],
],
],
];
$response = $client->indices()->create($params);
----
docs/examples/210cf5c76bff517f48e80fa1c2d63907.asciidoc 0000644 00000000234 14373463016 0015404 0 ustar 00 // indices/put-mapping.asciidoc:561
[source, php]
----
$params = [
'index' => 'my_index',
];
$response = $client->indices()->getMapping($params);
----
docs/examples/213ab768f1b6a895e09403a0880e259a.asciidoc 0000644 00000001021 14373463016 0015152 0 ustar 00 // aggregations/metrics/valuecount-aggregation.asciidoc:65
[source, php]
----
$params = [
'index' => 'sales',
'body' => [
'aggs' => [
'types_count' => [
'value_count' => [
'script' => [
'id' => 'my_script',
'params' => [
'field' => 'type',
],
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/216848930c2d344fe0bed0daa70c35b9.asciidoc 0000644 00000000144 14373463016 0015365 0 ustar 00 // docs/delete-by-query.asciidoc:593
[source, php]
----
$response = $client->tasks()->list();
----
docs/examples/22334f4b24bb8977d3e1bf2ffdc29d3f.asciidoc 0000644 00000003646 14373463016 0015556 0 ustar 00 // search/request/sort.asciidoc:289
[source, php]
----
$params = [
'body' => [
'query' => [
'nested' => [
'path' => 'parent',
'query' => [
'bool' => [
'must' => [
'range' => [
'parent.age' => [
'gte' => 21,
],
],
],
'filter' => [
'nested' => [
'path' => 'parent.child',
'query' => [
'match' => [
'parent.child.name' => 'matt',
],
],
],
],
],
],
],
],
'sort' => [
[
'parent.child.age' => [
'mode' => 'min',
'order' => 'asc',
'nested' => [
'path' => 'parent',
'filter' => [
'range' => [
'parent.age' => [
'gte' => 21,
],
],
],
'nested' => [
'path' => 'parent.child',
'filter' => [
'match' => [
'parent.child.name' => 'matt',
],
],
],
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/231aa0bb39c35fe199d28fe0e4a62b2e.asciidoc 0000644 00000000425 14373463016 0015526 0 ustar 00 // getting-started.asciidoc:495
[source, php]
----
$params = [
'index' => 'bank',
'body' => [
'query' => [
'match_phrase' => [
'address' => 'mill lane',
],
],
],
];
$response = $client->search($params);
----
docs/examples/23ab0f1023b1b2cd5cdf2a8f9ccfd57b.asciidoc 0000644 00000000520 14373463016 0015731 0 ustar 00 // indices/aliases.asciidoc:304
[source, php]
----
$params = [
'index' => 'test1',
'body' => [
'mappings' => [
'properties' => [
'user' => [
'type' => 'keyword',
],
],
],
],
];
$response = $client->indices()->create($params);
----
docs/examples/2468ab381257d759d8a88af1141f6f9c.asciidoc 0000644 00000000230 14373463016 0015256 0 ustar 00 // docs/get.asciidoc:288
[source, php]
----
$params = [
'index' => 'twitter',
'id' => '1',
];
$response = $client->existsSource($params);
----
docs/examples/251ea12c1248385ab409906ac64d9ee9.asciidoc 0000644 00000001121 14373463016 0015233 0 ustar 00 // getting-started.asciidoc:544
[source, php]
----
$params = [
'index' => 'bank',
'body' => [
'query' => [
'bool' => [
'must' => [
'match_all' => [
],
],
'filter' => [
'range' => [
'balance' => [
'gte' => 20000,
'lte' => 30000,
],
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/2533e4b36ae837eaecda08407ecb6383.asciidoc 0000644 00000001016 14373463016 0015453 0 ustar 00 // search/suggesters.asciidoc:51
[source, php]
----
$params = [
'body' => [
'suggest' => [
'my-suggest-1' => [
'text' => 'tring out Elasticsearch',
'term' => [
'field' => 'message',
],
],
'my-suggest-2' => [
'text' => 'kmichy',
'term' => [
'field' => 'user',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/2891aa10ee9d474780adf94d5607f2db.asciidoc 0000644 00000000517 14373463016 0015413 0 ustar 00 // search/request/sort.asciidoc:153
[source, php]
----
$params = [
'index' => 'index_long,index_double',
'body' => [
'sort' => [
[
'field' => [
'numeric_type' => 'double',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/28aad2c5942bfb221c2bf1bbdc01658e.asciidoc 0000644 00000000544 14373463016 0015575 0 ustar 00 // query-dsl/query-string-query.asciidoc:316
[source, php]
----
$params = [
'body' => [
'query' => [
'query_string' => [
'fields' => [
'city.*',
],
'query' => 'this AND that OR thus',
],
],
],
];
$response = $client->search($params);
----
docs/examples/2a1de18774f9c68cafa169847832b2bc.asciidoc 0000644 00000000531 14373463016 0015413 0 ustar 00 // query-dsl/term-query.asciidoc:94
[source, php]
----
$params = [
'index' => 'my_index',
'body' => [
'mappings' => [
'properties' => [
'full_text' => [
'type' => 'text',
],
],
],
],
];
$response = $client->indices()->create($params);
----
docs/examples/2bb2339ac055337abf753bddb7771659.asciidoc 0000644 00000000632 14373463016 0015321 0 ustar 00 // aggregations/bucket/datehistogram-aggregation.asciidoc:232
[source, php]
----
$params = [
'index' => 'sales',
'body' => [
'aggs' => [
'sales_over_time' => [
'date_histogram' => [
'field' => 'date',
'fixed_interval' => '2w',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/2fd69fb0538e4f36ac69a8b8f8bf5ae8.asciidoc 0000644 00000000610 14373463016 0015647 0 ustar 00 // docs/update-by-query.asciidoc:355
[source, php]
----
$params = [
'index' => 'twitter',
'body' => [
'script' => [
'source' => 'ctx._source.likes++',
'lang' => 'painless',
],
'query' => [
'term' => [
'user' => 'kimchy',
],
],
],
];
$response = $client->updateByQuery($params);
----
docs/examples/2fe28d9a91b3081a9ec4601af8fb7b1c.asciidoc 0000644 00000001773 14373463016 0015546 0 ustar 00 // docs/update-by-query.asciidoc:662
[source, php]
----
$params = [
'index' => 'test',
'body' => [
'mappings' => [
'dynamic' => false,
'properties' => [
'text' => [
'type' => 'text',
],
],
],
],
];
$response = $client->indices()->create($params);
$params = [
'index' => 'test',
'body' => [
'text' => 'words words',
'flag' => 'bar',
],
];
$response = $client->index($params);
$params = [
'index' => 'test',
'body' => [
'text' => 'words words',
'flag' => 'foo',
],
];
$response = $client->index($params);
$params = [
'index' => 'test',
'body' => [
'properties' => [
'text' => [
'type' => 'text',
],
'flag' => [
'type' => 'text',
'analyzer' => 'keyword',
],
],
],
];
$response = $client->indices()->putMapping($params);
----
docs/examples/311c4b632a29b9ead63b02d01f10096b.asciidoc 0000644 00000000316 14373463016 0015264 0 ustar 00 // getting-started.asciidoc:251
[source, php]
----
$params = [
'index' => 'customer',
'id' => '1',
'body' => [
'name' => 'John Doe',
],
];
$response = $client->index($params);
----
docs/examples/3342c69b2c2303247217532956fcce85.asciidoc 0000644 00000000367 14373463016 0015026 0 ustar 00 // query-dsl/exists-query.asciidoc:20
[source, php]
----
$params = [
'body' => [
'query' => [
'exists' => [
'field' => 'user',
],
],
],
];
$response = $client->search($params);
----
docs/examples/33f148e3d8676de6cc52f58749898a13.asciidoc 0000644 00000001167 14373463016 0015226 0 ustar 00 // query-dsl/multi-match-query.asciidoc:275
[source, php]
----
$params = [
'body' => [
'query' => [
'dis_max' => [
'queries' => [
[
'match_phrase_prefix' => [
'subject' => 'quick brown f',
],
],
[
'match_phrase_prefix' => [
'message' => 'quick brown f',
],
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/34efeade38445b2834749ced59782e25.asciidoc 0000644 00000001220 14373463016 0015342 0 ustar 00 // aggregations/bucket/terms-aggregation.asciidoc:263
[source, php]
----
$params = [
'body' => [
'aggs' => [
'genres' => [
'terms' => [
'field' => 'genre',
'order' => [
'playback_stats.max' => 'desc',
],
],
'aggs' => [
'playback_stats' => [
'stats' => [
'field' => 'play_count',
],
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/35e8da9410b8432cf4095f2541ad7b1d.asciidoc 0000644 00000000631 14373463016 0015313 0 ustar 00 // aggregations/bucket/terms-aggregation.asciidoc:162
[source, php]
----
$params = [
'body' => [
'aggs' => [
'products' => [
'terms' => [
'field' => 'product',
'size' => 5,
'show_term_doc_count_error' => true,
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/3653567181f43a5f64c74f934aa821c2.asciidoc 0000644 00000000530 14373463016 0015104 0 ustar 00 // indices/aliases.asciidoc:186
[source, php]
----
$params = [
'body' => [
'actions' => [
[
'remove' => [
'index' => 'test1',
'alias' => 'alias1',
],
],
],
],
];
$response = $client->indices()->updateAliases($params);
----
docs/examples/36818c6d9f434d387819c30bd9addb14.asciidoc 0000644 00000000425 14373463016 0015337 0 ustar 00 // docs/index_.asciidoc:237
[source, php]
----
$params = [
'index' => 'twitter',
'body' => [
'user' => 'kimchy',
'post_date' => '2009-11-15T14:12:12',
'message' => 'trying out Elasticsearch',
],
];
$response = $client->index($params);
----
docs/examples/36b2778f23d0955255f52c075c4d213d.asciidoc 0000644 00000001051 14373463016 0015077 0 ustar 00 // docs/reindex.asciidoc:905
[source, php]
----
$params = [
'body' => [
'source' => [
'remote' => [
'host' => 'http://otherhost:9200',
'username' => 'user',
'password' => 'pass',
],
'index' => 'source',
'query' => [
'match' => [
'test' => 'data',
],
],
],
'dest' => [
'index' => 'dest',
],
],
];
$response = $client->reindex($params);
----
docs/examples/3722cb3705b6bc7f486969deace3dd83.asciidoc 0000644 00000000656 14373463016 0015505 0 ustar 00 // aggregations/metrics/valuecount-aggregation.asciidoc:46
[source, php]
----
$params = [
'index' => 'sales',
'body' => [
'aggs' => [
'type_count' => [
'value_count' => [
'script' => [
'source' => 'doc[\'type\'].value',
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/381fced1882ca8337143e6bb180a5715.asciidoc 0000644 00000000361 14373463016 0015235 0 ustar 00 // docs/update.asciidoc:84
[source, php]
----
$params = [
'index' => 'test',
'id' => '1',
'body' => [
'counter' => 1,
'tags' => [
'red',
],
],
];
$response = $client->index($params);
----
docs/examples/38c1d0f6668e9563c0827f839f9fa505.asciidoc 0000644 00000000351 14373463016 0015214 0 ustar 00 // docs/update.asciidoc:218
[source, php]
----
$params = [
'index' => 'test',
'id' => '1',
'body' => [
'doc' => [
'name' => 'new_name',
],
],
];
$response = $client->update($params);
----
docs/examples/39a6a038c4b551022afe83de0523634e.asciidoc 0000644 00000000710 14373463016 0015221 0 ustar 00 // aggregations/bucket/datehistogram-aggregation.asciidoc:636
[source, php]
----
$params = [
'index' => 'sales',
'body' => [
'aggs' => [
'sale_date' => [
'date_histogram' => [
'field' => 'date',
'calendar_interval' => 'year',
'missing' => '2000/01/01',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/3a700f836d8d5da1b656a876554028aa.asciidoc 0000644 00000000770 14373463016 0015244 0 ustar 00 // search/request/scroll.asciidoc:172
[source, php]
----
$params = [
'body' => [
'scroll_id' => [
'DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==',
'DnF1ZXJ5VGhlbkZldGNoBQAAAAAAAAABFmtSWWRRWUJrU2o2ZExpSGJCVmQxYUEAAAAAAAAAAxZrUllkUVlCa1NqNmRMaUhiQlZkMWFBAAAAAAAAAAIWa1JZZFFZQmtTajZkTGlIYkJWZDFhQQAAAAAAAAAFFmtSWWRRWUJrU2o2ZExpSGJCVmQxYUEAAAAAAAAABBZrUllkUVlCa1NqNmRMaUhiQlZkMWFB',
],
],
];
$response = $client->clearScroll($params);
----
docs/examples/3ae03ba3b56e5e287953094050766738.asciidoc 0000644 00000000264 14373463016 0015031 0 ustar 00 // docs/reindex.asciidoc:237
[source, php]
----
$response = $client->indices()->refresh();
$params = [
'index' => 'new_twitter',
];
$response = $client->search($params);
----
docs/examples/3b04cc894e6a47d57983484010feac0c.asciidoc 0000644 00000000420 14373463016 0015316 0 ustar 00 // docs/reindex.asciidoc:804
[source, php]
----
$params = [
'index' => 'metricbeat-2016.05.30-1',
'id' => '1',
];
$response = $client->get($params);
$params = [
'index' => 'metricbeat-2016.05.31-1',
'id' => '1',
];
$response = $client->get($params);
----
docs/examples/3cd50a789b8e1f0ebbbc53a8d7ecf656.asciidoc 0000644 00000002017 14373463016 0015707 0 ustar 00 // query-dsl/multi-match-query.asciidoc:438
[source, php]
----
$params = [
'body' => [
'query' => [
'bool' => [
'should' => [
[
'multi_match' => [
'query' => 'Will Smith',
'type' => 'cross_fields',
'fields' => [
'first',
'last',
],
'minimum_should_match' => '50%',
],
],
[
'multi_match' => [
'query' => 'Will Smith',
'type' => 'cross_fields',
'fields' => [
'*.edge',
],
],
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/3d1ff6097e2359f927c88c2ccdb36252.asciidoc 0000644 00000000140 14373463016 0015333 0 ustar 00 // setup/install/check-running.asciidoc:7
[source, php]
----
$response = $client->info();
----
docs/examples/3e573bfabe00f8bfb8bb69aa5820768e.asciidoc 0000644 00000000547 14373463016 0015633 0 ustar 00 // docs/delete-by-query.asciidoc:456
[source, php]
----
$response = $client->indices()->refresh();
$params = [
'index' => 'twitter',
'body' => [
'query' => [
'range' => [
'likes' => [
'lt' => 10,
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/3f3b3e207f79303ce6f86e03e928e062.asciidoc 0000644 00000000227 14373463016 0015253 0 ustar 00 // getting-started.asciidoc:290
[source, php]
----
$params = [
'index' => 'customer',
'id' => '1',
];
$response = $client->get($params);
----
docs/examples/400e89eb46ead8e9c9e40f123fd5e590.asciidoc 0000644 00000000477 14373463016 0015506 0 ustar 00 // docs/reindex.asciidoc:398
[source, php]
----
$params = [
'body' => [
'source' => [
'index' => 'source',
'size' => 100,
],
'dest' => [
'index' => 'dest',
'routing' => '=cat',
],
],
];
$response = $client->reindex($params);
----
docs/examples/42744a175125df5be0ef77413bf8f608.asciidoc 0000644 00000000376 14373463016 0015254 0 ustar 00 // indices/update-settings.asciidoc:79
[source, php]
----
$params = [
'index' => 'twitter',
'body' => [
'index' => [
'refresh_interval' => null,
],
],
];
$response = $client->indices()->putSettings($params);
----
docs/examples/427f6b5c5376cbf0f71f242a60ca3d9e.asciidoc 0000644 00000000207 14373463016 0015456 0 ustar 00 // indices/aliases.asciidoc:394
[source, php]
----
$params = [
'index' => 'alias2',
];
$response = $client->search($params);
----
docs/examples/43af86de5e49aa06070092fffc138208.asciidoc 0000644 00000000551 14373463016 0015322 0 ustar 00 // query-dsl/exists-query.asciidoc:56
[source, php]
----
$params = [
'body' => [
'query' => [
'bool' => [
'must_not' => [
'exists' => [
'field' => 'user',
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/4646764bf09911fee7d58630c72d3137.asciidoc 0000644 00000000752 14373463016 0015124 0 ustar 00 // aggregations/bucket/terms-aggregation.asciidoc:444
[source, php]
----
$params = [
'body' => [
'aggs' => [
'genres' => [
'terms' => [
'script' => [
'id' => 'my_script',
'params' => [
'field' => 'genre',
],
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/46658f00edc4865dfe472a392374cd0f.asciidoc 0000644 00000000234 14373463016 0015333 0 ustar 00 // indices/templates.asciidoc:249
[source, php]
----
$params = [
'name' => 'template_1',
];
$response = $client->indices()->getTemplate($params);
----
docs/examples/46c4b0dfb674825f9579203d41e7f404.asciidoc 0000644 00000000530 14373463016 0015171 0 ustar 00 // mapping/types/keyword.asciidoc:20
[source, php]
----
$params = [
'index' => 'my_index',
'body' => [
'mappings' => [
'properties' => [
'tags' => [
'type' => 'keyword',
],
],
],
],
];
$response = $client->indices()->create($params);
----
docs/examples/47b5ff897f26e9c943cee5c06034181d.asciidoc 0000644 00000000224 14373463016 0015343 0 ustar 00 // docs/delete.asciidoc:75
[source, php]
----
$params = [
'index' => 'twitter',
'id' => '1',
];
$response = $client->delete($params);
----
docs/examples/47bb632c6091ad0cd94bc660bdd309a5.asciidoc 0000644 00000001167 14373463016 0015450 0 ustar 00 // getting-started.asciidoc:512
[source, php]
----
$params = [
'index' => 'bank',
'body' => [
'query' => [
'bool' => [
'must' => [
[
'match' => [
'age' => '40',
],
],
],
'must_not' => [
[
'match' => [
'state' => 'ID',
],
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/4acf902c2598b2558f34f20c1744c433.asciidoc 0000644 00000000270 14373463016 0015156 0 ustar 00 // docs/update-by-query.asciidoc:564
[source, php]
----
$response = $client->indices()->refresh();
$params = [
'index' => 'twitter',
];
$response = $client->search($params);
----
docs/examples/4b90feb9d5d3dbfce424dac0341320b7.asciidoc 0000644 00000000573 14373463016 0015606 0 ustar 00 // getting-started.asciidoc:461
[source, php]
----
$params = [
'index' => 'bank',
'body' => [
'query' => [
'match_all' => [
],
],
'sort' => [
[
'account_number' => 'asc',
],
],
'from' => 10,
'size' => 10,
],
];
$response = $client->search($params);
----
docs/examples/4cd246e5c4c035a2cd4081ae9a3d54e5.asciidoc 0000644 00000000562 14373463016 0015447 0 ustar 00 // docs/update.asciidoc:114
[source, php]
----
$params = [
'index' => 'test',
'id' => '1',
'body' => [
'script' => [
'source' => 'ctx._source.tags.add(params.tag)',
'lang' => 'painless',
'params' => [
'tag' => 'blue',
],
],
],
];
$response = $client->update($params);
----
docs/examples/4d46dbb96125b27f46299547de9d8709.asciidoc 0000644 00000000410 14373463016 0015211 0 ustar 00 // indices/create-index.asciidoc:190
[source, php]
----
$params = [
'index' => 'test',
'body' => [
'settings' => [
'index.write.wait_for_active_shards' => '2',
],
],
];
$response = $client->indices()->create($params);
----
docs/examples/4d56b179242fed59e3d6476f817b6055.asciidoc 0000644 00000000735 14373463016 0015213 0 ustar 00 // indices/create-index.asciidoc:143
[source, php]
----
$params = [
'index' => 'test',
'body' => [
'aliases' => [
'alias_1' => [
],
'alias_2' => [
'filter' => [
'term' => [
'user' => 'kimchy',
],
],
'routing' => 'kimchy',
],
],
],
];
$response = $client->indices()->create($params);
----
docs/examples/4d6997c70a1851f9151443c0d38b532e.asciidoc 0000644 00000002151 14373463016 0015104 0 ustar 00 // mapping/types/array.asciidoc:42
[source, php]
----
$params = [
'index' => 'my_index',
'id' => '1',
'body' => [
'message' => 'some arrays in this document...',
'tags' => [
'elasticsearch',
'wow',
],
'lists' => [
[
'name' => 'prog_list',
'description' => 'programming list',
],
[
'name' => 'cool_list',
'description' => 'cool stuff list',
],
],
],
];
$response = $client->index($params);
$params = [
'index' => 'my_index',
'id' => '2',
'body' => [
'message' => 'no arrays in this document...',
'tags' => 'elasticsearch',
'lists' => [
'name' => 'prog_list',
'description' => 'programming list',
],
],
];
$response = $client->index($params);
$params = [
'index' => 'my_index',
'body' => [
'query' => [
'match' => [
'tags' => 'elasticsearch',
],
],
],
];
$response = $client->search($params);
----
docs/examples/5043b83a89091fa00edb341ddf7ba370.asciidoc 0000644 00000000542 14373463016 0015362 0 ustar 00 // query-dsl/match-query.asciidoc:219
[source, php]
----
$params = [
'body' => [
'query' => [
'match' => [
'message' => [
'query' => 'this is a testt',
'fuzziness' => 'AUTO',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/506844befdc5691d835771bcbb1c1a60.asciidoc 0000644 00000000517 14373463016 0015377 0 ustar 00 // getting-started.asciidoc:392
[source, php]
----
$params = [
'index' => 'bank',
'body' => [
'query' => [
'match_all' => [
],
],
'sort' => [
[
'account_number' => 'asc',
],
],
],
];
$response = $client->search($params);
----
docs/examples/5271f4ff29bb48838396e5a674664ee0.asciidoc 0000644 00000002335 14373463016 0015216 0 ustar 00 // mapping/params/multi-fields.asciidoc:10
[source, php]
----
$params = [
'index' => 'my_index',
'body' => [
'mappings' => [
'properties' => [
'city' => [
'type' => 'text',
'fields' => [
'raw' => [
'type' => 'keyword',
],
],
],
],
],
],
];
$response = $client->indices()->create($params);
$params = [
'index' => 'my_index',
'id' => '1',
'body' => [
'city' => 'New York',
],
];
$response = $client->index($params);
$params = [
'index' => 'my_index',
'id' => '2',
'body' => [
'city' => 'York',
],
];
$response = $client->index($params);
$params = [
'index' => 'my_index',
'body' => [
'query' => [
'match' => [
'city' => 'york',
],
],
'sort' => [
'city.raw' => 'asc',
],
'aggs' => [
'Cities' => [
'terms' => [
'field' => 'city.raw',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/527324766814561b75aaee853ede49a7.asciidoc 0000644 00000000543 14373463016 0015202 0 ustar 00 // aggregations/bucket/terms-aggregation.asciidoc:369
[source, php]
----
$params = [
'body' => [
'aggs' => [
'tags' => [
'terms' => [
'field' => 'tags',
'min_doc_count' => 10,
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/5275842787967b6db876025f4a1c6942.asciidoc 0000644 00000000747 14373463016 0015003 0 ustar 00 // search/suggesters.asciidoc:127
[source, php]
----
$params = [
'body' => [
'suggest' => [
'text' => 'tring out Elasticsearch',
'my-suggest-1' => [
'term' => [
'field' => 'message',
],
],
'my-suggest-2' => [
'term' => [
'field' => 'user',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/52a87b81e4e0b6b11e23e85db1602a63.asciidoc 0000644 00000000426 14373463016 0015303 0 ustar 00 // docs/update-by-query.asciidoc:307
[source, php]
----
$params = [
'index' => 'twitter',
'body' => [
'query' => [
'term' => [
'user' => 'kimchy',
],
],
],
];
$response = $client->updateByQuery($params);
----
docs/examples/52b2bfbdd78f8283b6f4891c48013237.asciidoc 0000644 00000000444 14373463016 0015254 0 ustar 00 // docs/reindex.asciidoc:635
[source, php]
----
$params = [
'body' => [
'max_docs' => 1,
'source' => [
'index' => 'twitter',
],
'dest' => [
'index' => 'new_twitter',
],
],
];
$response = $client->reindex($params);
----
docs/examples/52c7e4172a446c394210a07c464c57d2.asciidoc 0000644 00000000265 14373463016 0015072 0 ustar 00 // docs/delete-by-query.asciidoc:579
[source, php]
----
$params = [
'task_id' => 'r1A2WoRbTwKZ516z6NEs5A:36619',
];
$response = $client->deleteByQueryRethrottle($params);
----
docs/examples/53b908c3432118c5a6e460f74d32006b.asciidoc 0000644 00000000572 14373463016 0015070 0 ustar 00 // query-dsl/multi-match-query.asciidoc:11
[source, php]
----
$params = [
'body' => [
'query' => [
'multi_match' => [
'query' => 'this is a test',
'fields' => [
'subject',
'message',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/53d938c754f36a912fcbe6473abb463f.asciidoc 0000644 00000000416 14373463016 0015414 0 ustar 00 // indices/put-mapping.asciidoc:473
[source, php]
----
$params = [
'body' => [
'source' => [
'index' => 'users',
],
'dest' => [
'index' => 'new_users',
],
],
];
$response = $client->reindex($params);
----
docs/examples/54092c8c646133f5dbbc047990dd458d.asciidoc 0000644 00000001723 14373463016 0015254 0 ustar 00 // query-dsl/nested-query.asciidoc:133
[source, php]
----
$params = [
'index' => 'drivers',
'body' => [
'mappings' => [
'properties' => [
'driver' => [
'type' => 'nested',
'properties' => [
'last_name' => [
'type' => 'text',
],
'vehicle' => [
'type' => 'nested',
'properties' => [
'make' => [
'type' => 'text',
],
'model' => [
'type' => 'text',
],
],
],
],
],
],
],
],
];
$response = $client->indices()->create($params);
----
docs/examples/54a770f053f3225ea0d1e34334232411.asciidoc 0000644 00000000224 14373463016 0014764 0 ustar 00 // docs/update-by-query.asciidoc:343
[source, php]
----
$params = [
'index' => 'twitter',
];
$response = $client->updateByQuery($params);
----
docs/examples/58b5003c0a53a39bf509aa3797aad471.asciidoc 0000644 00000000605 14373463016 0015305 0 ustar 00 // query-dsl/query-string-query.asciidoc:352
[source, php]
----
$params = [
'body' => [
'query' => [
'query_string' => [
'fields' => [
'content',
'name.*^5',
],
'query' => 'this AND that OR thus',
],
],
],
];
$response = $client->search($params);
----
docs/examples/58df61acbfb15b8ef0aaa18b81ae98a6.asciidoc 0000644 00000000342 14373463016 0015753 0 ustar 00 // docs/update.asciidoc:164
[source, php]
----
$params = [
'index' => 'test',
'id' => '1',
'body' => [
'script' => 'ctx._source.remove(\'new_field\')',
],
];
$response = $client->update($params);
----
docs/examples/5925c23a173a63bdb30b458248d1df76.asciidoc 0000644 00000000230 14373463016 0015226 0 ustar 00 // api-conventions.asciidoc:416
[source, php]
----
$params = [
'index' => 'twitter',
];
$response = $client->indices()->getSettings($params);
----
docs/examples/5b7d6f1db88ca6f42c48fa3dbb4341e8.asciidoc 0000644 00000000435 14373463016 0015627 0 ustar 00 // indices/get-mapping.asciidoc:78
[source, php]
----
$params = [
'index' => '*',
];
$response = $client->indices()->getMapping($params);
$params = [
'index' => '_all',
];
$response = $client->indices()->getMapping($params);
$response = $client->indices()->getMapping();
----
docs/examples/5be23858b35043fcb7b50fe36b873e6e.asciidoc 0000644 00000000443 14373463016 0015411 0 ustar 00 // indices/put-mapping.asciidoc:13
[source, php]
----
$params = [
'index' => 'twitter',
'body' => [
'properties' => [
'email' => [
'type' => 'keyword',
],
],
],
];
$response = $client->indices()->putMapping($params);
----
docs/examples/5c2f486c27bd5346e512265f93375d16.asciidoc 0000644 00000000614 14373463016 0015115 0 ustar 00 // query-dsl/range-query.asciidoc:219
[source, php]
----
$params = [
'body' => [
'query' => [
'range' => [
'timestamp' => [
'time_zone' => '+01:00',
'gte' => '2020-01-01T00:00:00',
'lte' => 'now',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/5d32279dcd52b22d9e1178a02a3ad957.asciidoc 0000644 00000000417 14373463016 0015316 0 ustar 00 // search.asciidoc:18
[source, php]
----
$params = [
'index' => 'twitter',
'body' => [
'user' => 'kimchy',
'post_date' => '2009-11-15T14:12:12',
'message' => 'trying out Elasticsearch',
],
];
$response = $client->index($params);
----
docs/examples/5d9d7b84e2fec7ecd832145cbb951cf1.asciidoc 0000644 00000001541 14373463016 0015633 0 ustar 00 // aggregations/bucket/terms-aggregation.asciidoc:549
[source, php]
----
$params = [
'body' => [
'size' => 0,
'aggs' => [
'expired_sessions' => [
'terms' => [
'field' => 'account_id',
'include' => [
'partition' => 0,
'num_partitions' => 20,
],
'size' => 10000,
'order' => [
'last_access' => 'asc',
],
],
'aggs' => [
'last_access' => [
'max' => [
'field' => 'access_date',
],
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/5da6efd5b038ada64c9e853c88c1ec47.asciidoc 0000644 00000000705 14373463016 0015636 0 ustar 00 // query-dsl/multi-match-query.asciidoc:113
[source, php]
----
$params = [
'body' => [
'query' => [
'multi_match' => [
'query' => 'brown fox',
'type' => 'best_fields',
'fields' => [
'subject',
'message',
],
'tie_breaker' => 0.3,
],
],
],
];
$response = $client->search($params);
----
docs/examples/5dd695679b5141d9142d3d30ba8d300a.asciidoc 0000644 00000000542 14373463016 0015232 0 ustar 00 // aggregations/metrics/valuecount-aggregation.asciidoc:13
[source, php]
----
$params = [
'index' => 'sales',
'body' => [
'aggs' => [
'types_count' => [
'value_count' => [
'field' => 'type',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/5eabcdbf61bfcb484dc694f25c2bba36.asciidoc 0000644 00000000362 14373463016 0016033 0 ustar 00 // docs/get.asciidoc:323
[source, php]
----
$params = [
'index' => 'twitter',
'id' => '1',
'body' => [
'counter' => 1,
'tags' => [
'red',
],
],
];
$response = $client->index($params);
----
docs/examples/5f210f74725ea0c9265190346edfa246.asciidoc 0000644 00000000651 14373463016 0015161 0 ustar 00 // indices/aliases.asciidoc:236
[source, php]
----
$params = [
'body' => [
'actions' => [
[
'add' => [
'indices' => [
'test1',
'test2',
],
'alias' => 'alias1',
],
],
],
],
];
$response = $client->indices()->updateAliases($params);
----
docs/examples/5f3549ac7fee94682ca0d7439eebdd2a.asciidoc 0000644 00000000523 14373463016 0015636 0 ustar 00 // search/request/sort.asciidoc:211
[source, php]
----
$params = [
'index' => 'index_long,index_double',
'body' => [
'sort' => [
[
'field' => [
'numeric_type' => 'date_nanos',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/5f3a3eefeefe6fa85ec49d499212d245.asciidoc 0000644 00000000665 14373463016 0015653 0 ustar 00 // indices/put-mapping.asciidoc:262
[source, php]
----
$params = [
'index' => 'my_index',
'body' => [
'properties' => [
'city' => [
'type' => 'text',
'fields' => [
'raw' => [
'type' => 'keyword',
],
],
],
],
],
];
$response = $client->indices()->putMapping($params);
----
docs/examples/609260ad1d5998be2ca09ff1fe237efa.asciidoc 0000644 00000000220 14373463016 0015540 0 ustar 00 // mapping.asciidoc:217
[source, php]
----
$params = [
'index' => 'my-index',
];
$response = $client->indices()->getMapping($params);
----
docs/examples/60ee33f3acfdd0fe6f288ac77312c780.asciidoc 0000644 00000000611 14373463016 0015542 0 ustar 00 // query-dsl/query-string-query.asciidoc:446
[source, php]
----
$params = [
'body' => [
'query' => [
'query_string' => [
'fields' => [
'title',
],
'query' => 'this that thus',
'minimum_should_match' => 2,
],
],
],
];
$response = $client->search($params);
----
docs/examples/6138d6919f3cbaaf61e1092f817d295c.asciidoc 0000644 00000000537 14373463016 0015337 0 ustar 00 // query-dsl/match-query.asciidoc:175
[source, php]
----
$params = [
'body' => [
'query' => [
'match' => [
'message' => [
'query' => 'this is a test',
'operator' => 'and',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/618d5f3d35921d8cb7e9ccfbe9a4c3e3.asciidoc 0000644 00000000673 14373463016 0015644 0 ustar 00 // query-dsl/regexp-query.asciidoc:23
[source, php]
----
$params = [
'body' => [
'query' => [
'regexp' => [
'user' => [
'value' => 'k.*y',
'flags' => 'ALL',
'max_determinized_states' => 10000,
'rewrite' => 'constant_score',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/621665fdbd7fc103c09bfeed28b67b1a.asciidoc 0000644 00000000127 14373463016 0015615 0 ustar 00 // api-conventions.asciidoc:307
[source, php]
----
$response = $client->count();
----
docs/examples/625dc94df1f9affb49a082fd99d41620.asciidoc 0000644 00000000425 14373463016 0015500 0 ustar 00 // docs/index_.asciidoc:286
[source, php]
----
$params = [
'index' => 'twitter',
'body' => [
'user' => 'kimchy',
'post_date' => '2009-11-15T14:12:12',
'message' => 'trying out Elasticsearch',
],
];
$response = $client->index($params);
----
docs/examples/626f8c4b3e2cd3d9beaa63a7f5799d7a.asciidoc 0000644 00000000777 14373463016 0015653 0 ustar 00 // search/suggesters.asciidoc:8
[source, php]
----
$params = [
'index' => 'twitter',
'body' => [
'query' => [
'match' => [
'message' => 'tring out Elasticsearch',
],
],
'suggest' => [
'my-suggestion' => [
'text' => 'tring out Elasticsearch',
'term' => [
'field' => 'message',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/645136747d37368a14ab34de8bd046c6.asciidoc 0000644 00000001705 14373463016 0015167 0 ustar 00 // mapping/types/date.asciidoc:35
[source, php]
----
$params = [
'index' => 'my_index',
'body' => [
'mappings' => [
'properties' => [
'date' => [
'type' => 'date',
],
],
],
],
];
$response = $client->indices()->create($params);
$params = [
'index' => 'my_index',
'id' => '1',
'body' => [
'date' => '2015-01-01',
],
];
$response = $client->index($params);
$params = [
'index' => 'my_index',
'id' => '2',
'body' => [
'date' => '2015-01-01T12:10:30Z',
],
];
$response = $client->index($params);
$params = [
'index' => 'my_index',
'id' => '3',
'body' => [
'date' => 1420070400001,
],
];
$response = $client->index($params);
$params = [
'index' => 'my_index',
'body' => [
'sort' => [
'date' => 'asc',
],
],
];
$response = $client->search($params);
----
docs/examples/645796e8047967ca4a7635a22a876f4c.asciidoc 0000644 00000001257 14373463016 0015136 0 ustar 00 // getting-started.asciidoc:691
[source, php]
----
$params = [
'index' => 'bank',
'body' => [
'size' => 0,
'aggs' => [
'group_by_state' => [
'terms' => [
'field' => 'state.keyword',
'order' => [
'average_balance' => 'desc',
],
],
'aggs' => [
'average_balance' => [
'avg' => [
'field' => 'balance',
],
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/645c4c6e209719d3a4d25b1a629cb23b.asciidoc 0000644 00000000550 14373463016 0015310 0 ustar 00 // query-dsl/function-score-query.asciidoc:241
[source, php]
----
$params = [
'body' => [
'query' => [
'function_score' => [
'random_score' => [
'seed' => 10,
'field' => '_seq_no',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/6464124d1677f4552ddddd95a340ca3a.asciidoc 0000644 00000001056 14373463016 0015316 0 ustar 00 // api-conventions.asciidoc:353
[source, php]
----
$params = [
'index' => 'library',
'body' => [
'title' => 'Book #1',
'rating' => 200.1,
],
];
$response = $client->index($params);
$params = [
'index' => 'library',
'body' => [
'title' => 'Book #2',
'rating' => 1.7,
],
];
$response = $client->index($params);
$params = [
'index' => 'library',
'body' => [
'title' => 'Book #3',
'rating' => 0.1,
],
];
$response = $client->index($params);
$response = $client->search();
----
docs/examples/64b9baa6d7556b960b29698f3383aa31.asciidoc 0000644 00000000767 14373463016 0015266 0 ustar 00 // docs/reindex.asciidoc:971
[source, php]
----
$params = [
'body' => [
'source' => [
'remote' => [
'host' => 'http://otherhost:9200',
],
'index' => 'source',
'size' => 10,
'query' => [
'match' => [
'test' => 'data',
],
],
],
'dest' => [
'index' => 'dest',
],
],
];
$response = $client->reindex($params);
----
docs/examples/6799d132c1c7ca3970763acde2337ef9.asciidoc 0000644 00000000537 14373463016 0015343 0 ustar 00 // indices/aliases.asciidoc:253
[source, php]
----
$params = [
'body' => [
'actions' => [
[
'add' => [
'index' => 'test*',
'alias' => 'all_test_indices',
],
],
],
],
];
$response = $client->indices()->updateAliases($params);
----
docs/examples/67bba546d835bca8f31df13e3587c348.asciidoc 0000644 00000000223 14373463016 0015406 0 ustar 00 // indices/aliases.asciidoc:453
[source, php]
----
$params = [
'index' => 'test',
'id' => '1',
];
$response = $client->get($params);
----
docs/examples/67ceac4bf2d9ac7cc500390544cdcb41.asciidoc 0000644 00000000525 14373463016 0015606 0 ustar 00 // query-dsl/range-query.asciidoc:157
[source, php]
----
$params = [
'body' => [
'query' => [
'range' => [
'timestamp' => [
'gte' => 'now-1d/d',
'lt' => 'now/d',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/68721288dc9ad8aa1b55099b4d303051.asciidoc 0000644 00000000643 14373463016 0015161 0 ustar 00 // query-dsl/multi-match-query.asciidoc:524
[source, php]
----
$params = [
'body' => [
'query' => [
'multi_match' => [
'query' => 'quick brown f',
'type' => 'bool_prefix',
'fields' => [
'subject',
'message',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/68738b4fd0dda177022be45be95b4c84.asciidoc 0000644 00000000247 14373463016 0015411 0 ustar 00 // docs/reindex.asciidoc:174
[source, php]
----
$params = [
'task_id' => 'r1A2WoRbTwKZ516z6NEs5A:36619',
];
$response = $client->reindexRethrottle($params);
----
docs/examples/69a7be47f85138b10437113ab2f0d72d.asciidoc 0000644 00000000217 14373463016 0015232 0 ustar 00 // docs/get.asciidoc:376
[source, php]
----
$params = [
'index' => 'twitter',
'id' => '2',
];
$response = $client->get($params);
----
docs/examples/6a1702dd50690cae833572e48a0ddf25.asciidoc 0000644 00000000563 14373463016 0015315 0 ustar 00 // query-dsl/multi-match-query.asciidoc:33
[source, php]
----
$params = [
'body' => [
'query' => [
'multi_match' => [
'query' => 'Will Smith',
'fields' => [
'title',
'*_name',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/6a4679531e64c492fce16dc12de6dcb0.asciidoc 0000644 00000000636 14373463016 0015467 0 ustar 00 // aggregations/bucket/terms-aggregation.asciidoc:207
[source, php]
----
$params = [
'body' => [
'aggs' => [
'genres' => [
'terms' => [
'field' => 'genre',
'order' => [
'_count' => 'asc',
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/6a81d00f0d73bc5985e76b3cadab645e.asciidoc 0000644 00000001117 14373463016 0015536 0 ustar 00 // mapping/params/fielddata.asciidoc:117
[source, php]
----
$params = [
'index' => 'my_index',
'body' => [
'mappings' => [
'properties' => [
'tag' => [
'type' => 'text',
'fielddata' => true,
'fielddata_frequency_filter' => [
'min' => 0.001,
'max' => 0.1,
'min_segment_size' => 500,
],
],
],
],
],
];
$response = $client->indices()->create($params);
----
docs/examples/6bbc613bd4f9aec1bbdbabf5db021d28.asciidoc 0000644 00000001420 14373463016 0016066 0 ustar 00 // query-dsl/multi-match-query.asciidoc:228
[source, php]
----
$params = [
'body' => [
'query' => [
'bool' => [
'should' => [
[
'match' => [
'title' => 'quick brown fox',
],
],
[
'match' => [
'title.original' => 'quick brown fox',
],
],
[
'match' => [
'title.shingles' => 'quick brown fox',
],
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/6be70810d6ebd6f09d8a49f9df847765.asciidoc 0000644 00000001703 14373463016 0015440 0 ustar 00 // query-dsl/nested-query.asciidoc:41
[source, php]
----
$params = [
'index' => 'my_index',
'body' => [
'query' => [
'nested' => [
'path' => 'obj1',
'query' => [
'bool' => [
'must' => [
[
'match' => [
'obj1.name' => 'blue',
],
],
[
'range' => [
'obj1.count' => [
'gt' => 5,
],
],
],
],
],
],
'score_mode' => 'avg',
],
],
],
];
$response = $client->search($params);
----
docs/examples/6bf63f2ec6ba55fcaf1092f48212bf25.asciidoc 0000644 00000000542 14373463016 0015535 0 ustar 00 // indices/put-mapping.asciidoc:527
[source, php]
----
$params = [
'index' => 'my_index',
'body' => [
'mappings' => [
'properties' => [
'user_identifier' => [
'type' => 'keyword',
],
],
],
],
];
$response = $client->indices()->create($params);
----
docs/examples/6d1e75312a28a5ba23837abf768f2510.asciidoc 0000644 00000000210 14373463016 0015222 0 ustar 00 // api-conventions.asciidoc:612
[source, php]
----
$params = [
'index' => 'twitter',
];
$response = $client->search($params);
----
docs/examples/6f097c298a7abf4c032c4314920c49c8.asciidoc 0000644 00000000505 14373463016 0015244 0 ustar 00 // docs/reindex.asciidoc:657
[source, php]
----
$params = [
'body' => [
'source' => [
'index' => [
'twitter',
'blog',
],
],
'dest' => [
'index' => 'all_together',
],
],
];
$response = $client->reindex($params);
----
docs/examples/6f21a878fee3b43c5332b81aaddbeac7.asciidoc 0000644 00000000730 14373463016 0015672 0 ustar 00 // query-dsl/query-string-query.asciidoc:528
[source, php]
----
$params = [
'body' => [
'query' => [
'query_string' => [
'fields' => [
'title',
'content',
],
'query' => 'this OR that OR thus',
'type' => 'cross_fields',
'minimum_should_match' => 2,
],
],
],
];
$response = $client->search($params);
----
docs/examples/6faf10a73f7d5fffbcb037bdb2cbaff8.asciidoc 0000644 00000000754 14373463016 0016202 0 ustar 00 // aggregations/bucket/datehistogram-aggregation.asciidoc:669
[source, php]
----
$params = [
'index' => 'sales',
'body' => [
'aggs' => [
'dayOfWeek' => [
'terms' => [
'script' => [
'lang' => 'painless',
'source' => 'doc[\'date\'].value.dayOfWeekEnum.value',
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/70f0aa5853697e265ef3b1df72940951.asciidoc 0000644 00000001332 14373463016 0015173 0 ustar 00 // aggregations/bucket/datehistogram-aggregation.asciidoc:380
[source, php]
----
$params = [
'index' => 'my_index',
'id' => '1',
'body' => [
'date' => '2015-10-01T00:30:00Z',
],
];
$response = $client->index($params);
$params = [
'index' => 'my_index',
'id' => '2',
'body' => [
'date' => '2015-10-01T01:30:00Z',
],
];
$response = $client->index($params);
$params = [
'index' => 'my_index',
'body' => [
'aggs' => [
'by_day' => [
'date_histogram' => [
'field' => 'date',
'calendar_interval' => 'day',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/710c7871f20f176d51209b1574b0d61b.asciidoc 0000644 00000000217 14373463016 0015065 0 ustar 00 // docs/get.asciidoc:335
[source, php]
----
$params = [
'index' => 'twitter',
'id' => '1',
];
$response = $client->get($params);
----
docs/examples/71b5b2ba9557d0f296ff2de91727d2f6.asciidoc 0000644 00000001212 14373463016 0015412 0 ustar 00 // aggregations/bucket/terms-aggregation.asciidoc:243
[source, php]
----
$params = [
'body' => [
'aggs' => [
'genres' => [
'terms' => [
'field' => 'genre',
'order' => [
'max_play_count' => 'desc',
],
],
'aggs' => [
'max_play_count' => [
'max' => [
'field' => 'play_count',
],
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/71ba9033107882f61cdc3b32fc73568d.asciidoc 0000644 00000000501 14373463016 0015233 0 ustar 00 // mapping.asciidoc:176
[source, php]
----
$params = [
'index' => 'my-index',
'body' => [
'properties' => [
'employee-id' => [
'type' => 'keyword',
'index' => false,
],
],
],
];
$response = $client->indices()->putMapping($params);
----
docs/examples/72231b7debac60c95b9869a97dafda3a.asciidoc 0000644 00000000564 14373463016 0015632 0 ustar 00 // query-dsl/match-phrase-query.asciidoc:30
[source, php]
----
$params = [
'body' => [
'query' => [
'match_phrase' => [
'message' => [
'query' => 'this is a test',
'analyzer' => 'my_analyzer',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/72beebe779a258c225dee7b023e60c52.asciidoc 0000644 00000000267 14373463016 0015465 0 ustar 00 // search/request/scroll.asciidoc:148
[source, php]
----
$params = [
'metric' => 'indices',
'index_metric' => 'search',
];
$response = $client->nodes()->stats($params);
----
docs/examples/734c2e2a1e45b84f1e4e65b51356fcd7.asciidoc 0000644 00000000533 14373463016 0015403 0 ustar 00 // indices/put-mapping.asciidoc:454
[source, php]
----
$params = [
'index' => 'new_users',
'body' => [
'mappings' => [
'properties' => [
'user_id' => [
'type' => 'keyword',
],
],
],
],
];
$response = $client->indices()->create($params);
----
docs/examples/73e5c88ad1488b213fb278ee1cb42289.asciidoc 0000644 00000000635 14373463016 0015337 0 ustar 00 // aggregations/bucket/datehistogram-aggregation.asciidoc:138
[source, php]
----
$params = [
'index' => 'sales',
'body' => [
'aggs' => [
'sales_over_time' => [
'date_histogram' => [
'field' => 'date',
'calendar_interval' => '2d',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/745f9b8cdb8e91073f6e520e1d9f8c05.asciidoc 0000644 00000000216 14373463016 0015423 0 ustar 00 // docs/get.asciidoc:73
[source, php]
----
$params = [
'index' => 'twitter',
'id' => '0',
];
$response = $client->get($params);
----
docs/examples/7477671958734843dd67cf0b8e6c7515.asciidoc 0000644 00000000535 14373463016 0015065 0 ustar 00 // search/request/sort.asciidoc:192
[source, php]
----
$params = [
'index' => 'index_long',
'body' => [
'mappings' => [
'properties' => [
'field' => [
'type' => 'date_nanos',
],
],
],
],
];
$response = $client->indices()->create($params);
----
docs/examples/75330ec1305d2beb0e2f34d2195464e2.asciidoc 0000644 00000000372 14373463016 0015222 0 ustar 00 // query-dsl/match-all-query.asciidoc:23
[source, php]
----
$params = [
'body' => [
'query' => [
'match_all' => [
'boost' => 1.2,
],
],
],
];
$response = $client->search($params);
----
docs/examples/764f9884b370cbdc82a1c5c42ed40ff3.asciidoc 0000644 00000000612 14373463016 0015464 0 ustar 00 // docs/reindex.asciidoc:609
[source, php]
----
$params = [
'body' => [
'source' => [
'index' => 'twitter',
'query' => [
'term' => [
'user' => 'kimchy',
],
],
],
'dest' => [
'index' => 'new_twitter',
],
],
];
$response = $client->reindex($params);
----
docs/examples/77243bbf92f2a55e0fca6c2a349a1c15.asciidoc 0000644 00000001335 14373463016 0015447 0 ustar 00 // search/request/sort.asciidoc:539
[source, php]
----
$params = [
'body' => [
'sort' => [
[
'_geo_distance' => [
'pin.location' => [
[
-70,
40,
],
[
-71,
42,
],
],
'order' => 'asc',
'unit' => 'km',
],
],
],
'query' => [
'term' => [
'user' => 'kimchy',
],
],
],
];
$response = $client->search($params);
----
docs/examples/774d715155cd13713e6e327adf6ce328.asciidoc 0000644 00000000547 14373463016 0015254 0 ustar 00 // aggregations/bucket/terms-aggregation.asciidoc:723
[source, php]
----
$params = [
'body' => [
'aggs' => [
'tags' => [
'terms' => [
'field' => 'tags',
'execution_hint' => 'map',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/78c96113ae4ed0054e581b17542528a7.asciidoc 0000644 00000000644 14373463016 0015105 0 ustar 00 // docs/reindex.asciidoc:373
[source, php]
----
$params = [
'body' => [
'source' => [
'index' => 'source',
'query' => [
'match' => [
'company' => 'cat',
],
],
],
'dest' => [
'index' => 'dest',
'routing' => '=cat',
],
],
];
$response = $client->reindex($params);
----
docs/examples/7b908b1189f076942de8cd497ff1fa59.asciidoc 0000644 00000000720 14373463016 0015356 0 ustar 00 // query-dsl/multi-match-query.asciidoc:212
[source, php]
----
$params = [
'body' => [
'query' => [
'multi_match' => [
'query' => 'quick brown fox',
'type' => 'most_fields',
'fields' => [
'title',
'title.original',
'title.shingles',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/7cac05cb589f1614fd5b8589153bef06.asciidoc 0000644 00000000412 14373463016 0015410 0 ustar 00 // docs/update.asciidoc:325
[source, php]
----
$params = [
'index' => 'test',
'id' => '1',
'body' => [
'doc' => [
'name' => 'new_name',
],
'doc_as_upsert' => true,
],
];
$response = $client->update($params);
----
docs/examples/7cf71671859be7c1ecf673396db377cd.asciidoc 0000644 00000000775 14373463016 0015445 0 ustar 00 // indices/aliases.asciidoc:320
[source, php]
----
$params = [
'body' => [
'actions' => [
[
'add' => [
'index' => 'test1',
'alias' => 'alias2',
'filter' => [
'term' => [
'user' => 'kimchy',
],
],
],
],
],
],
];
$response = $client->indices()->updateAliases($params);
----
docs/examples/7df191cc7f814e410a4ac7261065e6ef.asciidoc 0000644 00000000144 14373463016 0015377 0 ustar 00 // docs/update-by-query.asciidoc:420
[source, php]
----
$response = $client->tasks()->list();
----
docs/examples/7e52bec09624cf6c0de5d13f2bfad5a5.asciidoc 0000644 00000000457 14373463016 0015700 0 ustar 00 // search/request/scroll.asciidoc:45
[source, php]
----
$params = [
'index' => 'twitter',
'body' => [
'size' => 100,
'query' => [
'match' => [
'title' => 'elasticsearch',
],
],
],
];
$response = $client->search($params);
----
docs/examples/7f28f8ae8fcdbd807dadde0b5b007a6d.asciidoc 0000644 00000001141 14373463016 0016037 0 ustar 00 // aggregations/bucket/terms-aggregation.asciidoc:641
[source, php]
----
$params = [
'body' => [
'aggs' => [
'actors' => [
'terms' => [
'field' => 'actors',
'size' => 10,
],
'aggs' => [
'costars' => [
'terms' => [
'field' => 'actors',
'size' => 5,
],
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/7f465b7e8ed42df6c42251b4481e699e.asciidoc 0000644 00000000603 14373463016 0015346 0 ustar 00 // mapping/params/format.asciidoc:13
[source, php]
----
$params = [
'index' => 'my_index',
'body' => [
'mappings' => [
'properties' => [
'date' => [
'type' => 'date',
'format' => 'yyyy-MM-dd',
],
],
],
],
];
$response = $client->indices()->create($params);
----
docs/examples/7f56755fb6c42f7e6203339a6d0cb6e6.asciidoc 0000644 00000000563 14373463016 0015341 0 ustar 00 // query-dsl/match-query.asciidoc:268
[source, php]
----
$params = [
'body' => [
'query' => [
'match' => [
'message' => [
'query' => 'ny city',
'auto_generate_synonyms_phrase_query' => false,
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/7f697eb436dfa3c30dfe610d8c32d132.asciidoc 0000644 00000001064 14373463016 0015460 0 ustar 00 // docs/reindex.asciidoc:1002
[source, php]
----
$params = [
'body' => [
'source' => [
'remote' => [
'host' => 'http://otherhost:9200',
'socket_timeout' => '1m',
'connect_timeout' => '10s',
],
'index' => 'source',
'query' => [
'match' => [
'test' => 'data',
],
],
],
'dest' => [
'index' => 'dest',
],
],
];
$response = $client->reindex($params);
----
docs/examples/804a97ff4d0613e6568e4efb19c52021.asciidoc 0000644 00000001151 14373463016 0015244 0 ustar 00 // docs/index_.asciidoc:188
[source, php]
----
$params = [
'body' => [
'persistent' => [
'action.auto_create_index' => 'twitter,index10,-index1*,+ind*',
],
],
];
$response = $client->cluster()->putSettings($params);
$params = [
'body' => [
'persistent' => [
'action.auto_create_index' => 'false',
],
],
];
$response = $client->cluster()->putSettings($params);
$params = [
'body' => [
'persistent' => [
'action.auto_create_index' => 'true',
],
],
];
$response = $client->cluster()->putSettings($params);
----
docs/examples/81c9aa2678d6166a9662ddf2c011a6a5.asciidoc 0000644 00000000333 14373463016 0015316 0 ustar 00 // query-dsl/match-all-query.asciidoc:39
[source, php]
----
$params = [
'body' => [
'query' => [
'match_none' => [
],
],
],
];
$response = $client->search($params);
----
docs/examples/83f95657beca9bf5d8264c80c7fb463f.asciidoc 0000644 00000000417 14373463016 0015514 0 ustar 00 // query-dsl/match-phrase-query.asciidoc:11
[source, php]
----
$params = [
'body' => [
'query' => [
'match_phrase' => [
'message' => 'this is a test',
],
],
],
];
$response = $client->search($params);
----
docs/examples/8653e76676de5d327201b77512afa3a0.asciidoc 0000644 00000000375 14373463016 0015165 0 ustar 00 // indices/update-settings.asciidoc:13
[source, php]
----
$params = [
'index' => 'twitter',
'body' => [
'index' => [
'number_of_replicas' => 2,
],
],
];
$response = $client->indices()->putSettings($params);
----
docs/examples/873fbbc6ab81409058591385fd602736.asciidoc 0000644 00000002000 14373463016 0015104 0 ustar 00 // query-dsl/nested-query.asciidoc:165
[source, php]
----
$params = [
'index' => 'drivers',
'id' => '1',
'body' => [
'driver' => [
'last_name' => 'McQueen',
'vehicle' => [
[
'make' => 'Powell Motors',
'model' => 'Canyonero',
],
[
'make' => 'Miller-Meteor',
'model' => 'Ecto-1',
],
],
],
],
];
$response = $client->index($params);
$params = [
'index' => 'drivers',
'id' => '2',
'body' => [
'driver' => [
'last_name' => 'Hudson',
'vehicle' => [
[
'make' => 'Mifune',
'model' => 'Mach Five',
],
[
'make' => 'Miller-Meteor',
'model' => 'Ecto-1',
],
],
],
],
];
$response = $client->index($params);
----
docs/examples/8871b8fcb6de4f0c7dff22798fb10fb7.asciidoc 0000644 00000000741 14373463016 0015646 0 ustar 00 // docs/reindex.asciidoc:850
[source, php]
----
$params = [
'body' => [
'source' => [
'index' => 'twitter',
],
'dest' => [
'index' => 'new_twitter',
'version_type' => 'external',
],
'script' => [
'source' => 'if (ctx._source.foo == \'bar\') {ctx._version++; ctx._source.remove(\'foo\')}',
'lang' => 'painless',
],
],
];
$response = $client->reindex($params);
----
docs/examples/899eef71a67a1b2aa11a2166ec7f48f1.asciidoc 0000644 00000000625 14373463016 0015465 0 ustar 00 // search/request/sort.asciidoc:369
[source, php]
----
$params = [
'body' => [
'sort' => [
[
'price' => [
'unmapped_type' => 'long',
],
],
],
'query' => [
'term' => [
'product' => 'chocolate',
],
],
],
];
$response = $client->search($params);
----
docs/examples/89a8ac1509936acc272fc2d72907bc45.asciidoc 0000644 00000000225 14373463016 0015326 0 ustar 00 // docs/get.asciidoc:269
[source, php]
----
$params = [
'index' => 'twitter',
'id' => '1',
];
$response = $client->getSource($params);
----
docs/examples/8a355eb25d2a01ba62dc1a22dd46f46f.asciidoc 0000644 00000000713 14373463016 0015515 0 ustar 00 // aggregations/bucket/datehistogram-aggregation.asciidoc:303
[source, php]
----
$params = [
'index' => 'sales',
'body' => [
'aggs' => [
'sales_over_time' => [
'date_histogram' => [
'field' => 'date',
'calendar_interval' => '1M',
'format' => 'yyyy-MM-dd',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/8acc1d67b152e7027e0f0e1a8b4b2431.asciidoc 0000644 00000001033 14373463016 0015351 0 ustar 00 // search.asciidoc:32
[source, php]
----
$params = [
'index' => 'twitter',
'body' => [
'query' => [
'bool' => [
'must' => [
'query_string' => [
'query' => 'some query string here',
],
],
'filter' => [
'term' => [
'user' => 'kimchy',
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/8baccd8688a6bad1749b8935f9601ea4.asciidoc 0000644 00000000665 14373463016 0015510 0 ustar 00 // mapping/types/nested.asciidoc:22
[source, php]
----
$params = [
'index' => 'my_index',
'id' => '1',
'body' => [
'group' => 'fans',
'user' => [
[
'first' => 'John',
'last' => 'Smith',
],
[
'first' => 'Alice',
'last' => 'White',
],
],
],
];
$response = $client->index($params);
----
docs/examples/8c5977410335d58217e0626618ce6641.asciidoc 0000644 00000000321 14373463016 0014671 0 ustar 00 // query-dsl/terms-query.asciidoc:160
[source, php]
----
$params = [
'index' => 'my_index',
'id' => '2',
'body' => [
'color' => 'blue',
],
];
$response = $client->index($params);
----
docs/examples/8cd00a3aba7c3c158277bc032aac2830.asciidoc 0000644 00000003255 14373463016 0015426 0 ustar 00 // docs/bulk.asciidoc:545
[source, php]
----
$params = [
'body' => [
[
'update' => [
'_id' => '1',
'_index' => 'index1',
'retry_on_conflict' => 3,
],
],
[
'doc' => [
'field' => 'value',
],
],
[
'update' => [
'_id' => '0',
'_index' => 'index1',
'retry_on_conflict' => 3,
],
],
[
'script' => [
'source' => 'ctx._source.counter += params.param1',
'lang' => 'painless',
'params' => [
'param1' => 1,
],
],
'upsert' => [
'counter' => 1,
],
],
[
'update' => [
'_id' => '2',
'_index' => 'index1',
'retry_on_conflict' => 3,
],
],
[
'doc' => [
'field' => 'value',
],
'doc_as_upsert' => true,
],
[
'update' => [
'_id' => '3',
'_index' => 'index1',
'_source' => true,
],
],
[
'doc' => [
'field' => 'value',
],
],
[
'update' => [
'_id' => '4',
'_index' => 'index1',
],
],
[
'doc' => [
'field' => 'value',
],
'_source' => true,
],
],
];
$response = $client->bulk($params);
----
docs/examples/8d9a63d7c31f08bd27d92ece3de1649c.asciidoc 0000644 00000001215 14373463016 0015554 0 ustar 00 // mapping/fields/id-field.asciidoc:12
[source, php]
----
$params = [
'index' => 'my_index',
'id' => '1',
'body' => [
'text' => 'Document with ID 1',
],
];
$response = $client->index($params);
$params = [
'index' => 'my_index',
'id' => '2',
'body' => [
'text' => 'Document with ID 2',
],
];
$response = $client->index($params);
$params = [
'index' => 'my_index',
'body' => [
'query' => [
'terms' => [
'_id' => [
'1',
'2',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/8dcc74dc01f26e853e3b3dfa458b1ad7.asciidoc 0000644 00000000555 14373463016 0015625 0 ustar 00 // indices/templates.asciidoc:231
[source, php]
----
$params = [
'name' => 'template_1',
'body' => [
'index_patterns' => [
'myindex-*',
],
'order' => 0,
'settings' => [
'number_of_shards' => 1,
],
'version' => 123,
],
];
$response = $client->indices()->putTemplate($params);
----
docs/examples/8de3206f80e18185a5ad6481f4c2ee07.asciidoc 0000644 00000000705 14373463016 0015326 0 ustar 00 // aggregations/bucket/datehistogram-aggregation.asciidoc:431
[source, php]
----
$params = [
'index' => 'my_index',
'body' => [
'aggs' => [
'by_day' => [
'date_histogram' => [
'field' => 'date',
'calendar_interval' => 'day',
'time_zone' => '-01:00',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/8e6bfb4441ffa15c86d5dc20fa083571.asciidoc 0000644 00000000373 14373463016 0015462 0 ustar 00 // setup/logging-config.asciidoc:155
[source, php]
----
$params = [
'body' => [
'transient' => [
'logger.org.elasticsearch.transport' => 'trace',
],
],
];
$response = $client->cluster()->putSettings($params);
----
docs/examples/8eaf4d5dd4ab1335deefa7749fdbbcc3.asciidoc 0000644 00000000675 14373463016 0016133 0 ustar 00 // query-dsl/function-score-query.asciidoc:269
[source, php]
----
$params = [
'body' => [
'query' => [
'function_score' => [
'field_value_factor' => [
'field' => 'likes',
'factor' => 1.2,
'modifier' => 'sqrt',
'missing' => 1,
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/8f0511f8a5cb176ff2afdd4311799a33.asciidoc 0000644 00000000745 14373463016 0015410 0 ustar 00 // search/count.asciidoc:99
[source, php]
----
$params = [
'index' => 'twitter',
'id' => '1',
'body' => [
'user' => 'kimchy',
],
];
$response = $client->index($params);
$params = [
'index' => 'twitter',
];
$response = $client->count($params);
$params = [
'index' => 'twitter',
'body' => [
'query' => [
'term' => [
'user' => 'kimchy',
],
],
],
];
$response = $client->count($params);
----
docs/examples/8fdf2344c4fb3de6902ad7c5735270df.asciidoc 0000644 00000000216 14373463016 0015466 0 ustar 00 // docs/get.asciidoc:65
[source, php]
----
$params = [
'index' => 'twitter',
'id' => '0',
];
$response = $client->get($params);
----
docs/examples/913770050ebbf3b9b549a899bc11060a.asciidoc 0000644 00000000761 14373463016 0015236 0 ustar 00 // docs/get.asciidoc:302
[source, php]
----
$params = [
'index' => 'twitter',
'body' => [
'mappings' => [
'properties' => [
'counter' => [
'type' => 'integer',
'store' => false,
],
'tags' => [
'type' => 'keyword',
'store' => true,
],
],
],
],
];
$response = $client->indices()->create($params);
----
docs/examples/93f1bdd72e79827dcf9a34efa02fd977.asciidoc 0000644 00000000634 14373463016 0015574 0 ustar 00 // aggregations/bucket/terms-aggregation.asciidoc:224
[source, php]
----
$params = [
'body' => [
'aggs' => [
'genres' => [
'terms' => [
'field' => 'genre',
'order' => [
'_key' => 'asc',
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/9524a9b7373fa4eb2905183b0e806962.asciidoc 0000644 00000000760 14373463016 0015113 0 ustar 00 // aggregations/bucket/datehistogram-aggregation.asciidoc:567
[source, php]
----
$params = [
'index' => 'sales',
'body' => [
'aggs' => [
'sales_over_time' => [
'date_histogram' => [
'field' => 'date',
'calendar_interval' => '1M',
'format' => 'yyyy-MM-dd',
'keyed' => true,
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/96de5703ba0bd43fd4ac239ec5408542.asciidoc 0000644 00000000561 14373463016 0015375 0 ustar 00 // docs/update.asciidoc:96
[source, php]
----
$params = [
'index' => 'test',
'id' => '1',
'body' => [
'script' => [
'source' => 'ctx._source.counter += params.count',
'lang' => 'painless',
'params' => [
'count' => 4,
],
],
],
];
$response = $client->update($params);
----
docs/examples/973a3ff47fc4ce036ecd9bd363fef9f7.asciidoc 0000644 00000000733 14373463016 0015735 0 ustar 00 // docs/reindex.asciidoc:784
[source, php]
----
$params = [
'body' => [
'source' => [
'index' => 'metricbeat-*',
],
'dest' => [
'index' => 'metricbeat',
],
'script' => [
'lang' => 'painless',
'source' => 'ctx._index = \'metricbeat-\' + (ctx._index.substring(\'metricbeat-\'.length(), ctx._index.length())) + \'-1\'',
],
],
];
$response = $client->reindex($params);
----
docs/examples/978088f989d45dd09339582e9cbc60e0.asciidoc 0000644 00000000435 14373463016 0015227 0 ustar 00 // api-conventions.asciidoc:88
[source, php]
----
$params = [
'index' => '%3Clogstash-%7Bnow%2Fd%7D%3E',
'body' => [
'query' => [
'match' => [
'test' => 'data',
],
],
],
];
$response = $client->search($params);
----
docs/examples/979d25dff2d8987119410291ad47b0d1.asciidoc 0000644 00000001074 14373463016 0015177 0 ustar 00 // search/request/sort.asciidoc:444
[source, php]
----
$params = [
'body' => [
'sort' => [
[
'_geo_distance' => [
'pin.location' => [
'lat' => 40,
'lon' => -70,
],
'order' => 'asc',
'unit' => 'km',
],
],
],
'query' => [
'term' => [
'user' => 'kimchy',
],
],
],
];
$response = $client->search($params);
----
docs/examples/97babc8d19ef0866774576716eb6d19e.asciidoc 0000644 00000000535 14373463016 0015362 0 ustar 00 // docs/update-by-query.asciidoc:727
[source, php]
----
$params = [
'index' => 'test',
];
$response = $client->updateByQuery($params);
$params = [
'index' => 'test',
'body' => [
'query' => [
'match' => [
'flag' => 'foo',
],
],
],
];
$response = $client->search($params);
----
docs/examples/98234499cfec70487cec5d013e976a84.asciidoc 0000644 00000000222 14373463016 0015267 0 ustar 00 // docs/get.asciidoc:253
[source, php]
----
$params = [
'index' => 'twitter',
'id' => '0',
];
$response = $client->exists($params);
----
docs/examples/98aeb275f829b5f7b8eb2147701565ff.asciidoc 0000644 00000000660 14373463016 0015351 0 ustar 00 // docs/update.asciidoc:177
[source, php]
----
$params = [
'index' => 'test',
'id' => '1',
'body' => [
'script' => [
'source' => 'if (ctx._source.tags.contains(params.tag)) { ctx.op = \'delete\' } else { ctx.op = \'none\' }',
'lang' => 'painless',
'params' => [
'tag' => 'green',
],
],
],
];
$response = $client->update($params);
----
docs/examples/98b121bf47cebd85671a2cb519688d28.asciidoc 0000644 00000001311 14373463016 0015332 0 ustar 00 // aggregations/bucket/terms-aggregation.asciidoc:520
[source, php]
----
$params = [
'body' => [
'aggs' => [
'JapaneseCars' => [
'terms' => [
'field' => 'make',
'include' => [
'mazda',
'honda',
],
],
],
'ActiveCarManufacturers' => [
'terms' => [
'field' => 'make',
'exclude' => [
'rover',
'jensen',
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/98f14fddddea54a7d6149ab7b92e099d.asciidoc 0000644 00000000227 14373463016 0015644 0 ustar 00 // indices/delete-index.asciidoc:10
[source, php]
----
$params = [
'index' => 'twitter',
];
$response = $client->indices()->delete($params);
----
docs/examples/99a52be903945b17e734a1d02a57e958.asciidoc 0000644 00000000264 14373463016 0015176 0 ustar 00 // mapping.asciidoc:263
[source, php]
----
$params = [
'index' => 'my-index',
'fields' => 'employee-id',
];
$response = $client->indices()->getFieldMapping($params);
----
docs/examples/9a4d5e41c52c20635d1fd9c6e13f6c7a.asciidoc 0000644 00000000616 14373463016 0015462 0 ustar 00 // docs/reindex.asciidoc:768
[source, php]
----
$params = [
'index' => 'metricbeat-2016.05.30',
'id' => '1',
'body' => [
'system.cpu.idle.pct' => 0.908,
],
];
$response = $client->index($params);
$params = [
'index' => 'metricbeat-2016.05.31',
'id' => '1',
'body' => [
'system.cpu.idle.pct' => 0.105,
],
];
$response = $client->index($params);
----
docs/examples/9a8995fd31351045d99c78e40444c8ea.asciidoc 0000644 00000000472 14373463016 0015212 0 ustar 00 // aggregations/bucket/terms-aggregation.asciidoc:57
[source, php]
----
$params = [
'body' => [
'aggs' => [
'genres' => [
'terms' => [
'field' => 'genre',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/9e56d79ad9a02b642c361f0b85dd95d7.asciidoc 0000644 00000000532 14373463016 0015417 0 ustar 00 // query-dsl/terms-query.asciidoc:127
[source, php]
----
$params = [
'index' => 'my_index',
'body' => [
'mappings' => [
'properties' => [
'color' => [
'type' => 'keyword',
],
],
],
],
];
$response = $client->indices()->create($params);
----
docs/examples/9efac5b23bf23de8d81a7455905e2979.asciidoc 0000644 00000001501 14373463016 0015420 0 ustar 00 // indices/templates.asciidoc:180
[source, php]
----
$params = [
'name' => 'template_1',
'body' => [
'index_patterns' => [
'te*',
],
'order' => 0,
'settings' => [
'number_of_shards' => 1,
],
'mappings' => [
'_source' => [
'enabled' => false,
],
],
],
];
$response = $client->indices()->putTemplate($params);
$params = [
'name' => 'template_2',
'body' => [
'index_patterns' => [
'tes*',
],
'order' => 1,
'settings' => [
'number_of_shards' => 1,
],
'mappings' => [
'_source' => [
'enabled' => true,
],
],
],
];
$response = $client->indices()->putTemplate($params);
----
docs/examples/a116949e446f34dc25ae57d4b703d0c1.asciidoc 0000644 00000000544 14373463016 0015316 0 ustar 00 // query-dsl/range-query.asciidoc:16
[source, php]
----
$params = [
'body' => [
'query' => [
'range' => [
'age' => [
'gte' => 10,
'lte' => 20,
'boost' => 2,
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/a1db5c822745fe167e9ef854dca3d129.asciidoc 0000644 00000000750 14373463016 0015474 0 ustar 00 // search/request/sort.asciidoc:491
[source, php]
----
$params = [
'body' => [
'sort' => [
[
'_geo_distance' => [
'pin.location' => 'drm3btev3e86',
'order' => 'asc',
'unit' => 'km',
],
],
],
'query' => [
'term' => [
'user' => 'kimchy',
],
],
],
];
$response = $client->search($params);
----
docs/examples/a2a25aad1fea9a541b52ac613c78fb64.asciidoc 0000644 00000000647 14373463016 0015604 0 ustar 00 // query-dsl/query-string-query.asciidoc:297
[source, php]
----
$params = [
'body' => [
'query' => [
'query_string' => [
'fields' => [
'content',
'name^5',
],
'query' => 'this AND that OR thus',
'tie_breaker' => 0,
],
],
],
];
$response = $client->search($params);
----
docs/examples/a34d70d7022eb4ba48909d440c80390f.asciidoc 0000644 00000000542 14373463016 0015230 0 ustar 00 // api-conventions.asciidoc:142
[source, php]
----
$params = [
'index' => '%3Clogstash-%7Bnow%2Fd-2d%7D%3E%2C%3Clogstash-%7Bnow%2Fd-1d%7D%3E%2C%3Clogstash-%7Bnow%2Fd%7D%3E',
'body' => [
'query' => [
'match' => [
'test' => 'data',
],
],
],
];
$response = $client->search($params);
----
docs/examples/a42f33e15b0995bb4b6058659bfdea85.asciidoc 0000644 00000000723 14373463016 0015411 0 ustar 00 // query-dsl/function-score-query.asciidoc:19
[source, php]
----
$params = [
'body' => [
'query' => [
'function_score' => [
'query' => [
'match_all' => [
],
],
'boost' => '5',
'random_score' => [
],
'boost_mode' => 'multiply',
],
],
],
];
$response = $client->search($params);
----
docs/examples/a49169b4622918992411fab4ec48191b.asciidoc 0000644 00000000735 14373463016 0015115 0 ustar 00 // aggregations/bucket/terms-aggregation.asciidoc:466
[source, php]
----
$params = [
'body' => [
'aggs' => [
'genres' => [
'terms' => [
'field' => 'genre',
'script' => [
'source' => '\'Genre: \' +_value',
'lang' => 'painless',
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/a4a396cd07657b3977713fb3a742c41b.asciidoc 0000644 00000000223 14373463016 0015237 0 ustar 00 // docs/update-by-query.asciidoc:12
[source, php]
----
$params = [
'index' => 'twitter',
];
$response = $client->updateByQuery($params);
----
docs/examples/a5a7050fb9dcb9574e081957ade28617.asciidoc 0000644 00000000503 14373463016 0015331 0 ustar 00 // docs/delete-by-query.asciidoc:494
[source, php]
----
$params = [
'index' => 'twitter',
'body' => [
'query' => [
'range' => [
'likes' => [
'lt' => 10,
],
],
],
],
];
$response = $client->deleteByQuery($params);
----
docs/examples/a6f8636b03cc5f677b7d89e750328612.asciidoc 0000644 00000000210 14373463016 0015174 0 ustar 00 // api-conventions.asciidoc:580
[source, php]
----
$params = [
'index' => 'twitter',
];
$response = $client->search($params);
----
docs/examples/a71c438cc4df1cafe3109ccff475afdb.asciidoc 0000644 00000001117 14373463016 0016033 0 ustar 00 // mapping/types/numeric.asciidoc:22
[source, php]
----
$params = [
'index' => 'my_index',
'body' => [
'mappings' => [
'properties' => [
'number_of_bytes' => [
'type' => 'integer',
],
'time_in_seconds' => [
'type' => 'float',
],
'price' => [
'type' => 'scaled_float',
'scaling_factor' => 100,
],
],
],
],
];
$response = $client->indices()->create($params);
----
docs/examples/a7c15fe6b5779c84ce9a34bf4b2a7ab7.asciidoc 0000644 00000000516 14373463016 0015634 0 ustar 00 // mapping/params/fielddata.asciidoc:84
[source, php]
----
$params = [
'index' => 'my_index',
'body' => [
'properties' => [
'my_field' => [
'type' => 'text',
'fielddata' => true,
],
],
],
];
$response = $client->indices()->putMapping($params);
----
docs/examples/a80f5db4357bb25b8704d374c18318ed.asciidoc 0000644 00000000442 14373463016 0015320 0 ustar 00 // query-dsl/term-query.asciidoc:165
[source, php]
----
$params = [
'index' => 'my_index',
'body' => [
'query' => [
'match' => [
'full_text' => 'Quick Brown Foxes!',
],
],
],
];
$response = $client->search($params);
----
docs/examples/a8fba09a46b2c3524428aa3259b7124f.asciidoc 0000644 00000000232 14373463016 0015301 0 ustar 00 // indices/get-mapping.asciidoc:11
[source, php]
----
$params = [
'index' => 'twitter',
];
$response = $client->indices()->getMapping($params);
----
docs/examples/aa6bfe54e2436eb668091fe31c2fbf4d.asciidoc 0000644 00000001401 14373463016 0015615 0 ustar 00 // aggregations/bucket/datehistogram-aggregation.asciidoc:502
[source, php]
----
$params = [
'index' => 'my_index',
'id' => '1',
'body' => [
'date' => '2015-10-01T05:30:00Z',
],
];
$response = $client->index($params);
$params = [
'index' => 'my_index',
'id' => '2',
'body' => [
'date' => '2015-10-01T06:30:00Z',
],
];
$response = $client->index($params);
$params = [
'index' => 'my_index',
'body' => [
'aggs' => [
'by_day' => [
'date_histogram' => [
'field' => 'date',
'calendar_interval' => 'day',
'offset' => '+6h',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/abd4fc3ce7784413a56fe2dcfe2809b5.asciidoc 0000644 00000000412 14373463016 0015623 0 ustar 00 // docs/update-by-query.asciidoc:700
[source, php]
----
$params = [
'index' => 'test',
'body' => [
'query' => [
'match' => [
'flag' => 'foo',
],
],
],
];
$response = $client->search($params);
----
docs/examples/abf329ebefaf58acd4ee30e685731499.asciidoc 0000644 00000000533 14373463016 0015640 0 ustar 00 // search/request/sort.asciidoc:122
[source, php]
----
$params = [
'index' => 'index_double',
'body' => [
'mappings' => [
'properties' => [
'field' => [
'type' => 'double',
],
],
],
],
];
$response = $client->indices()->create($params);
----
docs/examples/ac544eb247a29ca42aab13826ca88561.asciidoc 0000644 00000000676 14373463016 0015374 0 ustar 00 // docs/update.asciidoc:135
[source, php]
----
$params = [
'index' => 'test',
'id' => '1',
'body' => [
'script' => [
'source' => 'if (ctx._source.tags.contains(params.tag)) { ctx._source.tags.remove(ctx._source.tags.indexOf(params.tag)) }',
'lang' => 'painless',
'params' => [
'tag' => 'blue',
],
],
],
];
$response = $client->update($params);
----
docs/examples/ad0dcbc7fc619e952c8825b8f307b7b2.asciidoc 0000644 00000000730 14373463016 0015547 0 ustar 00 // query-dsl/multi-match-query.asciidoc:400
[source, php]
----
$params = [
'body' => [
'query' => [
'multi_match' => [
'query' => 'Jon',
'type' => 'cross_fields',
'fields' => [
'first',
'first.edge',
'last',
'last.edge',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/ad6ea0c1e46712aa1fd6d3bfa0ec979e.asciidoc 0000644 00000000513 14373463016 0015746 0 ustar 00 // query-dsl/query-string-query.asciidoc:42
[source, php]
----
$params = [
'body' => [
'query' => [
'query_string' => [
'query' => '(new york city) OR (big apple)',
'default_field' => 'content',
],
],
],
];
$response = $client->search($params);
----
docs/examples/ad79228630684d950fe9792a768d24c5.asciidoc 0000644 00000001115 14373463016 0015132 0 ustar 00 // indices/aliases.asciidoc:462
[source, php]
----
$params = [
'body' => [
'actions' => [
[
'add' => [
'index' => 'test',
'alias' => 'alias1',
'is_write_index' => false,
],
],
[
'add' => [
'index' => 'test2',
'alias' => 'alias1',
'is_write_index' => true,
],
],
],
],
];
$response = $client->indices()->updateAliases($params);
----
docs/examples/ae9b5fbd42af2386ffbf56ad4a697e51.asciidoc 0000644 00000001113 14373463016 0015710 0 ustar 00 // search/request/sort.asciidoc:30
[source, php]
----
$params = [
'index' => 'my_index',
'body' => [
'sort' => [
[
'post_date' => [
'order' => 'asc',
],
],
'user',
[
'name' => 'desc',
],
[
'age' => 'desc',
],
'_score',
],
'query' => [
'term' => [
'user' => 'kimchy',
],
],
],
];
$response = $client->search($params);
----
docs/examples/ae9ccfaa146731ab9176df90670db1c2.asciidoc 0000644 00000001513 14373463016 0015531 0 ustar 00 // docs/bulk.asciidoc:434
[source, php]
----
$params = [
'body' => [
[
'index' => [
'_index' => 'test',
'_id' => '1',
],
],
[
'field1' => 'value1',
],
[
'delete' => [
'_index' => 'test',
'_id' => '2',
],
],
[
'create' => [
'_index' => 'test',
'_id' => '3',
],
],
[
'field1' => 'value3',
],
[
'update' => [
'_id' => '1',
'_index' => 'test',
],
],
[
'doc' => [
'field2' => 'value2',
],
],
],
];
$response = $client->bulk($params);
----
docs/examples/af3fb9fa5691a7b37a6dc2a69ff66e64.asciidoc 0000644 00000000764 14373463016 0015651 0 ustar 00 // indices/aliases.asciidoc:204
[source, php]
----
$params = [
'body' => [
'actions' => [
[
'remove' => [
'index' => 'test1',
'alias' => 'alias1',
],
],
[
'add' => [
'index' => 'test1',
'alias' => 'alias2',
],
],
],
],
];
$response = $client->indices()->updateAliases($params);
----
docs/examples/afc29b61c532cf683f749baf013e7bfe.asciidoc 0000644 00000000522 14373463016 0015624 0 ustar 00 // indices/put-mapping.asciidoc:544
[source, php]
----
$params = [
'index' => 'my_index',
'body' => [
'properties' => [
'user_id' => [
'type' => 'alias',
'path' => 'user_identifier',
],
],
],
];
$response = $client->indices()->putMapping($params);
----
docs/examples/b02e4907c9936c1adc16ccce9d49900d.asciidoc 0000644 00000000142 14373463016 0015460 0 ustar 00 // cluster/health.asciidoc:150
[source, php]
----
$response = $client->cluster()->health();
----
docs/examples/b0d64d0a554549e5b2808002a0725493.asciidoc 0000644 00000000353 14373463016 0015005 0 ustar 00 // search/request/scroll.asciidoc:161
[source, php]
----
$params = [
'body' => [
'scroll_id' => 'DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==',
],
];
$response = $client->clearScroll($params);
----
docs/examples/b0eaf67e5cce24ef8889bf20951ccec1.asciidoc 0000644 00000001171 14373463016 0015712 0 ustar 00 // query-dsl/multi-match-query.asciidoc:130
[source, php]
----
$params = [
'body' => [
'query' => [
'dis_max' => [
'queries' => [
[
'match' => [
'subject' => 'brown fox',
],
],
[
'match' => [
'message' => 'brown fox',
],
],
],
'tie_breaker' => 0.3,
],
],
],
];
$response = $client->search($params);
----
docs/examples/b0ec418bf416c62bed602b0a32a6d5f5.asciidoc 0000644 00000000306 14373463016 0015512 0 ustar 00 // indices/aliases.asciidoc:441
[source, php]
----
$params = [
'index' => 'alias1',
'id' => '1',
'body' => [
'foo' => 'bar',
],
];
$response = $client->index($params);
----
docs/examples/b1efa1c51a34dd5ab5511b71a399f5b1.asciidoc 0000644 00000000465 14373463016 0015520 0 ustar 00 // docs/reindex.asciidoc:417
[source, php]
----
$params = [
'body' => [
'source' => [
'index' => 'source',
],
'dest' => [
'index' => 'dest',
'pipeline' => 'some_ingest_pipeline',
],
],
];
$response = $client->reindex($params);
----
docs/examples/b214942b938e47f2c486e523546cb574.asciidoc 0000644 00000001135 14373463016 0015116 0 ustar 00 // mapping/types/nested.asciidoc:58
[source, php]
----
$params = [
'index' => 'my_index',
'body' => [
'query' => [
'bool' => [
'must' => [
[
'match' => [
'user.first' => 'Alice',
],
],
[
'match' => [
'user.last' => 'Smith',
],
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/b41dce56b0e640d32b1cf452f87cec17.asciidoc 0000644 00000000377 14373463016 0015536 0 ustar 00 // search/request/scroll.asciidoc:63
[source, php]
----
$params = [
'body' => [
'scroll' => '1m',
'scroll_id' => 'DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==',
],
];
$response = $client->scroll($params);
----
docs/examples/b4392116f2cc57ce8064ccbad30318d5.asciidoc 0000644 00000000525 14373463016 0015367 0 ustar 00 // indices/aliases.asciidoc:170
[source, php]
----
$params = [
'body' => [
'actions' => [
[
'add' => [
'index' => 'test1',
'alias' => 'alias1',
],
],
],
],
];
$response = $client->indices()->updateAliases($params);
----
docs/examples/b4a0d0ed512dffc10ee53bca2feca49b.asciidoc 0000644 00000002242 14373463016 0016070 0 ustar 00 // query-dsl/function-score-query.asciidoc:41
[source, php]
----
$params = [
'body' => [
'query' => [
'function_score' => [
'query' => [
'match_all' => [
],
],
'boost' => '5',
'functions' => [
[
'filter' => [
'match' => [
'test' => 'bar',
],
],
'random_score' => [
],
'weight' => 23,
],
[
'filter' => [
'match' => [
'test' => 'cat',
],
],
'weight' => 42,
],
],
'max_boost' => 42,
'score_mode' => 'max',
'boost_mode' => 'multiply',
'min_score' => 42,
],
],
],
];
$response = $client->search($params);
----
docs/examples/b68c85fe1b0d2f264dc0d1cbf530f319.asciidoc 0000644 00000001335 14373463016 0015532 0 ustar 00 // query-dsl/function-score-query.asciidoc:175
[source, php]
----
$params = [
'body' => [
'query' => [
'function_score' => [
'query' => [
'match' => [
'message' => 'elasticsearch',
],
],
'script_score' => [
'script' => [
'params' => [
'a' => 5,
'b' => 1.2,
],
'source' => 'params.a / Math.pow(params.b, doc[\'likes\'].value)',
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/b789292f9cf63ce912e058c46d90ce20.asciidoc 0000644 00000000640 14373463016 0015342 0 ustar 00 // aggregations/bucket/datehistogram-aggregation.asciidoc:119
[source, php]
----
$params = [
'index' => 'sales',
'body' => [
'aggs' => [
'sales_over_time' => [
'date_histogram' => [
'field' => 'date',
'calendar_interval' => 'month',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/b918d6b798da673a33e49b94f61dcdc0.asciidoc 0000644 00000000446 14373463016 0015504 0 ustar 00 // docs/index_.asciidoc:411
[source, php]
----
$params = [
'index' => 'twitter',
'id' => '1',
'body' => [
'user' => 'kimchy',
'post_date' => '2009-11-15T14:12:12',
'message' => 'trying out Elasticsearch',
],
];
$response = $client->index($params);
----
docs/examples/b919f88e6f47a40d5793479440a90ba6.asciidoc 0000644 00000004743 14373463016 0015217 0 ustar 00 // mapping/types/nested.asciidoc:85
[source, php]
----
$params = [
'index' => 'my_index',
'body' => [
'mappings' => [
'properties' => [
'user' => [
'type' => 'nested',
],
],
],
],
];
$response = $client->indices()->create($params);
$params = [
'index' => 'my_index',
'id' => '1',
'body' => [
'group' => 'fans',
'user' => [
[
'first' => 'John',
'last' => 'Smith',
],
[
'first' => 'Alice',
'last' => 'White',
],
],
],
];
$response = $client->index($params);
$params = [
'index' => 'my_index',
'body' => [
'query' => [
'nested' => [
'path' => 'user',
'query' => [
'bool' => [
'must' => [
[
'match' => [
'user.first' => 'Alice',
],
],
[
'match' => [
'user.last' => 'Smith',
],
],
],
],
],
],
],
],
];
$response = $client->search($params);
$params = [
'index' => 'my_index',
'body' => [
'query' => [
'nested' => [
'path' => 'user',
'query' => [
'bool' => [
'must' => [
[
'match' => [
'user.first' => 'Alice',
],
],
[
'match' => [
'user.last' => 'White',
],
],
],
],
],
'inner_hits' => [
'highlight' => [
'fields' => [
'user.first' => [
],
],
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/b93ed4ef309819734f0eeea82e8b0f1f.asciidoc 0000644 00000001152 14373463016 0015555 0 ustar 00 // aggregations/bucket/filter-aggregation.asciidoc:9
[source, php]
----
$params = [
'index' => 'sales',
'body' => [
'aggs' => [
't_shirts' => [
'filter' => [
'term' => [
'type' => 't-shirt',
],
],
'aggs' => [
'avg_price' => [
'avg' => [
'field' => 'price',
],
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/b94cee0f74f57742b3948f9b784dfdd4.asciidoc 0000644 00000000665 14373463016 0015527 0 ustar 00 // search/request/scroll.asciidoc:194
[source, php]
----
$params = [
'scroll_id' => 'DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==,DnF1ZXJ5VGhlbkZldGNoBQAAAAAAAAABFmtSWWRRWUJrU2o2ZExpSGJCVmQxYUEAAAAAAAAAAxZrUllkUVlCa1NqNmRMaUhiQlZkMWFBAAAAAAAAAAIWa1JZZFFZQmtTajZkTGlIYkJWZDFhQQAAAAAAAAAFFmtSWWRRWUJrU2o2ZExpSGJCVmQxYUEAAAAAAAAABBZrUllkUVlCa1NqNmRMaUhiQlZkMWFB',
];
$response = $client->clearScroll($params);
----
docs/examples/b997885974522ef439d5e345924cc5ba.asciidoc 0000644 00000001210 14373463016 0015211 0 ustar 00 // search/request/sort.asciidoc:94
[source, php]
----
$params = [
'index' => 'my_index',
'id' => '1',
'body' => [
'product' => 'chocolate',
'price' => [
20,
4,
],
],
];
$response = $client->index($params);
$params = [
'body' => [
'query' => [
'term' => [
'product' => 'chocolate',
],
],
'sort' => [
[
'price' => [
'order' => 'asc',
'mode' => 'avg',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/b9a153725b28fdd0a5aabd7f17a8c2d7.asciidoc 0000644 00000000230 14373463016 0015604 0 ustar 00 // api-conventions.asciidoc:386
[source, php]
----
$params = [
'index' => 'twitter',
];
$response = $client->indices()->getSettings($params);
----
docs/examples/b9c5d7ca6ca9c6f747201f45337a4abf.asciidoc 0000644 00000000435 14373463016 0015545 0 ustar 00 // indices/create-index.asciidoc:99
[source, php]
----
$params = [
'index' => 'twitter',
'body' => [
'settings' => [
'number_of_shards' => 3,
'number_of_replicas' => 2,
],
],
];
$response = $client->indices()->create($params);
----
docs/examples/ba0b4081c98f3387f76b77847c52ee9a.asciidoc 0000644 00000001101 14373463016 0015336 0 ustar 00 // indices/update-settings.asciidoc:169
[source, php]
----
$params = [
'index' => 'twitter',
];
$response = $client->indices()->close($params);
$params = [
'index' => 'twitter',
'body' => [
'analysis' => [
'analyzer' => [
'content' => [
'type' => 'custom',
'tokenizer' => 'whitespace',
],
],
],
],
];
$response = $client->indices()->putSettings($params);
$params = [
'index' => 'twitter',
];
$response = $client->indices()->open($params);
----
docs/examples/bb143628fd04070683eeeadc9406d9cc.asciidoc 0000644 00000000446 14373463016 0015463 0 ustar 00 // docs/index_.asciidoc:498
[source, php]
----
$params = [
'index' => 'twitter',
'id' => '1',
'body' => [
'user' => 'kimchy',
'post_date' => '2009-11-15T14:12:12',
'message' => 'trying out Elasticsearch',
],
];
$response = $client->index($params);
----
docs/examples/bc1ad5cc6d3eab98e3ce01f209ba7094.asciidoc 0000644 00000000572 14373463016 0015671 0 ustar 00 // indices/aliases.asciidoc:348
[source, php]
----
$params = [
'body' => [
'actions' => [
[
'add' => [
'index' => 'test',
'alias' => 'alias1',
'routing' => '1',
],
],
],
],
];
$response = $client->indices()->updateAliases($params);
----
docs/examples/bd5918ab903c0889bb1f09c8c2466e43.asciidoc 0000644 00000000524 14373463016 0015331 0 ustar 00 // indices/put-mapping.asciidoc:417
[source, php]
----
$params = [
'index' => 'users',
'body' => [
'mappings' => [
'properties' => [
'user_id' => [
'type' => 'long',
],
],
],
],
];
$response = $client->indices()->create($params);
----
docs/examples/bdb30dd52d32f50994008f4f9c0da5f0.asciidoc 0000644 00000000265 14373463016 0015453 0 ustar 00 // docs/update-by-query.asciidoc:517
[source, php]
----
$params = [
'task_id' => 'r1A2WoRbTwKZ516z6NEs5A:36619',
];
$response = $client->updateByQueryRethrottle($params);
----
docs/examples/be1bd47393646ac6bbee177d1cdb7738.asciidoc 0000644 00000000650 14373463016 0015547 0 ustar 00 // query-dsl/query-string-query.asciidoc:472
[source, php]
----
$params = [
'body' => [
'query' => [
'query_string' => [
'fields' => [
'title',
'content',
],
'query' => 'this that thus',
'minimum_should_match' => 2,
],
],
],
];
$response = $client->search($params);
----
docs/examples/be3a6431d01846950dc1a39a7a6a1faa.asciidoc 0000644 00000000252 14373463016 0015433 0 ustar 00 // docs/update-by-query.asciidoc:478
[source, php]
----
$params = [
'task_id' => 'r1A2WoRbTwKZ516z6NEs5A:36619',
];
$response = $client->tasks()->get($params);
----
docs/examples/be8f28f31207b173de61be032fcf239c.asciidoc 0000644 00000000221 14373463016 0015446 0 ustar 00 // indices/get-index.asciidoc:11
[source, php]
----
$params = [
'index' => 'twitter',
];
$response = $client->indices()->get($params);
----
docs/examples/bfcd65ab85d684d36a8550080032958d.asciidoc 0000644 00000000133 14373463016 0015244 0 ustar 00 // search/request-body.asciidoc:65
[source, php]
----
$response = $client->search();
----
docs/examples/bfdad8a928ea30d7cf60d0a0a6bc6e2e.asciidoc 0000644 00000001443 14373463016 0016025 0 ustar 00 // docs/bulk.asciidoc:646
[source, php]
----
$params = [
'body' => [
[
'update' => [
'_id' => '5',
'_index' => 'index1',
],
],
[
'doc' => [
'my_field' => 'baz',
],
],
[
'update' => [
'_id' => '6',
'_index' => 'index1',
],
],
[
'doc' => [
'my_field' => 'baz',
],
],
[
'update' => [
'_id' => '7',
'_index' => 'index1',
],
],
[
'doc' => [
'my_field' => 'baz',
],
],
],
];
$response = $client->bulk($params);
----
docs/examples/c22b72c4a52ee098331b3f252c22860d.asciidoc 0000644 00000000374 14373463016 0015224 0 ustar 00 // docs/delete-by-query.asciidoc:369
[source, php]
----
$params = [
'index' => 'twitter,blog',
'body' => [
'query' => [
'match_all' => [
],
],
],
];
$response = $client->deleteByQuery($params);
----
docs/examples/c2c21e2824fbf6b7198ede30419da82b.asciidoc 0000644 00000000224 14373463016 0015455 0 ustar 00 // search/request/scroll.asciidoc:186
[source, php]
----
$params = [
'scroll_id' => '_all',
];
$response = $client->clearScroll($params);
----
docs/examples/c32a3f8071d87f0a3f5a78e07fe7a669.asciidoc 0000644 00000000502 14373463016 0015413 0 ustar 00 // docs/delete-by-query.asciidoc:383
[source, php]
----
$params = [
'index' => 'twitter',
'body' => [
'query' => [
'range' => [
'age' => [
'gte' => 10,
],
],
],
],
];
$response = $client->deleteByQuery($params);
----
docs/examples/c48264ec5d9b9679fddd72e5c44425b9.asciidoc 0000644 00000000222 14373463016 0015430 0 ustar 00 // cluster/health.asciidoc:186
[source, php]
----
$params = [
'index' => 'twitter',
];
$response = $client->cluster()->health($params);
----
docs/examples/c4b278ba293abd0d02a0b5ad1a99f84a.asciidoc 0000644 00000000747 14373463016 0015604 0 ustar 00 // docs/update-by-query.asciidoc:396
[source, php]
----
$params = [
'id' => 'set-foo',
'body' => [
'description' => 'sets foo',
'processors' => [
[
'set' => [
'field' => 'foo',
'value' => 'bar',
],
],
],
],
];
$response = $client->ingest()->putPipeline($params);
$params = [
'index' => 'twitter',
];
$response = $client->updateByQuery($params);
----
docs/examples/c5e5873783246c7b1c01d8464fed72c4.asciidoc 0000644 00000000225 14373463016 0015253 0 ustar 00 // docs/delete.asciidoc:172
[source, php]
----
$params = [
'index' => 'twitter',
'id' => '1',
];
$response = $client->delete($params);
----
docs/examples/c612d93e7f682a0d731e385edf9f5d56.asciidoc 0000644 00000000530 14373463016 0015423 0 ustar 00 // query-dsl/nested-query.asciidoc:23
[source, php]
----
$params = [
'index' => 'my_index',
'body' => [
'mappings' => [
'properties' => [
'obj1' => [
'type' => 'nested',
],
],
],
],
];
$response = $client->indices()->create($params);
----
docs/examples/c849c6c8f8659dbb93e1c14356f74e37.asciidoc 0000644 00000000524 14373463016 0015357 0 ustar 00 // indices/put-mapping.asciidoc:239
[source, php]
----
$params = [
'index' => 'my_index',
'body' => [
'mappings' => [
'properties' => [
'city' => [
'type' => 'text',
],
],
],
],
];
$response = $client->indices()->create($params);
----
docs/examples/cb01106bf524df5e0501d4c655c1aa7b.asciidoc 0000644 00000000413 14373463016 0015422 0 ustar 00 // docs/reindex.asciidoc:264
[source, php]
----
$params = [
'body' => [
'source' => [
'index' => 'twitter',
],
'dest' => [
'index' => 'new_twitter',
],
],
];
$response = $client->reindex($params);
----
docs/examples/cd247f267968aa0927bfdad56852f8f5.asciidoc 0000644 00000000416 14373463016 0015431 0 ustar 00 // getting-started.asciidoc:482
[source, php]
----
$params = [
'index' => 'bank',
'body' => [
'query' => [
'match' => [
'address' => 'mill lane',
],
],
],
];
$response = $client->search($params);
----
docs/examples/cd5bc5bf7cd58d7b1492c9c298b345f6.asciidoc 0000644 00000001230 14373463016 0015556 0 ustar 00 // aggregations/bucket/terms-aggregation.asciidoc:672
[source, php]
----
$params = [
'body' => [
'aggs' => [
'actors' => [
'terms' => [
'field' => 'actors',
'size' => 10,
'collect_mode' => 'breadth_first',
],
'aggs' => [
'costars' => [
'terms' => [
'field' => 'actors',
'size' => 5,
],
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/cde4dddae5c06e7f1d38c9d933dbc7ac.asciidoc 0000644 00000000231 14373463016 0016121 0 ustar 00 // docs/update-by-query.asciidoc:326
[source, php]
----
$params = [
'index' => 'twitter,blog',
];
$response = $client->updateByQuery($params);
----
docs/examples/cdedd5f33f7e5f7acde561e97bff61de.asciidoc 0000644 00000000441 14373463016 0016144 0 ustar 00 // query-dsl/term-query.asciidoc:132
[source, php]
----
$params = [
'index' => 'my_index',
'body' => [
'query' => [
'term' => [
'full_text' => 'Quick Brown Foxes!',
],
],
],
];
$response = $client->search($params);
----
docs/examples/cf02e3d8b371bd59f0224967c36330da.asciidoc 0000644 00000000241 14373463016 0015310 0 ustar 00 // indices/get-mapping.asciidoc:68
[source, php]
----
$params = [
'index' => 'twitter,kimchy',
];
$response = $client->indices()->getMapping($params);
----
docs/examples/cfbaea6f0df045c5d940bbb6a9c69cd8.asciidoc 0000644 00000001102 14373463016 0016033 0 ustar 00 // getting-started.asciidoc:665
[source, php]
----
$params = [
'index' => 'bank',
'body' => [
'size' => 0,
'aggs' => [
'group_by_state' => [
'terms' => [
'field' => 'state.keyword',
],
'aggs' => [
'average_balance' => [
'avg' => [
'field' => 'balance',
],
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/cfc37446bd892d1ac42a3c8e8b204e6c.asciidoc 0000644 00000000221 14373463016 0015531 0 ustar 00 // docs/reindex.asciidoc:735
[source, php]
----
$params = [
'index' => 'test2',
'id' => '1',
];
$response = $client->get($params);
----
docs/examples/d0a8a938a2fa913b6fdbc871079a59dd.asciidoc 0000644 00000000512 14373463016 0015545 0 ustar 00 // query-dsl/term-query.asciidoc:28
[source, php]
----
$params = [
'body' => [
'query' => [
'term' => [
'user' => [
'value' => 'Kimchy',
'boost' => 1,
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/d17269bb80fb63ec0bf37d219e003dcb.asciidoc 0000644 00000001254 14373463016 0015527 0 ustar 00 // search/request/sort.asciidoc:391
[source, php]
----
$params = [
'body' => [
'sort' => [
[
'_geo_distance' => [
'pin.location' => [
-70,
40,
],
'order' => 'asc',
'unit' => 'km',
'mode' => 'min',
'distance_type' => 'arc',
'ignore_unmapped' => true,
],
],
],
'query' => [
'term' => [
'user' => 'kimchy',
],
],
],
];
$response = $client->search($params);
----
docs/examples/d1b3b7d2bb2ab90d15fd10318abd24db.asciidoc 0000644 00000001137 14373463016 0015641 0 ustar 00 // search/request/sort.asciidoc:11
[source, php]
----
$params = [
'index' => 'my_index',
'body' => [
'mappings' => [
'properties' => [
'post_date' => [
'type' => 'date',
],
'user' => [
'type' => 'keyword',
],
'name' => [
'type' => 'keyword',
],
'age' => [
'type' => 'integer',
],
],
],
],
];
$response = $client->indices()->create($params);
----
docs/examples/d1bcf2eb63a462bfdcf01a68e68d5b4a.asciidoc 0000644 00000000621 14373463016 0015746 0 ustar 00 // query-dsl/terms-query.asciidoc:186
[source, php]
----
$params = [
'index' => 'my_index',
'body' => [
'query' => [
'terms' => [
'color' => [
'index' => 'my_index',
'id' => '2',
'path' => 'color',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/d222c6a6ec7a3beca6c97011b0874512.asciidoc 0000644 00000000225 14373463016 0015357 0 ustar 00 // docs/get.asciidoc:278
[source, php]
----
$params = [
'index' => 'twitter',
'id' => '1',
];
$response = $client->getSource($params);
----
docs/examples/d3016e4e8025362ad9a05ee86bb2061f.asciidoc 0000644 00000000526 14373463016 0015310 0 ustar 00 // indices/aliases.asciidoc:12
[source, php]
----
$params = [
'body' => [
'actions' => [
[
'add' => [
'index' => 'twitter',
'alias' => 'alias1',
],
],
],
],
];
$response = $client->indices()->updateAliases($params);
----
docs/examples/d3088d5fa59b3ab110f64fb4f9b0065c.asciidoc 0000644 00000000377 14373463016 0015461 0 ustar 00 // query-dsl/terms-query.asciidoc:145
[source, php]
----
$params = [
'index' => 'my_index',
'id' => '1',
'body' => [
'color' => [
'blue',
'green',
],
],
];
$response = $client->index($params);
----
docs/examples/d31062ff8c015387889fed4ad86fd914.asciidoc 0000644 00000000603 14373463016 0015345 0 ustar 00 // query-dsl/wildcard-query.asciidoc:21
[source, php]
----
$params = [
'body' => [
'query' => [
'wildcard' => [
'user' => [
'value' => 'ki*y',
'boost' => 1,
'rewrite' => 'constant_score',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/d4b4cefba4318caeba7480187faf2b13.asciidoc 0000644 00000000342 14373463016 0015662 0 ustar 00 // query-dsl/term-query.asciidoc:113
[source, php]
----
$params = [
'index' => 'my_index',
'id' => '1',
'body' => [
'full_text' => 'Quick Brown Foxes!',
],
];
$response = $client->index($params);
----
docs/examples/d50a3c64890f88af32c6d4ef4899d82a.asciidoc 0000644 00000000742 14373463016 0015431 0 ustar 00 // search/request/sort.asciidoc:470
[source, php]
----
$params = [
'body' => [
'sort' => [
[
'_geo_distance' => [
'pin.location' => '40,-70',
'order' => 'asc',
'unit' => 'km',
],
],
],
'query' => [
'term' => [
'user' => 'kimchy',
],
],
],
];
$response = $client->search($params);
----
docs/examples/d5dcddc6398b473b6ad9bce5c6adf986.asciidoc 0000644 00000000275 14373463016 0016011 0 ustar 00 // search/request/scroll.asciidoc:95
[source, php]
----
$params = [
'body' => [
'sort' => [
'_doc',
],
],
];
$response = $client->search($params);
----
docs/examples/d718b63cf1b6591a1d59a0cf4fd995eb.asciidoc 0000644 00000000446 14373463016 0015556 0 ustar 00 // docs/index_.asciidoc:544
[source, php]
----
$params = [
'index' => 'twitter',
'id' => '1',
'body' => [
'user' => 'kimchy',
'post_date' => '2009-11-15T14:12:12',
'message' => 'trying out Elasticsearch',
],
];
$response = $client->index($params);
----
docs/examples/d8b115341da772a628a024e7d1644e73.asciidoc 0000644 00000000224 14373463016 0015146 0 ustar 00 // docs/update-by-query.asciidoc:334
[source, php]
----
$params = [
'index' => 'twitter',
];
$response = $client->updateByQuery($params);
----
docs/examples/d8b2a88b5eca99d3691ad3cd40266736.asciidoc 0000644 00000000770 14373463016 0015417 0 ustar 00 // mapping.asciidoc:147
[source, php]
----
$params = [
'index' => 'my-index',
'body' => [
'mappings' => [
'properties' => [
'age' => [
'type' => 'integer',
],
'email' => [
'type' => 'keyword',
],
'name' => [
'type' => 'text',
],
],
],
],
];
$response = $client->indices()->create($params);
----
docs/examples/d90a84a24a407731dfc1929ac8327746.asciidoc 0000644 00000000225 14373463016 0015162 0 ustar 00 // docs/delete.asciidoc:131
[source, php]
----
$params = [
'index' => 'twitter',
'id' => '1',
];
$response = $client->delete($params);
----
docs/examples/d9474f66970c6955e24b17c7447e7b5f.asciidoc 0000644 00000000731 14373463016 0015222 0 ustar 00 // indices/put-mapping.asciidoc:149
[source, php]
----
$params = [
'index' => 'my_index',
'body' => [
'mappings' => [
'properties' => [
'name' => [
'properties' => [
'first' => [
'type' => 'text',
],
],
],
],
],
],
];
$response = $client->indices()->create($params);
----
docs/examples/db6cba451ba562abe953d09ad80cc15c.asciidoc 0000644 00000000437 14373463016 0015662 0 ustar 00 // query-dsl/query-string-query.asciidoc:333
[source, php]
----
$params = [
'body' => [
'query' => [
'query_string' => [
'query' => 'city.\*:(this AND that OR thus)',
],
],
],
];
$response = $client->search($params);
----
docs/examples/dc15e2373e5ecbe09b4ea0858eb63d47.asciidoc 0000644 00000001772 14373463016 0015552 0 ustar 00 // aggregations/bucket/terms-aggregation.asciidoc:309
[source, php]
----
$params = [
'body' => [
'aggs' => [
'countries' => [
'terms' => [
'field' => 'artist.country',
'order' => [
'rock>playback_stats.avg' => 'desc',
],
],
'aggs' => [
'rock' => [
'filter' => [
'term' => [
'genre' => 'rock',
],
],
'aggs' => [
'playback_stats' => [
'stats' => [
'field' => 'play_count',
],
],
],
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/de139866a220124360e5e27d1a736ea4.asciidoc 0000644 00000001334 14373463016 0015150 0 ustar 00 // search/request/sort.asciidoc:262
[source, php]
----
$params = [
'body' => [
'query' => [
'term' => [
'product' => 'chocolate',
],
],
'sort' => [
[
'offer.price' => [
'mode' => 'avg',
'order' => 'asc',
'nested' => [
'path' => 'offer',
'filter' => [
'term' => [
'offer.color' => 'blue',
],
],
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/de176bc4788ea286fff9e92418a43ea8.asciidoc 0000644 00000001177 14373463016 0015521 0 ustar 00 // indices/aliases.asciidoc:276
[source, php]
----
$params = [
'index' => 'test',
];
$response = $client->indices()->create($params);
$params = [
'index' => 'test_2',
];
$response = $client->indices()->create($params);
$params = [
'body' => [
'actions' => [
[
'add' => [
'index' => 'test_2',
'alias' => 'test',
],
],
[
'remove_index' => [
'index' => 'test',
],
],
],
],
];
$response = $client->indices()->updateAliases($params);
----
docs/examples/df17f920b0deab3529b98df88b781f55.asciidoc 0000644 00000002027 14373463016 0015504 0 ustar 00 // query-dsl/function-score-query.asciidoc:578
[source, php]
----
$params = [
'body' => [
'query' => [
'function_score' => [
'functions' => [
[
'gauss' => [
'price' => [
'origin' => '0',
'scale' => '20',
],
],
],
[
'gauss' => [
'location' => [
'origin' => '11, 12',
'scale' => '2km',
],
],
],
],
'query' => [
'match' => [
'properties' => 'balcony',
],
],
'score_mode' => 'multiply',
],
],
],
];
$response = $client->search($params);
----
docs/examples/dfac8d098b50aa0181161bcd17b38ef4.asciidoc 0000644 00000000377 14373463016 0015532 0 ustar 00 // indices/update-settings.asciidoc:103
[source, php]
----
$params = [
'index' => 'twitter',
'body' => [
'index' => [
'refresh_interval' => '-1',
],
],
];
$response = $client->indices()->putSettings($params);
----
docs/examples/dfb1fe96d806a644214d06f9b4b87878.asciidoc 0000644 00000000426 14373463016 0015350 0 ustar 00 // docs/delete-by-query.asciidoc:401
[source, php]
----
$params = [
'index' => 'twitter',
'body' => [
'query' => [
'term' => [
'user' => 'kimchy',
],
],
],
];
$response = $client->deleteByQuery($params);
----
docs/examples/dfef545b1e2c247bafd1347e8e807ac1.asciidoc 0000644 00000000633 14373463016 0015621 0 ustar 00 // indices/create-index.asciidoc:123
[source, php]
----
$params = [
'index' => 'test',
'body' => [
'settings' => [
'number_of_shards' => 1,
],
'mappings' => [
'properties' => [
'field1' => [
'type' => 'text',
],
],
],
],
];
$response = $client->indices()->create($params);
----
docs/examples/e0d6e02b998bdea99c9c08dcc3630c5e.asciidoc 0000644 00000000465 14373463016 0015637 0 ustar 00 // query-dsl/match-query.asciidoc:18
[source, php]
----
$params = [
'body' => [
'query' => [
'match' => [
'message' => [
'query' => 'this is a test',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/e17e8852ec3f31781e1364f4dffeb6d0.asciidoc 0000644 00000000473 14373463016 0015500 0 ustar 00 // query-dsl/query-string-query.asciidoc:281
[source, php]
----
$params = [
'body' => [
'query' => [
'query_string' => [
'query' => '(content:this OR name:this) AND (content:that OR name:that)',
],
],
],
];
$response = $client->search($params);
----
docs/examples/e21e1c26dc8687e7bf7bd2bf019a6698.asciidoc 0000644 00000000367 14373463016 0015506 0 ustar 00 // docs/delete-by-query.asciidoc:356
[source, php]
----
$params = [
'index' => 'twitter',
'body' => [
'query' => [
'match_all' => [
],
],
],
];
$response = $client->deleteByQuery($params);
----
docs/examples/e270f3f721a5712cd11a5ca03554f5b0.asciidoc 0000644 00000000712 14373463016 0015270 0 ustar 00 // query-dsl/multi-match-query.asciidoc:170
[source, php]
----
$params = [
'body' => [
'query' => [
'multi_match' => [
'query' => 'Will Smith',
'type' => 'best_fields',
'fields' => [
'first_name',
'last_name',
],
'operator' => 'and',
],
],
],
];
$response = $client->search($params);
----
docs/examples/e2a042c629429855c3bcaefffb26b7fa.asciidoc 0000644 00000000643 14373463016 0015623 0 ustar 00 // mapping/types/date.asciidoc:77
[source, php]
----
$params = [
'index' => 'my_index',
'body' => [
'mappings' => [
'properties' => [
'date' => [
'type' => 'date',
'format' => 'yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis',
],
],
],
],
];
$response = $client->indices()->create($params);
----
docs/examples/e30ea6e3823a139d7693d8cce1920a06.asciidoc 0000644 00000000574 14373463016 0015324 0 ustar 00 // query-dsl/multi-match-query.asciidoc:50
[source, php]
----
$params = [
'body' => [
'query' => [
'multi_match' => [
'query' => 'this is a test',
'fields' => [
'subject^3',
'message',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/e4be53736bcc02b03068fd72fdbfe271.asciidoc 0000644 00000000445 14373463016 0015534 0 ustar 00 // indices/put-mapping.asciidoc:97
[source, php]
----
$params = [
'index' => 'publications',
'body' => [
'properties' => [
'title' => [
'type' => 'text',
],
],
],
];
$response = $client->indices()->putMapping($params);
----
docs/examples/e567e6dbf86300142573c73789c8fce4.asciidoc 0000644 00000000211 14373463016 0015261 0 ustar 00 // docs/reindex.asciidoc:280
[source, php]
----
$params = [
'index' => 'new_twitter',
];
$response = $client->search($params);
----
docs/examples/e5d2172b524332196cac0f031c043659.asciidoc 0000644 00000000515 14373463016 0015057 0 ustar 00 // indices/create-index.asciidoc:81
[source, php]
----
$params = [
'index' => 'twitter',
'body' => [
'settings' => [
'index' => [
'number_of_shards' => 3,
'number_of_replicas' => 2,
],
],
],
];
$response = $client->indices()->create($params);
----
docs/examples/e5f50b31f165462d883ecbff45f74985.asciidoc 0000644 00000001336 14373463016 0015351 0 ustar 00 // indices/templates.asciidoc:20
[source, php]
----
$params = [
'name' => 'template_1',
'body' => [
'index_patterns' => [
'te*',
'bar*',
],
'settings' => [
'number_of_shards' => 1,
],
'mappings' => [
'_source' => [
'enabled' => false,
],
'properties' => [
'host_name' => [
'type' => 'keyword',
],
'created_at' => [
'type' => 'date',
'format' => 'EEE MMM dd HH:mm:ss Z yyyy',
],
],
],
],
];
$response = $client->indices()->putTemplate($params);
----
docs/examples/e8e451bc8c45bcf16df43804c4fc8329.asciidoc 0000644 00000001050 14373463016 0015466 0 ustar 00 // search/request/sort.asciidoc:597
[source, php]
----
$params = [
'body' => [
'track_scores' => true,
'sort' => [
[
'post_date' => [
'order' => 'desc',
],
],
[
'name' => 'desc',
],
[
'age' => 'desc',
],
],
'query' => [
'term' => [
'user' => 'kimchy',
],
],
],
];
$response = $client->search($params);
----
docs/examples/e9c2e15b36372d5281c879d336322b6c.asciidoc 0000644 00000000545 14373463016 0015172 0 ustar 00 // docs/reindex.asciidoc:683
[source, php]
----
$params = [
'body' => [
'source' => [
'index' => 'twitter',
'_source' => [
'user',
'_doc',
],
],
'dest' => [
'index' => 'new_twitter',
],
],
];
$response = $client->reindex($params);
----
docs/examples/e9fe608f105d7e3268a15e409e2cb9ab.asciidoc 0000644 00000002473 14373463016 0015475 0 ustar 00 // aggregations/metrics/valuecount-aggregation.asciidoc:96
[source, php]
----
$params = [
'index' => 'metrics_index',
'id' => '1',
'body' => [
'network.name' => 'net-1',
'latency_histo' => [
'values' => [
0.1,
0.2,
0.3,
0.4,
0.5,
],
'counts' => [
3,
7,
23,
12,
6,
],
],
],
];
$response = $client->index($params);
$params = [
'index' => 'metrics_index',
'id' => '2',
'body' => [
'network.name' => 'net-2',
'latency_histo' => [
'values' => [
0.1,
0.2,
0.3,
0.4,
0.5,
],
'counts' => [
8,
17,
8,
7,
6,
],
],
],
];
$response = $client->index($params);
$params = [
'index' => 'metrics_index',
'body' => [
'aggs' => [
'total_requests' => [
'value_count' => [
'field' => 'latency_histo',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/ea02de2dbe05091fcb0dac72c8ba5f83.asciidoc 0000644 00000000411 14373463016 0015731 0 ustar 00 // docs/update-by-query.asciidoc:593
[source, php]
----
$params = [
'index' => 'twitter',
'body' => [
'script' => [
'source' => 'ctx._source[\'extra\'] = \'test\'',
],
],
];
$response = $client->updateByQuery($params);
----
docs/examples/eb30ba547e4a7b8f54f33ab259aca523.asciidoc 0000644 00000000357 14373463016 0015532 0 ustar 00 // docs/update.asciidoc:153
[source, php]
----
$params = [
'index' => 'test',
'id' => '1',
'body' => [
'script' => 'ctx._source.new_field = \'value_of_new_field\'',
],
];
$response = $client->update($params);
----
docs/examples/ebb6b59fbc9325c17e45f524602d6be2.asciidoc 0000644 00000000437 14373463016 0015466 0 ustar 00 // docs/delete-by-query.asciidoc:10
[source, php]
----
$params = [
'index' => 'twitter',
'body' => [
'query' => [
'match' => [
'message' => 'some message',
],
],
],
];
$response = $client->deleteByQuery($params);
----
docs/examples/ec27afee074001b0e4e393611010842b.asciidoc 0000644 00000000772 14373463016 0015214 0 ustar 00 // query-dsl/function-score-query.asciidoc:380
[source, php]
----
$params = [
'body' => [
'query' => [
'function_score' => [
'gauss' => [
'date' => [
'origin' => '2013-09-17',
'scale' => '10d',
'offset' => '5d',
'decay' => 0.5,
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/ec473de07fe89bcbac1f8e278617fe46.asciidoc 0000644 00000001075 14373463016 0015650 0 ustar 00 // query-dsl/function-score-query.asciidoc:137
[source, php]
----
$params = [
'body' => [
'query' => [
'function_score' => [
'query' => [
'match' => [
'message' => 'elasticsearch',
],
],
'script_score' => [
'script' => [
'source' => 'Math.log(2 + doc[\'likes\'].value)',
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/ef0f4fa4272c47ff62fb7b422cf975e7.asciidoc 0000644 00000000620 14373463016 0015556 0 ustar 00 // search/request/sort.asciidoc:345
[source, php]
----
$params = [
'body' => [
'sort' => [
[
'price' => [
'missing' => '_last',
],
],
],
'query' => [
'term' => [
'product' => 'chocolate',
],
],
],
];
$response = $client->search($params);
----
docs/examples/ef9111c1648d7820925f12e07d1346c5.asciidoc 0000644 00000001010 14373463016 0015071 0 ustar 00 // mapping/params/fielddata.asciidoc:56
[source, php]
----
$params = [
'index' => 'my_index',
'body' => [
'mappings' => [
'properties' => [
'my_field' => [
'type' => 'text',
'fields' => [
'keyword' => [
'type' => 'keyword',
],
],
],
],
],
],
];
$response = $client->indices()->create($params);
----
docs/examples/f085fb032dae56a3b104ab874eaea2ad.asciidoc 0000644 00000000540 14373463016 0015650 0 ustar 00 // aggregations/bucket/terms-aggregation.asciidoc:748
[source, php]
----
$params = [
'body' => [
'aggs' => [
'tags' => [
'terms' => [
'field' => 'tags',
'missing' => 'N/A',
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/f0e21e03a07c8fa0209b0aafdb3791e6.asciidoc 0000644 00000000761 14373463016 0015516 0 ustar 00 // indices/aliases.asciidoc:222
[source, php]
----
$params = [
'body' => [
'actions' => [
[
'add' => [
'index' => 'test1',
'alias' => 'alias1',
],
],
[
'add' => [
'index' => 'test2',
'alias' => 'alias1',
],
],
],
],
];
$response = $client->indices()->updateAliases($params);
----
docs/examples/f29a28fffa7ec604a33a838f48f7ea79.asciidoc 0000644 00000002023 14373463016 0015565 0 ustar 00 // query-dsl/query_filter_context.asciidoc:62
[source, php]
----
$params = [
'body' => [
'query' => [
'bool' => [
'must' => [
[
'match' => [
'title' => 'Search',
],
],
[
'match' => [
'content' => 'Elasticsearch',
],
],
],
'filter' => [
[
'term' => [
'status' => 'published',
],
],
[
'range' => [
'publish_date' => [
'gte' => '2015-01-01',
],
],
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/f2d68493abd3ca430bd03a7f7f8d18f9.asciidoc 0000644 00000000571 14373463016 0015552 0 ustar 00 // query-dsl/query-string-query.asciidoc:265
[source, php]
----
$params = [
'body' => [
'query' => [
'query_string' => [
'fields' => [
'content',
'name',
],
'query' => 'this AND that',
],
],
],
];
$response = $client->search($params);
----
docs/examples/f32f0c19b42de3b87dd764fe4ca17e7c.asciidoc 0000644 00000000563 14373463016 0015632 0 ustar 00 // query-dsl/query-string-query.asciidoc:418
[source, php]
----
$params = [
'body' => [
'query' => [
'query_string' => [
'default_field' => 'title',
'query' => 'ny city',
'auto_generate_synonyms_phrase_query' => false,
],
],
],
];
$response = $client->search($params);
----
docs/examples/f4a1008b3f9baa67bb03ce9ef5ab4cb4.asciidoc 0000644 00000000531 14373463016 0015740 0 ustar 00 // search/request/sort.asciidoc:180
[source, php]
----
$params = [
'index' => 'index_double',
'body' => [
'mappings' => [
'properties' => [
'field' => [
'type' => 'date',
],
],
],
],
];
$response = $client->indices()->create($params);
----
docs/examples/f6b5032bf27c2445d28845be0d413970.asciidoc 0000644 00000000527 14373463016 0015161 0 ustar 00 // search/request/sort.asciidoc:134
[source, php]
----
$params = [
'index' => 'index_long',
'body' => [
'mappings' => [
'properties' => [
'field' => [
'type' => 'long',
],
],
],
],
];
$response = $client->indices()->create($params);
----
docs/examples/f6d6889667f56b8f49d2858070571a6b.asciidoc 0000644 00000001036 14373463016 0015150 0 ustar 00 // indices/aliases.asciidoc:415
[source, php]
----
$params = [
'body' => [
'actions' => [
[
'add' => [
'index' => 'test',
'alias' => 'alias1',
'is_write_index' => true,
],
],
[
'add' => [
'index' => 'test2',
'alias' => 'alias1',
],
],
],
],
];
$response = $client->indices()->updateAliases($params);
----
docs/examples/f70a54cd9a9f4811bf962e469f2ca2ea.asciidoc 0000644 00000000546 14373463016 0015557 0 ustar 00 // query-dsl/bool-query.asciidoc:88
[source, php]
----
$params = [
'body' => [
'query' => [
'bool' => [
'filter' => [
'term' => [
'status' => 'active',
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/f8cc4b331a19ff4df8e4a490f906ee69.asciidoc 0000644 00000000137 14373463016 0015564 0 ustar 00 // getting-started.asciidoc:167
[source, php]
----
$response = $client->cat()->health();
----
docs/examples/f9636d7ef1a45be4f36418c875cf6bef.asciidoc 0000644 00000001066 14373463016 0015574 0 ustar 00 // docs/update.asciidoc:296
[source, php]
----
$params = [
'index' => 'sessions',
'id' => 'dh3sgudg8gsrgl',
'body' => [
'scripted_upsert' => true,
'script' => [
'id' => 'my_web_session_summariser',
'params' => [
'pageViewEvent' => [
'url' => 'foo.com/bar',
'response' => 404,
'time' => '2014-01-01 12:32',
],
],
],
'upsert' => [
],
],
];
$response = $client->update($params);
----
docs/examples/fa0f4485cd48f986b7ae8cbb24e331c4.asciidoc 0000644 00000000657 14373463016 0015561 0 ustar 00 // indices/aliases.asciidoc:368
[source, php]
----
$params = [
'body' => [
'actions' => [
[
'add' => [
'index' => 'test',
'alias' => 'alias2',
'search_routing' => '1,2',
'index_routing' => '2',
],
],
],
],
];
$response = $client->indices()->updateAliases($params);
----
docs/examples/fa2fe60f570bd930d2891778c6efbfe6.asciidoc 0000644 00000000402 14373463016 0015557 0 ustar 00 // query-dsl/match-query.asciidoc:150
[source, php]
----
$params = [
'body' => [
'query' => [
'match' => [
'message' => 'this is a test',
],
],
],
];
$response = $client->search($params);
----
docs/examples/fa88f6f5a7d728ec4f1d05244228cb09.asciidoc 0000644 00000000722 14373463016 0015414 0 ustar 00 // query-dsl/bool-query.asciidoc:107
[source, php]
----
$params = [
'body' => [
'query' => [
'bool' => [
'must' => [
'match_all' => [
],
],
'filter' => [
'term' => [
'status' => 'active',
],
],
],
],
],
];
$response = $client->search($params);
----
docs/examples/fabe14480624a99e8ee42c7338672058.asciidoc 0000644 00000000225 14373463016 0015176 0 ustar 00 // indices/create-index.asciidoc:203
[source, php]
----
$params = [
'index' => 'test',
];
$response = $client->indices()->create($params);
----
docs/examples/fbcf5078a6a9e09790553804054c36b3.asciidoc 0000644 00000000217 14373463016 0015167 0 ustar 00 // docs/get.asciidoc:224
[source, php]
----
$params = [
'index' => 'twitter',
'id' => '0',
];
$response = $client->get($params);
----
docs/examples/fc8097bdfb6f3a4017bf4186ccca8a84.asciidoc 0000644 00000002362 14373463016 0015630 0 ustar 00 // mapping/params/multi-fields.asciidoc:75
[source, php]
----
$params = [
'index' => 'my_index',
'body' => [
'mappings' => [
'properties' => [
'text' => [
'type' => 'text',
'fields' => [
'english' => [
'type' => 'text',
'analyzer' => 'english',
],
],
],
],
],
],
];
$response = $client->indices()->create($params);
$params = [
'index' => 'my_index',
'id' => '1',
'body' => [
'text' => 'quick brown fox',
],
];
$response = $client->index($params);
$params = [
'index' => 'my_index',
'id' => '2',
'body' => [
'text' => 'quick brown foxes',
],
];
$response = $client->index($params);
$params = [
'index' => 'my_index',
'body' => [
'query' => [
'multi_match' => [
'query' => 'quick brown foxes',
'fields' => [
'text',
'text.english',
],
'type' => 'most_fields',
],
],
],
];
$response = $client->search($params);
----
docs/examples/fdcaba9547180439ff4b6275034a5170.asciidoc 0000644 00000000610 14373463016 0015233 0 ustar 00 // search/request/scroll.asciidoc:268
[source, php]
----
$params = [
'index' => 'twitter',
'body' => [
'slice' => [
'field' => 'date',
'id' => 0,
'max' => 10,
],
'query' => [
'match' => [
'title' => 'elasticsearch',
],
],
],
];
$response = $client->search($params);
----
docs/examples/fdd38f0d248385a444c777e7acd97846.asciidoc 0000644 00000000656 14373463016 0015363 0 ustar 00 // query-dsl/query-string-query.asciidoc:496
[source, php]
----
$params = [
'body' => [
'query' => [
'query_string' => [
'fields' => [
'title',
'content',
],
'query' => 'this OR that OR thus',
'minimum_should_match' => 2,
],
],
],
];
$response = $client->search($params);
----
docs/examples/fe5763d32955e8b65eb3048e97b1580c.asciidoc 0000644 00000000237 14373463016 0015266 0 ustar 00 // indices/update-settings.asciidoc:133
[source, php]
----
$params = [
'index' => 'twitter',
];
$response = $client->indices()->forcemerge($params);
----
docs/examples/feefeb68144002fd1fff57b77b95b85e.asciidoc 0000644 00000000541 14373463016 0015643 0 ustar 00 // getting-started.asciidoc:578
[source, php]
----
$params = [
'index' => 'bank',
'body' => [
'size' => 0,
'aggs' => [
'group_by_state' => [
'terms' => [
'field' => 'state.keyword',
],
],
],
],
];
$response = $client->search($params);
----
docs/experimental-beta-apis.asciidoc 0000644 00000003574 14373463016 0013554 0 ustar 00 [[experimental_and_beta_apis]]
=== Experimental and beta APIs
The PHP client offers also `experimental` and `beta` APIs for {es}.
The {es} APIs are marked using the following convention:
- **Stable** APIs should be safe to use extensively in production. Any breaking
changes to these APIs should only occur in major versions and will be
documented in the breaking changes documentation for that release.
- **Beta** APIs are on track to become stable and permanent features. Use them
with caution because it is possible that breaking changes are made to these
APIs in a minor version.
- **Experimental** APIs are just that - an experiment. An experimental API might
have breaking changes in any future version, or it might even be removed
entirely.
All the `experimental` and `beta` APIs are marked with a `@note` tag in the
phpdoc section of the code.
[discrete]
=== Experimental
The experimental APIs included in the current version of `elasticsearch-php`
are:
- https://www.elastic.co/guide/en/elasticsearch/reference/7.4/search-rank-eval.html[Ranking Evaluation]
[source,php]
----
$client = ClientBuilder::create()->build();
$params = [
// ...
];
$result = $client->rankEval($params);
----
- https://www.elastic.co/guide/en/elasticsearch/painless/7.4/painless-execute-api.html[Painless Execute]
[source,php]
----
$client = ClientBuilder::create()->build();
$params = [
// ...
];
$result = $client->scriptsPainlessExecute($params);
----
- Get Script Context
Returns all script contexts.
[source,php]
----
$client = ClientBuilder::create()->build();
$result = $client->getScriptContext();
----
- Get Script Languages
Returns available script types, languages and contexts.
[source,php]
----
$client = ClientBuilder::create()->build();
$result = $client->getScriptLanguages();
----
[discrete]
=== Beta
There are no beta APIs in the current version of `elasticsearch-php`. docs/helpers.asciidoc 0000644 00000004467 14373463016 0010660 0 ustar 00 [[client-helpers]]
== Client helpers
The client comes with helpers to give you a more comfortable experience with
some APIs.
[discrete]
[[iterators]]
=== Iterators
[discrete]
[[search-response-iterator]]
==== Search response iterator
The `SearchResponseIterator` can be used to iterate page by page in a search
result using
https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#paginate-search-results[pagination].
An example as follows:
[source,php]
----
use Elasticsearch\Helper\Iterators\SearchResponseIterator;
$search_params = [
'scroll' => '5m', // period to retain the search context
'index' => '', // here the index name
'size' => 100, // 100 results per page
'body' => [
'query' => [
'match_all' => new StdClass // {} in JSON
]
]
];
// $client is Elasticsearch\Client instance
$pages = new SearchResponseIterator($client, $search_params);
// Sample usage of iterating over page results
foreach($pages as $page) {
// do something with hit e.g. copy its data to another index
// e.g. prints the number of document per page (100)
echo count($page['hits']['hits']), PHP_EOL;
}
----
[discrete]
[[search-hit-iterator]]
==== Search hit iterator
The `SearchHitIterator` can be used to iterate in a `SearchResponseIterator`
without worrying about
https://www.elastic.co/guide/en/elasticsearch/reference/current/paginate-search-results.html#paginate-search-results[pagination].
An example as follows:
[source,php]
----
use Elasticsearch\Helper\Iterators\SearchHitIterator;
use Elasticsearch\Helper\Iterators\SearchResponseIterator;
$search_params = [
'scroll' => '5m', // period to retain the search context
'index' => '', // here the index name
'size' => 100, // 100 results per page
'body' => [
'query' => [
'match_all' => new StdClass // {} in JSON
]
]
];
// $client is Elasticsearch\Client instance
$pages = new SearchResponseIterator($client, $search_params);
$hits = new SearchHitIterator($pages);
// Sample usage of iterating over hits
foreach($hits as $hit) {
// do something with hit e.g. write to CSV, update a database, etc
// e.g. prints the document id
echo $hit['_id'], PHP_EOL;
}
---- docs/host-config.asciidoc 0000644 00000003355 14373463016 0011431 0 ustar 00 [[host-config]]
=== Host Configuration
The client offers an options to configure hosts.
The most common configuration is telling the client about your cluster: the
number of nodes, their addresses, and ports. If no hosts are specified, the
client attempts to connect to `localhost:9200`.
This behavior can be changed by using the `setHosts()` method on
`ClientBuilder`. The method accepts an array of values, each entry corresponding
to one node in your cluster. The format of the host can vary, depending on your
needs (ip vs hostname, port, ssl, etc).
[source,php]
----
$hosts = [
'192.168.1.1:9200', // IP + Port
'192.168.1.2', // Just IP
'mydomain.server.com:9201', // Domain + Port
'mydomain2.server.com', // Just Domain
'https://localhost', // SSL to localhost
'https://192.168.1.3:9200' // SSL to IP + Port
];
$client = ClientBuilder::create() // Instantiate a new ClientBuilder
->setHosts($hosts) // Set the hosts
->build(); // Build the client object
----
Notice that the `ClientBuilder` object allows chaining method calls for brevity.
It is also possible to call the methods individually:
[source,php]
----
$hosts = [
'192.168.1.1:9200', // IP + Port
'192.168.1.2', // Just IP
'mydomain.server.com:9201', // Domain + Port
'mydomain2.server.com', // Just Domain
'https://localhost', // SSL to localhost
'https://192.168.1.3:9200' // SSL to IP + Port
];
$clientBuilder = ClientBuilder::create(); // Instantiate a new ClientBuilder
$clientBuilder->setHosts($hosts); // Set the hosts
$client = $clientBuilder->build(); // Build the client object
----
docs/http-client.asciidoc 0000644 00000007434 14373463016 0011446 0 ustar 00 [[http-client]]
=== Configure the HTTP client
Elasticsearch-php uses https://github.com/elastic/elastic-transport-php[elastic-transport-php]
for managing the HTTP tranport. This is an HTTP client provided by Elastic
that can be configured to use any https://www.php-fig.org/psr/psr-18/[PSR-18] client library.
Elasticsearch-php uses Guzzle as default HTTP client but you can specify
any other client using the `setHttpClient()` function, as follows:
[source,php]
----
use Symfony\Component\HttpClient\Psr18Client;
$client = ClientBuilder::create()
->setHttpClient(new Psr18Client)
->build();
----
For instance, in this example we used the https://symfony.com/doc/current/http_client.html[Symfony HTTP Client].
[discrete]
==== Setting the client options
If you want you can set the options for a specific PSR-18 client
using the `ClientBuilder::setHttpClientOptions($options)` method.
The `$options` is an array of key:value options that are
specifics to the HTTP client used.
For instance, if you are using Guzzle (default) and you need to use a
https://docs.guzzlephp.org/en/stable/request-options.html#proxy[proxy]
you can use the following settings:
[source,php]
----
$client = ClientBuilder::create()
->setHttpClientOptions([
'proxy' => 'http://localhost:8125'
])
->build();
----
[discrete]
==== Configuring the HTTP async client
Elasticsearch-php can works using an asyncronous HTTP client that implements
the https://github.com/php-http/httplug/blob/master/src/HttpAsyncClient.php[HttpAsyncClient] interface
of the http://httplug.io/[HTTPlug] project.
Unfortunately, there is not yet a PSR standard for HTTP async client.
We used the HTTPlug interface that is quite simple, as follows:
[source,php]
----
namespace Http\Client;
use Http\Promise\Promise;
use Psr\Http\Message\RequestInterface; // PSR-7 response
interface HttpAsyncClient
{
/**
* @return Promise
*/
public function sendAsyncRequest(RequestInterface $request);
}
----
You can enable the HTTP async in elasticsearch-php using the `setAsync()` function,
as follows:
[source,php]
----
$client = ClientBuilder::create()
->build();
$client->setAsync(true);
$promise = [];
for ($i=0; $i<10; $i++) {
$promise[] = $client->index([
'index' => 'my-index'
'body' => [
'foo' => base64_encode(random_bytes(24))
]
]);
}
----
The previous example stores 10 random documents using the HTTP asyncronous feature.
The `$promise` response is an object of https://github.com/php-http/promise/blob/master/src/Promise.php[promises/a+]
interface.
A promise represents a single result of an asynchronous operation.
It is not necessarily available at a specific time, but should become in the future.
If you need to know the response you can just call the `wait()` function,
as follows:
[source,php]
----
$promise = $client->index([
'index' => 'my-index',
'body' => [
'foo' => 'bar'
]
]);
$result = $promise->wait();
print_r($result->asArray());
----
The `wait()` function block the execution until we will recevie the
HTTP response from {es}.
Instead of waiting, you can handle things asynchronously using the
`then()` function, as follows:
[source,php]
----
use Psr\Http\Message\ResponseInterface; // PSR-7
$promise = $client->index([
'index' => 'my-index',
'body' => [
'foo' => 'bar'
]
]);
$promise->then(
// The success callback
function (ResponseInterface $response) {
// Success
// insert here the logic for managing the response
return $response;
},
// The failure callback
function (\Exception $exception) {
// Error
throw $exception;
}
);
----
More information about Promise are available at the
https://docs.php-http.org/en/latest/components/promise.html[HTTPlug documentation page].
docs/http-meta-data.asciidoc 0000644 00000001531 14373463016 0012015 0 ustar 00 [[http-meta-data]]
=== HTTP Meta Data
By default, the client sends some meta data about the HTTP connection using
custom headers.
You can disable or enable it using the following methods:
==== Elastic Meta Header
The client sends a `x-elastic-client-meta` header by default.
This header is used to collect meta data about the versions of the components
used by the client. For instance, a value of `x-elastic-client-meta` can be
`es=8.0.0-s,php=8.0.0,t=8.0.0-s,a=0,gu=7.4.2, where each value is the
version of `es=Elasticsearch`, `t` is the transport version (same of client),
`a` is asyncronouts (`0=false` by default) and `gu=Guzzle`.
If you would like to disable it you can use the `setElasticMetaHeader()`
method, as follows:
[source,php]
----
$client = Elasticsearch\ClientBuilder::create()
->setElasticMetaHeader(false)
->build();
----
docs/images/api_key_name.png 0000644 00000077723 14373463016 0012117 0 ustar 00 PNG
IHDR p 7 zTXtRaw profile type exif xYv#߱^@ `<_$)]I.$?@n~ZOEN/\_jM߲2
?UC<̥v=Q*M}l>u,F2=ΣQՋRqc2F<+-X ٸyeylb%tI-$/.?גi{\᙭1Nܚ%}½
)w)֕ex7tA'?W!Qv$ZQy~d1$dh9[Jҳ<@R͛E" }jb5k2reRҨEU6:RjAqX VͬYѤ6k6zhjz뽏0Sff6s,g.[m5v]'J锣;3.v%rk~gһm>~#k靵doϬD=g$Id<tŖJɞ9Y왮"sg_+i悧73Ǽ*kih={u5
=,Hϡc>ISz24&u4:Y˙uXbkf
w,mSKk~uiߍ2ļM[dnij]$;6F;^)}2[^i{80akgHǂ;BCX%؝\3]f1ۅO*Y,(%F\ߩvo2kMY'%$89׳FaجhvLY&gz(w|{2:Fȷ]"dԤ
|lkuBv*Me֩EA9UKySRJnx~"jmm
dCwE|b#sezIK}*'lY)82i_hP0n,|q4 t2aիo7YEaIiW}B=AVJЇ#h/sFZ([ZSNJR5;GUmYS<\jgoV; |p<,xTrpS'~&sH97j(3ҷ!ԼfG.+. E,4U
Px:[{wf`CZwyV)*]ɾJR<1uL*BJ.-|>H-QiR BmZXۨFÝԂEm$ dGFi,rW)öaDR(B],@EErw/k40O.$qIX>mC*.ۜEYRO)ۦ}N';XpH2 E@u24OÿOÿOcʀ^mR?3"ͨ{ȋ.
4Eq\Xvl|wx