ElasticSearch:如何在全文搜索中对技能评级进行排名?

时间:2017-11-14 15:05:38

标签: elasticsearch

我有一个非常简单的案例,但无法找到解决问题的好方法:

我有People,他们的Skills被评为。他们还附上其他信息(例如:城市)。所有这些都在我的ElasticSearch索引中。

示例:

约翰 巴黎 Python:7/10

鲍里斯 巴黎 Python:3/10

麦克 法兰克福 Python:7/10

我想执行文字搜索来查找人。

  • 如果我输入" Python",对某人评分越高,应该越高
  • 如果我键入" Python Paris",它应该让所有巴黎人按Python等级排序

以下是ES索引中人员文档的示例:

    {
  "_index": "senso",
  "_type": "talent",
  "_id": "12469",
  "_version": 1,
  "found": true,
  "_source": {
    "id": 12469,
    "nickname": "Roger",
    "first_name": "Moore",
    "last_name": "Bond",
    "companyName": null,
    "email": "example@example.org",
    "city": "Marseille",
    "region": "Provence-Alpes-Côte d'Azur",
    "internalGlobalRating": 5,
    "declaredDailyPrice": 650,
    "declaredAnnualSalaryTarget": null,
    "boughtDailyPrice": null,
    "soldDailyPrice": null,
    "skillsRatings": [
      {
        "skillName": "Direction Artistique Web",
        "skillId": 1298,
        "rating": 9
      },
      {
        "skillName": "UX Design",
        "skillId": 1295,
        "rating": 9
      },
      {
        "skillName": "Identité Visuelle",
        "skillId": 1319,
        "rating": 8
      },
      {
        "skillName": "Illustrator",
        "skillId": 1425,
        "rating": 9
      },
      {
        "skillName": "Photoshop",
        "skillId": 1427,
        "rating": 9
      },
      {
        "skillName": "InDesign",
        "skillId": 1426,
        "rating": 9
      }
    ],
    "expertises": [
      {
        "name": "Direction Artistique Web",
        "id": 1298
      },
      {
        "name": "UX Design",
        "id": 1295
      },
      {
        "name": "Identité Visuelle",
        "id": 1319
      }
    ],
    "missionTypes": [
      {
        "name": "Freelance sur place",
        "id": 2
      },
      {
        "name": "Freelance en télétravail",
        "id": 3
      },
      {
        "name": "Forfait",
        "id": 4
      }
    ],
    "tools": [
      {
        "name": "Illustrator",
        "id": 1425
      },
      {
        "name": "Photoshop",
        "id": 1427
      },
      {
        "name": "InDesign",
        "id": 1426
      }
    ],
    "themes": [],
    "medias": [],
    "organizationType": {
      "id": 2,
      "name": "Studio"
    },
    "source": {
      "id": 2
    },
    "spokenLanguages": [
      {
        "id": 2
      },
      {
        "id": 3
      }
    ],
    "mainLanguage": {
      "id": 1,
      "name": "Français"
    }
    "created": "2011-10-05T20:17:52+02:00",
    "updated": "2017-07-03T15:59:11+02:00",
    "applicationDate": "2011-10-05T20:17:52+02:00",
    "portfolio": {
      "id": 95,
      "visible": true,
      "submissionTime": "2017-01-13T18:20:31+01:00",
      "isDisplayed": 1,
      "isPublic": 1
    }
  }
}

我想知道我应该选择哪种方法:在索引时调整或自定义查询,或两者兼而有之?

如何解决这个问题的任何线索都将不胜感激。

谢谢。

0 个答案:

没有答案