내 django 사이트에서 사용자 프로파일을 검색하기 위해 djapian 기반 전체 텍스트 검색을 구현하려고합니다. 기본적으로 다음 단계를 수행하여 색인을 작성했습니다.djapian 기반 검색 결과가 없습니다.
- djapian 인덱서를 추가하도록 모델 프로파일을 업데이트했습니다.
- Ran
python manage.py index --rebuild
색인을 다시 작성하십시오. 그것이 나에게 어떤 결과를 제공하지 않습니다Profile.indexer.search("query")
:
그러나 나는 사용하여 프로필 인덱서를 사용하여 검색 할 때. 나는 어떤 오류도받지 않는다.
누군가 나를 도와 줄 수 있습니까? 나는 초보자입니다. 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')
은, 우리에게 인덱서 정의를 줘 어디 말해 코드로 살고 있습니까? –
Alex에게 답변 해 주셔서 감사합니다. 귀하의 질문에 답변하기 위해 내 게시물을 업데이트했습니다. – kartikq