Elasticsearch手记
1. illegal_argument_exception 报错
当我们向elasticsearch
中,添加一条数据时(此时,如果索引存在则直接新增或者更新文档,不存在则先创建索引),首先检查该amount
字段的映射类型。如上示例中,我们添加第一篇文档时(z1
索引不存在),elasticsearch
会自动的创建索引,然后为age
字段创建映射关系(es就猜此时amount字段的值是什么类型,如果发现是text
类型,那么存储该字段的映射类型就是text
),此时amount字段的值是text
类型,所以,第二条插入数据,amount的值也是text
类型,而不是我们看到的long
类型。我们可以查看一下该索引的mappings
信息:
GET idx_202012/_mapping
推荐处理方式:
1. 查看原来的mapping
1 | GET idx_202012/_mapping |
2. 创建新index
1 | PUT idx_202012_v2 |
3. 预先定义类型
1 2 3 4 5 6 7 8 9 | POST youi_idx_202101_v2/_mapping?pretty { "properties" : { "amount" : { "type" : "long" , "store" : "true" } } } |
4.数据同步
1 2 3 4 5 6 7 8 9 | POST _reindex { "source" : { "index" : "idx_202101" }, "dest" : { "index" : "idx_202101_v2" } } |
5. 删除旧索引
1 | DELETE idx_202101 |
6.设置别名
1 2 3 4 5 6 | POST /_aliases { "actions" : [ { "add" : { "index" : "idx_202101" , "alias" : "idx_202101_v2" }} ] } |
我用的: https://www.cnblogs.com/blogabc/p/12664274.html
https://www.cnblogs.com/royfans/p/11436395.html
其他处理方式:
5.x后对排序,聚合这些操作用单独的数据结构(fielddata)缓存到内存里了,需要单独开启,官方解释在此fielddata
简单来说就是在聚合前执行如下操作
1 2 3 4 5 6 7 8 9 | PUT idx_202012/_mapping/ { "amount" : { "interests" : { "type" : "text" , "fielddata" : true } } } |
参考: https://blog.csdn.net/u011403655/article/details/71107415
Elasticsearch - 常见错误:https://www.cnblogs.com/Neeo/articles/10771885.html#illegal_argument_exception
1. read_only_allow_delete" : "true"
2. illegal_argument_exception
3. Result window is too large
elasticsearch-mapping字段类型:https://blog.csdn.net/gongpulin/article/details/78570246
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 通过 API 将Deepseek响应流式内容输出到前端
· 因为Apifox不支持离线,我果断选择了Apipost!
2018-01-19 python 文字识别 之 pytesseract
2018-01-19 2018年网络开发者的路线图