gpt4 book ai didi

elasticsearch - 如何在 Magento 2 中使用 ElasticSearch

转载 作者:行者123 更新时间:2023-11-29 02:55:32 27 4
gpt4 key购买 nike

我正在学习 Magento 2。我有一个使用 ElasticSearch 的项目,我不知道 Magento 2 如何与 ElasticSearch 一起使用。你能告诉我它是如何工作的吗?因为我对 Magento 的 Sort By 和 Elastic 的 Sort 感到困惑。

  1. Sort By 函数究竟是如何工作的?

    1.1。当我按价格或名称排序时,产品的集合是由 Magento 或 ElasticSearch 排序的?

  2. Magento 是否支持使用 ElasticSearch 对 Product Collection 进行排序?

  3. 当按相关性排序时,产品集合按 Elastic 或 Magento 排序?

  4. 如果 Magento 不支持使用 ElasticSearch 的排序属性,我应该做些什么来改进它

我使用过 Magento 2.1.3 和 ElasticSearch 2.2(Magento 2.1 不适用于更高版本)

问候。

感谢任何提示。

最佳答案

简而言之,Magento 仅支持使用 Elasticsearch 按分数(相关性)排序以进行全文搜索。

其他排序选项在数据库查询之后执行。

事实上,即使在 ElasticSearch 中存储了相当多的信息,Elasticsearch 也只会返回一个 ID 列表 - Score 给 Magento。然后 Magento 执行 SQL 请求以加载排序等所需的所有信息。

为了按分数排序,Magento 使用 ElasticSearch ID - Score 的结果创建了一个临时表来对 Magento 产品集合进行排序。

但是您可以扩展该模块以添加完整的功能。

所以回答你的问题:

  • The Collection of the product was sorted by Magento or ElasticSearch when I have sort by Price or Name?

排序在 Magento 端完成

  • Does Magento support sort Product Collection using ElasticSearch?

它不支持原生的 Elasticsearch 排序功能。但可以延长。但是最后的结果还是可以的。

  • When Sorted by Relevance the product collection was sort by Elastic or Magento?

相关性(分数)由 ElasticSearch 执行,然后存储到临时表并在 JOIN SQL 请求中使用。

  • If Magento doesn't support Sort Attribute using ElasticSearch what should I do to improve that

扩展 ElasticSearch SearchAdapter。我可以帮你。您需要根据您的请求在查询中构建排序值。然后管理响应中的排序值。

关于elasticsearch - 如何在 Magento 2 中使用 ElasticSearch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44385326/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com