3
votes

I am unable to find any documentation regarding how do I implement Simple Query String Query in my Django Elasticsearch-dsl

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-simple-query-string-query.html

Can someone guide me through it?

This is my search function.

def search(q_string):
client = Elasticsearch(
    [
        'elasticsearch'
    ]
)
s = Search(using=client).query(SimpleQueryString(q_string))

Above code is showing me paring error.

1

1 Answers

1
votes

Follow the same structure as the json document - whatever keys in the object will become kwargs, so:

SimpleQueryString(query="QUERY", fields=[...], default_operator='and')

also please don't create a new instance of Elasticsearch for every search, use a global instance and reuse it.

Hope this helps!