From f56baeaa77773008a937c792d8445e965634954b Mon Sep 17 00:00:00 2001 From: Marci W <333176+marciw@users.noreply.github.com> Date: Wed, 29 May 2024 16:27:06 -0400 Subject: [PATCH] Minor edits this time without extra files :-/ --- docs/helpers/esql.asciidoc | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/docs/helpers/esql.asciidoc b/docs/helpers/esql.asciidoc index 48d8f22ad..7e1d0ee64 100644 --- a/docs/helpers/esql.asciidoc +++ b/docs/helpers/esql.asciidoc @@ -13,10 +13,9 @@ There are two ways to use ES|QL in the PHP client: is the most flexible approach, but it's also the most complex because you must handle results in their raw form. You can choose the precise format of results, such as JSON, CSV, or text. -* Use ES|QL `mapTo($class)` helper. This mapper take care of parsing the raw +* Use ES|QL `mapTo($class)` helper. This mapper takes care of parsing the raw response and converting into an array of objects. If you don't specify the class -using the `$class` parameter the mapping will use the https://www.php.net/manual/en/class.stdclass.php[stdClass] -of PHP. +using the `$class` parameter, the mapper uses https://www.php.net/manual/en/class.stdclass.php[stdClass]. [discrete] [[esql-how-to]] @@ -28,10 +27,11 @@ results should be returned. You can choose a JSON, then fine-tune it with parameters like column separators and locale. -The default response from Elasticsearch is a table in JSON specified using `columns` -as array of descriptions and `values` as array of rows with the values. +The default response from Elasticsearch is a table in JSON, where `columns` +is an array of descriptions and `values` is an array of rows containing the values. -An example is as follows: +[[query-script]] +Here's an example query and PHP script: ```php $query = <<>) produces the following output: ```php author : Stephen King @@ -133,9 +133,9 @@ $result = $client->esql()->query([ var_dump($result->asArray()); ``` -The response will look something as follows: +The response looks something like this: -``` +```json array(12) { [0]=> array(6) { @@ -168,7 +168,7 @@ array(12) { string(4) "2002" } ``` -where the first row is the column descriptions and the other rows contain +In the response, the first row contains the column descriptions and the other rows contain the values, using a plain PHP array. @@ -179,8 +179,8 @@ the values, using a plain PHP array. Although the `esql()->query()` API covers many use cases, your application might require a custom mapping. -You can map the ES|QL result into an array of object, using the `mapTo()` -function, as follows: +You can map the ES|QL result into an array of objects, using the `mapTo()` +function. Here's an example: ```php $result = $client->esql()->query([ @@ -199,10 +199,10 @@ foreach ($books as $book) { } ``` -You can also specify the class name to be used for the mapping. +You can also specify a class name for the mapping. All the values will be assigned to the properties of the class. -Here's an example mapper that returns an array of `Book` objects. +Here's an example mapper that returns an array of `Book` objects: ```php class Book