4

そのため、Algolia.com を使用して、ユーザーをすばやく検索できるようにインデックスを作成しています。

インデックス内のオブジェクトの例:

{
    id: 1,
    username: "john.doe",
    name: "John Doe",
    attributes: {
        gender: "male",
        hair_color: "blonde",
        eye_color: "blue",
        height: 165
    }
}

属性オブジェクトの特定の属性 (オブジェクト キー) で結果をフィルター処理したいと思います。

を使用するとうまくいくのではないかと思いfacetFiltersましたが、うまくいきません。

私はこのコードの多くのバリエーションを試しました:

user_index.search('', {
    facets: '*',
    facetFilters: ['attributes.hair_color:blonde', 'attributes.eye_color:blue']
}, function(error, data) {
    console.log(error, data);
});

-- / --

user_index.search('', {
    facets: '*',
    facetFilters: ['hair_color:blonde']
}, function(error, data) {
    console.log(error, data);
});

ここでドキュメントを見つけてください: https://www.algolia.com/doc/javascript

4

2 に答える 2

1

この質問を回答済みとしてマークできるようにするためだけに:

(インデックスダッシュボードの表示タブ)に追加する必要attributes.hair_colorattributesForFacetingあります。簡単にできるはずです

user_index.search('', {
  facetFilters: 'attributes.hair_color:blonde'
}, function () {
  console.log(arguments);
});

検索する。

于 2015-12-11T18:52:19.557 に答える