版本: 7.11-7.15
简要来说,当 Elasticsearch 尝试对具有多个值的字段进行排序时,会发生此错误。Elasticsearch 只能对单值字段进行排序。要解决此问题,您可以更改数据模型以确保用于排序的字段在每个文档中只有一个值,或者使用脚本将多个字段值合并为一个值用于排序。另外,您可以使用 max 或 min 函数从多个值中选择一个值进行排序。
日志上下文 #
日志 “Encountered more than one sort value for a” 的类名是 GeoLineBucketedSort.java。我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入了解的人参考:
@Override
protected boolean advanceExact(int doc) throws IOException {
if (docSortValues.advanceExact(doc)) {
if (docSortValues.docValueCount() > 1) {
throw new AggregationExecutionException("Encountered more than one sort value for a " +
"single document. Use a script to combine multiple sort-values-per-doc into a single value.");
} // There should always be one weight if advanceExact lands us here; either
// a real weight or a `missing` weight





