Download the PHP package doctrine/search without Composer
On this page you can find all versions of the php package doctrine/search. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download doctrine/search
More information about doctrine/search
Files in doctrine/search
Package search
Short Description ElasticSearch and Solr entity mapping library
License MIT
Homepage https://github.com/doctrine/search
Informations about the package search
Doctrine Search
Note: This project is a prototype at the moment. See demo
folder for practical implementation example.
Supported search engines
- ElasticSearch (functional)
- 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
The search manager connection can be configured as shown in the following example:
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).
Indexing
Documents can be serialized for indexing currently in the following ways. If required an event listener can be used with your ORM as shown in this example. If an event listener is not needed, entities can be persisted or removed directly using the search manager.
CallbackSerializer
This approach simply expects a toArray()
method on the entity, although this method be configured as required.
The interface suggested in this example can be any interface you desire, as long as your event listener can identify
entities that need to be persisted to the search engine (see above example).
JMS Serializer
You can alternatively use the advanced serialization power of the JMS Serializer
to automatically handle
serialization for you based on annotations such as those shown in this example.
AnnotationSerializer
Not yet available.
Queries
Queries can be executed through the search manager as shown below. Use of the result cache refers to using the
cache for the hydration query. Search engine specific adapter interfaces are exposed magically so as in this
example, Elastica\Query::addSort
method is amalgamated with Doctrine\Search\Query
methods. Thus any complexity
of query supported by the search engine client library is supported.
Simple Repository ID queries and Term
search can by done using the following technique. Deserialization is done
independently of Doctrine\ORM
but the same models are hydrated according to the registered SerializerInterface
.