-1

以前はmapper-attachmentsプラグインを使用していましたが、現在は非推奨になっています。これは通常のインデックス作成と一緒に使用するのがかなり簡単です。摂取アタッチメントがそれを置き換え、パイプラインが必要になったので、これを正しく使用する方法が混乱しています。elasticsearch-railsでingest-attachmentプラグインをどのように使用しますか?

Mediaというモデルがあり、fileフィールドにbase64でエンコードされたファイルが含まれているとします。以前の単純なMedia.last.__elasticsearch__.index_document、レコード、実際に伴い、インデックスには十分だっただろう、今

curl -XPUT 'localhost:9200/_ingest/pipeline/attachment' -d' 
{ 
    "description" : "Extract attachment information", 
    "processors" : [ 
    { 
     "attachment" : { 
     "field" : "file" 
     } 
    } 
    ] 
}' 

:私はカールを経由して添付ファイルパイプラインを作成している

mapping '_source' => { :excludes => ['file'] } do 
    indexes :id, type: :long, index: :not_analyzed 
    indexes :name, type: :text 
    indexes :visibility, type: :integer, index: :not_analyzed 
    indexes :created_at, type: :date, include_in_all: false 
    indexes :updated_at, type: :date, include_in_all: false 

    # attachment specific mappings 
    indexes 'attachment.title', type: :text, store: 'yes' 
    indexes 'attachment.author', type: :text, store: 'yes' 
    indexes 'attachment.name', type: :text, store: 'yes' 
    indexes 'attachment.date', type: :date, store: 'yes' 
    indexes 'attachment.content_type', type: :text, store: 'yes' 
    indexes 'attachment.content_length', type: :integer, store: 'yes' 
    indexes 'attachment.content', term_vector: 'with_positions_offsets', type: :text, store: 'yes' 
end 

:私は、そのファイルに次のマッピングを持っていますmapper-attachmentsプラグインを使用してfile

ingest-attachmentパイプラインとelasticsearch-rails gemを使用してこれを行う方法がわかりません。

私はカールを経由して、次のPUTを行うことができます。

curl -XPUT 'localhost:9200/assets/media/68?pipeline=attachment' -d' 
{ "file" : "my_really_long_encoded_file_string" }' 

この意志指数エンコードされたファイルが、明らかにそれは、インデックスモデルのデータの残りの部分(またはそれが以前にインデックスされた場合は、それを完全に上書き)しません。私は実際には、ファイルと一緒にすべての単一のモデルの属性をカールコマンドに含める必要はありません。これを行うためのより良い方法や簡単な方法がありますか?私はちょうど完全にパイプラインを外して摂取していますか?

答えて

0

最後にこれを認識しました。 ESの宝石、特にelasticsearch-apiを更新する必要がありました。私はそれを持っているように設定したマッピングおよびパイプラインで

、あなただけで簡単に行うことができます

Media.last.__elasticsearch__.index_document pipeline: :attachment

または

Media.last.__elasticsearch__.update_document pipeline: :attachment

をこの意志インデックスすべて正しく、あなたのファイルは次のようになります適切に解析され、インジェストパイプラインを介して索引付けされます。

関連する問題