首先搜索特定类别的阿尔及利亚

编程入门 行业动态 更新时间:2024-10-10 10:28:51
本文介绍了首先搜索特定类别的阿尔及利亚的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正尝试搜索Algolia,并在所有其他类别之前显示特定类别的结果。例如:

I'm trying to search Algolia and have results for a certain category show up before all other categories. Here's an example:

阿尔及利亚的数据

{ name: Harry Potter, category: book}, { name: The Avengers, category: movie}, { name: Pottery, category: movie}

问题

比方说正常的Algolia算法与电影陶器相比,哈利·波特的相关性更高,因此通常如果您搜索 pot ,然后 Harry Potter 将出现在 Pottery 之前。

Let's say the normal Algolia algorithm has Harry Potter way more relevant than the movie Pottery, so normally if you searched pot then Harry Potter would show up ahead of Pottery.

我想将搜索词 pot 和类别 movie 传递给Algolia,然后将陶器首先出现。它必须是动态的,即我应该能够搜索类别为 book 的 pot 并获得首先是哈利·波特。

I want to pass Algolia the search term pot and the category movie and then have Pottery show up ahead of everything else. It needs to be dynamic, i.e. I should be able to search pot with category book and get Harry Potter first.

阿尔戈利亚有办法做到这一点吗?

Is there a way to do this with Algolia?

推荐答案

实际上,有一种很好的方法可以使用可选构面过滤器来实现该行为(即将发布的高级功能-截至2016年12月1日)。

There is actually a nice way to implement that behavior using "optional" facet filters (a soon to be released advanced feature - as of 2016/12/01).

可选方面过滤器是不需要进行匹配以检索结果的方面过滤器,但是-默认值-确保首先检索具有构面值的匹配(这要感谢Algolia抢七式排名公式的过滤器标准)。

An "Optional Facet Filter" is a facet filter that doesn't need to match to retrieve a result but that will - by default - make sure the hits that have the facet value are retrieved first (thanks to the filters criterion of Algolia's tie-breaking ranking formula).

这正是您想要的:在每个页面上,您需要首先获取共享 category 值的某些结果;只需使用 category:value 可选构面过滤器查询Algolia索引即可。

This is exactly what you want: on every single page where you want some results sharing a category value to be retrieved first; just query the Algolia index with the category:value optional facet filter.

  • make确保您的类别属性是查询中 attributesForFacet 索引设置
  • 的一部分时间,请使用 index.search('',{optionalFacetFilters:[ category:book])
  • make sure your category attribute is part of your attributesForFacet index setting
  • at query time, query the index with index.search('', { optionalFacetFilters: ["category:book"])

您可以在此(测试版)文档页面。

更多推荐

首先搜索特定类别的阿尔及利亚

本文发布于:2023-11-28 19:28:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1643668.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:阿尔及利亚   类别

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!