see also https://django-elasticsearch-dsl-drf.readthedocs.io/en/0.1.8/basic_usage_examples.html
The generic enpoint to access mappings is
http://localhost:9000/search/mapping/?format=json
This returns all mappings ass paginated results. To access a given subset of mappings
use the search
and filter
options on the endpoint described below.
Multiple search terms are joined with OR
.
Let’s assume we have a number of Mapping
items with fields source.term
, qualifier
and source.collection.namespace
.
Search in all fields (name, address, city, state_province and country) for word “reilly”.
/search/publisher/?search=reilly
/search/mapping/?search=CHEBI:123
In order to search in specific field (name) for term “reilly”, add the field name separated with | to the search term.
http://127.0.0.1:8080/search/publisher/?search=name|reilly
In order to search for multiple terms “reilly”, “bloomsbury” add multiple search query params.
http://127.0.0.1:8080/search/publisher/?search=reilly&search=bloomsbury
In order to search for multiple terms “reilly”, “bloomsbury” in specific fields add multiple search query params and field names separated with | to each of the search terms.
http://127.0.0.1:8080/search/publisher/?search=name|reilly&search=city|london
Let’s assume we have a number of Publisher documents with in cities (Yerevan, Groningen, Amsterdam, London).
Multiple filter terms are joined with AND
.
Filter documents by field (city) “yerevan”.
http://127.0.0.1:8080/search/publisher/?city=yerevan
Filter documents by city “Yerevan” and “Groningen”.
http://127.0.0.1:8080/search/publisher/?city__in=yerevan|groningen
You can achieve the same effect by specifying multiple filters (city) “Yerevan” and “Amsterdam”. Note, that in this case multiple filter terms are joined with OR.
http://127.0.0.1:8080/search/publisher/?city=yerevan&city=amsterdam
If you want the same as above, but joined with AND, add __term to each lookup.
http://127.0.0.1:8080/search/publisher/?city__term=education&city__term=economy
Filter documents by a part word part in single field (city) “ondon”.
http://127.0.0.1:8080/search/publisher/?city__wildcard=*ondon
The -
prefix means ordering should be descending.
Filter documents by field city (ascending).
http://127.0.0.1:8080/search/publisher/?search=country|armenia&ordering=city
Filter documents by field country (descending).
http://127.0.0.1:8080/search/publisher/?ordering=-country
If you want to order by multiple fields, use multiple ordering query params. In the example below, documents would be ordered first by field country (descending), then by field city (ascending).
http://127.0.0.1:8080/search/publisher/?ordering=-country&ordering=city