ElasticSearch学习问题记录——Invalid shift value in prefixCoded bytes (is encoded value really an INT?)
最近在做一个电商项目,其中商品搜索中出现一个奇怪的现象,根据某个字段排序的时候会出现商品数量减少的情况。按照一般路要么查不出来,要么正常显示,为什么增加了按照销量排序就会出现查询结果减少的情况。
查了下ES日志发现有报错:nested: NumberFormatException[Invalid shift value in prefixCoded bytes (is encoded value really an INT?)
看得出是数据类型转换错误,但是为什么错还是不清楚。求助GOOGLE。发现下面一则和我的情形相同。
https://github.com/elastic/elasticsearch/issues/9191#issuecomment-77784022 查看了下索引中索引类型映射到数据结构,发现确实存在同名字段不同类型的情况。将错误的索引类型删除,保持同一结构,问题就解决了。 为了进一步证实,我又写了一个小例子。先制造些错误,school使用先设置类型映射在添加数据。school2直接加数据,类型自动识别。下面是索引类型的映射结构:
{
"state": "open",
"settings": {
"index.version.created": "901399",
"index.number_of_replicas": "1",
"index.uuid": "qK4PV5IsQZm8eb1QCU7b6w",
"index.number_of_shards": "5"
},
"mappings": {
"school2": {
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"age": {
"type": "long"
},
"studentList": {
"properties": {
"sex": {
"type": "string"
},
"studentId": {
"type": "string"
},
"studentName": {
"type": "string"
}
}
}
}
},
"school": {
"properties": {
"id": {
"store": true,
"analyzer": "ik",
"type": "string"
},
"name": {
"store": true,
"analyzer": "ik",
"type": "string"
},
"age": {
"store": true,
"type": "integer"
},
"studentList": {
"properties": {
"sex": {
"store": true,
"analyzer": "ik",
"type": "string"
},
"studentId": {
"store": true,
"analyzer": "ik",
"type": "string"
},
"studentName": {
"store": true,
"analyzer": "ik",
"type": "string"
}
},
"type": "nested"
}
}
}
},
"aliases": [ ]
}
注意索引类型school和school2中age字段的类型前者是Integer后者是long。我们按照全匹配查询并根据age进行排序。问题产生了。下面就是报错的结果。
{
"error": "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[iJhim0-hSMKr_uHZFrBfTA][demoindex][3]: RemoteTransportException[[node2][inet[/192.168.0.202:9300]][search/phase/query]]; nested: QueryPhaseExecutionException[[demoindex][3]: query[filtered(ConstantScore(*:*))->cache(_type:school2)],from[0],size[20],sort[<custom:\"age\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@32780f73>!]: Query Failed [Failed to execute main query]]; nested: ElasticSearchException[java.lang.NumberFormatException: Invalid shift value in prefixCoded bytes (is encoded value really an INT?)]; nested: UncheckedExecutionException[java.lang.NumberFormatException: Invalid shift value in prefixCoded bytes (is encoded value really an INT?)]; nested: NumberFormatException[Invalid shift value in prefixCoded bytes (is encoded value really an INT?)]; }{[0P8agoQGSS-h4abY0hMI8Q][demoindex][4]: QueryPhaseExecutionException[[demoindex][4]: query[filtered(ConstantScore(*:*))->cache(_type:school2)],from[0],size[20],sort[<custom:\"age\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@1d42c789>!]: Query Failed [Failed to execute main query]]; nested: ElasticSearchException[java.lang.NumberFormatException: Invalid shift value in prefixCoded bytes (is encoded value really an INT?)]; nested: UncheckedExecutionException[java.lang.NumberFormatException: Invalid shift value in prefixCoded bytes (is encoded value really an INT?)]; nested: NumberFormatException[Invalid shift value in prefixCoded bytes (is encoded value really an INT?)]; }{[0P8agoQGSS-h4abY0hMI8Q][demoindex][1]: QueryPhaseExecutionException[[demoindex][1]: query[filtered(ConstantScore(*:*))->cache(_type:school2)],from[0],size[20],sort[<custom:\"age\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@2998a407>!]: Query Failed [Failed to execute main query]]; nested: ElasticSearchException[java.lang.NumberFormatException: Invalid shift value in prefixCoded bytes (is encoded value really an INT?)]; nested: UncheckedExecutionException[java.lang.NumberFormatException: Invalid shift value in prefixCoded bytes (is encoded value really an INT?)]; nested: NumberFormatException[Invalid shift value in prefixCoded bytes (is encoded value really an INT?)]; }{[iJhim0-hSMKr_uHZFrBfTA][demoindex][2]: RemoteTransportException[[node2][inet[/192.168.0.202:9300]][search/phase/query]]; nested: QueryPhaseExecutionException[[demoindex][2]: query[filtered(ConstantScore(*:*))->cache(_type:school2)],from[0],size[20],sort[<custom:\"age\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@65fde78f>!]: Query Failed [Failed to execute main query]]; nested: ElasticSearchException[java.lang.NumberFormatException: Invalid shift value in prefixCoded bytes (is encoded value really an INT?)]; nested: UncheckedExecutionException[java.lang.NumberFormatException: Invalid shift value in prefixCoded bytes (is encoded value really an INT?)]; nested: NumberFormatException[Invalid shift value in prefixCoded bytes (is encoded value really an INT?)]; }{[iJhim0-hSMKr_uHZFrBfTA][demoindex][0]: RemoteTransportException[[node2][inet[/192.168.0.202:9300]][search/phase/query]]; nested: QueryPhaseExecutionException[[demoindex][0]: query[filtered(ConstantScore(*:*))->cache(_type:school2)],from[0],size[20],sort[<custom:\"age\": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@f6e47a1>!]: Query Failed [Failed to execute main query]]; nested: ElasticSearchException[java.lang.NumberFormatException: Invalid shift value in prefixCoded bytes (is encoded value really an INT?)]; nested: UncheckedExecutionException[java.lang.NumberFormatException: Invalid shift value in prefixCoded bytes (is encoded value really an INT?)]; nested: NumberFormatException[Invalid shift value in prefixCoded bytes (is encoded value really an INT?)]; }]",
"status": 500
}
ElasticSearch学习问题记录——Invalid shift value in prefixCoded bytes (is encoded value really an INT?)的更多相关文章
- ElasticSearch学习问题记录——nested查询不到数据
通过代码创建了索引名称为demoindex,索引类型为school,以下是索引类型的数据映射结构: { "state": "open", "setti ...
- ElasticSearch 学习记录之ES几种常见的聚合操作
ES几种常见的聚合操作 普通聚合 POST /product/_search { "size": 0, "aggs": { "agg_city&quo ...
- ElasticSearch 学习记录之ES短语匹配基本用法
短语匹配 短语匹配故名思意就是对分词后的短语就是匹配,而不是仅仅对单独的单词进行匹配 下面就是根据下面的脚本例子来看整个短语匹配的有哪些作用和优点 GET /my_index/my_type/_sea ...
- ElasticSearch 学习记录之 分布式文档存储往ES中存数据和取数据的原理
分布式文档存储 ES分布式特性 屏蔽了分布式系统的复杂性 集群内的原理 垂直扩容和水平扩容 真正的扩容能力是来自于水平扩容–为集群添加更多的节点,并且将负载压力和稳定性分散到这些节点中 ES集群特点 ...
- ElasticSearch 学习记录之如任何设计可扩容的索引结构
扩容设计 扩容的单元 一个分片即一个 Lucene 索引 ,一个 Elasticsearch 索引即一系列分片的集合 一个分片即为 扩容的单元 . 一个最小的索引拥有一个分片. 一个只有一个分片的索引 ...
- ElasticSearch 学习记录之ES高亮搜索
高亮搜索 ES 通过在查询的时候可以在查询之后的字段数据加上html 标签字段,使文档在在web 界面上显示的时候是由颜色或者字体格式的 GET /product/_search { "si ...
- ElasticSearch 学习记录之ES查询添加排序字段和使用missing或existing字段查询
ES添加排序 在默认的情况下,ES 是根据文档的得分score来进行文档额排序的.但是自己可以根据自己的针对一些字段进行排序.就像下面的查询脚本一样.下面的这个查询是根据productid这个值进行排 ...
- ElasticSearch 学习记录之父子结构的查询
父子结构 父亲type属性查询子type 的类型 父子结构的查询,可以通过父亲类型的字段,查询出子类型的索引信息 POST /product/_search { "query": ...
- ElasticSearch 学习记录之Text keyword 两种基本类型区别
ElasticSearch 系列文章 1 ES 入门之一 安装ElasticSearcha 2 ES 记录之如何创建一个索引映射 3 ElasticSearch 学习记录之Text keyword 两 ...
随机推荐
- DevExpress GridView加入DevExpress中的右键菜单PopuMenu
1. 添加一个Barmanager控件 2. 加入popumenu控件,点击该控件右上角的黑色三角号,编辑选项,点击编辑的选项,选择事件,编辑事件. 3. 在使用该右键菜单的控件添加MouseUp事件 ...
- iOS开发-Masonry简易教程
关于iOS布局自动iPhone6之后就是AutoLayOut,AutoLayOut固然非常好用,不过有时候我们需要在页面手动进行页面布局,VFL算是一种选择,如果对VFL不是很熟悉可以参考iOS开发- ...
- LeetCode Minimum Height Trees
原题链接在这里:https://leetcode.com/problems/minimum-height-trees/ 题目: For a undirected graph with tree cha ...
- LUA语言注意点归集
统计元素个数接口--只计算以整数为下标的 第一段连续元素的数目 #tab 和 table.getn() http://ju.outofmemory.cn/entry/29450 我们修改table: ...
- lighttpd与fastcgi+cgilua原理、代码分析与安装
原理 http://www.cnblogs.com/skynet/p/4173450.html 快速通用网关接口(Fast Common Gateway Interface/FastCGI)是通用网关 ...
- Leetcode: Find Right Interval
Given a set of intervals, for each of the interval i, check if there exists an interval j whose star ...
- Android中悬浮窗口
调用WindowManager,并设置WindowManager.LayoutParams的相关属性,通过WindowManager的addView方法创建View,这样产生出来的View根据Wind ...
- bzoj1741 [Usaco2005 nov]Asteroids 穿越小行星群
网络流,对于每一个行星,将行星所在行到行星连一条流量为1的边,将行星到其所在列连一条流量为1的边,从源点到所有行连一条流量为1的边,将所有列到汇点都连一条流量为1的边,最大流即为答案. 代码 #inc ...
- 《zw版·Halcon-delphi系列原创教程》 Halcon分类函数013,shape模型
<zw版·Halcon-delphi系列原创教程> Halcon分类函数013,shape模型 为方便阅读,在不影响说明的前提下,笔者对函数进行了简化: :: 用符号“**”,替换:“pr ...
- Windows Azure Mangement API 之 更方便的使用Mangement API
许多.Net 程序员在使用Azure Management API的时候都选择参考微软官方示例,通过创建HttpWebRequest来创建. 或者自己创建类库来封装这些API,使之调用起来更加方便. ...