繁体   English   中英

Instantsearch.js:使用来自Algolia的查询参数过滤初始搜索

[英]instantsearch.js: filter initial search with query parameter from Algolia

我一直在尝试使用来自Algolia的此查询参数过滤初始搜索,但没有成功。 我在文档中读到的是,您必须添加查询参数和查询字符串,但到目前为止,它已经完成了工作。

这是我一直在使用的代码

var search = instantsearch({
  appId: 'API ID',
  apiKey: 'APY KEY SEARCH',
  indexName: 'per_posts_product',
   searchParameters: {
        facets: ['taxonomies.product_cat'],
        facetsRefinements: {'taxonomies.product_cat': 'Dual Daggers'}
    },
  routing: true
});

提供给facetsRefinements的值应为数组而不是字符串。 这是一个显示如何使用它的示例:

const search = instantsearch({
  appId: 'APP_ID',
  apiKey: 'API_KEY',
  indexName: 'INDEX_NAME',
  searchParameters: {
    facets: ['taxonomies.product_cat'],
    facetsRefinements: {
      'taxonomies.product_cat': ['Dual Daggers'],
    },
  },
});

不要忘记在索引内部将attributesForFaceting声明为attributesForFaceting

暂无
暂无

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

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