【问题标题】:Filtering in haystack does not work干草堆中的过滤不起作用
【发布时间】:2011-05-10 16:35:04
【问题描述】:

我有一个模型,其字段状态定义为:

class Model(models.Model):
    ...
    status = models.CharField(_('entry status'), default=ENTRY_DRAFT, max_length=2, choices=ENTRY_CHOICES)

现在我使用带有简单引擎集的 haystack。我的搜索索引如下:

class EntryIndex(SearchIndex):
    text = CharField(document=True, use_template=True)
    author = CharField(model_attr='owner')
    date_published = DateTimeField(model_attr='date_published')
    status = CharField(model_attr='status')

    def index_queryset(self):
        """Used when the entire index for model is updated."""
        return Entry.objects.all().distinct()

site.register(Entry, EntryIndex)

问题是当我尝试使用 entries.filter(status=ENTRY_DRAFT) 我收到的所有对象不仅与过滤匹配。 Entries 是传递给其他函数的 SearchQuerySet。怎么了?

【问题讨论】:

  • 你找到答案了吗?
  • 谢谢你提醒我回答这个问题:)

标签: django search-engine django-haystack


【解决方案1】:

只有当我使用虚拟搜索引擎时才会出现问题。解决方案是将搜索引擎更改为其他。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-18
    • 1970-01-01
    相关资源
    最近更新 更多