'Searching in Elasticsearch returns index response body

I have implemented this simple Elastic class that I want to use for searching. Problem is the response I'm getting is the one you get after indexing (probably) even though I use the search function. I have no idea what could be the problem.

class Elastic:
    def __init__(self):
        self.conn = Elasticsearch(hosts=api_settings.ES_CONNECTION_STRING, verify_certs=False)
        self.index = api_settings.ELASTIC_INDEX_NAME
    
    ...
        
    def search(self, query, keywords, regions, page_num, size):
        self.build_query(query, keywords, regions, page_num, size)
        response = self.conn.search(index=self.index, doc_type="_doc", body=self.body)
        return response

Here is the response I get:

{'_index': 'articles_index', '_id': '_search', '_version': 34, 'result': 'updated', '_shards': {'total': 2, 'successful': 1, 'failed': 0}, '_seq_no': 133, '_primary_term': 9}

Here is the response I want:

{'took': 1468, 'timed_out': False, '_shards': {'total': 1, 'successful': 1, 'skipped': 0, 'failed': 0}, 'hits': {'total': {'value': 7, 'relation': 'eq'}, 'max_score': 3.9133883, 'hits': [{'_index': 'articles_index', ...


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source