# Search term not searching in attachments\_content field

**URL:** <https://discuss.elastic.co/t/search-term-not-searching-in-attachments-content-field/82218>\
**Category:** Elasticsearch\
**Created:** [April 12, 2017, 7:47pm UTC](https://discuss.elastic.co/t/search-term-not-searching-in-attachments-content-field/82218 "2017-04-12T19:47:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mlopez360](https://avatars.discourse-cdn.com/v4/letter/m/ec9cab/32.png) [@mlopez360](https://discuss.elastic.co/u/mlopez360)\
**Post date:** [April 12, 2017, 7:47pm UTC](https://discuss.elastic.co/t/search-term-not-searching-in-attachments-content-field/82218/1 "2017-04-12T19:47:08Z")

</div>

Hello to all,  
Maybe someone can enlighten me. What should be the correct query to be able to search a term in in all fields, including document contents (attachments\_content field)?

I was using this query, and it was able to search the term in titles of pages, content of pages and titles of documents. However it was not able to return results that had the search term in the contents of the documents. I thought using the '\_all' would search all available fields including the attachments\_content field where the content of a document is stored.

```
{
    'query' : {
        'term' : {'_all' : $search_term},
    },
}

```

Then I used

```
{
    ‘query’ : {
        ‘bool’ : {
            ‘should’ : {
                { ‘match_phrase’ : { ‘title’ : $search_term }},
                { ‘match_phrase’ : { ‘body:value’ : $search_term }},
                { ‘match_phrase’ : { ‘attachments_content’ : $search_term }},
            },
        },
    }
}

```

It was still able to search for the term in title pages, content pages, title documents but now it returns every document even if it is not related to the term.

Any help would be appreciated

---

<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:** [May 10, 2017, 7:53pm UTC](https://discuss.elastic.co/t/search-term-not-searching-in-attachments-content-field/82218/2 "2017-05-10T19:53:15Z")

</div>

Closed on May 10, 2017, 7:53pm UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
