Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

教程里的聚合例子在elasticsearch 6.0.1下的写法 #539

Open
evanliang0 opened this issue Dec 15, 2017 · 0 comments
Open

教程里的聚合例子在elasticsearch 6.0.1下的写法 #539

evanliang0 opened this issue Dec 15, 2017 · 0 comments

Comments

@evanliang0
Copy link

原文链接:https://www.elastic.co/guide/cn/elasticsearch/guide/current/_analytics.html

原例子:
GET /megacorp/employee/_search
{
"aggs": {
"all_interests": {
"terms": { "field": "interests" }
}
}
}

在elasticsearch 6.0.1下执行会报如下错误:
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [interests] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "megacorp",
"node": "S_-UcyJiRGmZvt1vDN-HjA",
"reason": {
"type": "illegal_argument_exception",
"reason": "Fielddata is disabled on text fields by default. Set fielddata=true on [interests] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead."
}
}
]
},
"status": 400
}

有两种方法可以解决,一种是设置fielddata=true,另一种是使用keyword,如下:
GET /megacorp/employee/_search
{
"aggs": {
"all_interests": {
"terms": {
"field": "interests.keyword"
}
}
}
}

官方文档:
https://www.elastic.co/guide/en/elasticsearch/reference/current/fielddata.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant