Skip to content

Commit

Permalink
Fixed query dsl docs to reflect reality
Browse files Browse the repository at this point in the history
Fixes #91 Thanks goodrichj!
  • Loading branch information
honzakral committed Mar 7, 2015
1 parent 6994764 commit f36d8df
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions docs/search_dsl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,31 +87,31 @@ The library provides classes for all Elasticsearch query types. Pass all the par

.. code:: python
from elasticsearch_dsl import Match
from elasticsearch_dsl.query import MultiMatch
# {"match": {"query": "python django", "field": "title", "operator": "or"}}
Match(query='python django', field='title', operator='or')
# {"multi_match": {"query": "python django", "fields": ["title", "body"]}
MultiMatch(query='python django', fields=['title', 'body'])
You can use the ``Q`` shortcut to construct the instance using a name with
parameters or the raw ``dict``:

.. code:: python
Q("match", query='python django', field='title', operator='or')
Q({"match": {"query": "python django", "field": "title", "operator": "or"}})
Q("multi_match", query='python django', fields=['title', 'body'])
Q({"multi_match": {"query": "python django", "fields": ["title", "body"]})
To add the query to the ``Search`` object, use the ``.query()`` method:
.. code:: python
q = Q("match", query='python django', field='title', operator='or')
q = Q("multi_match", query='python django', fields=['title', 'body'])
s = s.query(q)
The method also accepts all the parameters as the ``Q`` shortcut:
.. code:: python
s = s.query('match', query='python django', field='title', operator='or')
s = s.query("multi_match", query='python django', fields=['title', 'body'])
If you already have a query object, or a ``dict`` representing one, you can
just override the query used in the ``Search`` object:
Expand Down

0 comments on commit f36d8df

Please sign in to comment.