Skip to content

Commit 90cbdfb

Browse files
Yassinepolyfractal
authored andcommitted
[DOCS] add getSource method to the readme (#465)
1 parent 8bcf1a8 commit 90cbdfb

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ The recommended method to install _Elasticsearch-PHP_ is through [Composer](http
7171

7272
```php
7373
<?php
74-
74+
7575
use Elasticsearch\ClientBuilder;
76-
76+
7777
require 'vendor/autoload.php';
7878

7979
$client = ClientBuilder::create()->build();
@@ -170,6 +170,19 @@ Array
170170
)
171171
```
172172

173+
If you want to retrieve the `_source` field directly, there is the `getSource` method:
174+
175+
```php
176+
$params = [
177+
'index' => 'my_index',
178+
'type' => 'my_type',
179+
'id' => 'my_id'
180+
];
181+
182+
$source = $client->getSource($params);
183+
doSomething($source);
184+
```
185+
173186
### Search for a document
174187

175188
Searching is a hallmark of Elasticsearch, so let's perform a search. We are going to use the Match query as a demonstration:

0 commit comments

Comments
 (0)