情況:
頁面查詢ES數(shù)據(jù),Java查詢報(bào)這個錯誤,但是,通過打印的語句,構(gòu)建curl
查詢時候又是正常的,這就讓我很費(fèi)解。
報(bào)錯信息:
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [aaa] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory."
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "aaa_bbb_info_2022-09-27",
"node": "CqKuZyFxSYqCsgaXM7jX2A",
"reason": {
"type": "illegal_argument_exception",
"reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [aaa] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory."
}
}
],
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [aaa] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory."
}
},
"status": 400
}
網(wǎng)上的解決辦法:
https://blog.csdn.net/qq_16417621/article/details/105859887
這個解決辦法其實(shí)是正確的,但是,有個前提條件,我們已經(jīng)導(dǎo)入過模板,所以,可以直接修改模板
而且,這個帖子中的語句,是基于 ES7 的。我所在環(huán)境是ES5的,所以,加fielddata=true配置時,還報(bào)錯。
具體解決辦法:
我直接重新創(chuàng)建模板,然后,重新刷一次數(shù)據(jù),解決問題。
導(dǎo)入模板語句:文章來源:http://www.zghlxwxcb.cn/news/detail-599220.html
curl -X PUT -u elastic:123456 "http://127.0.0.1:9200/_template/aaa_bbb_info_temple" -H 'Content-Type: application/json' -d'{"template":"aaa_bbb_*","settings":{"index":{"mapping":{"ignore_malformed":"true"},"refresh_interval":"20s","number_of_shards":"5","translog":{"flush_threshold_size":"512mb","sync_interval":"60s","durability":"async"},"number_of_replicas":"1"}},"mappings":{"default":{"properties":{"aaa":{"store":true,"type":"keyword"}}}}}'
查詢導(dǎo)入是否成功:文章來源地址http://www.zghlxwxcb.cn/news/detail-599220.html
curl -H "Content-Type:application/json" -XGET -u elastic:123456 '192.168.92.82:9222/_template/aaa_bbb_info_temple' > aaa_bbb_info_temple.txt
到了這里,關(guān)于ElasticSearch 錯誤 Fielddata is disabled on text fields by default. Set fielddata=true 解決辦法的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!