03/06/2016 - ELASTICSEARCH, SYMFONY
We have been investing plenty of personal time and energy for many years to share our knowledge with you all. However, we now need your help to keep this blog running. All you have to do is just click one of the adverts on the site, otherwise it will sadly be taken down due to hosting etc. costs. Thank you.
The notes below are for those who use FOSElasticaBundle in their projects. You'll find an example for each points below in this blog.
provider.query_builder_methodmethod which is a custom built method in a repository.
provider.query_builder_methodoption to manually select specific fields in database to populate elasticsearch index. The smaller the index size, the faster the query.
use Elastica\Type;) dependency injection service for elasticsearch processes rather than
use FOS\ElasticaBundle\Finder\TransformedFinder;) dependency injection service. Using native 'index' option will give you faster result and more options to use while querying the index. In the case of 'finder' option, you might end up using third party libraries like Pagerfanta that adds overhead to process behind the scene while querying the index.
listener.[insert|update|delete]options to 'false' individually or all.
For more information and options available, check Configuration.php.
driver: The driver you are using.
model: The entity class that you want to create an index from.
finder: Used to query ES finder. No need to touch this.
provider: Used to create a custom repository QueryBuilder (query_builder_method) that manually selects records from the DB to populate the index from. Or, we can populate index with the data coming from somewhere else rather than the database by using a custom provider class (service).
listener: Define how do you wish to update elasticsearch index after CRUD operations in DB.
model_to_elastica_transformer: Used to create a custom class which is used to populate/manipulate ES index creation.