diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 87cb99d186..68cbd6c292 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -5,6 +5,7 @@ Changelog ~~~~~~~~~~~~~~~~ * Django 1.9 support + * Support for indexing fields across relations in Elasticsearch * Added `WAGTAIL_PASSWORD_RESET_ENABLED` setting to allow password resets to be disabled independently of the password management interface (John Draper) * Updated fonts for more comprehensive Unicode support * Added `.alt` attribute to image renditions diff --git a/docs/releases/1.3.rst b/docs/releases/1.3.rst index 048bf7e8b3..b8cd86ef81 100644 --- a/docs/releases/1.3.rst +++ b/docs/releases/1.3.rst @@ -16,6 +16,33 @@ Django 1.9 support Wagtail is now compatible with Django 1.9. +Indexing fields across relations in Elasticsearch +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Fields on related objects can now be indexed in Elasticsearch using the new ``indexed.RelatedFields`` declaration type: + +.. code-block:: python + + class Book(models.Model, indexed.Indexed): + ... + + search_fields = [ + indexed.SearchField('title'), + indexed.FilterField('published_date'), + + indexed.RelatedFields('author', [ + indexed.SearchField('name'), + indexed.FilterField('date_of_birth'), + ]), + ] + + # Search books where their author was born after 1950 + # Both the book title and the authors name will be searched + >>> Book.objects.filter(author__date_of_birth__gt=date(1950, 1, 1)).search("Hello") + +See: :ref:`wagtailsearch_index_relatedfields` + + Minor features ~~~~~~~~~~~~~~ diff --git a/docs/topics/search/indexing.rst b/docs/topics/search/indexing.rst index 9a33456cea..847b30a8e8 100644 --- a/docs/topics/search/indexing.rst +++ b/docs/topics/search/indexing.rst @@ -111,6 +111,8 @@ Options These are added to the search index but are not used for full-text searches. Instead, they allow you to run filters on your search results. +.. _wagtailsearch_index_relatedfields: + ``index.RelatedFields`` -----------------------