I can't run update_index

6 views
Skip to first unread message

Sandra Django

unread,
Jul 22, 2009, 10:40:42 AM7/22/09
to who...@googlegroups.com
Hi friends, I have a problem. I can't run update_index and I can't index existing content. Why?

Adam Blinkinsop

unread,
Jul 22, 2009, 10:41:29 AM7/22/09
to who...@googlegroups.com
A bit more detail might be helpful: what version are you running?  What does your schema look like?


On Wed, Jul 22, 2009 at 7:40 AM, Sandra Django <sandra...@gmail.com> wrote:
Hi friends, I have a problem. I can't run update_index and I can't index existing content. Why?





--
Adam Blinkinsop <bli...@acm.org>

Sandra Django

unread,
Jul 22, 2009, 10:52:14 AM7/22/09
to who...@googlegroups.com
Well, I downloaded Whoosh-0.1.19-py2.5. Sorry, I don't understand the last one question.
Thanks

Matt Chaput

unread,
Jul 22, 2009, 10:54:53 AM7/22/09
to who...@googlegroups.com
Sandra Django wrote:
> Well, I downloaded Whoosh-0.1.19-py2.5. Sorry, I don't understand the
> last one question.

Could you please explain in detail what you're trying to do, what your
code looks like, and what exactly is going wrong (i.e. error messages)?
Is this an issue with a Django plugin? What is update_index?

Thanks,

Matt

Adam Blinkinsop

unread,
Jul 22, 2009, 10:54:20 AM7/22/09
to who...@googlegroups.com
That is, to index content, you need a schema and a store, and then you create an index that uses the schema (a description of your data) to write to the store (a persistent data store).  Once you've created the index, you need a writer to add to it.  Perhaps you could send some code that's causing you trouble?
--
Adam Blinkinsop <bli...@acm.org>

Sandra Django

unread,
Jul 22, 2009, 11:10:23 AM7/22/09
to who...@googlegroups.com
Well, I'm using Whoosh, but it only indexes new terms that I add from Django admin site, not existing terms, that I imported from another Data Base.
Then, I have this code in the __init__.py of my search app:

def update_index(sender, instance, created, **kwargs):
    storage = store.FileStorage(settings.WHOOSH_INDEX)
    ix = index.Index(storage, schema=WHOOSH_SCHEMA)
    writer = ix.writer()
    if created:
        writer.add_document(title=unicode(instance.get_title()), content=instance.termino, url=unicode(instance.get_absolute_url()))
        writer.commit()
    else:
        writer.update_document(title=unicode(instance.get_title()), content=instance.termino, url=unicode(instance.get_absolute_url()))
        writer.commit()

signals.post_save.connect(update_index, sender= Descriptor)

Really, it don't show any error, but nor work OK.

Adam Blinkinsop

unread,
Jul 22, 2009, 11:50:18 AM7/22/09
to who...@googlegroups.com
What happens?  What's "work OK"?
--
Adam Blinkinsop <bli...@acm.org>

Sandra Django

unread,
Jul 22, 2009, 1:14:17 PM7/22/09
to who...@googlegroups.com
Sorry, I don't speak English, and I'm trying to talk the best possible.
"work Ok" = not work, not run, talking about update_index. I can't do it.

Adam Blinkinsop

unread,
Jul 22, 2009, 1:18:07 PM7/22/09
to who...@googlegroups.com
No, your English is fine (much better than my French, I assure you), I just meant: have you gotten it to work before?  What do you expect in the index?  Is nothing appearing there?  How are you looking at the index?  Are you searching it directly?  Are you printing out the documents in it directly?

Your update_index function looks fine, but how are you pulling data out?  It's hard enough to debug when you've got all the information, but when half of the program is missing... :-D
--
Adam Blinkinsop <bli...@acm.org>

Nathan Yergler

unread,
Jul 22, 2009, 5:52:28 PM7/22/09
to who...@googlegroups.com
If I understand the question correctly, the following is true:

* You're using Whoosh with Django
* Things that you add through the Django admin show up in searches
* Data you imported through some means other than the Django ORM (ie,
using SQL statements directly) aren't showing up in searches

While I haven't used Django with Whoosh specifically, [assuming the
above is true] the problem is that the "old" resources aren't getting
included in the Whoosh index. This points out that:

* Whoosh uses an index separate from Django's (which is why you're
using Whoosh in the first place, I suppose)
* Things need to be manually added to that index

In the code you provided the update_index function is responsible for
adding (or updating) a single document to the index. But the
following line:

signals.post_save.connect(update_index, sender= Descriptor)

means that this code only gets called when you save something through
the Django ORM. Since you didn't use the Django ORM (admin) to add
the old resources, they're never indexed. You'll need to write a
script to add the resources to the index. Something like:

for obj in MyModel.objects.all():
update_index(None, obj, False)

[this is total psuedo code]

Hope that helps,

Nathan
Reply all
Reply to author
Forward
0 new messages