2012-09-13 2 views
0

Djapian 복합 인덱스에 태그 검색을 수행하는 방법 ..나는이 같은 Djapian 인덱서 뭔가를

class SomeModelIndexer(Indexer): 
    fields = ["body"] 
    tags = [('title', 'title', 2), 
      ('tag', 'strtags')] 

space.add_index(SomeModel, SomeModelIndexer, attach_as="indexer") 

이 날 같은 검색과 태그로 SomeModels를 검색 할 수 있습니다 : 하나를 찾을 것 "태그 소시지" SomeModels는 "소시지"로 태그되었습니다. (strtags는 SomeModel의 @property 장식 함수입니다).

In [1]: from project.someapp.models import SomeModel 
In [2]: from project.someapp import index 
In [3]: SomeModel.indexer.search("tag:sausages").count() 
Out[3]: 2L 

그래서 작동,하지만 나는 또한 SomeModelIndexer 만에 그 인덱서 검색을 포함하는 CompositeIndexer이 "태그 : 소시지하는"제로 결과를 반환합니다.

composite_index = CompositeIndexer(SomeModel.indexer, AnotherModel.indexer) 

In [4]: index.composite_index.search("tag:sausages").count() 
Out[4]: 0L 

어떻게 작동시킬 수 있는지에 대한 단서가 있습니까?

답변

2

나는 당신이 버그를 제기해야한다고 생각한다.

sausages 만 검색하면 결과가 반환됩니다.

내가 어떤 쿼리를 만든 tutorial 다음, 몇 가지 테스트를 수행 :

Person.indexer.search("name:alex").count() --> 2L --> OK 
Movie.indexer.search("director:alex").count() --> 1L --> OK 

index.complete_indexer.search("name:alex").count() --> 0L --> WRONG 
index.complete_indexer.search("director:alex").count() --> 0L --> WRONG 
index.complete_indexer.search("alex").count() --> 3L --> OK 

complete_indexer 두 인덱스 사이 CompositeIndexer이다.