问题描述 es 返回的字段过大,需要把没有使用的多余字段过滤掉
详细描述 es 存储结构 { "content_all": [{ "orgWidth":100, "orgHeight":200, "column3":"非常大的字段" }, { "orgWidth":100, "orgHeight":200, "column3":"非常大的字段" },{ "orgWidth":100, "orgHeight":200, "column3":"非常大的字段" },{ "orgWidth":100, "orgHeight":200, "column3":"非常大的字段" } ] }
由于 column3 字段很大,返回时间过长;需要只返回 content_all.orgWidth 和 content_all.orgHeight 字段
尝试的过滤条件 "_source":{"includes":["content_all.orgWidth "],"excludes":[]} 返回记录 "_source": {} 返回内容为空了
请问下如何才能实现只返回 content_all.orgWidth 和 content_all.orgHeight 字段,感谢
![]() | 1 zhengsidao 2021-07-12 10:07:27 +08:00 mapping 结构展示一下 |
![]() | 2 est 2021-07-12 10:11:26 +08:00 实在不行,索引拆了重建吧 |
![]() | 3 so1n 2021-07-12 10:18:34 +08:00 其实更应该考虑该字段是否存在 es, 即使不返回数据, 它也会占用 es 的内存 |
![]() | 4 kimera OP @zhengsidao { "zdw_index_1000_199": { "mappings": { "properties": { "content": { "type": "text", "analyzer": "charSplit" }, "content_all": { "type": "text", "analyzer": "charSplit" } } } } } |
5 weofuh 2021-07-12 10:57:44 +08:00 你这 content_all 又不是 nested 类型的,这没法过滤了吧 |
6 ldx101214 2021-07-12 11:05:24 +08:00 fetchSource?? |
![]() | 7 jay4497 2021-07-12 11:11:08 +08:00 抽出来做 runtime 字段试试? |
![]() | 8 vindurriel 2021-07-12 11:45:15 +08:00 via iPhone 有什么特殊需求必须用 content all 吗?改成 nested 虽然可以返回 但是有最大数量限制 object array 最好拆成单独的 index |
9 jifengg 2021-07-12 13:03:24 +08:00 "content_all": { "type": "text" array 字段被当成 string 处理了,需要改一下 mapping |
![]() | 10 Nielsen 2021-07-12 13:25:14 +08:00 via Android 尝试的过滤条件 "_source":{"includes":["content_all.orgWidth "],"excludes":[]} 返回记录 "_source": {} 返回内容为空了 orgWidth 后面那个空格是你粘过来的嘛还是 |
![]() | 11 zhengsidao 2021-07-12 18:27:13 +08:00 这个字段类型我也不知道取得了不,你可以试试用脚本 scrip , 个人建议还是 re-index 操作 |