Search code examples
djangoelasticsearchdjango-rest-frameworkelasticsearch-dsl

Django Elasticsearch dsl drf OR query


How to make OR query (using django-elasticsearch-dsl-drf) with multiple contains statements? Query in words: Search for objects where title contains "hello" OR description contains "world"

I can't find about it in documentation: https://django-elasticsearch-dsl-drf.readthedocs.io/en/0.3.12/advanced_usage_examples.html#usage-example


Solution

  • what you need is boolean query with should clause, its very easy to construct in JSON format, and validate the search results.

    For Django, although I am not familiar, this page of queries DSL and specifically this sub-section should fix your issue.