# Attachment Search

**URL:** <https://discuss.elastic.co/t/attachment-search/38690>\
**Category:** Elasticsearch\
**Created:** [January 8, 2016, 4:29am UTC](https://discuss.elastic.co/t/attachment-search/38690 "2016-01-08T04:29:04Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sivaprakash\_Shanmuga](https://avatars.discourse-cdn.com/v4/letter/s/ecae2f/32.png) [@Sivaprakash\_Shanmuga](https://discuss.elastic.co/u/Sivaprakash_Shanmuga)\
**Post date:** [January 8, 2016, 4:29am UTC](https://discuss.elastic.co/t/attachment-search/38690/1 "2016-01-08T04:29:04Z")

</div>

Hi

Im following this link to implement my first attachment script

> **[GitHub - elastic/elasticsearch-mapper-attachments: Mapper Attachments Type...](https://github.com/elastic/elasticsearch-mapper-attachments)**
>
> Mapper Attachments Type plugin for Elasticsearch. Contribute to elastic/elasticsearch-mapper-attachments development by creating an account on GitHub.

After indexing if I run

[http://localhost:9400/mytestatachment/person/1](http://localhost:9400/mytestatachment/person/1)

I get

> {"\_index":"mytestatachment","\_type":"person","\_id":"1","\_version":1,"found":true,"\_source":{  
> "cv": "e1xydGYxXGFuc2kNCkxvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0DQpccGFyIH0="  
> }}

but with search Query

> {  
> "query": {  
> "query\_string": {  
> "query": "ipsum"  
> }}}

I'm not getting any result. Any configuration is missing with Base64?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 8, 2016, 5:25am UTC](https://discuss.elastic.co/t/attachment-search/38690/2 "2016-01-08T05:25:37Z")

</div>

What is the mapping?

---

<div class="post-metadata">

**Author:** ![Sivaprakash\_Shanmuga](https://avatars.discourse-cdn.com/v4/letter/s/ecae2f/32.png) [@Sivaprakash\_Shanmuga](https://discuss.elastic.co/u/Sivaprakash_Shanmuga)\
**Post date:** [January 8, 2016, 5:44am UTC](https://discuss.elastic.co/t/attachment-search/38690/3 "2016-01-08T05:44:13Z")

</div>

Here is the mapping

> {  
> "properties": {  
> "cv": { "type": "attachment" }  
> }}

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 8, 2016, 6:25am UTC](https://discuss.elastic.co/t/attachment-search/38690/4 "2016-01-08T06:25:36Z")

</div>

Which versions are you using?

---

<div class="post-metadata">

**Author:** ![Sivaprakash\_Shanmuga](https://avatars.discourse-cdn.com/v4/letter/s/ecae2f/32.png) [@Sivaprakash\_Shanmuga](https://discuss.elastic.co/u/Sivaprakash_Shanmuga)\
**Post date:** [January 8, 2016, 6:58am UTC](https://discuss.elastic.co/t/attachment-search/38690/5 "2016-01-08T06:58:11Z")

</div>

Elastisearch

> {  
> "status" : 200,  
> "name" : "The Symbiote",  
> "cluster\_name" : "elasticsearch",  
> "version" : {  
> "number" : "1.4.4",  
> "build\_hash" : "c88f77ffc81301dfa9dfd81ca2232f09588bd512",  
> "build\_timestamp" : "2015-02-19T13:05:36Z",  
> "build\_snapshot" : false,  
> "lucene\_version" : "4.10.3"  
> },  
> "tagline" : "You Know, for Search"  
> }

elasticsearch-mapper-attachments version --\> 3.1.1

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 8, 2016, 9:08am UTC](https://discuss.elastic.co/t/attachment-search/38690/6 "2016-01-08T09:08:44Z")

</div>

Well. Look at the README. You should use version `2.4.3`.  
Related doc here: [https://github.com/elastic/elasticsearch-mapper-attachments/tree/v2.4.3#version-243-for-elasticsearch-14](https://github.com/elastic/elasticsearch-mapper-attachments/tree/v2.4.3#version-243-for-elasticsearch-14)

---

<div class="post-metadata">

**Author:** ![Sivaprakash\_Shanmuga](https://avatars.discourse-cdn.com/v4/letter/s/ecae2f/32.png) [@Sivaprakash\_Shanmuga](https://discuss.elastic.co/u/Sivaprakash_Shanmuga)\
**Post date:** [January 8, 2016, 9:59am UTC](https://discuss.elastic.co/t/attachment-search/38690/7 "2016-01-08T09:59:19Z")

</div>

Yes it works !! But the result is in base64, any option to show the actual text or should I have to read the file and show?

```
{
  "took": 9,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 2,
    "max_score": 0.095891505,
    "hits": [
      {
        "_index": "mytestatachment",
        "_type": "person",
        "_id": "4",
        "_score": 0.095891505,
        "_source": {
          "cv": "e1xydGYxXGFuc2kNCkxvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0DQpccGFyIH0="
        }
      },
      {
        "_index": "mytestatachment",
        "_type": "person",
        "_id": "2",
        "_score": 0.095891505,
        "_source": {
          "cv": "e1xydGYxXGFuc2kNCkxvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0DQpccGFyIH0="
        }
      }
    ]
  }
}
```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 8, 2016, 10:37am UTC](https://discuss.elastic.co/t/attachment-search/38690/8 "2016-01-08T10:37:04Z")

</div>

You have to change the mapping and store the inner `cv` field. See what is done there: [https://github.com/elastic/elasticsearch-mapper-attachments/tree/v2.4.3#highlighting-attachments](https://github.com/elastic/elasticsearch-mapper-attachments/tree/v2.4.3#highlighting-attachments)

Then ask for it using `fields` like here: [https://github.com/elastic/elasticsearch-mapper-attachments/tree/v2.4.3#querying-or-accessing-metadata](https://github.com/elastic/elasticsearch-mapper-attachments/tree/v2.4.3#querying-or-accessing-metadata)

---

<div class="post-metadata">

**Author:** ![Sivaprakash\_Shanmuga](https://avatars.discourse-cdn.com/v4/letter/s/ecae2f/32.png) [@Sivaprakash\_Shanmuga](https://discuss.elastic.co/u/Sivaprakash_Shanmuga)\
**Post date:** [January 8, 2016, 10:56am UTC](https://discuss.elastic.co/t/attachment-search/38690/9 "2016-01-08T10:56:50Z")

</div>

Yes this works for me !! Thank you.

---

<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 5, 2017, 11:26pm UTC](https://discuss.elastic.co/t/attachment-search/38690/10 "2017-07-05T23:26:04Z")

</div>


