Demo API interfacing with elastic search written in Slim PHP microframework
- Console interface (
symfony/console
) - HTTP API interface (
slim/slim
)
docker
docker-compose
docker-compose up -d
docker-compose run --rm app composer install
docker-compose run --rm app console db:init
docker-compose run --rm app console data:import
Unit tests are provided in the /tests
folder.
To execute tests, run following:
docker-compose run --rm app bin/phpunit
- Search by name and website
curl -X POST \
http://localhost:8888/companies \
-H 'Content-Type: application/json' \
-d '{
"query" : {
"bool" : {
"should": [{
"match": {
"name": "libranda"
}
}, {
"match": {
"website": "www.gescola.com"
}
}]
}
}
}'
- Search all companies in food industry without delivery tag
curl -X POST \
http://localhost:8888/companies \
-H 'Content-Type: application/json' \
-d '{
"query" : {
"bool" : {
"must_not" : {
"match": {
"tags": "delivery"
}
},
"must": {
"match": {
"industry": "food"
}
}
}
}
}'
- Search by city name
curl -X POST \
http://localhost:8888/companies \
-H 'Content-Type: application/json' \
-d '{
"query" : {
"bool" : {
"should": [{
"match": {
"hq": "Barcelona"
}
}, {
"match": {
"hq": "Juncosa"
}
}]
}
}
}'