Exemple #1
0
def cleanup_fulltext():
    """Remove stale units from fulltext"""
    fulltext = Fulltext()
    languages = list(Language.objects.have_translation().values_list(
        'code', flat=True))
    # We operate only on target indexes as they will have all IDs anyway
    for lang in languages:
        index = fulltext.get_target_index(lang)
        try:
            fields = index.reader().all_stored_fields()
        except EmptyIndexError:
            continue
        for item in fields:
            if Unit.objects.filter(pk=item['pk']).exists():
                continue
            fulltext.clean_search_unit(item['pk'], lang)
Exemple #2
0
def cleanup_fulltext():
    """Remove stale units from fulltext"""
    fulltext = Fulltext()
    languages = list(Language.objects.values_list('code', flat=True)) + [None]
    # We operate only on target indexes as they will have all IDs anyway
    for lang in languages:
        if lang is None:
            index = fulltext.get_source_index()
        else:
            index = fulltext.get_target_index(lang)
        try:
            fields = index.reader().all_stored_fields()
        except EmptyIndexError:
            continue
        for item in fields:
            if Unit.objects.filter(pk=item['pk']).exists():
                continue
            fulltext.clean_search_unit(item['pk'], lang)
Exemple #3
0
def cleanup_fulltext():
    """Remove stale units from fulltext."""
    fulltext = Fulltext()
    languages = list(Language.objects.values_list("code", flat=True)) + [None]
    # We operate only on target indexes as they will have all IDs anyway
    for lang in languages:
        if lang is None:
            index = fulltext.get_source_index()
        else:
            index = fulltext.get_target_index(lang)
        try:
            fields = index.reader().all_stored_fields()
        except EmptyIndexError:
            continue
        for item in fields:
            if Unit.objects.filter(pk=item["pk"]).exists():
                continue
            fulltext.clean_search_unit(item["pk"], lang)