在弹性搜索中忽略 TF-IDF
Ignoring TF-IDF in Elastic Search
我有一个根据职位描述关键字简历筛选候选人的用例。由于每次将新的候选人资料添加到内容列表时我都无法承受分数的变化(我假设 IDF 会发生变化),因此我想省略 TF_IDF。
索引文档是
{
"_index": "crawler_profiles",
"_type": "_doc",
"_id": "81ebeb3ff52d90a488b7bce752a4a0cf",
"_score": 1,
"_source": {
"content": "Peachtree MBA"
}
}
根据此处的 documentation,我创建了以下查询
{
"query": {
"bool": {
"should": [
{ "constant_score": {
"query": { "match": { "content": "corporate strategy" }}
}},
{ "constant_score": {
"query": { "match": { "content": "strategy consulting" }}
}},
{ "constant_score": {
"query": { "match": { "content": "international strategy" }}
}},
{ "constant_score": {
"query": { "match": { "content": "MBA" }}
}}
]
}
}
}
我收到以下错误
[constant_score] query does not support [query]
我只想为 1-or-n 存在一个术语打 1 分,如果不存在则打 0 分(最终跳过 tf-idf)。感谢任何帮助。
ES 版本:6.4.2
您链接的文档适用于 ES 版本 2.x。在 6.4.x 中有一些变化,如下所示:https://www.elastic.co/guide/en/elasticsearch/reference/6.4/query-dsl-constant-score-query.html
您应该能够将您的查询更新为如下内容:
编辑: 更新了 "term"
过滤器以使用 "match"
.
{
"query": {
"bool": {
"should": [
{ "constant_score": {
"filter": { "match": { "description": "corporate strategy" }}
}},
{ "constant_score": {
"filter": { "match": { "description": "strategy consulting" }}
}},
{ "constant_score": {
"filter": { "match": { "description": "international strategy" }}
}},
{ "constant_score": {
"filter": { "match": { "description": "MBA" }}
}}
]
}
}
}
我有一个根据职位描述关键字简历筛选候选人的用例。由于每次将新的候选人资料添加到内容列表时我都无法承受分数的变化(我假设 IDF 会发生变化),因此我想省略 TF_IDF。
索引文档是
{
"_index": "crawler_profiles",
"_type": "_doc",
"_id": "81ebeb3ff52d90a488b7bce752a4a0cf",
"_score": 1,
"_source": {
"content": "Peachtree MBA"
}
}
根据此处的 documentation,我创建了以下查询
{
"query": {
"bool": {
"should": [
{ "constant_score": {
"query": { "match": { "content": "corporate strategy" }}
}},
{ "constant_score": {
"query": { "match": { "content": "strategy consulting" }}
}},
{ "constant_score": {
"query": { "match": { "content": "international strategy" }}
}},
{ "constant_score": {
"query": { "match": { "content": "MBA" }}
}}
]
}
}
}
我收到以下错误
[constant_score] query does not support [query]
我只想为 1-or-n 存在一个术语打 1 分,如果不存在则打 0 分(最终跳过 tf-idf)。感谢任何帮助。
ES 版本:6.4.2
您链接的文档适用于 ES 版本 2.x。在 6.4.x 中有一些变化,如下所示:https://www.elastic.co/guide/en/elasticsearch/reference/6.4/query-dsl-constant-score-query.html
您应该能够将您的查询更新为如下内容:
编辑: 更新了 "term"
过滤器以使用 "match"
.
{
"query": {
"bool": {
"should": [
{ "constant_score": {
"filter": { "match": { "description": "corporate strategy" }}
}},
{ "constant_score": {
"filter": { "match": { "description": "strategy consulting" }}
}},
{ "constant_score": {
"filter": { "match": { "description": "international strategy" }}
}},
{ "constant_score": {
"filter": { "match": { "description": "MBA" }}
}}
]
}
}
}