繁体   English   中英

Algolia + Woocommerce类别的分层索引

[英]Algolia + Woocommerce hierarchical indexing of categories

我已经完成了多个Algolia安装。 现在,我将在Wordpress上完成另一篇有关Woocommerce产品的索引。 使用Algolia Woocommerce WP插件( https://github.com/algolia/algoliasearch-wordpress

到目前为止,一切看起来都不错,尽管索引产品类别存在一个小问题:

在Wordpress中,它们是分层的,但是当它们被索引时,它们是扁平的

categories: ['parent', 'child', 'child']

我的问题是:有什么办法可以使索引更“聪明”,输出是否像:

categories : {
    parent: ['child', 'child2'],
    parent2: ['child3', 'child4', 'child5']
}

我猜你可以在索引器中编写一些自定义代码https://github.com/algolia/algoliasearch-wordpress/blob/c2b791d3a018f2b3c4e7fe46815bc412ccce90f6/core/Indexer.php将类别转换为该架构

{
  "objectID": "123",
  "categories": {
    "lvl0": "child",
    "lvl1": "child > child2"
  }
}

然后,您可以使用以下方法轻松利用它:

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM