gpt4 book ai didi

amazon-web-services - AWS Elastic search:应该在给定查询的所有组合上执行搜索

转载 作者:行者123 更新时间:2023-12-03 01:19:05 25 4
gpt4 key购买 nike

我正在研究AWS Elastic Search。我在项目中遇到一种情况,在该情况下,我必须在报告中搜索“冠状病毒”之类的关键字。

但是结果应包含“Corona virus”和“corona”以及“virus”和“coronavirus”之类的关键字。

请指导我如何构建查询DSL。

注意:使用PHP语言。

感谢您的帮助。

//发出

最佳答案

您需要使用shingle token filter

A token filter of type shingle that constructs shingles (token n-grams) from a token stream. In other words, it creates combinations of tokens as a single token. For example, the sentence "please divide this sentence into shingles" might be tokenized into shingles "please divide", "divide this", "this sentence", "sentence into", and "into shingles".



制图
PUT index91
{
"settings": {
"analysis": {
"analyzer": {
"my_analyzer": {
"tokenizer": "standard",
"filter": [
"lowercase",
"shingle_filter"
]
}
},
"filter": {
"shingle_filter": {
"type": "shingle",
"min_shingle_size": 2,
"max_shingle_size": 3,
"output_unigrams": true,
"token_separator": ""
}
}
}
},
"mappings": {
"properties": {
"title": {
"type": "text",
"analyzer": "my_analyzer"
}
}
}
}


数据:
POST index91/_doc
{
"title":"corona virus"
}

查询:
GET index91/_search
{
"query": {
"match": {
"title": "coronavirus"
}
}
}

结果:
"hits" : [
{
"_index" : "index91",
"_type" : "_doc",
"_id" : "gNmUZHEBrJsHVOidaoU_",
"_score" : 0.9438393,
"_source" : {
"title" : "corona virus"
}
}

它还适用于“电晕”,“电晕病毒”,“病毒”

关于amazon-web-services - AWS Elastic search:应该在给定查询的所有组合上执行搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61142369/

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