Algolia Instant搜索默认顺序按州(`Live','发布)

发布于 2025-02-05 05:59:33 字数 424 浏览 0 评论 0原文

我正在尝试以特别的顺序获取Algolia的结果,命中列有状态列,并且状态值可以是live/partered/草稿

Algolia中的数据

{ name: Post1, state: draft},
{ name: Post2, state: published},
{ name: Post3, state: live}

预期结果< /stront>

默认订单应首先进行,然后发表,然后显示草稿

{ name: Post3, state: live},
{ name: Post2, state: published},
{ name: Post1, state: draft}

I'm trying to fetch Algolia results in particular order, hits have state column, and state values can be live/published/draft

Data in algolia

{ name: Post1, state: draft},
{ name: Post2, state: published},
{ name: Post3, state: live}

Expected Result

Default order should be, first live then published and then show draft

{ name: Post3, state: live},
{ name: Post2, state: published},
{ name: Post1, state: draft}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苏大泽ㄣ 2025-02-12 05:59:33

Algolia不支持像这样的枚举类型进行排序。相反,在搜索中,将状态用作方面并允许用户根据枚举值过滤结果更为常见。

您可以通过执行“ noreflowrer”>“ noreflowrer”>多索引查询带有三个单独的查询对相同索引,每个状态值作为过滤器,然后显示每个状态的结果。

Algolia doesn't support sorting by an enumerated type like this. Instead, in search, it is more common to use the state as a facet and allow users to filter results based on the enumerated value.

You could simulate the enumerated sort by performing a multi-index query with three separate queries to the same index with each of the state values as a filter, then display the results for each state.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文