gpt4 book ai didi

search - Elasticsearch找不到分析器,但它创建索引没有任何错误

转载 作者:行者123 更新时间:2023-12-03 01:48:34 26 4
gpt4 key购买 nike

这是我测试时的索引设置json
http://localhost:9200/myIndex/_analyze?text=“测试分析​​仪”&analyzer = nGram_analyzer
我收到以下异常。

{
"error": {
"root_cause": [
{
"type": "remote_transport_exception",
"reason": "[Infectia][127.0.0.1:9300][indices:admin/analyze[s]]"
}
],
"type": "illegal_argument_exception",
"reason": "failed to find analyzer [nGram_analyzer]"
},
"status": 400
}

索引设定
  {
"myIndex": {
"mappings": {
"practices": {
"properties": {
"practiceCity": {
"type": "string",
"index":"analyzed",
"analyzer": "nGram_analyzer"
},
"practiceId": {
"type": "long",
"index":"not_analyzed"
},
"practiceName": {
"type": "string",
"boost": 10,
"index":"analyzed",
"analyzer": "nGram_analyzer"
},
"practicePhone": {
"type": "long",
"boost": 10,
"index":"analyzed",
"analyzer": "nGram_analyzer"
},
"practiceService": {
"type": "string",
"boost": 5,
"index":"not_analyzed"
}
}
},
"users": {
"_all": {
"analyzer": "nGram_analyzer"
},
"properties": {
"userCityId": {
"type": "long",
"index":"not_analyzed",
"analyzer": "nGram_analyzer"
},
"userCityName": {
"type": "string",
"index":"not_analyzed"
},
"userEmail": {
"type": "string",
"index":"analyzed",
"analyzer": "nGram_analyzer"
},
"userFirstName": {
"type": "string",
"boost": 10,
"index":"analyzed",
"analyzer": "nGram_analyzer"
},
"userId": {
"type": "long"
},
"userLastName": {
"type": "string",
"boost": 10,
"index":"analyzed",
"analyzer": "nGram_analyzer"
},
"userMobile": {
"type": "string",
"index":"analyzed",
"analyzer": "nGram_analyzer"
},
"userSpecialization": {
"type": "string",
"boost": 5,
"index":"not_analyzed"
}
}
}
},
"settings": {
"index": {
"analysis": {
"analyzer": {
"nGram_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"nGram_filter"
]
}
},
"filter": {
"nGram_filter": {
"max_gram": "20",
"type": "edgeNGram",
"min_gram": "3",
"token_chars": [
"letter",
"digit",
"punctuation",
"symbol"
]
}
}
},
"number_of_replicas": "1",
"number_of_shards": "5"
}
}
}
}

我正在使用自动完成功能,索引看起来不错吗?
对性能有什么建议吗?

最佳答案

您需要像这样更改settings部分:(即analysis直接位于settings下,而不是index中)

PUT myindex
{
"mappings": {
"practices": {
"properties": {
"practiceCity": {
"type": "string",
"index": "analyzed",
"analyzer": "nGram_analyzer"
},
"practiceId": {
"type": "long",
"index": "not_analyzed"
},
"practiceName": {
"type": "string",
"boost": 10,
"index": "analyzed",
"analyzer": "nGram_analyzer"
},
"practicePhone": {
"type": "long",
"boost": 10
},
"practiceService": {
"type": "string",
"boost": 5,
"index": "not_analyzed"
}
}
},
"users": {
"properties": {
"userCityId": {
"type": "long"
},
"userCityName": {
"type": "string",
"index": "not_analyzed"
},
"userEmail": {
"type": "string",
"index": "analyzed",
"analyzer": "nGram_analyzer"
},
"userFirstName": {
"type": "string",
"boost": 10,
"index": "analyzed",
"analyzer": "nGram_analyzer"
},
"userId": {
"type": "long"
},
"userLastName": {
"type": "string",
"boost": 10,
"index": "analyzed",
"analyzer": "nGram_analyzer"
},
"userMobile": {
"type": "string",
"index": "analyzed",
"analyzer": "nGram_analyzer"
},
"userSpecialization": {
"type": "string",
"boost": 5,
"index": "not_analyzed"
}
}
}
},
"settings": {
"index": {
"number_of_replicas": "1",
"number_of_shards": "5"
},
"analysis": {
"analyzer": {
"nGram_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"nGram_filter"
]
}
},
"filter": {
"nGram_filter": {
"max_gram": "20",
"type": "edgeNGram",
"min_gram": "3",
"token_chars": [
"letter",
"digit",
"punctuation",
"symbol"
]
}
}
}
}
}

关于search - Elasticsearch找不到分析器,但它创建索引没有任何错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42136837/

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