# Attachment base64でエンコードしたフィールドが検索できない

**URL:** <https://discuss.elastic.co/t/attachment-base64/59089>\
**Category:** 日本語による質問・議論はこちら\
**Created:** [August 27, 2016, 6:03am UTC](https://discuss.elastic.co/t/attachment-base64/59089 "2016-08-27T06:03:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rei](https://avatars.discourse-cdn.com/v4/letter/r/ecd19e/32.png) [@Rei](https://discuss.elastic.co/u/Rei)\
**Post date:** [August 27, 2016, 6:03am UTC](https://discuss.elastic.co/t/attachment-base64/59089/1 "2016-08-27T06:03:00Z")

</div>

・事象  
ES2.3.5にてbase64でエンコードしたフィールドが検索できない  
ES1.6だとできる

・データの状態  
ES2.3.5とES1.6のbase64エンコード値は全く同じ

・クエリー  
{"query":{"match":{"fileContent":"ソフトウェアプログラム"}}}  
・環境  
win2008/ES2.3.5/jre1.8.0\_91 64bit  
・成功した環境  
win2008/ES1.6/jre1.8.0\_91 64bit

1.6だとうまくいくのですが、2.3.5だと何か特殊な設定が必要なのでしょうか？

---

<div class="post-metadata">

**Author:** ![johtani](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/johtani/32/44956_2.png) [@johtani](https://discuss.elastic.co/u/johtani)\
**Post date:** [August 30, 2016, 6:30am UTC](https://discuss.elastic.co/t/attachment-base64/59089/2 "2016-08-30T06:30:37Z")

</div>

`mapper-attachment` pluginを使ってており、`fileContent`というフィールドに`attachment`のTypeを指定していると想定して回答します。（間違ってたら言ってください。あと、質問するときはMappingなどを提示するとわかりやすいです。）

1.6の場合、Mapper-attachmentは`fileContent`の下に`fileContent`という[フィールドを生成していました](https://github.com/elastic/elasticsearch-mapper-attachments/tree/v2.7.1/#version-271-for-elasticsearch-17)。

2.xのMapper-attachmentは`attachment`のタイプが指定してあるフィールド名ではなく、[`content`というフィールド名固定となるように変わっています](https://www.elastic.co/guide/en/elasticsearch/plugins/current/mapper-attachments-usage.html#mapper-attachments-usage)。

まず、この点が2.xとの違いです。  
さらに、2.xでは、検索のDSLなどで利用する[フィールド名を厳密に指定するように変更](https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking_20_mapping_changes.html#_fields_cannot_be_referenced_by_short_name)が入っています。

1.xでは`fileContent`で検索した場合に、どの階層にあるかはわからないが、`fileContent`というフィールド全てに検索する仕組みでした。厳密には1.6では`fileContent.fileContent`というフィールドに検索が実行されています。

ですので、2.xでは、クエリを`fileContent.content`に変更すると検索できるようになるはずです。

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:45pm UTC](https://discuss.elastic.co/t/attachment-base64/59089/3 "2017-07-06T13:45:55Z")

</div>


