Comments (6)
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.
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.
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.
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.
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.
Okay, thank you for the clarification. I updated that wiki page to help others with the same issue.
from django-watson.
Related Issues (20)
- Installation conflict with other watsons HOT 4
- AttributeError: module 'blog.admin' has no attribute 'site' HOT 2
- rebuilding index doesn't remove entries for deleted objects HOT 3
- No results for partial keywords HOT 1
- support extra fields to be indexed HOT 1
- expose metadata also in .filter() results HOT 3
- Registering Django FlatPage in apps.py or __init__.py Throws "Apps aren't loaded yet" Exception HOT 6
- Error after updating django to latest version HOT 2
- Possible to search with partial match? HOT 4
- Django 3.2 Warning in migration HOT 1
- psycopg2.errors.UndefinedTable: relation "watson_searchentry" does not exist HOT 3
- Search for a subset by filtering on related model fields HOT 2
- I ran python manage.py buildwatson and an error was returned... HOT 1
- 'QuerySet' object has no attribute 'strip' HOT 1
- Using non numeric primary keys HOT 1
- Issues with indexing with taggit HOT 2
- The search returns not only variants of the same word, but also words starting with the requested word HOT 3
- Doesn't pick up worded numbers in search terms HOT 1
- Searching for non-model related items (like views) HOT 1
- Support Multi-Database configuration
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-watson.