在特定字段上分组时的 ClassCastException [null]
ClassCastException[null] when grouping on a particular field
我正在尝试使用以下查询对特定字段的结果进行分组:
{
"from": 0,
"size": 0,
"fields": [
"exitPage.categoryId"
],
"aggs": {
"check": {
"terms": {
"field": "exitPage.categoryId"
}
}
}
}
Elasticsearch 服务器抛出此异常:
{
"error": "ClassCastException[null]",
"status": 500
}
而且也是间歇性的 - 有时 returns 结果有时没有。服务器日志中没有更多可用的描述性信息。
有人知道这个问题吗?
编辑:添加了 Val
要求的错误日志
[2016-02-01 12:42:28,773][DEBUG][action.search.type ] [elastic71] failed to reduce search
org.elasticsearch.action.search.ReduceSearchPhaseException: Failed to execute phase [fetch], [reduce]
at org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.onFailure(TransportSearchQueryThenFetchAction.java:159)
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:41)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassCastException
您遇到该异常是因为您的某些文档没有 exitPage
属性,因此聚合器无法获取这些文档的 categoryId
值。
为了防止这种情况,您需要做的是过滤掉没有 exitPage
属性 的文档,例如使用 exists
查询.
{
"from": 0,
"size": 0,
"query": { <--- add this query
"filtered": {
"filter": {
"exists": {
"field": "exitPage"
}
}
}
},
"aggs": {
"check": {
"terms": {
"field": "exitPage.categoryId"
}
}
}
}
我重新启动了实例,这解决了问题。
我假设这是内部的一些损坏的缓存/索引,一旦实例重新启动就会被清理干净。如果有人知道更好的解释,请编辑此 post。
我正在尝试使用以下查询对特定字段的结果进行分组:
{
"from": 0,
"size": 0,
"fields": [
"exitPage.categoryId"
],
"aggs": {
"check": {
"terms": {
"field": "exitPage.categoryId"
}
}
}
}
Elasticsearch 服务器抛出此异常:
{
"error": "ClassCastException[null]",
"status": 500
}
而且也是间歇性的 - 有时 returns 结果有时没有。服务器日志中没有更多可用的描述性信息。
有人知道这个问题吗?
编辑:添加了 Val
要求的错误日志[2016-02-01 12:42:28,773][DEBUG][action.search.type ] [elastic71] failed to reduce search
org.elasticsearch.action.search.ReduceSearchPhaseException: Failed to execute phase [fetch], [reduce]
at org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.onFailure(TransportSearchQueryThenFetchAction.java:159)
at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:41)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassCastException
您遇到该异常是因为您的某些文档没有 exitPage
属性,因此聚合器无法获取这些文档的 categoryId
值。
为了防止这种情况,您需要做的是过滤掉没有 exitPage
属性 的文档,例如使用 exists
查询.
{
"from": 0,
"size": 0,
"query": { <--- add this query
"filtered": {
"filter": {
"exists": {
"field": "exitPage"
}
}
}
},
"aggs": {
"check": {
"terms": {
"field": "exitPage.categoryId"
}
}
}
}
我重新启动了实例,这解决了问题。
我假设这是内部的一些损坏的缓存/索引,一旦实例重新启动就会被清理干净。如果有人知道更好的解释,请编辑此 post。