在使用Django-Haystack时往Solr索引添加数据的问题

3 投票
2 回答
1914 浏览
提问于 2025-04-16 14:02

我正在尝试用django-haystack在Solr中建立一个模型的索引,但在使用rebuild_index或update_index时出现了以下错误:

Failed to add documents to Solr: [Reason: ERROR:unknown field 'django_ct']

我一步一步按照Haystack-Search的“入门指南”操作。

我使用的是:

  • 最新版本的Apache Solr(1.4.1)
  • 最新版本的django-haystack

我的search_indexes.py文件是:

from haystack.indexes import *
from haystack import site
from models import Entity

class EntityIndex(SearchIndex):
    name = CharField(document=True)

    def get_queryset(self):
        return Entity.objects.all()


site.register(Entity, EntityIndex)

2 个回答

0

试着用 text = CharField(document

1

确保你的 $SOLR_HOME/conf/schema.xml 文件里有 'django_ct' 这个字段的声明。这个字段是自定义的,需要手动添加,和你使用的其他自定义字段一起添加。

撰写回答