ElasticSearch Facet异常处理

当facet时数据返回数字不对,或者出现异常,不做facet不报错,百思不得其解,在独立的index下建index type,facet也不报错。
QueryPhaseExecutionException[[dn][2]: query[ConstantScore(NotDeleted(cache(_type:dn_character_glory)))],from[0],size[1]: Query Failed [Failed to execute main query]]; nested: NumberFormatException[Invalid shift value in prefixCoded string (is encoded value really a LONG?


猜想跟integer数据类型有关系

后来看到ES大拿kimchy说到
When you facet on a field across index types, they need to be of the same field type (string, long). You can name the field differently.


恍然大悟, terms facet估计是为string类型设计的,如果要对integer类型做term,要不增加一个field,要不直接做成string.

因为不考虑number类型统计,这里将field直接做成string数据类型,问题解决。

思考:
当建index type mapping时,要适当选择field的code type。

BTW:
似乎插件head自带的any request也会有数据bug

猜你喜欢

转载自zhousheng29.iteye.com/blog/1849549