gpt4 book ai didi

Elasticsearch : Completion suggester not working with whitespace Analyzer

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

我是 Elastic search 的新手,我正在尝试使用 whitespace Analyzer 创建一个 Completion suggester 演示。

As per the documentation of Whitespace Analyzer, It breaks text into terms whenever it encounters a whitespace character. So my question is do it works with Completion suggester too?

So for my completion suggester prefix : "ela", I am expecting output as "Hello elastic search."

我知道一个简单的解决方案是将多字段输入添加为:

"suggest": {
"input": ["Hello","elastic","search"]
}

However, if this is the solution then what is meaning of using analyzer? Does analyzer make sense in completion suggester?

我的映射:

{
"settings": {
"analysis": {
"analyzer": {
"completion_analyzer": {
"type": "custom",
"filter": [
"lowercase"
],
"tokenizer": "whitespace"
}
}
}
},
"mappings": {
"my-type": {
"properties": {
"mytext": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"suggest": {
"type": "completion",
"analyzer": "completion_analyzer",
"search_analyzer": "completion_analyzer",
"max_input_length": 50
}
}
}
}
}

我的文档:

{
"_index": "my-index",
"_type": "my-type",
"_id": "KTWJBGEBQk_Zl_sQdo9N",
"_score": 1,
"_source": {
"mytext": "dummy text",
"suggest": {
"input": "Hello elastic search."
}
}
}

搜索请求:

{
"suggest": {
"test-suggest" : {
"prefix" :"ela",
"completion" : {
"field" : "suggest",
"skip_duplicates": true
}
}
}
}

此搜索没有返回正确的输出,但如果我使用 prefix = 'hel',我会得到正确的输出:“Hello elastic search。”

简而言之,我想知道 whitespace Analyzer 是否与 completion suggester 一起工作?如果有办法,请给我建议。

PS:我已经在寻找这个链接,但没有找到有用的答案。

ElasticSearch completion suggester Standard Analyzer not working

What Elasticsearch Analyzer to use for this completion suggester?

我发现此链接很有用 Word-oriented completion suggester (ElasticSearch 5.x) .但是他们没有使用完成建议器。

提前致谢。

吉米

最佳答案

补全建议器无法执行全文查询,这意味着它无法根据多词字段中间的词返回建议。

来自 ElasticSearch本身:

The reason is that an FST query is not the same as a full text query. We can't find words anywhere within a phrase. Instead, we have to start at the left of the graph and move towards the right.

正如您所发现的,可以匹配字段中间的完成建议器的最佳替代方法是边缘 n-gram 过滤器。

关于 Elasticsearch : Completion suggester not working with whitespace Analyzer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48304499/

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