shopsys/microservice-product-search
[ABANDONED] Microservice product search was experimental functionality and has been removed.
3.3K
Microservice responsible for product search via 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
As the base of the microservice, we used 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.
For the search process is used a super fast no-SQL database Elasticsearch. For more information about the Elasticsearch on Shopsys Framework, see Product search via Elasticsearch
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:latest
.
If you don't use Docker, please check Shopsys Framework Native Installation Guide to see how to install and run it natively.
To call the microservice from the Shopsys Framework based application, there is an already prepared component MicroserviceClient. The instance of this component is parametrized with the URL on which the microservice is available.
Instance of MicroserviceClient
for the Microservice Product Search:
# services.yml:
shopsys.microservice_client.product_search:
factory: 'Shopsys\FrameworkBundle\Component\Microservice\MicroserviceClientFactory:create'
arguments:
$microserviceUrl: '%microservice_product_search_url%'
Search with the usage of Microservice Product Search is done by calling the method get
of MicroserviceClient
:
public function get(string $resource, array $parameters = [])
{
// ...
}
A resource is represented with the specific uri address.
They are two required parameters to call the Microservice Product Search:
Example:
$this->microserviceProductSearchClient->get('search-product-ids', [
'searchText' => 'Graphic card',
'domainId' => 1,
]);
The microservice returns an array of ids of products that match the search string. Ids of products are ordered by relevance. The response is represented as the JSON.
{"productIds":[2,1,3]}
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 | grep 'microservice'
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.
docker pull shopsys/microservice-product-search