Bundle that handle search indexes with an ElasticSearch instance.
You must have an ElasticSearch running and properly configured
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
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
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"
Run the FOSElasticaBundle command bin/console fos:elastica:populate
to init elastic search indexes.