如何防止附件存储在_source与弹性搜索和轮胎? [英] How to prevent attachments from being stored in _source with Elasticsearch and Tire?

查看:114
本文介绍了如何防止附件存储在_source与弹性搜索和轮胎?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些PDF附件被索引在Elasticsearch,使用轮胎宝石。这一切都很好,但是我会有很多GB的PDF,我们可能会在S3中存储PDF以供访问。现在,base64编码的PDF存储在Elasticsearch _source中,这将使索引变大。我想让附件被索引,但没有存储,我还没有想出正确的咒语放在轮胎的映射块中以防止它。块现在是这样的:

I've got some PDF attachments being indexed in Elasticsearch, using the Tire gem. It's all working great, but I'm going to have many GB of PDFs, and we will likely store the PDFs in S3 for access. Right now the base64-encoded PDFs are being stored in Elasticsearch _source, which will make the index huge. I want to have the attachments indexed, but not stored, and I haven't yet figured out the right incantation to put in Tire's "mapping" block to prevent it. The block is like this right now:

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

我尝试过一些变体,如:

I've tried some variations like:

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

当我运行轮胎时,它看起来不错:导入耙子任务,但它不似乎有所作为。有人知道A)如果这是可能的话和/或B)如何做?

And it looks nice when I run the tire:import rake task, but it doesn't seem to make a difference. Does anyone know A) if this is possible? and B) how to do it?

提前感谢

推荐答案

p> _source字段设置包含字段列表被排除在来源之外。我会猜测,在轮胎的情况下,这样的事情应该这样做:

The _source field settings contain a list of fields what should be excluded from the source. I would guess that in case of tire, something like this should do it:

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

这篇关于如何防止附件存储在_source与弹性搜索和轮胎?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆