我正在嘗試在我的django網站中搜索用戶 配置文件的基於djapian的全文搜索。我基本上按照以下步驟來構建 索引:基於djapian的搜索不返回結果
- 更新了模型配置文件以添加djapian索引器。
- 然
python manage.py index --rebuild
重建索引。
然而,當我嘗試使用使用檔案索引搜索: Profile.indexer.search("query")
它並沒有給我任何結果。我沒有收到任何錯誤。
有人可以幫助我嗎?我是新手w.r.t. Django的+ djapian。
---更新06/29/09
我的索引定義住在models.py和如下:
class Profile(models.Model): user = models.ForeignKey(User, unique=True, verbose_name=('user')) name = models.CharField(('name'), max_length=50, null=True, blank=True) about = models.TextField(('about'), null=True, blank=True) institution = models.CharField(('institution'),max_length=100,null=True, blank=True) location = models.CharField(_('location'), max_length=40, null=True, blank=True) website = models.URLField(_('website'), null=True, blank=True, verify_exists=False) def unicode(self): return self.user.username def get_absolute_url(self): return ('profile_detail', None, {'username': self.user.username}) get_absolute_url = models.permalink(get_absolute_url) class Meta: verbose_name = _('profile') verbose_name_plural = _('profiles')
class ProfileIndexer(djapian.Indexer): fields = ['name', 'about', 'institution','location'] tags = [ ('name','name'),('about','about'),('institution','institution'),('location','location')]
djapian.add_index(Profile,ProfileIndexer,attach_as = 'indexer')
請給我們您的索引定義和分不清哪裏它住在代碼中嗎? – 2009-06-29 06:59:37
感謝Alex的迴應。我更新了我的帖子來回答你的問題。 – kartikq 2009-06-30 04:23:04