【问题标题】:Algolia: Search across multiple fields and scoring resultsAlgolia:跨多个字段搜索和评分结果
【发布时间】:2020-10-04 02:32:34
【问题描述】:

我在 algolia 有以下任务要完成

上下文

我的索引中有以下记录集

[
    {
        "name" : "Don Joe",
        "experience": {
          "job_title": "Example 1",
          "superpowers": [
            "Golang", // <- MATCH (see below)
            "Vue",    // <- MATCH (see below)
            "React"
          ],
          "skills": [
            "Docker",
            "Goa",
            "Elixir",
            "Kubernetes",
            "Istio",
            "Phoenix",
            "Javascript"
          ]
      },
      "completed_at": 1590509228,
    },
    {
        "name" : "John Doe"
        "experience": {
          "job_title": "Example 2",
          "superpowers": [
            "Golang", // <- MATCH (see below)
            "Phoenix",
            "React"
          ],
          "skills": [
            "Docker",
            "Vue",    // <- MATCH (see below)
            "Kubernetes",
            "Elixir",
            "Goa",
            "Javascript",
            "Typescript"
          ]
      },
      "completed_at": 1590519361,
    }
]

可搜索属性设置为

  • 无序(experience.superpowers)
  • 无序(experience.skills)

排名是默认的,加号

  • 自定义排名 desc(completed_at)

我做什么

一个简单的文本搜索Golang Vue

我的期望

超能力优先于技能,因此“Don Joe”的超能力中有 Golang 和 Vue(而“John Doe”有 Golang 超能力和 Vue 技能)应该首先出现

会发生什么

2 条记录得分相同,并且平局算法会导致错误的记录(这不是这里的主要问题,问题是它们的得分相同)

我应该如何配置 algolia 以执行我的预期?

提前致谢

【问题讨论】:

    标签: search ranking facet algolia scoring


    【解决方案1】:

    解决方案

    我解决如下:

    1. 将文本搜索转换为“基于方面”的搜索
    2. experience.skillsexperience.superpowers 设置为构面
    3. 使用一系列带有分数的OR 过滤器来获得所需的方面
      {
         "filters": "experience.skills:Vue<score=1> OR experience.skills:Golang<score=1> OR experience.superpowers:Vue<score=2> OR experience.superpowers:Golang<score=2>",
         "sumOrFiltersScores": true 
      }
      
      重要提示:设置 "sumOrFiltersScores": true 以启用分数总和并使用加权搜索
    4. 使用上一步中的有效负载调用您的搜索方法。

    资源:

    https://www.algolia.com/doc/guides/managing-results/refine-results/filtering/in-depth/filter-scoring/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-11
      • 2013-01-23
      • 2018-07-30
      • 2016-05-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多