PHPackages                             lekarna/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. [Database &amp; ORM](/categories/database)
4. /
5. lekarna/search

ActiveLibrary[Database &amp; ORM](/categories/database)

lekarna/search
==============

ElasticSearch and Solr entity mapping library

0.5.1(3y ago)015.0kMITPHPPHP &gt;=5.3.2

Since Dec 29Pushed 3y agoCompare

[ Source](https://github.com/Lekarna/search)[ Packagist](https://packagist.org/packages/lekarna/search)[ Docs](https://github.com/doctrine/search)[ RSS](/packages/lekarna-search/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (11)Used By (0)

Doctrine Search
===============

[](#doctrine-search)

Note: This project is a prototype at the moment. See `demo` folder for practical implementation example.

**Supported search engines**

- [ElasticSearch](http://www.elasticsearch.org/) (functional)
- [Solr](http://lucene.apache.org/solr/) (partial implementation)

**Features**

- SearchManager
    - Can be used stand-alone or in a hybrid configuration
    - Configurable search manager supports aggregate entity manager
    - supports direct API calls through search engine adapters such as Elastica
    - transforms returned ID's via batch operation into hydrated objects as required
    - Supports event manager listeners for customizable entity handling
- Support for indexing through event listeners via JMS Serializer or simple entity callback.
- Annotations for index and data type creation using ObjectManager::getClassMetadata() as the base structure

\#Usage#

Configuration
-------------

[](#configuration)

The search manager connection can be configured as shown in the following example:

```
$config = new Doctrine\Search\Configuration();
$config->setMetadataCacheImpl(new Doctrine\Common\Cache\ArrayCache());
$config->setEntitySerializer(
  new Doctrine\Search\Serializer\JMSSerializer(
    JMS\Serializer\SerializationContext::create()->setGroups('search')
  )
);

$eventManager = new Doctrine\Search\EventManager();
$eventManager->addListener($listener);

$searchManager = new Doctrine\Search\SearchManager(
  $config,
  new Doctrine\Search\ElasticSearch\Client(
    new Elastica\Client(array(
      array('host' => 'localhost', 'port' => '9200')
    )
  ),
  $eventManager
);
```

Mappings
--------

[](#mappings)

Basic entity mappings for index and type generation can be annotated as shown in the following example. Mappings can be rendered into a format suitable for automatically generating indexes and types using a build script (advanced setup required).

```
