88use Ensi \LaravelElasticQuery \Search \SearchQuery ;
99use Ensi \LaravelElasticQuery \Suggesting \SuggestQuery ;
1010use Exception ;
11+ use Http \Promise \Promise ;
1112
1213trait InteractsWithIndex
1314{
@@ -28,50 +29,50 @@ protected function settings(): array
2829 /**
2930 * @see SearchIndex::search()
3031 */
31- public function search (array $ dsl , ?string $ searchType = null ): array
32+ public function search (array $ dsl , ?string $ searchType = null ): array | Promise
3233 {
3334 return $ this ->resolveClient ()->search ($ this ->indexName (), $ dsl , $ searchType );
3435 }
3536
3637 /**
3738 * @see SearchIndex::search()
3839 */
39- public function deleteByQuery (array $ dsl ): array
40+ public function deleteByQuery (array $ dsl ): array | Promise
4041 {
4142 return $ this ->resolveClient ()->deleteByQuery ($ this ->indexName (), $ dsl );
4243 }
4344
44- public function isCreated (): bool
45+ public function isCreated (): bool | Promise
4546 {
4647 return $ this ->resolveClient ()->indicesExists ($ this ->indexName ());
4748 }
4849
49- public function create (): void
50+ public function create (): ? Promise
5051 {
51- $ this ->resolveClient ()->indicesCreate ($ this ->indexName (), $ this ->settings ());
52+ return $ this ->resolveClient ()->indicesCreate ($ this ->indexName (), $ this ->settings ());
5253 }
5354
54- public function bulk (array $ body ): array
55+ public function bulk (array $ body ): array | Promise
5556 {
5657 return $ this ->resolveClient ()->bulk ($ this ->indexName (), $ body );
5758 }
5859
59- public function get (int |string $ id ): array
60+ public function get (int |string $ id ): array | Promise
6061 {
6162 return $ this ->resolveClient ()->get ($ this ->indexName (), $ id );
6263 }
6364
64- public function documentDelete (int |string $ id ): array
65+ public function documentDelete (int |string $ id ): array | Promise
6566 {
6667 return $ this ->resolveClient ()->documentDelete ($ this ->indexName (), $ id );
6768 }
6869
69- public function catIndices (string $ indexName , ?array $ getFields = null ): array
70+ public function catIndices (string $ indexName , ?array $ getFields = null ): array | Promise
7071 {
7172 return $ this ->resolveClient ()->catIndices ($ indexName , $ getFields );
7273 }
7374
74- public function indicesInfo (array $ columns = ['i ' ], array $ sort = [], ?string $ health = null ): array
75+ public function indicesInfo (array $ columns = ['i ' ], array $ sort = [], ?string $ health = null ): array | Promise
7576 {
7677 return $ this ->resolveClient ()->indicesInfo (
7778 indices: [$ this ->indexName ()],
@@ -81,17 +82,17 @@ public function indicesInfo(array $columns = ['i'], array $sort = [], ?string $h
8182 );
8283 }
8384
84- public function indicesDelete (string $ index ): array
85+ public function indicesDelete (string $ index ): array | Promise
8586 {
8687 return $ this ->resolveClient ()->indicesDelete ($ index );
8788 }
8889
89- public function indicesRefresh (): array
90+ public function indicesRefresh (): array | Promise
9091 {
9192 return $ this ->resolveClient ()->indicesRefresh ($ this ->indexName ());
9293 }
9394
94- public function indicesReloadSearchAnalyzers (): array
95+ public function indicesReloadSearchAnalyzers (): array | Promise
9596 {
9697 return $ this ->resolveClient ()->indicesReloadSearchAnalyzers ($ this ->indexName ());
9798 }
0 commit comments