Search term not searching in attachments_content field

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

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