Skip to content

Commit

Permalink
Added the documentation for Elasticsearch Search API
Browse files Browse the repository at this point in the history
  • Loading branch information
ezimuel committed Aug 24, 2022
1 parent 3e106dd commit dfa8329
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions docs/guide/app-search-api.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,38 @@ $result = $this->appSearch->search(
);
print_r($result->asArray());
----------------------------

=== Elasticsearch Search API (beta)

This is a beta feature that can be used to search using the Elasticsearch API.
You can use the `Request\SearchEsSearch` to perform a https://www.elastic.co/guide/en/elasticsearch/reference/current/search-your-data.html[search query]
using the Elasticsearch API.

For more information about this feature you can read the Elasticsearch search API for App Search
https://www.elastic.co/guide/en/app-search/current/elasticsearch-search-api-reference.html#elasticsearch-search-api-reference[documentation].

In order to use the `Request\SearchEsSearch` endpoint you need to have an Elasticsearch
OAuth2 token, you can read how to generate one https://www.elastic.co/guide/en/app-search/current/authentication.html#authentication-elasticsearch-tokens[here].

[source,php]
----------------------------
$engineName = 'videogames';
// Elasticsearch query
$searchParams = new Schema\EsSearchParams();
$searchParams->query = [
'match' => [
'title' => 'Super Luigi 64'
]
];
// This is the Elasticsearch token API (Bearer)
$elasticsearchApiKey = 'xxx';
$result = $this->appSearch->searchEsSearch(
(new Request\SearchEsSearch($engineName, $searchParams))
->setAuthorization($elasticsearchApiKey)
);
print_r($result->asArray()); // Elasticsearch result in ['hits']['hits']
----------------------------

0 comments on commit dfa8329

Please sign in to comment.