سؤال

I have a Djapian Indexer something like this..

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

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

This allows me to search SomeModels by tag with a search like "tag:sausages" which would find any SomeModels tagged with "sausages". (strtags is a @property decorated function on SomeModel).

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

So that works, but I also have a CompositeIndexer which includes the SomeModelIndexer but searching that indexer for "tag:sausages" returns zero results.

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

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

Any clues on how I might get that to work?

هل كانت مفيدة؟

المحلول

I think that you should file a bug.

If you search for sausages only it should return some results.

Doing some tests, following the tutorial i made some queries:

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 is a CompositeIndexer between both indexes.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top