pombreda / djapian

Automatically exported from code.google.com/p/djapian
Other
0 stars 0 forks source link

have to constantly rebuild index #120

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The update() functionality isn't working consistently and I am forced to 
constantly use "python manage index --rebuild" to get good search results.  
Unfortunately this is not practical from a scaling perspective.  Can this be 
solved?

Original issue reported on code.google.com by mcdanieldave@gmail.com on 2 Nov 2010 at 6:13

GoogleCodeExporter commented 9 years ago
Can you explain with more details what is not working?

Original comment by daevaorn on 2 Nov 2010 at 6:28

GoogleCodeExporter commented 9 years ago
when i add model instances to mysql db i also use indexer.update() in hopes of 
updating the index incrementally and not having to rebuild everytime.  this 
sometimes works and other times does not.  it especially seems to fail after 
adding and saving many instances.  but even sometimes fails after only adding 
one, in this case it seems dependent on how long it has been since the index 
rebuild command has been issued.

i can only seem to get things working correctly by rebuilding the entire indexs 
with a cron job (which is currently set to 1 min).  this will obviously be 
unreasonable as the db grows with our userbase.  also if a search attempts 
during the rebuild it will throw back a data error.  

Original comment by mcdanieldave@gmail.com on 2 Nov 2010 at 6:45

GoogleCodeExporter commented 9 years ago
Try to use index command without --rebuild option.

Original comment by daevaorn on 2 Nov 2010 at 7:09

GoogleCodeExporter commented 9 years ago
I've tried that as well.  indexer.update() still doesn't work.

Original comment by mcdanieldave@gmail.com on 2 Nov 2010 at 7:11

GoogleCodeExporter commented 9 years ago
hi,

i have the same problem. i'm only editing is_deleted option of my object which 
can be True or False. but after saving object, index.update() results no change.

bye

Original comment by matu...@gmail.com on 24 Nov 2010 at 3:42

GoogleCodeExporter commented 9 years ago
i found the reason.

i my model i've changed the _default_manager, cause it returns only not deleted 
items.

in index command is this piece of code:

indexer.update(
    ct.model_class()._default_manager.filter(
    pk__in=[c.object_id for c in page.object_list]
    ).order_by('pk'),
    ...

so, cause it uses my PublishedObjectsManager and there is not anymore that 
deleted one, no object is updated at all.

i think this is just problem of my application. djapian project has nathing to 
do with it.

bye

Original comment by matu...@gmail.com on 24 Nov 2010 at 4:11

GoogleCodeExporter commented 9 years ago
or can we just change it to something like this

indexer.update(
    ct.model_class().objects.filter(
    pk__in=[c.object_id for c in page.object_list]
    ).order_by('pk'),
    ...

use .objects instead of ._default_manager 

hmm?

Original comment by matu...@gmail.com on 24 Nov 2010 at 4:14

GoogleCodeExporter commented 9 years ago
You don't have `to override `_default_manager`. It is used by internal django 
and djapian code. `_default_manager` must return all entries without any 
filtration.

Original comment by daevaorn on 24 Nov 2010 at 4:46

GoogleCodeExporter commented 9 years ago
# Each model class gets a "_default_manager" attribute, which is a reference
# to the first manager defined in the class. In this case, it's "cars".

this is in django documentation
http://www.djangoproject.com/documentation/models/custom_managers/

and my getpublished manager is defined first in given model

i've changed it in my copy of djapian and it works fine now

Original comment by matu...@gmail.com on 24 Nov 2010 at 5:22

GoogleCodeExporter commented 9 years ago
Just place `objects = models.Manager()` in the first place to avoid 
`_default_manager` assignment with your custom manager.

Original comment by daevaorn on 24 Nov 2010 at 5:29

GoogleCodeExporter commented 9 years ago
yes, right

as I said, it was the first solution. but i just wanted to know, why not just 
use objects() function instead. in djapian application.

thanks. bye

Original comment by matu...@gmail.com on 24 Nov 2010 at 6:13

GoogleCodeExporter commented 9 years ago

Original comment by esizi...@gmail.com on 21 Oct 2011 at 6:31