我们使用elasticsearch正在执行搜索公司名单,但它不是我们所期望的Elasticsearch优化查询
**Example companies:**
Infosys technologies
Infosys technologies ltd
Infosys technologies pvt ltd
Infosys technologies Limited
Infosys technologies Private Limited
BAC Infosys ltd
场景:
当搜索关键字“Infosys公司”,它应该返回“印孚瑟斯 技术“列表。
当搜索关键字“Infosys ltd”时,应返回“Infosys technologies”列表。
当搜索关键字“BAC Infosys ltd”时,应返回“BAC Infosys ltd”列表。
以下设置和映射使用
{
"settings": {
"analysis": {
"filter": {
"nGram_filter": {
"type": "nGram",
"min_gram": 3,
"max_gram": 3,
"token_chars": [
"letter",
"digit",
"punctuation",
"symbol"
]
}
},
"analyzer": {
"nGram_analyzer": {
"type": "custom",
"tokenizer": "keyword",
"filter": [
"lowercase",
"asciifolding",
"nGram_filter"
]
},
"keyword_analyzer": {
"type": "custom",
"tokenizer": "keyword",
"filter": [
"lowercase",
"asciifolding"
]
}
}
}
},
"mappings": {
"companies": {
"properties": {
"company_name": {
"type": "string",
"store": "true",
"index_analyzer": "nGram_analyzer",
"search_analyzer": "keyword_analyzer",
"null_value": "null"
}
}
}
}
}
查询:
{"query":
{
"bool": {
"must": [
{ "match": { "company_name": "Infosys technologies" }}
],
"minimum_should_match": "80%"
}
}
}
请帮助我如何实现这一目标。
你可以给我任何例子,因为我是Elasticsearch的新手。请帮助我 – azhagu