gpt4 book ai didi

elasticsearch - 如何使用 Elasticsearch 和 Tire 防止附件存储在 _source 中?

转载 作者:行者123 更新时间:2023-11-29 02:52:17 24 4
gpt4 key购买 nike

我使用 Tire gem 在 Elasticsearch 中为一些 PDF 附件建立了索引。一切都很好,但我将拥有许多 GB 的 PDF,并且我们可能会将 PDF 存储在 S3 中以供访问。现在 base64 编码的 PDF 存储在 Elasticsearch _source 中,这将使索引变得巨大。我想将附件编入索引,但不存储,而且我还没有想出正确的咒语来放入 Tire 的“映射” block 以防止它。现在的 block 是这样的:

mapping do
indexes :id, :type => 'integer'
indexes :title
indexes :last_update, :type => 'date'
indexes :attachment, :type => 'attachment'
end

我尝试了一些变体,例如:

indexes :attachment, :type => 'attachment', :_source => { :enabled => false }

当我运行 tire:import rake 任务时它看起来不错,但它似乎没有什么不同。有谁知道 A) 这是否可能? B) 怎么做?

提前致谢。

最佳答案

_source field settings包含应从源中排除的字段列表。我想如果是轮胎,应该这样做:

mapping :_source => { :excludes => ['attachment'] } do
indexes :id, :type => 'integer'
indexes :title
indexes :last_update, :type => 'date'
indexes :attachment, :type => 'attachment'
end

关于elasticsearch - 如何使用 Elasticsearch 和 Tire 防止附件存储在 _source 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11873248/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com