【问题标题】:Elasticsearch limit the number of nested objects returnedElasticsearch 限制返回的嵌套对象的数量
【发布时间】:2016-08-01 13:31:59
【问题描述】:

我有一个 user 模型,它有一个 articles 对象数组。当我尝试使用ID 加载用户时,该过程需要很长时间,因为它可能是数组中的数千个文章对象。我要做的是只加载 100 篇嵌套文章。我正在使用Elasticsearch 1.5(旧,因为它托管在 AWS 上)、ES Persistence gemRuby 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

【问题讨论】:

    标签: ruby-on-rails ruby elasticsearch


    【解决方案1】:

    实现您想要的方法是使用inner_hits,但它尚不支持开箱即用。

    有一个pending pull request 旨在添加对嵌套inner_hits 的支持,但它尚未合并。

    更多信息here

    【讨论】:

    • 您需要更多信息吗?
    • 谢谢@Val 有没有不使用 PR 的解决方法?正如我提到的,我在 AWS 上使用 1.5 版
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-14
    • 1970-01-01
    • 1970-01-01
    • 2020-04-16
    • 1970-01-01
    相关资源
    最近更新 更多