2012-09-13 72 views
0

我有一個Djapian索引是這樣的..怎麼辦標籤搜索上Djapian複合索引

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

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

這讓我按標籤與像搜索搜索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 

這樣的作品,但我也有一個CompositeIndexer其中包括SomeModelIndexer但搜索是索引器「標籤:香腸」返回零個結果。

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