【问题标题】:django-haystack & solr: rebuild_index not adding models to indexdjango-haystack & solr:rebuild_index 不将模型添加到索引
【发布时间】:2013-06-24 11:41:03
【问题描述】:

如何让我的模型包含在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 数据库。有人明白吗?

【问题讨论】:

    标签: solr django-haystack


    【解决方案1】:

    search_index.py ?这是一个错字吗,因为它应该是 search_indexes.py 。是不是。如果您使用正确的名称,请详细说明。

    【讨论】:

      【解决方案2】:

      这是一个我发现为时已晚的有用链接:http://django-haystack.readthedocs.org/en/latest/debugging.html

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-07-02
        • 1970-01-01
        • 1970-01-01
        • 2012-01-19
        • 1970-01-01
        • 2015-09-21
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多