Limit field length when querying Elasticsearch

删除回忆录丶 提交于 2020-01-24 03:21:44

问题


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.


回答1:


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)



来源:https://stackoverflow.com/questions/25635811/limit-field-length-when-querying-elasticsearch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!