I am unable to get Elasticsearch, through Wagtail's update_index command, to index a many-to-many relationship with a reverse accessor.
To demonstrate the problem, consider the models available here: https://bpaste.net/show/6b1477ff0971 (This is a minimal working example that shows both working and non-working indexing for two many-to-many relationships).
This is using Wagtail 1.8.1, Elasticsearch 5.1.1, and elasticsearch-py 5.1.0.
Here, I make two attempts to index many-to-many relationships:
Tags: which have an explicit field in the MyPage model, and a through attribute for that field.
Categories: which are attached to MyPage in the MyPageCategory model using a related_name='categories' (no explicit field in MyPage). In the code above, I show three different attempts to capture the categories relationship in the search_fields of the MyPage model, none of which is successful.
There may be other differences between the way tags and categories are configured too that may be causing the problem.
Problem: Elasticsearch does not index the categories, but does index the tags:
"indexing_mypage__categories" : null,
"indexing_mypage__tags" : [
{
"name" : "tag2"
}
],
Question: How can I get Elasticsearch to index the categories of MyPage? What should MyPage.search_fields look like?
The goal is to be able to search pages by their categories.
PS. I posted this question on StackOverflow, but got no answers:
http://stackoverflow.com/questions/41913185/wagtail-indexing-many-to-many-relationships-with-reverse-accessors-in-elasticse