0

I have implemented simple Elastic class for some project. Problem is that searching like this doesn't return the results I want. I just get some weird response (see below). Only way I can get the resulst is through curl requests (also below). I tried googling, and looking for some similiar problems, but without success. Im new to Elasticsearch so I dont really know what to look for.

class Elastic:
    def __init__(self, index):
        self.conn = Elasticsearch(hosts='https://elastic:passwd@localhost:9200/', verify_certs=False)
        self.index = index

    ...

    def search(self, query, keywords):
        self.build_query(query, keywords)
        response = self.conn.search(index=self.index, doc_type="_doc", body=self.body)
        return response

Here is the response. I noticed that version field is increasing every time I run the program.

{'_index': 'my_index', '_id': '_search', '_version': 12, 'result': 'updated', '_shards': {'total': 2, 'successful': 1, 'failed': 0}, '_seq_no': 111, '_primary_term': 4}

Here are working curl requests (they don't work without -k):

curl -k -XGET --header "Content-Type: application/json" "https://localhost:9200/articles_index/_search" -d "{my query ...}" -u elastic:passwd               

curl -k -X GET --header "Content-Type: application/json" "https://elastic:passwd@localhost:9200/articles_index/_search" -d "{my query ...}"                 

0 Answers0