PHPackages                             elastic/app-search - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. elastic/app-search

Abandoned → [elastic/enterprise-search](/?search=elastic%2Fenterprise-search)Library[Search &amp; Filtering](/categories/search)

elastic/app-search
==================

Elastic App Search Official PHP Client

7.13.0(4y ago)52232.2k↓94.3%18[8 issues](https://github.com/elastic/app-search-php/issues)Apache-2.0PHPPHP ^5.6|^7.0CI failing

Since Jun 13Pushed 1y ago21 watchersCompare

[ Source](https://github.com/elastic/app-search-php)[ Packagist](https://packagist.org/packages/elastic/app-search)[ Docs](https://github.com/elastic/app-search-php)[ RSS](/packages/elastic-app-search/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (7)Versions (30)Used By (0)

> **⚠️ This client is deprecated ⚠️**
>
> As of Enterprise Search version 7.13.0, we are directing users to the new [Enterprise Search PHP Client](https://github.com/elastic/enterprise-search-php) and deprecating this client.
>
> This client will be compatible with all Enterprise Search 7.x releases, but will not be compatible with 8.x releases. Our development effort on this project will be limited to bug fixes. All future enhancements will be focused on the Enterprise Search PHP Client.
>
> Thank you! - Elastic

[![Elastic App Search Logo](https://github.com/elastic/app-search-php/raw/master/logo-app-search.png?raw=true)](https://github.com/elastic/app-search-php/blob/master/logo-app-search.png?raw=true)

[![CircleCI buidl](https://camo.githubusercontent.com/6b10be20fba9967e76ac53f5ee51a610db86421434b882157afad6bfaff6e1ab/68747470733a2f2f636972636c6563692e636f6d2f67682f656c61737469632f6170702d7365617263682d7068702e737667)](https://circleci.com/gh/elastic/app-search-php)

> A first-party PHP client for building excellent, relevant search experiences with [Elastic App Search](https://www.elastic.co/products/app-search).

Contents
--------

[](#contents)

- [Getting started](#getting-started-)
- [Usage](#usage)
- [Development](#development)
- [FAQ](#faq-)
- [Contribute](#contribute-)
- [License](#license-)

---

Getting started 🐣
-----------------

[](#getting-started-)

Using this client assumes that you have already an instance of Elastic App Search up and running.

You can find more information about Elastic App Search at : .

You can install the client in your project by using composer:

```
composer require elastic/app-search
```

### Versioning

[](#versioning)

This client is versioned and released alongside App Search.

To guarantee compatibility, use the most recent version of this library within the major version of the corresponding App Search implementation.

For example, for App Search `7.3`, use `7.3` of this library or above, but not `8.0`.

If you are using the [SaaS version available on swiftype.com](https://app.swiftype.com/as) of App Search, you should use the version 7.5.x of the client.

Usage
-----

[](#usage)

### Configuring the client

[](#configuring-the-client)

#### Basic client instantiation

[](#basic-client-instantiation)

To instantiate a new client you can use `\Elastic\AppSearch\Client\ClientBuilder`:

```
  $apiEndpoint   = 'http://localhost:3002/';
  $apiKey        = 'private-XXXXXXXXXXXX';
  $clientBuilder = \Elastic\AppSearch\Client\ClientBuilder::create($apiEndpoint, $apiKey);

  $client = $clientBuilder->build();
```

**Notes:**

- The resulting client will be of type `\Elastic\AppSearch\Client\Client`
- You can find the API endpoint and your API key URL in the credentials sections of the App Search dashboard.
- You can use any type of API Key (private, public or admin). The client will throw an exception if you try to execute an action that is not authorized for the key used.

### Basic usage

[](#basic-usage)

#### Retrieve or create an engine

[](#retrieve-or-create-an-engine)

Most methods of the API require that you have access to an Engine.

To check if an Engine exists and retrieve its configuration, you can use the `Client::getEngine` method :

```
  $engine = $client->getEngine('my-engine');
```

If the Engine does not exists yet, you can create it by using the `Client::createEngine` method :

```
  $engine = $client->createEngine('my-engine', 'en');
```

The second parameter (`$language`) is optional. Set it to `null` to apply the `universal` language.

[Read more](https://swiftype.com/documentation/app-search/api/engines#multi-language) about language support.

#### Index some documents

[](#index-some-documents)

You can use the `Client::indexDocuments` method to index some documents into the Engine:

```
    $documents = [
      ['id' => 'first-document', 'name' => 'Document name', 'description' => 'Document description'],
      ['id' => 'other-document', 'name' => 'Other document name', 'description' => 'Other description'],
    ];

    $indexingResults = $client->indexDocuments('my-engine', $documents);
```

The `$indexingResults` array will contain the result of the indexation of each documents. You should always check the content of the result.

[Read more](https://swiftype.com/documentation/app-search/api/documents#create) about document indexing.

#### Search

[](#search)

You can use the `Client::search` method to search in your Engine:

```
    $searchParams = [
      'page'  => ['current' => 1, 'size' => 10]
    ];

    $searchResponse = $client->search('my-engine', 'search text', $searchParams);
```

If you want to match all documents you can use and empty search query `''` as second parameter (`$queryText`).

The `$searchRequestParams` parameter is optional and can be used to use advanced search features. Allowed params are :

Param nameDocumentation URL`page``filters``facets``sort``boosts``search_fields``result_fields``group`The search response will contains at least a meta field and a results field as shown in this example:

```
[
    'meta' => [
      'warnings' => [],
      'page' => [
        'current' => 1,
        'total_pages' => 1,
        'total_results' => 1,
        'size' => 10
      ],
      'request_id' => 'feff7cf2359a6f6da84586969ef0ca89'
    ],
    'results' => [
      [
        'id' => ['raw' => 'first-document'],
        'name' => ['raw' => 'Document name'],
        'description' => ['raw' => ['Document description']
      ]
    ]
  ]
]
```

### Clients methods

[](#clients-methods)

MethodDescriptionDocumentation**`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)**`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)**`getCuration`**Retrieve a curation by id.

 **Parameters :**
 - `$engineName` (required)
 - `$curationId` (required)
[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/curations#single)**`getDocuments`**Retrieves one or more documents by id.

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

 **Parameters :**
 - `$engineName` (required)
[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/engines#get)**`getSchema`**Retrieve current schema for then engine.

 **Parameters :**
 - `$engineName` (required)
[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/schema#read)**`getSearchSettings`**Retrive current search settings for the engine.

 **Parameters :**
 - `$engineName` (required)
[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/search-settings#show)**`getSynonymSet`**Retrieve a synonym set by id.

 **Parameters :**
 - `$engineName` (required)
 - `$synonymSetId` (required)
[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/synonyms#list-one)**`getTopClicksAnalytics`**Returns the number of clicks received by a document in descending order.

 **Parameters :**
 - `$engineName` (required)
 - `$query`
 - `$pageSize`
 - `$filters`
[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/analytics/clicks)**`getTopQueriesAnalytics`**Returns queries anlaytics by usage count.

 **Parameters :**
 - `$engineName` (required)
 - `$pageSize`
 - `$filters`
[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/analytics/queries)**`indexDocuments`**Create or update documents.

 **Parameters :**
 - `$engineName` (required)
 - `$documents` (required)
[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/documents#create)**`listCurations`**Retrieve available curations for the engine.

 **Parameters :**
 - `$engineName` (required)
 - `$currentPage`
 - `$pageSize`
[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/curations#read)**`listDocuments`**List all available documents with optional pagination support.

 **Parameters :**
 - `$engineName` (required)
 - `$currentPage`
 - `$pageSize`
[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/documents#list)**`listEngines`**Retrieves all engines with optional pagination support.

 **Parameters :**
 - `$currentPage`
 - `$pageSize`
[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/engines#list)**`listSynonymSets`**Retrieve available synonym sets for the engine.

 **Parameters :**
 - `$engineName` (required)
 - `$currentPage`
 - `$pageSize`
[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/synonyms#get)**`logClickthrough`**Send data about clicked results.

 **Parameters :**
 - `$engineName` (required)
 - `$queryText` (required)
 - `$documentId` (required)
 - `$requestId`
 - `$tags`
[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/clickthrough)**`multiSearch`**Run several search in the same request.

 **Parameters :**
 - `$engineName` (required)
 - `$queries` (required)
[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/search#multi)**`querySuggestion`**Provide relevant query suggestions for incomplete queries.

 **Parameters :**
 - `$engineName` (required)
 - `$query` (required)
 - `$fields`
 - `$size`
[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/query-suggestion)**`resetSearchSettings`**Reset search settings for the engine.

 **Parameters :**
 - `$engineName` (required)
[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/search-settings#reset)**`search`**Allows you to search over, facet and filter your data.

 **Parameters :**
 - `$engineName` (required)
 - `$queryText` (required)
 - `$searchRequestParams`
[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/search)**`updateCuration`**Update an existing curation.

 **Parameters :**
 - `$engineName` (required)
 - `$curationId` (required)
 - `$queries` (required)
 - `$promotedDocIds`
 - `$hiddenDocIds`
[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/curations#update)**`updateDocuments`**Partial update of documents.

 **Parameters :**
 - `$engineName` (required)
 - `$documents` (required)
[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/documents#partial)**`updateSchema`**Update schema for the current engine.

 **Parameters :**
 - `$engineName` (required)
 - `$schema` (required)
[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/schema#patch)**`updateSearchSettings`**Update search settings for the engine.

 **Parameters :**
 - `$engineName` (required)
 - `$searchSettings` (required)
[Endpoint Documentation](https://swiftype.com/documentation/app-search/api/search-settings#update)Development
-----------

[](#development)

Code for the endpoints is generated automatically using a custom version of [OpenAPI Generator](https://github.com/openapitools/openapi-generator).

To regenerate endpoints, use the docker laucher packaged in `vendor/bin`:

```
./vendor/bin/elastic-openapi-codegen.sh
```

The custom generator will be built and launched using the following Open API spec file : `resources/api/api-spec.yml`.

You can then commit and PR the modified api-spec file and your endpoints code files.

The client class and readme may be changed in some cases. Do not forget to include them in your commit!

FAQ 🔮
-----

[](#faq-)

### Where do I report issues with the client?

[](#where-do-i-report-issues-with-the-client)

If something is not working as expected, please open an [issue](https://github.com/elastic/app-search-php/issues/new).

### Where can I find the full API documentation ?

[](#where-can-i-find-the-full-api-documentation-)

Your best bet is to read the [documentation](https://swiftype.com/documentation/app-search).

### Where else can I go to get help?

[](#where-else-can-i-go-to-get-help)

You can checkout the [Elastic community discuss forums](https://discuss.elastic.co/c/app-search).

Contribute 🚀
------------

[](#contribute-)

We welcome contributors to the project. Before you begin, a couple notes...

- Before opening a pull request, please create an issue to [discuss the scope of your proposal](https://github.com/elastic/app-search-php/issues).
- Please write simple code and concise documentation, when appropriate.

License 📗
---------

[](#license-)

[Apache 2.0](https://github.com/elastic/app-search-php/blob/master/LICENSE) © [Elastic](https://github.com/elastic)

Thank you to all the [contributors](https://github.com/elastic/app-search-php/graphs/contributors)!

###  Health Score

44

↑

FairBetter than 92% of packages

Maintenance26

Infrequent updates — may be unmaintained

Popularity47

Moderate usage in the ecosystem

Community25

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 67.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~27 days

Recently: every ~34 days

Total

27

Last Release

1762d ago

Major Versions

1.0.2 → 7.3.02019-08-27

### Community

Maintainers

![](https://www.gravatar.com/avatar/75c7c511421feb14316a01d29a7566bd4fdd97147b5a4f3faa5a065f9d0a0193?d=identicon)[ezimuel](/maintainers/ezimuel)

![](https://www.gravatar.com/avatar/ba68169b385c1d03c63650369b86685236583f1c8c223f840d54b6582922b911?d=identicon)[afoucret](/maintainers/afoucret)

![](https://www.gravatar.com/avatar/f887e605035c0c2b5ae9b8affd560079327e995aa92f08e2102c468359121e97?d=identicon)[JasonStoltz](/maintainers/JasonStoltz)

---

Top Contributors

[![afoucret](https://avatars.githubusercontent.com/u/529238?v=4)](https://github.com/afoucret "afoucret (46 commits)")[![richkuz](https://avatars.githubusercontent.com/u/62522248?v=4)](https://github.com/richkuz "richkuz (9 commits)")[![goodroot](https://avatars.githubusercontent.com/u/9484709?v=4)](https://github.com/goodroot "goodroot (5 commits)")[![miiimooo](https://avatars.githubusercontent.com/u/1226434?v=4)](https://github.com/miiimooo "miiimooo (4 commits)")[![JasonStoltz](https://avatars.githubusercontent.com/u/1427475?v=4)](https://github.com/JasonStoltz "JasonStoltz (2 commits)")[![kaioken](https://avatars.githubusercontent.com/u/118385?v=4)](https://github.com/kaioken "kaioken (1 commits)")[![andsel](https://avatars.githubusercontent.com/u/1038545?v=4)](https://github.com/andsel "andsel (1 commits)")

---

Tags

api-clientelasticelastic-app-searchphpsearchswiftypephpclientsearchelastic

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/elastic-app-search/health.svg)

```
[![Health](https://phpackages.com/badges/elastic-app-search/health.svg)](https://phpackages.com/packages/elastic-app-search)
```

###  Alternatives

[elasticsearch/elasticsearch

PHP Client for Elasticsearch

5.5k175.3M849](/packages/elasticsearch-elasticsearch)[babenkoivan/elastic-client

The official PHP Elasticsearch client integrated with Laravel

543.9M5](/packages/babenkoivan-elastic-client)[babenkoivan/elastic-adapter

Adapter for official PHP Elasticsearch client

403.9M8](/packages/babenkoivan-elastic-adapter)[elastic/enterprise-search

Enterprise Search official PHP client

25602.5k8](/packages/elastic-enterprise-search)[elastic/app-search-magento

Elastic App Search official integration for Magento 2

255.0k](/packages/elastic-app-search-magento)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
