etianen / django-watson

Full-text multi-table search application for Django. Easy to install and use, with good performance.
BSD 3-Clause "New" or "Revised" License
1.2k stars 130 forks source link

Not "live" search results still appearing in index #244

Closed ianfitzpatrick closed 4 years ago

ianfitzpatrick commented 6 years ago

When registering my User model for search indexing like this:

        watson.register(
            User.objects.filter(is_active=True),
            CaseInsensitiveSearchAdapter,
            fields=(
                'first_name',
                'last_name',
                'username'
            )
        )

I am still seeing Users with is_active=False in my search index. Again sorry I don't have a good repro for this, I have dropped all data in the table and run manage.py buildwatson multiple times (also tried User.objects.exclude(is_active=False) and a few other things) but users always show up in index.

Any idea what might be causing this? My backend is MySQL.

etianen commented 6 years ago

Registering a filtered queryset with django-watson will only affect results returned by watson.search().

If you're using watson.filter(), you need to pass the same filtered queryset in:

watson.filter(User.objects.filter(is_active=True))

I realise the docs could be clearer about this.

On 26 April 2018 at 17:28, Ian Fitzpatrick notifications@github.com wrote:

When registering my User model for search indexing like this:

    watson.register(
        User.objects.filter(is_active=True),
        CaseInsensitiveSearchAdapter,
        fields=(
            'first_name',
            'last_name',
            'username'
        )
    )

I am still seeing Users with is_active=False in my search index. Again sorry I don't have a good repro for this, I have dropped all data in the table and run manage.py buildwatson multiple times (also tried User.objects.exclude(is_active=False) and a few other things) but users always show up in index.

Any idea what might be causing this? My backend is MySQL.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/etianen/django-watson/issues/244, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJFCE_0QuQZbfXpzKzDviabJTFnTjBoks5tsfW2gaJpZM4Tlz-K .