retire icon indicating copy to clipboard operation
retire copied to clipboard

Add support for binary attachments (PDF, DOC, etc)

Open karmi opened this issue 13 years ago • 13 comments

Add support for binary attachments, such as PDF, DOC, etc file. See http://www.elasticsearch.org/guide/reference/mapping/attachment-type.html.

Basically, ES expects attachment in the form of base64-encoded data, so the API could/should take cue from rest-client here.

karmi avatar May 06 '11 08:05 karmi

yes, I would definitely appreciate that

morgler avatar May 25 '11 20:05 morgler

+1

ysf avatar Jun 03 '11 15:06 ysf

+100000 (This is so important for this gem)

Has this been added yet? If not when might it be? Much appreciated!

jmangoubi avatar Feb 07 '12 23:02 jmangoubi

Yup! Yes please. +1

arvindang avatar Feb 09 '12 16:02 arvindang

Hi all -- I'm not currently planning any focus on attachment support. There are many parts of the codebase which need to be refactored and cleaned up, many important features piled up in pull requests and my mind, and I don't immediately need it. I tend to not implement features without real use cases to check them against.

That said, there's some shitty code in the attachments branch which I sketched when I was playing with it. Feel free to check it out and play with it some more.

karmi avatar Feb 10 '12 17:02 karmi

Is there any solution to use attachment-type plugin (using tika) with Tire?

vecernik avatar Jun 23 '12 22:06 vecernik

Is there still no planned support for this feature?

ryudice avatar Jun 24 '12 02:06 ryudice

@vecernik You can work with attachment support via the "sending Hashes over HTTP" approach, which Tire (and other ES libraries) support. There is yet not a native, Ruby-like wrapping available.

@ryudice It is absolutely planned as a feature.

karmi avatar Jun 24 '12 10:06 karmi

+1 on seeing a native Ruby wrapper for this in Tire...pretty please!

demetrios avatar Jun 25 '12 23:06 demetrios

@karmi Would you provide some clues how to add attachments (via has_many) to AR model index (with Tire::Model::Callbacks)? I have tire-app.jar installed in exec path as well as elasticsearch-mapper-attachments, but can't find how to setup that.

vecernik avatar Aug 30 '12 16:08 vecernik

hi guys, I use method milion times described on the internet to include binary attachement, but I got problems when a model has_many attachments, through: attachment_mapping...

How is it with this feature ? (just asking, this might help me actually :) thx)

redrick avatar Oct 24 '13 06:10 redrick

I got Tire working with attachments plugin. May be it helps to someone for simple implementations...

The to_indexed_json method:

def to_indexed_json
    {
      title:              title,
      description:  description,
      author:         author,
      attachment: attachment
    }.to_json
end

And here is the attachment method which converts the attachment to Base64

def attachment
    if file.present?
      path_to_file = Rails.root.to_s + '/public' + file_url.to_s
      Base64.encode64(open(path_to_file) { |f| f.read })
    else
      Base64.encode64('missing')
    end
end

jonarrien avatar Dec 03 '13 12:12 jonarrien

@jonarrien, thank you

roma86 avatar Aug 02 '15 09:08 roma86