@@ -74,11 +74,11 @@ Documents contain the OpenSearch document ID and source payload:
7474``` php
7575use DirectoryTree\OpenSearchAdapter\Documents\Document;
7676
77- $documents->index('books', collect( [
77+ $documents->index('books', [
7878 new Document('1', [
7979 'title' => 'The Hobbit',
8080 ]),
81- ])) ;
81+ ]);
8282```
8383
8484Routing values can be attached by document ID:
@@ -88,11 +88,11 @@ use DirectoryTree\OpenSearchAdapter\Documents\Routing;
8888
8989$routing = (new Routing)->add('1', 'tenant-1');
9090
91- $documents->index('books', collect( [
91+ $documents->index('books', [
9292 new Document('1', [
9393 'title' => 'The Hobbit',
9494 ]),
95- ]) , routing: $routing);
95+ ], routing: $routing);
9696```
9797
9898## Searching Documents
@@ -118,9 +118,10 @@ $response = $documents->search('books', $request);
118118
119119$total = $response->total();
120120
121- $hits = $response->hits()->map(function ($hit) {
122- return $hit->document()->content();
123- });
121+ $hits = array_map(
122+ fn ($hit) => $hit->document()->content(),
123+ $response->hits(),
124+ );
124125```
125126
126127## Aliases
@@ -148,6 +149,6 @@ $aliases = $indices->getAliases('books');
148149Search response objects expose the original OpenSearch payload through ` raw() ` :
149150
150151``` php
151- $rawHit = $response->hits()->first() ->raw();
152+ $rawHit = $response->hits()[0] ->raw();
152153$rawResponse = $response->raw();
153154```
0 commit comments