查询Elasticsearch时限制字段长度 [英] Limit field length when querying Elasticsearch

查看:2386
本文介绍了查询Elasticsearch时限制字段长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从Elasticsearch获取结果时,是否可以将字段限制为一定数量的字符?我知道如何将结果限制为一组特定的字段,但是我看不到如何仅获取一部分数据.我只想接收前100个字符以显示数据预览并限制I/O.

Is there a way to limit a field to a certain number of characters when getting results from Elasticsearch? I know how to limit my results to a specific set of fields, but I don't see how to get just a piece of the data. I would like to receive just the first 100 characters to display a preview of data and limit I/O.

我已经看到突出显示可以设置片段大小,但是我不一定要从想要子字符串的字段中查询任何内容.

I have seen that highlighting gives the option of setting a fragment size, but I am not necessarily querying for anything from the field I want a substring of.

推荐答案

Elasticsearch不提供此类选项.实现这种情况的理想方法是更改​​索引数据的方式,并可以将代码段和长字段存储在一起. (@foresightyj提供了很好的链接以在索引/查询时排除/包含字段)

Elasticsearch doesn't provide such an option. The ideal way to achieve this kind of scenario is to change the way you are indexing data and may be store a snippet along with the long length fields. ( @foresightyj has provided good links to exclude/include fields at indexing/querying time)

这篇关于查询Elasticsearch时限制字段长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆