How can i search in elasticsearch dsl python module on multi fields, example on title
and body
field and order it by created_at
field DESC.
I have this example that search only on title
field:
q = request.GET.get('q', None)
s = Search(using=elastic_client, index='post').query('match', title=q)
response = s.execute()
how can i do this?
Found solution:
from elasticsearch_dsl.query import MultiMatch
q = request.GET.get('q', None)
query = MultiMatch(query=q, fields=['title', 'body'], fuzziness='AUTO')
s = Search(using=elastic_client, index='post').query(query)
response = s.execute()