如何让我的模型包含在索引中rebuild_index
?
运行python manage.py rebuild_index -v2输出:
WARNING: This will irreparably remove EVERYTHING from your search index in connection 'default'.
Your choices after this are to restore from backups or rebuild via the `rebuild_index` command.
Are you sure you wish to continue? [y/N] y
Removing all documents from your index because you said so.
All documents removed.
Skipping '<class 'django.contrib.auth.models.Permission'>' - no index.
Skipping '<class 'django.contrib.auth.models.Group'>' - no index.
Skipping '<class 'django.contrib.auth.models.User'>' - no index.
Skipping '<class 'django.contrib.contenttypes.models.ContentType'>' - no index.
Skipping '<class 'django.contrib.sessions.models.Session'>' - no index.
Skipping '<class 'django.contrib.sites.models.Site'>' - no index.
Skipping '<class 'django.contrib.admin.models.LogEntry'>' - no index.
Skipping '<class 'myapp.models.Article'>' - no index.
Skipping '<class 'myapp.models.Source'>' - no index.
Skipping '<class 'taggit.models.Tag'>' - no index.
Skipping '<class 'taggit.models.TaggedItem'>' - no index.
以上,myapp.models.Article
应包括在内。我在myproject/myapp/search_index.py中有这个:
from haystack import indexes
from myapp.models import Article
class ArticleIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
def get_model(self):
return Article
def index_queryset(self, using=None):
return self.get_model().objects.all()
我在 sqlite3 数据库上运行django 1.5、solr 4和haystack 2.0 。在我的谷歌搜索中,我看到人们在使用 xapian & whoosh 时遇到了类似的问题,但到目前为止还没有提供解决方案。我觉得可能是 haystack 的新版本,或者我的 sqlite3 数据库。有人明白这个吗?