Skip to content

Keep indexed copies of django-treebeard internal fields in sync after node move operations #94

Description

@gasman

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions