Problem statement
On models inheriting from django-treebeard's MP_Node and NS_Node, it's useful to define FilterFields on the fields that manage tree structure (path and depth for MP_Node; lft, rght, depth and tree_id for NS_Node) so that we can search querysets derived from tree operations, such as get_descendants to search over a subtree. (See #91.)
However, on backends like Elasticsearch, this relies on those fields being kept in sync between the database and the search index. The post_save signals are insufficient for this, because tree move operations are performed with a bulk queryset update, which doesn't fire these. As a result, subsequent searches may end up searching over the wrong set of nodes.
Proposed solution
In django-treebeard/django-treebeard#381 I proposed that django-treebeard should implement signals that fire when a bulk queryset update is performed. Once these signals are in place, modelsearch should listen to them and (if an Elasticsearch-like backend is in use) perform the corresponding bulk update on the search index.
Alternative solutions
No response
Additional context
No response
Working on this
Contribute to the discussion to help this move forward. Explain your use cases, discuss possible solutions, research how to adapt existing code, or compatibility concerns.
Once others agree with the proposed changes, anyone can contribute to this. View our contributing guidelines. Add a comment to the issue to explain what approach you are taking.
Problem statement
On models inheriting from django-treebeard's
MP_NodeandNS_Node, it's useful to defineFilterFields on the fields that manage tree structure (pathanddepthforMP_Node;lft,rght,depthandtree_idforNS_Node) so that we can search querysets derived from tree operations, such asget_descendantsto search over a subtree. (See #91.)However, on backends like Elasticsearch, this relies on those fields being kept in sync between the database and the search index. The
post_savesignals are insufficient for this, because tree move operations are performed with a bulk queryset update, which doesn't fire these. As a result, subsequent searches may end up searching over the wrong set of nodes.Proposed solution
In django-treebeard/django-treebeard#381 I proposed that django-treebeard should implement signals that fire when a bulk queryset update is performed. Once these signals are in place, modelsearch should listen to them and (if an Elasticsearch-like backend is in use) perform the corresponding bulk update on the search index.
Alternative solutions
No response
Additional context
No response
Working on this
Contribute to the discussion to help this move forward. Explain your use cases, discuss possible solutions, research how to adapt existing code, or compatibility concerns.
Once others agree with the proposed changes, anyone can contribute to this. View our contributing guidelines. Add a comment to the issue to explain what approach you are taking.