虽然之前知道elasticsearch不同类型下同名字段要慎用,并且会出问题,但是只真正碰到了才印象深刻啊,前几天就碰到了,是关于一个排序的问题,事情的经过是这样的,在异常服务重启之后,某个查询突然出问题了,提示信息显示的是排序失败,如下:
1
2
{"error":"SearchPhaseExecutionException[Failed to execute phase [query], total failure; shardFailures {[Pqdw_LAFSbOfyo9yVU9aaw][xxx][0]: QueryPhaseExecutionException[[xxx][0]: query[ConstantScore(*:*)],from[0],size[10],sort[<custom:\"ActivityTimestamp\": org.elasticsearch.index.field.data.strings.StringFieldDataType$1@1693f17f>]: Query Failed [Failed to execute main query]]; nested: IOException[Can't sort on string types with more than one value per doc, or more than one token per field]; }{[Pqdw_LAFSbOfyo9yVU9aaw][xxx][1]: QueryPhaseExecutionException[[xxx][1]: query[ConstantScore(*:*)],from[0],size[10],sort[<custom:\"ActivityTimestamp\": org.elasticsearch.index.field.data.strings.StringFieldDataType$1@3a18c8ca>]:
1
2
{"error":"SearchPhaseExecutionException[Failed to execute phase [query], total failure; shardFailures {[Pqdw_LAFSbOfyo9yVU9aaw][xxx][0]: QueryPhaseExecutionException[[xxx][0]: query[ConstantScore(*:*)],from[0],size[10],sort[<custom:\"ActivityTimestamp\": org.elasticsearch.index.field.data.strings.StringFieldDataType$1@1693f17f>]: Query Failed [Failed to execute main query]]; nested: IOException[Can't sort on string types with more than one value per doc, or more than one token per field]; }{[Pqdw_LAFSbOfyo9yVU9aaw][xxx][1]: QueryPhaseExecutionException[[xxx][1]: query[ConstantScore(*:*)],from[0],size[10],sort[<custom:\"ActivityTimestamp\": org.elasticsearch.index.field.data.strings.StringFieldDataType$1@3a18c8ca>]: