エラー: ClassCastException[org.elasticsearch.search. aggregates.support.ValuesSource$Bytes$WithOrdinals$FieldData は org.elasticsearch.search.aggregations.support.ValuesSource$Numeric にキャストできません]}{[vTHdFzpuTEGMGR8MES_b9g]
私のクエリ:
GET _search
{
"size" : 0,
"query" : {
"filtered" : {
"query" : {
"dis_max" : {
"tie_breaker" : 0.7,
"queries" : [ {
"bool" : {
"should" : [ {
"match" : {
"post.body" : {
"query" : "check",
"type" : "boolean"
}
}
}, {
"match" : {
"post.parentBody" : {
"query" : "check",
"type" : "boolean",
"boost" : 2.0
}
}
} ]
}
} ]
}
}
}
},
"aggregations" : {
"by_parent_id" : {
"terms" : {
"field" : "post.parentId",
"order" : {
"max_score" : "desc"
}
},
"aggregations" : {
"max_score" : {
"max" : {}
},
"top_post" : {
"top_hits" : {
"size" : 1
}
}
}
}
}
エラスティック検索のデフォルトの動作ではmax_score
なく、バケットをソートしたい。doc_count
投稿 (body と parentBody を含む) を集約してから、取得している各バケットでバケットをparentId
並べ替えようとしています。しかし、最大スコア集計を定義してバケットをソートすると、上記のエラーが発生します。集計を削除すると、残りのすべてが機能します。すべての投稿オブジェクトには、parentId、body、parentBody があります。これをコーディングするために、次のリファレンスを使用しました。max_score
top_hits
max_score
Elasticsearch Aggregation: バケットの順序を並べ替える方法 https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-top-hits-aggregation.html#_field_collapse_example
私が間違っていることを教えてください。上記のクエリを共有しました。