1

我正在尝试使用 Django haystack 和 solr 实现搜索,但是在尝试在 SearchIndex 上实现分面搜索然后尝试运行服务器时出现此错误:

TypeError: init () got an unexpected keyword argument 'faceted'

这是搜索索引:

import datetime
from haystack.indexes import *
from haystack import site
from resources.models import Resource

class ResourceIndex(SearchIndex):
    text = CharField(document=True, use_template=True)
    author = CharField(model_attr='submitter', faceted=True)
    pub_date = DateTimeField(model_attr='created')

    def get_queryset(self):
        """Used when the entire index for model is updated."""
        return Resource.objects.filter(last_modified__lte=datetime.datetime.now())

site.register(Resource, ResourceIndex)
4

1 回答 1

2

如果您使用 easy_install 或 pip 安装了 haystack,您将获得 1.01 版,并且显然不支持 haystack.indexes.CharField 上的“faceted”关键字参数。

来自 Daniel Lindsley:刻面等于真线

您必须安装 git master 版本而不是 PyPi 中提供的 1.01 版本(easy_install 和 pip 将默认安装)

于 2010-10-06T19:36:16.997 回答