我有一个user
模型,其中包含articles
个对象数组。当我尝试加载具有ID
的用户时,该过程需要很长时间,因为它可能是数组中的数千个文章对象。我要做的是只加载100个嵌套文章。我正在使用Elasticsearch 1.5
(旧版,因为它托管在AWS上),ES Persistence gem
和Ruby on Rails
尝试了一些文档,但没有一个工作,例如 https://www.elastic.co/guide/en/elasticsearch/reference/1.5/search-aggregations-bucket-nested-aggregation.html
class User
include Elasticsearch::Persistence::Model
attribute :articles, Array[MiniArticle], mapping: { type: 'nested'}
attribute :since_id
end
答案 0 :(得分:0)