Microservice responsible for product export into Elasticsearch on Shopsys Framework.
This repository is maintained by shopsys/shopsys monorepo, information about the changes are in monorepo CHANGELOG.md.
Microservice acts as a fully independent unit.
It uses its own separate server, separate logic and it uses own vendor directory for Composer dependencies.
All of these parts are located in a separate Docker container.
This container is configured in docker-compose.yml under the name microservice-product-search-export
As the base of the microservice uses micro-kernel which is made up of Symfony 4. This leanest Symfony version is highly optimized and it is suitable for this type of project.
The microservice is responsible for feeding the Elasticsearch by product data so product search microservice can work properly.
Microservice is installed by running container from image, during build of image all dependencies gets installed and nginx with php-fpm si configured to allow traffic into microservice.
If you don't want to build the Docker image yourself, you can use shopsys/microservice-product-search-export:latest
.
If you don't use Docker, please check Shopsys Framework Native Installation Guide to see how to install and run it natively.
The microservice is available by HTTP protocol and is called from Shopsys Framework by standard HTTP requests.
Checks that microservice is running. You can only get 200 OK
response or message that the endpoint was not found.
GET / HTTP/1.1
Host: microservice-product-search-export:8000
Content-Type: application/json
HTTP/1.1 200 OK
Content-Type: application/json
{
"info": "running"
}
Creates Elasticsearch index structure for a domain. This operation must be performed before updating products.
{domainId} - int, ID of domain
POST /{domainId} HTTP/1.1
Host: microservice-product-search-export:8000
Content-Type: application/json
HTTP/1.1 200 OK
Content-Type: application/json
{}
HTTP/1.1 500 Internal Server Error
Content-Type: application/json
{
"message": "Index 1 already exists"
}
Deletes Elasticsearch index structure for a domain. Deleting not existing index doesn't produce an error.
{domainId} - int, ID of domain
DELETE /{domainId} HTTP/1.1
Host: microservice-product-search-export:8000
Content-Type: application/json
HTTP/1.1 200 OK
Content-Type: application/json
{}
Updates existing products and also creates new ones if they do not exists. This operation doesn't delete products.
{domainId} - int, ID of domain
{
{productId}: {
{attributeKey}: {attributeValue},
...
},
...
}
PATCH /{domainId}/products HTTP/1.1
Host: microservice-product-search-export:8000
Content-Type: application/json
{
"1": {
"catnum": "9177759",
"partno": "SLE 22F46DM4",
"ean": "8845781245930",
"name": "22\" Sencor SLE 22F46DM4 HELLO KITTY",
"description": "...",
"shortDescription": "Sencor..."
},
"58": {
"catnum": "789",
"partno": "SLX 45945D87",
"ean": "5875781245548",
"name": "Genius repro SP-M120 black",
"description": "...",
"shortDescription": "Genius ..."
}
}
HTTP/1.1 200 OK
Content-Type: application/json
{}
HTTP/1.1 500 Internal Server Error
Content-Type: application/json
{
"message": "reason ..."
}
We define what products we want to keep during deleting, everything else is deleted. We do this because from the Shopsys Framework we don't know what is and what isn't in Elasticsearch.
{domainId} - int, ID of domain
{
"keep": [{productId1}, {productId2}, ...]
}
DELETE /{domainId}/products HTTP/1.1
Host: microservice-product-search-export:8000
Content-Type: application/json
{
"keep": [1, 2, 57, 58]
}
HTTP/1.1 200 OK
Content-Type: application/json
{}
Microservice Product Search is a Symfony based application that uses Monolog with symfony/monolog-bundle as a logging tool.
By default, the logs are routed into a named pipe /tmp/log-pipe
(the same way as Logging in the main application works).
To see the logs simply run:
docker-compose logs microservice-product-search-export
One of the main ideas of implementing the microservice is to keep its scope as small as possible. This makes it possible to completely change the behaviour of the microservice by overwriting its code without having to deal with the complex dependencies. The only thing that must remain preserved is the original minimalist interface.
Thank you for your contributions to Microservice Product Search. Together we are making Shopsys Framework better.
This repository is READ-ONLY. If you want to report issues and/or send pull requests, please use the main Shopsys repository.
Please, check our Contribution Guide before contributing.
What to do when you are in troubles or need some help? The best way is to contact us on our Slack http://slack.shopsys-framework.com/
If you want to report issues, please use the main Shopsys repository.
Source code is under MIT license, for more information, read LICENSE.
Built image is under GPL license, for more information read LICENSE-docker-image.