PHPackages                             haguiry/awscloudsearchbundle - 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. [API Development](/categories/api)
4. /
5. haguiry/awscloudsearchbundle

ActiveSymfony-bundle[API Development](/categories/api)

haguiry/awscloudsearchbundle
============================

AWS Cloud Search bundle for Symfony 2

081PHP

Since Jun 30Pushed 11y ago2 watchersCompare

[ Source](https://github.com/haguiry/AWSCloudSearchBundle)[ Packagist](https://packagist.org/packages/haguiry/awscloudsearchbundle)[ RSS](/packages/haguiry-awscloudsearchbundle/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

AWSCloudSearchBundle
====================

[](#awscloudsearchbundle)

Note: This bundle is in alpha development stage and is as such not for production environments. Our aim is to complete development and testing in the next two weeks. All contributions welcome.

This bundle is designed to make it easier to integrate Amazon Cloud Search with Symfony2 projects to index entities regardless of database implementation.

Full AWS Cloud Search API Doco available at:

1. Installation

---

Install PHP Curl module:

```
    yum install php-curl

```

Add to composer.json:

```
    "redeyeapps/awscloudsearchbundle" : "dev-master"

```

2. Configuration

---

In your Symfony2 projects config.yml you needs to configure you AWS indexes. doc\_endpoint and search\_endpoint can be copied directly for AWS Cloud Search console, remember to change protocol to https for ssl encryption.

Example Configuration:

```
aws_cloud_search:
indexes:
    index1 :
        doc_endpoint: https://doc-index1.us-west-1.cloudsearch.amazonaws.com
        search_endpoint: https://search-index1.cloudsearch.amazonaws.com
        lang: en
    index2 :
        doc_endpoint: https://doc-index2.us-west-1.cloudsearch.amazonaws.com
        search_endpoint: https://search-index2-test.cloudsearch.amazonaws.com
        lang: en

```

Also remember to setup your AWS Cloud Search access rules to allow indexing and searching from appropriate ip's.

3. Indexer Usage

---

To index documents you need to create a JSON array of documents that match the AWS Cloud Search fields format you configured in the AWS console and post it to Cloud Search.

To index changes to entities (adds/updates/removes) it is recommended you us an event subscriber to doctrine persist events to index entity changes on the fly.

To create a subscriber see: [http://symfony.com/doc/current/cookbook/doctrine/event\_listeners\_subscribers.html](http://symfony.com/doc/current/cookbook/doctrine/event_listeners_subscribers.html)

For full example subscriber see Resources/doc/ExampleSubscriber.php

To do initial indexing of entities it is recommended you use a Symfony2 command. For full example indexing command see Resources/doc/ExampleIndexCommand.php

Notes on Converting Entity to Json
----------------------------------

[](#notes-on-converting-entity-to-json)

There are a couple of approaches, one is to use this bundle:

This bundle is pretty complex to setup and adds a few extra depenacies. In our case we have created a simple function on the entities we need to index called getSearchFields() which manually converts the entity to an object that that matches the fields configured for our indexes. This is then json encoded and passed to the indexer service.

Example:

```
    //src/MyOrg/MyBundle/Entity/MyEntity.php
    public function getSearchFields() {
        $obj = new \StdClass;
        $obj->id = $this->getId();
        $number = $this->getNumber();

        //Be careful with null fields
        if($code == null) {
            $number = '';
        }
        $obj->number = $number;

        $title = $this->getTitle();
        if($title == null) {
            $title = '';
        }
        $obj->title = $title;

        //Groups Array
        $groups = array();
        foreach($this->getGroups() as $group) {
            $groups[] = $group->getId();
        }

        if(count($groups) > 0){
            $obj->groups = $groups;
        }

        return $obj;
    }

```

This matches an index with the fields:

```
    id : uint
    number : uint
    title : text
    groups : uint

```

4. Search Usage

---

Searching using the CloudSearchClient service is pretty straight forward (the only required setting is setIndex):

```
    // Create search client
    $cloudsearcher = $this->get('cloudsearchclient');

    //Specify index to search. Must match indexname in config.yml
    $cloudsearcher->setIndex('redeyevms');

    //Set text fields to search with search term
    $cloudsearcher->addSearchField('title');
    $cloudsearcher->addSearchField('desc');

    //Set fields to recieve in results
    $cloudsearcher->addReturnField('title');

    //Set a sort field
    $cloudsearcher->addSort('title', 'ASC');

    //Set offsets and result limit, useful for paging.
    $cloudsearcher->setOffset($offset);
    $cloudsearcher->setLimit($resultlength);

    // Match mode, one of: normal, exact, startswith, endswith, any. Defaults to normal.
    $cloudsearcher->setMatchMode('startswith');

    //Add a filter to search
    $cloudsearcher->addFilter('genre', 'or', array('horror', 'sci-fi')); //Genre can be either horror or sci-fi.

    //Do search with string as search term
    $results = $cloudsearcher->search('star wars');

```

Format of results is documented here:

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/42a69976b93fb7d016c90638dfb6cf84e029d177a2a12dba7627adee22e1c37c?d=identicon)[haguiry](/maintainers/haguiry)

---

Top Contributors

[![haguiry](https://avatars.githubusercontent.com/u/3484553?v=4)](https://github.com/haguiry "haguiry (2 commits)")

### Embed Badge

![Health badge](/badges/haguiry-awscloudsearchbundle/health.svg)

```
[![Health](https://phpackages.com/badges/haguiry-awscloudsearchbundle/health.svg)](https://phpackages.com/packages/haguiry-awscloudsearchbundle)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[facebook/php-business-sdk

PHP SDK for Facebook Business

90821.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

74513.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

265103.1M454](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)

PHPackages © 2026

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