blast-project / search-bundle
A search system coupled with ElasticSearch
Installs: 80
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 5
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^7.1
- friendsofsymfony/elastica-bundle: ^5.0
- knplabs/knp-paginator-bundle: ^2.7
- sonata-project/block-bundle: ^3.9
- symfony/symfony: ^3.4
Requires (Dev)
- phpunit/phpunit: ^6.4
- symfony/phpunit-bridge: ^3.4
This package is not auto-updated.
Last update: 2024-10-27 05:20:21 UTC
README
Bundle that handle search indexes with an ElasticSearch instance.
Requirements
You must have an ElasticSearch running and properly configured
(OPTIONNAL) Using an Elastic Stack stack
Using distribution
sudo apt-get install elasticsearch
Configure your elastic instance to listen to the right network interface by editing /etc/elasticsearch/elasticsearch.yml
:
network.host: 0.0.0.0 # change 0.0.0.0 with your public IP or 127.0.0.1 for local exposure only http.port: 9200
Using Docker
For development purposes only, you can use a complete Elastic Stack (previouly ELK stack).
For simplicity, you can use a Docker image for that stack : https://hub.docker.com/r/sebp/elk/
docker run -p 5601:5601 -p 9200:9200 -p 5044:5044 -it --name elk sebp/elk:611
Note : Don't use ElasticSearch 6 because of a incompatibility between ES 6 and FOSElasticaBundle (see this issue FriendsOfSymfony/FOSElasticaBundle#1267)
You can launch this Docker image at stratup with a custom SystemD service (create the service file /etc/systemd/system/elk.service
) :
[Unit] Description=Start ELK (Elastic search, Logstash and Kibana) at startup After=network.target Requires=docker.service [Service] Type=simple KillMode=none ExecStart=/usr/bin/docker start -a elk ExecStop=/usr/bin/docker stop -t 5 elk [Install] WantedBy=default.target
sudo systemctl daemon-reload
sudo systemctl enable elk
Map your entities with the search index
In a config file, add this content
fos_elastica: clients: default: host: localhost port: 9200 indexes: global: types: # Below is an example about how to map an entity to a search index user: properties: username: ~ email: ~ persistence: driver: orm model: "%sil.model.user.class%" listener: ~ # by default, listens to "insert", "update" and "delete"
Populate indexes
Run the FOSElasticaBundle command bin/console fos:elastica:populate
to init elastic search indexes.