Issue
I'm learning Magento 2. I have a project working with ElasticSearch, I don't know how exactly Magento 2 working with ElasticSearch. Could you please tell me how it works. Because I was confused between Sort By of Magento and Sort by Elastic.
How exactly Sort By function work?
1.1. The Collection of the product was sorted by Magento or ElasticSearch when I have sort by Price or Name?
Does Magento support sort Product Collection using ElasticSearch?
When Sorted by Relevance the product collection was sort by Elastic or Magento?
If Magento doesn't support Sort Attribute using ElasticSearch what should I do to improve that
I have used Magento 2.1.3 & ElasticSearch 2.2 (Magento 2.1 doesn't work with the higher version)
Regards.
Thanks any típs.
Solution
For being short, Magento only support sort by score (relevance) with Elasticsearch for fulltext search.
The other sort options are performed after, during database query.
Indeed, even if a quite lot information are stored in ElasticSearch, Elasticsearch returns only a list of IDs - Score to Magento. Then Magento do a SQL request in order to load all information needed with the sort etc.
In order to sort by score, Magento create a temporary table with the result of ElasticSearch ID - Score to sort the Magento product collection.
But you can extend the module to add your complete feature.
So for answer your questions :
- The Collection of the product was sorted by Magento or ElasticSearch when I have sort by Price or Name?
The sort is done on Magento side
- Does Magento support sort Product Collection using ElasticSearch?
It doesnt support the native Elasticsearch sort feature. But can be extended. But the final result is ok.
- When Sorted by Relevance the product collection was sort by Elastic or Magento?
The relevance (score) is performed by ElasticSearch and then stored to a temporary table and use in a JOIN SQL request.
- If Magento doesn't support Sort Attribute using ElasticSearch what should I do to improve that
Extend the ElasticSearch SearchAdapter. I can help you on that. You need to build the sort values in the query based on your request. And then manage the sort values in the response.
Answered By - Franck Garnier Answer Checked By - Cary Denson (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.