Git Product home page Git Product logo

Comments (6)

etianen avatar etianen commented on June 29, 2024

Are you suggesting that only models in model._default_manager.all() should
be indexed?

In reality, this is tricky. django-watson indexes any model that is
registered whenever you call save(). Telling whether that model is part of
the default manager would involve another database query.

On 10 April 2013 13:56, Julian Bez [email protected] wrote:

It seems the default manager of a model is ignored, as always all objects
are indexed and you have to manually add a filter to the register
statements. Is that intended and just not documented?


Reply to this email directly or view it on GitHubhttps://github.com//issues/16
.

from django-watson.

webjunkie avatar webjunkie commented on June 29, 2024

I don't know watson works internally. Let me just describe the situation:

I have a model where I just want the published objects to appear on my site, that's why I have a custom default manager that filters by published=True. Obviously, only the published objects should appear in the search, too. When I register the model, it does not use the manager, so I have to use the filter manually.
What would be the difference of watson using the manager versus me using the filter?

from django-watson.

etianen avatar etianen commented on June 29, 2024

You can get the functionality you want by registering your models as
follows:

watson.register(YourModel.objects.all())

All models will still be indexed, but only ones that match the given
queryset supplied to register() will be returned in searches.

On 11 April 2013 09:08, Julian Bez [email protected] wrote:

I don't know watson works internally. Let me just describe the situation:

I have a model where I just want the published objects to appear on my
site, that's why I have a custom default manager that filters by
published=True. Obviously, only the published objects should appear in the
search, too. When I register the model, it does not use the manager, so I
have to use the filter manually.
What would be the difference of watson using the manager versus me using
the filter?


Reply to this email directly or view it on GitHubhttps://github.com//issues/16#issuecomment-16221712
.

from django-watson.

webjunkie avatar webjunkie commented on June 29, 2024

Ah, so
watson.register(YourModel)
will not try to match with Queryset on search and thus ignore managers, but
watson.register(YourModel.objects.all())
will? That wasn't clear to me from the docs.

from django-watson.

etianen avatar etianen commented on June 29, 2024

I'm sorry to hear that. The actual documentation for this feature is here:

https://github.com/etianen/django-watson/wiki/registering-models

The reason using the default manager isn't the default behaviour for watson
is that it incurs an additional overhead on multi-table searches, and in
most cases the default manager doesn't provide any extra filtering, so that
overhead would be wasted effort.

On 11 April 2013 09:51, Julian Bez [email protected] wrote:

Ah, so
watson.register(YourModel)
will not try to match with Queryset on search and thus ignore managers,
but
watson.register(YourModel.objects.all())
will? That wasn't clear to me from the docs.


Reply to this email directly or view it on GitHubhttps://github.com//issues/16#issuecomment-16223254
.

from django-watson.

webjunkie avatar webjunkie commented on June 29, 2024

Okay, thank you for the clarification. I updated that wiki page to help others with the same issue.

from django-watson.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.