gpt4 book ai didi

elasticsearch - Elastic Search 中带有附加条件的 Completion Suggester

转载 作者:行者123 更新时间:2023-11-29 02:50:23 26 4
gpt4 key购买 nike

我有一个索引可以返回不同语言的工作。

我需要根据针对单一语言的单一文本搜索类似的工作。比方说,我已将 1 设置为英语的 LanguageId。我想搜索与帐户匹配的工作。所以如果我在下面写查询,它会获取所有不同语言的工作。所以基本上 “必须” 查询没有任何影响。

GET jobs/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"languageid": "1"
}
}
]
}
},
"suggest": {
"suggestions": {
"text": "acce",
"completion": {
"field": "jobs.suggest",
"size": 30
}
}
}
}

我的映射如下所示

   "mappings": {
"jobs": {
"properties": {
"@timestamp": {
"type": "date"
},
"@version": {
"type": "text"
},
"industytype": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"jobs": {
"properties": {
"suggest": {
"type": "completion",
"analyzer": "simple",
"preserve_separators": true,
"preserve_position_increments": true,
"max_input_length": 50
}
}
},
"language": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"type": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"updateddate": {
"type": "date"
}
}
}
}
}

最佳答案

无法在查询时过滤掉建议,因为completion suggester 使用FST - 在索引时构建的特殊内存数据结构:

Suggesters in Lucene are built in-memory by loading the completion values from the index, then building the FST. This can be a slow, resource intensive process. And, as soon as the index changes, the FST needs to be rebuilt. "Real time search" is a mantra of Elasticsearch. It is not acceptable to return out of date suggestions, nor to require a full rebuild whenever the index changes. Instead of building the FST at search time, we now build an FST per-segment at index time.

所以你所能做的就是添加context对于你的建议者。上下文也在索引时与 completion 字段一起填充,因此可以在查询时在 suggest 查询中使用。另外,这个 article可能对您有用。

关于elasticsearch - Elastic Search 中带有附加条件的 Completion Suggester,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52933189/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com