2016-08-01 30 views
0

我有一個user模型,它有一個articles對象的數組。當我嘗試使用ID加載用戶時,該過程需要很長時間,因爲它可能會有數千個數組中的項目對象。我想要做的只是加載100個嵌套文章。我使用Elasticsearch 1.5(舊,因爲它是在AWS託管),ES Persistence gemRuby on RailsElasticsearch限制返回的嵌套對象的數量

嘗試了一些文件,但沒有工作,例如 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

的方式來實現你想要的是使用inner_hits,但它現在還不支持。

有一個pending pull request旨在增加對嵌套inner_hits的支持,但它尚未合併。

更多信息here

+0

您需要更多信息? – Val

+0

感謝@Val有沒有使用PR的工作?正如我所提到的,我在AWS –

+0

上使用版本1.5,恐怕不行。 – Val

相關問題