簡體   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