我們使用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