Elasticsearch无法找到分析仪,但它没有任何错误
问题描述:
这里是我的索引设置JSON创建索引,当我测试 http://localhost:9200/myIndex/_analyze?text=“测试仪” &仪= nGram_analyzer 我得到了以下异常。Elasticsearch无法找到分析仪,但它没有任何错误
{
"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"
]
}
}
}
}
}
抱歉这样说......不工作的Val,同样的错误响应。 我刚刚复制了您的固定索引设置节点。 –
我已解决问题并更新了我的答案,请再试一次。 – Val
没有先生,它尚未修复,获得相同的错误响应。 –