I'm not entirely sure what faceting means, but it looks like a way to scope a query to a subset of records with key-value match. I want to facet filter on social accounts like account = facebook:123
or account = twitter:567
.
Filter the query by a list of facets. Facets are separated by commas and each facet is encoded as
attributeName:value
.
-- algolia docs
The issue is the syntax includes a colon already. I haven't had any luck with either two colons account:facebook:123
or uri encoded account:facebook%3A123
.
Is there a way to facet query without changing the data?
Is this the best way scope queries to a subset of documents?
答案 0 :(得分:5)
你对方面的范围界定能力是正确的。你也可以将faceting视为过滤。
在facet过滤器中传递冒号没有问题,但是一旦开始想知道要使用什么语法,只需使用以下语法:
{ facetFilters: '["facetKey:facetValue"]' }
JS客户端应该自己编码。
在这里,我猜你没有在account
中声明属性attributesForFaceting
。您可以使用API或在Algolia仪表板中,在索引的“显示”选项卡中执行此操作。