From 942d8a8f1e33a312263386be3ea420c1b18035ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20FOUCRET?= Date: Tue, 11 Feb 2020 13:54:57 +0100 Subject: [PATCH 1/2] Meta engine API support. --- AbstractClient.php | 778 ++++++++++++++++++ Client.php | 743 +---------------- .../{CreateEngine.php => DoCreateEngine.php} | 6 +- README.md | 3 +- composer.json | 2 +- resources/api/api-spec.yml | 16 +- resources/api/config.json | 1 + resources/api/templates/README.mustache | 16 + 8 files changed, 824 insertions(+), 741 deletions(-) create mode 100644 AbstractClient.php rename Endpoint/{CreateEngine.php => DoCreateEngine.php} (70%) create mode 100644 resources/api/templates/README.mustache diff --git a/AbstractClient.php b/AbstractClient.php new file mode 100644 index 0000000..eabb310 --- /dev/null +++ b/AbstractClient.php @@ -0,0 +1,778 @@ + $engineName, + 'queries' => $queries, + 'promoted' => $promotedDocIds, + 'hidden' => $hiddenDocIds, + ]; + + $endpoint = $this->getEndpoint('CreateCuration'); + $endpoint->setParams($params); + + return $this->performRequest($endpoint); + } + + /** + * Create a new synonym set. + * + * Documentation: https://swiftype.com/documentation/app-search/api/synonyms#create + * + * @param string $engineName Name of the engine. + * @param array $synonyms List of synonyms words. + * + * @return array + */ + public function createSynonymSet($engineName, $synonyms) + { + $params = [ + 'engine_name' => $engineName, + 'synonyms' => $synonyms, + ]; + + $endpoint = $this->getEndpoint('CreateSynonymSet'); + $endpoint->setParams($params); + + return $this->performRequest($endpoint); + } + + /** + * Delete a curation by id. + * + * Documentation: https://swiftype.com/documentation/app-search/api/curations#destroy + * + * @param string $engineName Name of the engine. + * @param string $curationId Curation id. + * + * @return array + */ + public function deleteCuration($engineName, $curationId) + { + $params = [ + 'engine_name' => $engineName, + 'curation_id' => $curationId, + ]; + + $endpoint = $this->getEndpoint('DeleteCuration'); + $endpoint->setParams($params); + + return $this->performRequest($endpoint); + } + + /** + * Delete documents by id. + * + * Documentation: https://swiftype.com/documentation/app-search/api/documents#partial + * + * @param string $engineName Name of the engine. + * @param array $documentIds List of document ids. + * + * @return array + */ + public function deleteDocuments($engineName, $documentIds) + { + $params = [ + 'engine_name' => $engineName, + ]; + + $endpoint = $this->getEndpoint('DeleteDocuments'); + $endpoint->setParams($params); + $endpoint->setBody($documentIds); + + return $this->performRequest($endpoint); + } + + /** + * Delete an engine by name. + * + * Documentation: https://swiftype.com/documentation/app-search/api/engines#delete + * + * @param string $engineName Name of the engine. + * + * @return array + */ + public function deleteEngine($engineName) + { + $params = [ + 'engine_name' => $engineName, + ]; + + $endpoint = $this->getEndpoint('DeleteEngine'); + $endpoint->setParams($params); + + return $this->performRequest($endpoint); + } + + /** + * Delete a synonym set by id. + * + * Documentation: https://swiftype.com/documentation/app-search/api/synonyms#delete + * + * @param string $engineName Name of the engine. + * @param string $synonymSetId Synonym set id. + * + * @return array + */ + public function deleteSynonymSet($engineName, $synonymSetId) + { + $params = [ + 'engine_name' => $engineName, + 'synonym_set_id' => $synonymSetId, + ]; + + $endpoint = $this->getEndpoint('DeleteSynonymSet'); + $endpoint->setParams($params); + + return $this->performRequest($endpoint); + } + + /** + * Creates a new engine. + * + * Documentation: https://swiftype.com/documentation/app-search/api/engines#create + * + * @param string $name Engine name. + * @param string $language Engine language (null for universal). + * @param string $type Engine type. + * @param array $sourceEngines Sources engines list. + * + * @return array + */ + protected function doCreateEngine($name, $language = null, $type = 'default', $sourceEngines = null) + { + $params = [ + 'name' => $name, + 'language' => $language, + 'type' => $type, + 'source_engines' => $sourceEngines, + ]; + + $endpoint = $this->getEndpoint('DoCreateEngine'); + $endpoint->setParams($params); + + return $this->performRequest($endpoint); + } + + /** + * The API Log displays API request and response data at the Engine level. + * + * Documentation: https://swiftype.com/documentation/app-search/api/logs + * + * @param string $engineName Name of the engine. + * @param string $fromDate Filter date from. + * @param string $toDate Filter date to. + * @param string $currentPage The page to fetch. Defaults to 1. + * @param string $pageSize The number of results per page. + * @param string $query Use this to specify a particular endpoint, like analytics, search, curations and so on. + * @param string $httpStatusFilter Filter based on a particular status code: 400, 401, 403, 429, 200. + * @param string $httpMethodFilter Filter based on a particular HTTP method: GET, POST, PUT, PATCH, DELETE. + * @param string $sortDirection Would you like to have your results ascending, oldest to newest, or descending, newest to oldest? + * + * @return array + */ + public function getApiLogs($engineName, $fromDate, $toDate, $currentPage = null, $pageSize = null, $query = null, $httpStatusFilter = null, $httpMethodFilter = null, $sortDirection = null) + { + $params = [ + 'engine_name' => $engineName, + 'filters.date.from' => $fromDate, + 'filters.date.to' => $toDate, + 'page.current' => $currentPage, + 'page.size' => $pageSize, + 'query' => $query, + 'filters.status' => $httpStatusFilter, + 'filters.method' => $httpMethodFilter, + 'sort_direction' => $sortDirection, + ]; + + $endpoint = $this->getEndpoint('GetApiLogs'); + $endpoint->setParams($params); + + return $this->performRequest($endpoint); + } + + /** + * Returns the number of clicks and total number of queries over a period. + * + * Documentation: https://swiftype.com/documentation/app-search/api/analytics/counts + * + * @param string $engineName Name of the engine. + * @param array $filters Analytics filters + * @param string $interval You can define an interval along with your date range. Can be either hour or day. + * + * @return array + */ + public function getCountAnalytics($engineName, $filters = null, $interval = null) + { + $params = [ + 'engine_name' => $engineName, + 'filters' => $filters, + 'interval' => $interval, + ]; + + $endpoint = $this->getEndpoint('GetCountAnalytics'); + $endpoint->setParams($params); + + return $this->performRequest($endpoint); + } + + /** + * Retrieve a curation by id. + * + * Documentation: https://swiftype.com/documentation/app-search/api/curations#single + * + * @param string $engineName Name of the engine. + * @param string $curationId Curation id. + * + * @return array + */ + public function getCuration($engineName, $curationId) + { + $params = [ + 'engine_name' => $engineName, + 'curation_id' => $curationId, + ]; + + $endpoint = $this->getEndpoint('GetCuration'); + $endpoint->setParams($params); + + return $this->performRequest($endpoint); + } + + /** + * Retrieves one or more documents by id. + * + * Documentation: https://swiftype.com/documentation/app-search/api/documents#get + * + * @param string $engineName Name of the engine. + * @param array $documentIds List of document ids. + * + * @return array + */ + public function getDocuments($engineName, $documentIds) + { + $params = [ + 'engine_name' => $engineName, + ]; + + $endpoint = $this->getEndpoint('GetDocuments'); + $endpoint->setParams($params); + $endpoint->setBody($documentIds); + + return $this->performRequest($endpoint); + } + + /** + * Retrieves an engine by name. + * + * Documentation: https://swiftype.com/documentation/app-search/api/engines#get + * + * @param string $engineName Name of the engine. + * + * @return array + */ + public function getEngine($engineName) + { + $params = [ + 'engine_name' => $engineName, + ]; + + $endpoint = $this->getEndpoint('GetEngine'); + $endpoint->setParams($params); + + return $this->performRequest($endpoint); + } + + /** + * Retrieve current schema for then engine. + * + * Documentation: https://swiftype.com/documentation/app-search/api/schema#read + * + * @param string $engineName Name of the engine. + * + * @return array + */ + public function getSchema($engineName) + { + $params = [ + 'engine_name' => $engineName, + ]; + + $endpoint = $this->getEndpoint('GetSchema'); + $endpoint->setParams($params); + + return $this->performRequest($endpoint); + } + + /** + * Retrive current search settings for the engine. + * + * Documentation: https://swiftype.com/documentation/app-search/api/search-settings#show + * + * @param string $engineName Name of the engine. + * + * @return array + */ + public function getSearchSettings($engineName) + { + $params = [ + 'engine_name' => $engineName, + ]; + + $endpoint = $this->getEndpoint('GetSearchSettings'); + $endpoint->setParams($params); + + return $this->performRequest($endpoint); + } + + /** + * Retrieve a synonym set by id. + * + * Documentation: https://swiftype.com/documentation/app-search/api/synonyms#list-one + * + * @param string $engineName Name of the engine. + * @param string $synonymSetId Synonym set id. + * + * @return array + */ + public function getSynonymSet($engineName, $synonymSetId) + { + $params = [ + 'engine_name' => $engineName, + 'synonym_set_id' => $synonymSetId, + ]; + + $endpoint = $this->getEndpoint('GetSynonymSet'); + $endpoint->setParams($params); + + return $this->performRequest($endpoint); + } + + /** + * Returns the number of clicks received by a document in descending order. + * + * Documentation: https://swiftype.com/documentation/app-search/api/analytics/clicks + * + * @param string $engineName Name of the engine. + * @param string $query Filter clicks over a search query. + * @param string $pageSize The number of results per page. + * @param array $filters Analytics filters + * + * @return array + */ + public function getTopClicksAnalytics($engineName, $query = null, $pageSize = null, $filters = null) + { + $params = [ + 'engine_name' => $engineName, + 'query' => $query, + 'page.size' => $pageSize, + 'filters' => $filters, + ]; + + $endpoint = $this->getEndpoint('GetTopClicksAnalytics'); + $endpoint->setParams($params); + + return $this->performRequest($endpoint); + } + + /** + * Returns queries anlaytics by usage count. + * + * Documentation: https://swiftype.com/documentation/app-search/api/analytics/queries + * + * @param string $engineName Name of the engine. + * @param string $pageSize The number of results per page. + * @param array $filters Analytics filters + * + * @return array + */ + public function getTopQueriesAnalytics($engineName, $pageSize = null, $filters = null) + { + $params = [ + 'engine_name' => $engineName, + 'page.size' => $pageSize, + 'filters' => $filters, + ]; + + $endpoint = $this->getEndpoint('GetTopQueriesAnalytics'); + $endpoint->setParams($params); + + return $this->performRequest($endpoint); + } + + /** + * Create or update documents. + * + * Documentation: https://swiftype.com/documentation/app-search/api/documents#create + * + * @param string $engineName Name of the engine. + * @param array $documents List of document to index. + * + * @return array + */ + public function indexDocuments($engineName, $documents) + { + $params = [ + 'engine_name' => $engineName, + ]; + + $endpoint = $this->getEndpoint('IndexDocuments'); + $endpoint->setParams($params); + $endpoint->setBody($documents); + + return $this->performRequest($endpoint); + } + + /** + * Retrieve available curations for the engine. + * + * Documentation: https://swiftype.com/documentation/app-search/api/curations#read + * + * @param string $engineName Name of the engine. + * @param string $currentPage The page to fetch. Defaults to 1. + * @param string $pageSize The number of results per page. + * + * @return array + */ + public function listCurations($engineName, $currentPage = null, $pageSize = null) + { + $params = [ + 'engine_name' => $engineName, + 'page.current' => $currentPage, + 'page.size' => $pageSize, + ]; + + $endpoint = $this->getEndpoint('ListCurations'); + $endpoint->setParams($params); + + return $this->performRequest($endpoint); + } + + /** + * List all available documents with optional pagination support. + * + * Documentation: https://swiftype.com/documentation/app-search/api/documents#list + * + * @param string $engineName Name of the engine. + * @param string $currentPage The page to fetch. Defaults to 1. + * @param string $pageSize The number of results per page. + * + * @return array + */ + public function listDocuments($engineName, $currentPage = null, $pageSize = null) + { + $params = [ + 'engine_name' => $engineName, + 'page.current' => $currentPage, + 'page.size' => $pageSize, + ]; + + $endpoint = $this->getEndpoint('ListDocuments'); + $endpoint->setParams($params); + + return $this->performRequest($endpoint); + } + + /** + * Retrieves all engines with optional pagination support. + * + * Documentation: https://swiftype.com/documentation/app-search/api/engines#list + * + * @param string $currentPage The page to fetch. Defaults to 1. + * @param string $pageSize The number of results per page. + * + * @return array + */ + public function listEngines($currentPage = null, $pageSize = null) + { + $params = [ + 'page.current' => $currentPage, + 'page.size' => $pageSize, + ]; + + $endpoint = $this->getEndpoint('ListEngines'); + $endpoint->setParams($params); + + return $this->performRequest($endpoint); + } + + /** + * Retrieve available synonym sets for the engine. + * + * Documentation: https://swiftype.com/documentation/app-search/api/synonyms#get + * + * @param string $engineName Name of the engine. + * @param string $currentPage The page to fetch. Defaults to 1. + * @param string $pageSize The number of results per page. + * + * @return array + */ + public function listSynonymSets($engineName, $currentPage = null, $pageSize = null) + { + $params = [ + 'engine_name' => $engineName, + 'page.current' => $currentPage, + 'page.size' => $pageSize, + ]; + + $endpoint = $this->getEndpoint('ListSynonymSets'); + $endpoint->setParams($params); + + return $this->performRequest($endpoint); + } + + /** + * Send data about clicked results. + * + * Documentation: https://swiftype.com/documentation/app-search/api/clickthrough + * + * @param string $engineName Name of the engine. + * @param string $queryText Search query text. + * @param string $documentId The id of the document that was clicked on. + * @param string $requestId The request id returned in the meta tag of a search API response. + * @param array $tags Array of strings representing additional information you wish to track with the clickthrough. + * + * @return array + */ + public function logClickthrough($engineName, $queryText, $documentId, $requestId = null, $tags = null) + { + $params = [ + 'engine_name' => $engineName, + 'query' => $queryText, + 'document_id' => $documentId, + 'request_id' => $requestId, + 'tags' => $tags, + ]; + + $endpoint = $this->getEndpoint('LogClickthrough'); + $endpoint->setParams($params); + + return $this->performRequest($endpoint); + } + + /** + * Run several search in the same request. + * + * Documentation: https://swiftype.com/documentation/app-search/api/search#multi + * + * @param string $engineName Name of the engine. + * @param array $queries Search queries. + * + * @return array + */ + public function multiSearch($engineName, $queries) + { + $params = [ + 'engine_name' => $engineName, + 'queries' => $queries, + ]; + + $endpoint = $this->getEndpoint('MultiSearch'); + $endpoint->setParams($params); + + return $this->performRequest($endpoint); + } + + /** + * Provide relevant query suggestions for incomplete queries. + * + * Documentation: https://swiftype.com/documentation/app-search/api/query-suggestion + * + * @param string $engineName Name of the engine. + * @param string $query A partial query for which to receive suggestions. + * @param array $fields List of fields to use to generate suggestions. Defaults to all text fields. + * @param int $size Number of query suggestions to return. Must be between 1 and 20. Defaults to 5. + * + * @return array + */ + public function querySuggestion($engineName, $query, $fields = null, $size = null) + { + $params = [ + 'engine_name' => $engineName, + 'query' => $query, + 'types.documents.fields' => $fields, + 'size' => $size, + ]; + + $endpoint = $this->getEndpoint('QuerySuggestion'); + $endpoint->setParams($params); + + return $this->performRequest($endpoint); + } + + /** + * Reset search settings for the engine. + * + * Documentation: https://swiftype.com/documentation/app-search/api/search-settings#reset + * + * @param string $engineName Name of the engine. + * + * @return array + */ + public function resetSearchSettings($engineName) + { + $params = [ + 'engine_name' => $engineName, + ]; + + $endpoint = $this->getEndpoint('ResetSearchSettings'); + $endpoint->setParams($params); + + return $this->performRequest($endpoint); + } + + /** + * Allows you to search over, facet and filter your data. + * + * Documentation: https://swiftype.com/documentation/app-search/api/search + * + * @param string $engineName Name of the engine. + * @param string $queryText Search query text. + * @param array $searchRequestParams Search request parameters. + * + * @return array + */ + public function search($engineName, $queryText, $searchRequestParams = null) + { + $params = [ + 'engine_name' => $engineName, + 'query' => $queryText, + ]; + + $endpoint = $this->getEndpoint('Search'); + $endpoint->setParams($params); + $endpoint->setBody($searchRequestParams); + + return $this->performRequest($endpoint); + } + + /** + * Update an existing curation. + * + * Documentation: https://swiftype.com/documentation/app-search/api/curations#update + * + * @param string $engineName Name of the engine. + * @param string $curationId Curation id. + * @param array $queries List of affected search queries. + * @param array $promotedDocIds List of promoted document ids. + * @param array $hiddenDocIds List of hidden document ids. + * + * @return array + */ + public function updateCuration($engineName, $curationId, $queries, $promotedDocIds = null, $hiddenDocIds = null) + { + $params = [ + 'engine_name' => $engineName, + 'curation_id' => $curationId, + 'queries' => $queries, + 'promoted' => $promotedDocIds, + 'hidden' => $hiddenDocIds, + ]; + + $endpoint = $this->getEndpoint('UpdateCuration'); + $endpoint->setParams($params); + + return $this->performRequest($endpoint); + } + + /** + * Partial update of documents. + * + * Documentation: https://swiftype.com/documentation/app-search/api/documents#partial + * + * @param string $engineName Name of the engine. + * @param array $documents List of document to update. + * + * @return array + */ + public function updateDocuments($engineName, $documents) + { + $params = [ + 'engine_name' => $engineName, + ]; + + $endpoint = $this->getEndpoint('UpdateDocuments'); + $endpoint->setParams($params); + $endpoint->setBody($documents); + + return $this->performRequest($endpoint); + } + + /** + * Update schema for the current engine. + * + * Documentation: https://swiftype.com/documentation/app-search/api/schema#patch + * + * @param string $engineName Name of the engine. + * @param array $schema Schema description. + * + * @return array + */ + public function updateSchema($engineName, $schema) + { + $params = [ + 'engine_name' => $engineName, + ]; + + $endpoint = $this->getEndpoint('UpdateSchema'); + $endpoint->setParams($params); + $endpoint->setBody($schema); + + return $this->performRequest($endpoint); + } + + /** + * Update search settings for the engine. + * + * Documentation: https://swiftype.com/documentation/app-search/api/search-settings#update + * + * @param string $engineName Name of the engine. + * @param array $searchSettings Search settings. + * + * @return array + */ + public function updateSearchSettings($engineName, $searchSettings) + { + $params = [ + 'engine_name' => $engineName, + ]; + + $endpoint = $this->getEndpoint('UpdateSearchSettings'); + $endpoint->setParams($params); + $endpoint->setBody($searchSettings); + + return $this->performRequest($endpoint); + } + + // phpcs:enable +} diff --git a/Client.php b/Client.php index 5007917..f346ab8 100644 --- a/Client.php +++ b/Client.php @@ -13,37 +13,8 @@ * * @package Elastic\AppSearch\Client */ -class Client extends \Elastic\OpenApi\Codegen\AbstractClient +class Client extends AbstractClient { - // phpcs:disable - - /** - * Create a new curation. - * - * Documentation: https://swiftype.com/documentation/app-search/api/curations#create - * - * @param string $engineName Name of the engine. - * @param array $queries List of affected search queries. - * @param array $promotedDocIds List of promoted document ids. - * @param array $hiddenDocIds List of hidden document ids. - * - * @return array - */ - public function createCuration($engineName, $queries, $promotedDocIds = null, $hiddenDocIds = null) - { - $params = [ - 'engine_name' => $engineName, - 'queries' => $queries, - 'promoted' => $promotedDocIds, - 'hidden' => $hiddenDocIds, - ]; - - $endpoint = $this->getEndpoint('CreateCuration'); - $endpoint->setParams($params); - - return $this->performRequest($endpoint); - } - /** * Creates a new engine. * @@ -56,719 +27,21 @@ public function createCuration($engineName, $queries, $promotedDocIds = null, $h */ public function createEngine($name, $language = null) { - $params = [ - 'name' => $name, - 'language' => $language, - ]; - - $endpoint = $this->getEndpoint('CreateEngine'); - $endpoint->setParams($params); - - return $this->performRequest($endpoint); - } - - /** - * Create a new synonym set. - * - * Documentation: https://swiftype.com/documentation/app-search/api/synonyms#create - * - * @param string $engineName Name of the engine. - * @param array $synonyms List of synonyms words. - * - * @return array - */ - public function createSynonymSet($engineName, $synonyms) - { - $params = [ - 'engine_name' => $engineName, - 'synonyms' => $synonyms, - ]; - - $endpoint = $this->getEndpoint('CreateSynonymSet'); - $endpoint->setParams($params); - - return $this->performRequest($endpoint); - } - - /** - * Delete a curation by id. - * - * Documentation: https://swiftype.com/documentation/app-search/api/curations#destroy - * - * @param string $engineName Name of the engine. - * @param string $curationId Curation id. - * - * @return array - */ - public function deleteCuration($engineName, $curationId) - { - $params = [ - 'engine_name' => $engineName, - 'curation_id' => $curationId, - ]; - - $endpoint = $this->getEndpoint('DeleteCuration'); - $endpoint->setParams($params); - - return $this->performRequest($endpoint); - } - - /** - * Delete documents by id. - * - * Documentation: https://swiftype.com/documentation/app-search/api/documents#partial - * - * @param string $engineName Name of the engine. - * @param array $documentIds List of document ids. - * - * @return array - */ - public function deleteDocuments($engineName, $documentIds) - { - $params = [ - 'engine_name' => $engineName, - ]; - - $endpoint = $this->getEndpoint('DeleteDocuments'); - $endpoint->setParams($params); - $endpoint->setBody($documentIds); - - return $this->performRequest($endpoint); - } - - /** - * Delete an engine by name. - * - * Documentation: https://swiftype.com/documentation/app-search/api/engines#delete - * - * @param string $engineName Name of the engine. - * - * @return array - */ - public function deleteEngine($engineName) - { - $params = [ - 'engine_name' => $engineName, - ]; - - $endpoint = $this->getEndpoint('DeleteEngine'); - $endpoint->setParams($params); - - return $this->performRequest($endpoint); - } - - /** - * Delete a synonym set by id. - * - * Documentation: https://swiftype.com/documentation/app-search/api/synonyms#delete - * - * @param string $engineName Name of the engine. - * @param string $synonymSetId Synonym set id. - * - * @return array - */ - public function deleteSynonymSet($engineName, $synonymSetId) - { - $params = [ - 'engine_name' => $engineName, - 'synonym_set_id' => $synonymSetId, - ]; - - $endpoint = $this->getEndpoint('DeleteSynonymSet'); - $endpoint->setParams($params); - - return $this->performRequest($endpoint); - } - - /** - * The API Log displays API request and response data at the Engine level. - * - * Documentation: https://swiftype.com/documentation/app-search/api/logs - * - * @param string $engineName Name of the engine. - * @param string $fromDate Filter date from. - * @param string $toDate Filter date to. - * @param string $currentPage The page to fetch. Defaults to 1. - * @param string $pageSize The number of results per page. - * @param string $query Use this to specify a particular endpoint, like analytics, search, curations and so on. - * @param string $httpStatusFilter Filter based on a particular status code: 400, 401, 403, 429, 200. - * @param string $httpMethodFilter Filter based on a particular HTTP method: GET, POST, PUT, PATCH, DELETE. - * @param string $sortDirection Would you like to have your results ascending, oldest to newest, or descending, newest to oldest? - * - * @return array - */ - public function getApiLogs($engineName, $fromDate, $toDate, $currentPage = null, $pageSize = null, $query = null, $httpStatusFilter = null, $httpMethodFilter = null, $sortDirection = null) - { - $params = [ - 'engine_name' => $engineName, - 'filters.date.from' => $fromDate, - 'filters.date.to' => $toDate, - 'page.current' => $currentPage, - 'page.size' => $pageSize, - 'query' => $query, - 'filters.status' => $httpStatusFilter, - 'filters.method' => $httpMethodFilter, - 'sort_direction' => $sortDirection, - ]; - - $endpoint = $this->getEndpoint('GetApiLogs'); - $endpoint->setParams($params); - - return $this->performRequest($endpoint); - } - - /** - * Returns the number of clicks and total number of queries over a period. - * - * Documentation: https://swiftype.com/documentation/app-search/api/analytics/counts - * - * @param string $engineName Name of the engine. - * @param array $filters Analytics filters - * @param string $interval You can define an interval along with your date range. Can be either hour or day. - * - * @return array - */ - public function getCountAnalytics($engineName, $filters = null, $interval = null) - { - $params = [ - 'engine_name' => $engineName, - 'filters' => $filters, - 'interval' => $interval, - ]; - - $endpoint = $this->getEndpoint('GetCountAnalytics'); - $endpoint->setParams($params); - - return $this->performRequest($endpoint); - } - - /** - * Retrieve a curation by id. - * - * Documentation: https://swiftype.com/documentation/app-search/api/curations#single - * - * @param string $engineName Name of the engine. - * @param string $curationId Curation id. - * - * @return array - */ - public function getCuration($engineName, $curationId) - { - $params = [ - 'engine_name' => $engineName, - 'curation_id' => $curationId, - ]; - - $endpoint = $this->getEndpoint('GetCuration'); - $endpoint->setParams($params); - - return $this->performRequest($endpoint); - } - - /** - * Retrieves one or more documents by id. - * - * Documentation: https://swiftype.com/documentation/app-search/api/documents#get - * - * @param string $engineName Name of the engine. - * @param array $documentIds List of document ids. - * - * @return array - */ - public function getDocuments($engineName, $documentIds) - { - $params = [ - 'engine_name' => $engineName, - ]; - - $endpoint = $this->getEndpoint('GetDocuments'); - $endpoint->setParams($params); - $endpoint->setBody($documentIds); - - return $this->performRequest($endpoint); - } - - /** - * Retrieves an engine by name. - * - * Documentation: https://swiftype.com/documentation/app-search/api/engines#get - * - * @param string $engineName Name of the engine. - * - * @return array - */ - public function getEngine($engineName) - { - $params = [ - 'engine_name' => $engineName, - ]; - - $endpoint = $this->getEndpoint('GetEngine'); - $endpoint->setParams($params); - - return $this->performRequest($endpoint); - } - - /** - * Retrieve current schema for then engine. - * - * Documentation: https://swiftype.com/documentation/app-search/api/schema#read - * - * @param string $engineName Name of the engine. - * - * @return array - */ - public function getSchema($engineName) - { - $params = [ - 'engine_name' => $engineName, - ]; - - $endpoint = $this->getEndpoint('GetSchema'); - $endpoint->setParams($params); - - return $this->performRequest($endpoint); - } - - /** - * Retrive current search settings for the engine. - * - * Documentation: https://swiftype.com/documentation/app-search/api/search-settings#show - * - * @param string $engineName Name of the engine. - * - * @return array - */ - public function getSearchSettings($engineName) - { - $params = [ - 'engine_name' => $engineName, - ]; - - $endpoint = $this->getEndpoint('GetSearchSettings'); - $endpoint->setParams($params); - - return $this->performRequest($endpoint); - } - - /** - * Retrieve a synonym set by id. - * - * Documentation: https://swiftype.com/documentation/app-search/api/synonyms#list-one - * - * @param string $engineName Name of the engine. - * @param string $synonymSetId Synonym set id. - * - * @return array - */ - public function getSynonymSet($engineName, $synonymSetId) - { - $params = [ - 'engine_name' => $engineName, - 'synonym_set_id' => $synonymSetId, - ]; - - $endpoint = $this->getEndpoint('GetSynonymSet'); - $endpoint->setParams($params); - - return $this->performRequest($endpoint); - } - - /** - * Returns the number of clicks received by a document in descending order. - * - * Documentation: https://swiftype.com/documentation/app-search/api/analytics/clicks - * - * @param string $engineName Name of the engine. - * @param string $query Filter clicks over a search query. - * @param string $pageSize The number of results per page. - * @param array $filters Analytics filters - * - * @return array - */ - public function getTopClicksAnalytics($engineName, $query = null, $pageSize = null, $filters = null) - { - $params = [ - 'engine_name' => $engineName, - 'query' => $query, - 'page.size' => $pageSize, - 'filters' => $filters, - ]; - - $endpoint = $this->getEndpoint('GetTopClicksAnalytics'); - $endpoint->setParams($params); - - return $this->performRequest($endpoint); - } - - /** - * Returns queries anlaytics by usage count. - * - * Documentation: https://swiftype.com/documentation/app-search/api/analytics/queries - * - * @param string $engineName Name of the engine. - * @param string $pageSize The number of results per page. - * @param array $filters Analytics filters - * - * @return array - */ - public function getTopQueriesAnalytics($engineName, $pageSize = null, $filters = null) - { - $params = [ - 'engine_name' => $engineName, - 'page.size' => $pageSize, - 'filters' => $filters, - ]; - - $endpoint = $this->getEndpoint('GetTopQueriesAnalytics'); - $endpoint->setParams($params); - - return $this->performRequest($endpoint); - } - - /** - * Create or update documents. - * - * Documentation: https://swiftype.com/documentation/app-search/api/documents#create - * - * @param string $engineName Name of the engine. - * @param array $documents List of document to index. - * - * @return array - */ - public function indexDocuments($engineName, $documents) - { - $params = [ - 'engine_name' => $engineName, - ]; - - $endpoint = $this->getEndpoint('IndexDocuments'); - $endpoint->setParams($params); - $endpoint->setBody($documents); - - return $this->performRequest($endpoint); - } - - /** - * Retrieve available curations for the engine. - * - * Documentation: https://swiftype.com/documentation/app-search/api/curations#read - * - * @param string $engineName Name of the engine. - * @param string $currentPage The page to fetch. Defaults to 1. - * @param string $pageSize The number of results per page. - * - * @return array - */ - public function listCurations($engineName, $currentPage = null, $pageSize = null) - { - $params = [ - 'engine_name' => $engineName, - 'page.current' => $currentPage, - 'page.size' => $pageSize, - ]; - - $endpoint = $this->getEndpoint('ListCurations'); - $endpoint->setParams($params); - - return $this->performRequest($endpoint); - } - - /** - * List all available documents with optional pagination support. - * - * Documentation: https://swiftype.com/documentation/app-search/api/documents#list - * - * @param string $engineName Name of the engine. - * @param string $currentPage The page to fetch. Defaults to 1. - * @param string $pageSize The number of results per page. - * - * @return array - */ - public function listDocuments($engineName, $currentPage = null, $pageSize = null) - { - $params = [ - 'engine_name' => $engineName, - 'page.current' => $currentPage, - 'page.size' => $pageSize, - ]; - - $endpoint = $this->getEndpoint('ListDocuments'); - $endpoint->setParams($params); - - return $this->performRequest($endpoint); - } - - /** - * Retrieves all engines with optional pagination support. - * - * Documentation: https://swiftype.com/documentation/app-search/api/engines#list - * - * @param string $currentPage The page to fetch. Defaults to 1. - * @param string $pageSize The number of results per page. - * - * @return array - */ - public function listEngines($currentPage = null, $pageSize = null) - { - $params = [ - 'page.current' => $currentPage, - 'page.size' => $pageSize, - ]; - - $endpoint = $this->getEndpoint('ListEngines'); - $endpoint->setParams($params); - - return $this->performRequest($endpoint); - } - - /** - * Retrieve available synonym sets for the engine. - * - * Documentation: https://swiftype.com/documentation/app-search/api/synonyms#get - * - * @param string $engineName Name of the engine. - * @param string $currentPage The page to fetch. Defaults to 1. - * @param string $pageSize The number of results per page. - * - * @return array - */ - public function listSynonymSets($engineName, $currentPage = null, $pageSize = null) - { - $params = [ - 'engine_name' => $engineName, - 'page.current' => $currentPage, - 'page.size' => $pageSize, - ]; - - $endpoint = $this->getEndpoint('ListSynonymSets'); - $endpoint->setParams($params); - - return $this->performRequest($endpoint); - } - - /** - * Send data about clicked results. - * - * Documentation: https://swiftype.com/documentation/app-search/api/clickthrough - * - * @param string $engineName Name of the engine. - * @param string $queryText Search query text. - * @param string $documentId The id of the document that was clicked on. - * @param string $requestId The request id returned in the meta tag of a search API response. - * @param array $tags Array of strings representing additional information you wish to track with the clickthrough. - * - * @return array - */ - public function logClickthrough($engineName, $queryText, $documentId, $requestId = null, $tags = null) - { - $params = [ - 'engine_name' => $engineName, - 'query' => $queryText, - 'document_id' => $documentId, - 'request_id' => $requestId, - 'tags' => $tags, - ]; - - $endpoint = $this->getEndpoint('LogClickthrough'); - $endpoint->setParams($params); - - return $this->performRequest($endpoint); + return $this->doCreateEngine($name, $language); } /** - * Run several search in the same request. + * Creates a new meta engine. * - * Documentation: https://swiftype.com/documentation/app-search/api/search#multi - * - * @param string $engineName Name of the engine. - * @param array $queries Search queries. - * - * @return array - */ - public function multiSearch($engineName, $queries) - { - $params = [ - 'engine_name' => $engineName, - 'queries' => $queries, - ]; - - $endpoint = $this->getEndpoint('MultiSearch'); - $endpoint->setParams($params); - - return $this->performRequest($endpoint); - } - - /** - * Provide relevant query suggestions for incomplete queries. - * - * Documentation: https://swiftype.com/documentation/app-search/api/query-suggestion - * - * @param string $engineName Name of the engine. - * @param string $query A partial query for which to receive suggestions. - * @param array $fields List of fields to use to generate suggestions. Defaults to all text fields. - * @param int $size Number of query suggestions to return. Must be between 1 and 20. Defaults to 5. - * - * @return array - */ - public function querySuggestion($engineName, $query, $fields = null, $size = null) - { - $params = [ - 'engine_name' => $engineName, - 'query' => $query, - 'types.documents.fields' => $fields, - 'size' => $size, - ]; - - $endpoint = $this->getEndpoint('QuerySuggestion'); - $endpoint->setParams($params); - - return $this->performRequest($endpoint); - } - - /** - * Reset search settings for the engine. - * - * Documentation: https://swiftype.com/documentation/app-search/api/search-settings#reset - * - * @param string $engineName Name of the engine. - * - * @return array - */ - public function resetSearchSettings($engineName) - { - $params = [ - 'engine_name' => $engineName, - ]; - - $endpoint = $this->getEndpoint('ResetSearchSettings'); - $endpoint->setParams($params); - - return $this->performRequest($endpoint); - } - - /** - * Allows you to search over, facet and filter your data. - * - * Documentation: https://swiftype.com/documentation/app-search/api/search - * - * @param string $engineName Name of the engine. - * @param string $queryText Search query text. - * @param array $searchRequestParams Search request parameters. - * - * @return array - */ - public function search($engineName, $queryText, $searchRequestParams = null) - { - $params = [ - 'engine_name' => $engineName, - 'query' => $queryText, - ]; - - $endpoint = $this->getEndpoint('Search'); - $endpoint->setParams($params); - $endpoint->setBody($searchRequestParams); - - return $this->performRequest($endpoint); - } - - /** - * Update an existing curation. - * - * Documentation: https://swiftype.com/documentation/app-search/api/curations#update - * - * @param string $engineName Name of the engine. - * @param string $curationId Curation id. - * @param array $queries List of affected search queries. - * @param array $promotedDocIds List of promoted document ids. - * @param array $hiddenDocIds List of hidden document ids. - * - * @return array - */ - public function updateCuration($engineName, $curationId, $queries, $promotedDocIds = null, $hiddenDocIds = null) - { - $params = [ - 'engine_name' => $engineName, - 'curation_id' => $curationId, - 'queries' => $queries, - 'promoted' => $promotedDocIds, - 'hidden' => $hiddenDocIds, - ]; - - $endpoint = $this->getEndpoint('UpdateCuration'); - $endpoint->setParams($params); - - return $this->performRequest($endpoint); - } - - /** - * Partial update of documents. - * - * Documentation: https://swiftype.com/documentation/app-search/api/documents#partial - * - * @param string $engineName Name of the engine. - * @param array $documents List of document to update. - * - * @return array - */ - public function updateDocuments($engineName, $documents) - { - $params = [ - 'engine_name' => $engineName, - ]; - - $endpoint = $this->getEndpoint('UpdateDocuments'); - $endpoint->setParams($params); - $endpoint->setBody($documents); - - return $this->performRequest($endpoint); - } - - /** - * Update schema for the current engine. - * - * Documentation: https://swiftype.com/documentation/app-search/api/schema#patch - * - * @param string $engineName Name of the engine. - * @param array $schema Schema description. - * - * @return array - */ - public function updateSchema($engineName, $schema) - { - $params = [ - 'engine_name' => $engineName, - ]; - - $endpoint = $this->getEndpoint('UpdateSchema'); - $endpoint->setParams($params); - $endpoint->setBody($schema); - - return $this->performRequest($endpoint); - } - - /** - * Update search settings for the engine. - * - * Documentation: https://swiftype.com/documentation/app-search/api/search-settings#update + * Documentation: https://swiftype.com/documentation/app-search/api/engines#create * - * @param string $engineName Name of the engine. - * @param array $searchSettings Search settings. + * @param string $name Engine name. + * @param string[] $sourceEngines Source engines list. * * @return array */ - public function updateSearchSettings($engineName, $searchSettings) + public function createMetaEngine($name, array $sourceEngines) { - $params = [ - 'engine_name' => $engineName, - ]; - - $endpoint = $this->getEndpoint('UpdateSearchSettings'); - $endpoint->setParams($params); - $endpoint->setBody($searchSettings); - - return $this->performRequest($endpoint); + return $this->doCreateEngine($name, null, 'meta', $sourceEngines); } - - // phpcs:enable } diff --git a/Endpoint/CreateEngine.php b/Endpoint/DoCreateEngine.php similarity index 70% rename from Endpoint/CreateEngine.php rename to Endpoint/DoCreateEngine.php index eca9864..ef5d2be 100644 --- a/Endpoint/CreateEngine.php +++ b/Endpoint/DoCreateEngine.php @@ -9,11 +9,11 @@ namespace Elastic\AppSearch\Client\Endpoint; /** - * Implementation of the CreateEngine endpoint. + * Implementation of the DoCreateEngine endpoint. * * @package Elastic\AppSearch\Client\Endpoint */ -class CreateEngine extends \Elastic\OpenApi\Codegen\Endpoint\AbstractEndpoint +class DoCreateEngine extends \Elastic\OpenApi\Codegen\Endpoint\AbstractEndpoint { // phpcs:disable /** @@ -26,6 +26,6 @@ class CreateEngine extends \Elastic\OpenApi\Codegen\Endpoint\AbstractEndpoint */ protected $uri = '/engines'; - protected $paramWhitelist = ['name', 'language']; + protected $paramWhitelist = ['name', 'language', 'type', 'source_engines']; // phpcs:enable } diff --git a/README.md b/README.md index 52f9c59..f1a04a7 100644 --- a/README.md +++ b/README.md @@ -153,8 +153,9 @@ The search response will contains at least a meta field and a results field as s Method | Description | Documentation ------------|-------------|-------------- -**`createCuration`**| Create a new curation.

**Parameters :**
- `$engineName` (required)
- `$queries` (required)
- `$promotedDocIds`
- `$hiddenDocIds`
|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/curations#create) **`createEngine`**| Creates a new engine.

**Parameters :**
- `$name` (required)
- `$language`
|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/engines#create) +**`createMetaEngine`**| Creates a new meta engine.

**Parameters :**
- `$name` (required)
- `$sourceEngines` (required)
|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/engines#create) +**`createCuration`**| Create a new curation.

**Parameters :**
- `$engineName` (required)
- `$queries` (required)
- `$promotedDocIds`
- `$hiddenDocIds`
|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/curations#create) **`createSynonymSet`**| Create a new synonym set.

**Parameters :**
- `$engineName` (required)
- `$synonyms` (required)
|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/synonyms#create) **`deleteCuration`**| Delete a curation by id.

**Parameters :**
- `$engineName` (required)
- `$curationId` (required)
|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/curations#destroy) **`deleteDocuments`**| Delete documents by id.

**Parameters :**
- `$engineName` (required)
- `$documentIds` (required)
|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/documents#partial) diff --git a/composer.json b/composer.json index ccf323f..d1a1e68 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ ], "require" : { "php" : "^5.6|^7.0", - "elastic/openapi-codegen" : "^1.0.3", + "elastic/openapi-codegen" : "^1.0.4", "psr/log" : "^1.0." }, "require-dev" : { diff --git a/resources/api/api-spec.yml b/resources/api/api-spec.yml index 79e2bc9..839f367 100644 --- a/resources/api/api-spec.yml +++ b/resources/api/api-spec.yml @@ -245,7 +245,8 @@ paths: default: $ref: "#/components/responses/jsonResponse" post: - operationId: createEngine + operationId: doCreateEngine + x-operation-scope: protected summary: Creates a new engine. externalDocs: url: https://swiftype.com/documentation/app-search/api/engines#create @@ -263,6 +264,19 @@ paths: description: Engine language (null for universal). schema: type: string + - name: type + in: query + description: Engine type. + schema: + type: string + default: 'default' + - name: source_engines + in: query + description: Sources engines list. + schema: + type: array + items: + type: string responses: default: $ref: "#/components/responses/jsonResponse" diff --git a/resources/api/config.json b/resources/api/config.json index 7f44f11..3ee66c5 100644 --- a/resources/api/config.json +++ b/resources/api/config.json @@ -1,4 +1,5 @@ { + "clientClass": "AbstractClient", "gitUserId": "elastic", "gitRepoId": "app-search-php", "artifactVersion": "1.0.0", diff --git a/resources/api/templates/README.mustache b/resources/api/templates/README.mustache new file mode 100644 index 0000000..7e606f1 --- /dev/null +++ b/resources/api/templates/README.mustache @@ -0,0 +1,16 @@ +{{>readme_title}} +{{>readme_content}} +{{>readme_install}} +{{>readme_usage}} +### Clients methods + +Method | Description | Documentation +------------|-------------|-------------- +**`createEngine`**| Creates a new engine.

**Parameters :**
- `$name` (required)
- `$language`
|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/engines#create) +**`createMetaEngine`**| Creates a new meta engine.

**Parameters :**
- `$name` (required)
- `$sourceEngines` (required)
|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/engines#create) +{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}{{#vendorExtensions.x-add-to-documentation}}**`{{operationId}}`**| {{#summary}}{{.}}{{/summary}}{{#allParams.0}}

**Parameters :**
{{#allParams}} - `${{paramName}}`{{#required}} (required) {{/required}}{{#hasMore}}
{{/hasMore}}{{/allParams}}{{/allParams.0}}
{{#externalDocs}}|[Endpoint Documentation]({{url}}){{/externalDocs}} +{{/vendorExtensions.x-add-to-documentation}}{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} +{{>readme_dev}} +{{>readme_faq}} +{{>readme_contrib}} +{{>readme_licence}} From b7997af8d438af27c7bf1a3eae1cc84fa1a68faa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20FOUCRET?= Date: Wed, 12 Feb 2020 10:52:32 +0100 Subject: [PATCH 2/2] Meta engine sources management support. --- AbstractClient.php | 46 +++++++++++++++++++++++++++++ Endpoint/AddMetaEngineSource.php | 31 +++++++++++++++++++ Endpoint/DeleteMetaEngineSource.php | 31 +++++++++++++++++++ README.md | 2 ++ resources/api/api-spec.yml | 38 ++++++++++++++++++++++++ 5 files changed, 148 insertions(+) create mode 100644 Endpoint/AddMetaEngineSource.php create mode 100644 Endpoint/DeleteMetaEngineSource.php diff --git a/AbstractClient.php b/AbstractClient.php index eabb310..b42f297 100644 --- a/AbstractClient.php +++ b/AbstractClient.php @@ -17,6 +17,29 @@ abstract class AbstractClient extends \Elastic\OpenApi\Codegen\AbstractClient { // phpcs:disable + /** + * Add a source engine to an existing meta engine. + * + * Documentation: https://swiftype.com/documentation/app-search/api/meta-engines#add-source-engines + * + * @param string $engineName Name of the engine. + * @param array $sourceEngines List of engine ids. + * + * @return array + */ + public function addMetaEngineSource($engineName, $sourceEngines) + { + $params = [ + 'engine_name' => $engineName, + ]; + + $endpoint = $this->getEndpoint('AddMetaEngineSource'); + $endpoint->setParams($params); + $endpoint->setBody($sourceEngines); + + return $this->performRequest($endpoint); + } + /** * Create a new curation. * @@ -134,6 +157,29 @@ public function deleteEngine($engineName) return $this->performRequest($endpoint); } + /** + * Delete a source engine from a meta engine. + * + * Documentation: https://swiftype.com/documentation/app-search/api/meta-engines#remove-source-engines + * + * @param string $engineName Name of the engine. + * @param array $sourceEngines List of engine ids. + * + * @return array + */ + public function deleteMetaEngineSource($engineName, $sourceEngines) + { + $params = [ + 'engine_name' => $engineName, + ]; + + $endpoint = $this->getEndpoint('DeleteMetaEngineSource'); + $endpoint->setParams($params); + $endpoint->setBody($sourceEngines); + + return $this->performRequest($endpoint); + } + /** * Delete a synonym set by id. * diff --git a/Endpoint/AddMetaEngineSource.php b/Endpoint/AddMetaEngineSource.php new file mode 100644 index 0000000..7384fb5 --- /dev/null +++ b/Endpoint/AddMetaEngineSource.php @@ -0,0 +1,31 @@ +
**Parameters :**
- `$name` (required)
- `$language`
|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/engines#create) **`createMetaEngine`**| Creates a new meta engine.

**Parameters :**
- `$name` (required)
- `$sourceEngines` (required)
|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/engines#create) +**`addMetaEngineSource`**| Add a source engine to an existing meta engine.

**Parameters :**
- `$engineName` (required)
- `$sourceEngines` (required)
|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/meta-engines#add-source-engines) **`createCuration`**| Create a new curation.

**Parameters :**
- `$engineName` (required)
- `$queries` (required)
- `$promotedDocIds`
- `$hiddenDocIds`
|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/curations#create) **`createSynonymSet`**| Create a new synonym set.

**Parameters :**
- `$engineName` (required)
- `$synonyms` (required)
|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/synonyms#create) **`deleteCuration`**| Delete a curation by id.

**Parameters :**
- `$engineName` (required)
- `$curationId` (required)
|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/curations#destroy) **`deleteDocuments`**| Delete documents by id.

**Parameters :**
- `$engineName` (required)
- `$documentIds` (required)
|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/documents#partial) **`deleteEngine`**| Delete an engine by name.

**Parameters :**
- `$engineName` (required)
|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/engines#delete) +**`deleteMetaEngineSource`**| Delete a source engine from a meta engine.

**Parameters :**
- `$engineName` (required)
- `$sourceEngines` (required)
|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/meta-engines#remove-source-engines) **`deleteSynonymSet`**| Delete a synonym set by id.

**Parameters :**
- `$engineName` (required)
- `$synonymSetId` (required)
|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/synonyms#delete) **`getApiLogs`**| The API Log displays API request and response data at the Engine level.

**Parameters :**
- `$engineName` (required)
- `$fromDate` (required)
- `$toDate` (required)
- `$currentPage`
- `$pageSize`
- `$query`
- `$httpStatusFilter`
- `$httpMethodFilter`
- `$sortDirection`
|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/logs) **`getCountAnalytics`**| Returns the number of clicks and total number of queries over a period.

**Parameters :**
- `$engineName` (required)
- `$filters`
- `$interval`
|[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/analytics/counts) diff --git a/resources/api/api-spec.yml b/resources/api/api-spec.yml index 839f367..7dd9ad2 100644 --- a/resources/api/api-spec.yml +++ b/resources/api/api-spec.yml @@ -131,6 +131,14 @@ components: schema: $ref: "#/components/schemas/documentIds" + engineIdsRequest: + required: true + description: List of engine ids. + content: + application/json: + schema: + $ref: "#/components/schemas/documentIds" + documentsIndexingRequest: required: true description: List of document to index. @@ -305,6 +313,36 @@ paths: default: $ref: "#/components/responses/jsonResponse" + /engines/{engine_name}/source_engines: + parameters: + - $ref: "#/components/parameters/engineNameParam" + post: + operationId: addMetaEngineSource + summary: Add a source engine to an existing meta engine. + externalDocs: + url: https://swiftype.com/documentation/app-search/api/meta-engines#add-source-engines + tags: + - Engine API + requestBody: + $ref: "#/components/requestBodies/engineIdsRequest" + x-codegen-request-body-name: sourceEngines + responses: + default: + $ref: "#/components/responses/jsonResponse" + delete: + operationId: deleteMetaEngineSource + summary: Delete a source engine from a meta engine. + externalDocs: + url: https://swiftype.com/documentation/app-search/api/meta-engines#remove-source-engines + tags: + - Engine API + requestBody: + $ref: "#/components/requestBodies/engineIdsRequest" + x-codegen-request-body-name: sourceEngines + responses: + default: + $ref: "#/components/responses/jsonResponse" + /engines/{engine_name}/documents: parameters: - $ref: "#/components/parameters/engineNameParam"