2009-06-28 3 views
0

내 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') 

+0

은, 우리에게 인덱서 정의를 줘 어디 말해 코드로 살고 있습니까? –

+0

Alex에게 답변 해 주셔서 감사합니다. 귀하의 질문에 답변하기 위해 내 게시물을 업데이트했습니다. – kartikq

답변

1

그것은 가능성이

Profile.indexer.update() 
을 실행하면 누락 모든 것을 models.py의 끝에

(한 번만 수행하면됩니다.) 나 (models.py의 끝)을 위해 제대로 작동 이제

, 나는 당신보다 Djapian의 이전 버전을 사용 할 수 있지만 다음

profile_indexer = djapian.Indexer(
    model=Profile, 
    fields=[..., ...], 
    tags=[(..., ...), (..., ...)] 
) 
# Run once and then comment out. 
Profile.indexer.update() 
+1

레모네이드, 그게 효과. 나는 인덱스 --rebuild가 인덱스를 재 작성해야한다고 생각했다. 고마워요! – kartikq

관련 문제