How to facet filter search with a colon in the value?

时间:2016-02-12 19:32:07

标签: algolia

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?

1 个答案:

答案 0 :(得分:5)

你对方面的范围界定能力是正确的。你也可以将faceting视为过滤。

在facet过滤器中传递冒号没有问题,但是一旦开始想知道要使用什么语法,只需使用以下语法:

{ facetFilters: '["facetKey:facetValue"]' }

JS客户端应该自己编码。

在这里,我猜你没有在account中声明属性attributesForFaceting。您可以使用API​​或在Algolia仪表板中,在索引的“显示”选项卡中执行此操作。