问题:ES查询时,如果有高亮的需求,需要小心一点,就是档文档字数太多时,高亮会报错
illegal_argument_exception
在查询一篇文档时,使用了高亮请求参数,报错如下:
The length [5054297] of field [xxxxx.xxxx] in doc[4159]/index[xxxx] exceeds the [index.hightlight.max_analyzed_offset] limit [1000000]. To avoid this error, set the query parameter [max_analyzed_offset] to a value less than index setting [1000000] and this will tolerate long field values by truncating them.
意思是 ES 存在一个限制 index.highlight.max_analyzed_offset 限制,为1000000
这时候需要在查询中设置 max_analyzed_offset 参数为一个小于该值的数字就可以