Feature: Replace Whoosh with tantivy search backend (#12471)

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Antoine Mérino <3023499+Merinorus@users.noreply.github.com>
This commit is contained in:
Trenton H
2026-04-02 12:38:22 -07:00
committed by GitHub
co-authored by Claude Sonnet 4.6 Antoine Mérino
parent e01a762e81
commit aed9abe48c
52 changed files with 4050 additions and 1708 deletions
@@ -0,0 +1,39 @@
import re
from django.db import migrations
# Matches "note:" when NOT preceded by a word character or dot.
# This avoids false positives like "denote:" or already-migrated "notes.note:".
# Handles start-of-string, whitespace, parentheses, +/- operators per Whoosh syntax.
_NOTE_RE = re.compile(r"(?<![.\w])note:")
# Same logic for "custom_field:" -> "custom_fields.value:"
_CUSTOM_FIELD_RE = re.compile(r"(?<![.\w])custom_field:")
def migrate_fulltext_query_field_prefixes(apps, schema_editor):
SavedViewFilterRule = apps.get_model("documents", "SavedViewFilterRule")
# rule_type 20 = "fulltext query" — value is a search query string
for rule in SavedViewFilterRule.objects.filter(rule_type=20).exclude(
value__isnull=True,
):
new_value = _NOTE_RE.sub("notes.note:", rule.value)
new_value = _CUSTOM_FIELD_RE.sub("custom_fields.value:", new_value)
if new_value != rule.value:
rule.value = new_value
rule.save(update_fields=["value"])
class Migration(migrations.Migration):
dependencies = [
("documents", "0016_sha256_checksums"),
]
operations = [
migrations.RunPython(
migrate_fulltext_query_field_prefixes,
migrations.RunPython.noop,
),
]