【问题标题】:Haystack and elasticsearch not working with one character干草堆和弹性搜索不适用于一个字符
【发布时间】:2014-11-13 03:09:14
【问题描述】:

我正在尝试使用 haystack 和 elasticsearch 进行搜索,但由于某种原因,它仅在我搜索包含多个字符的单词时才返回结果。

如何启用一个字符搜索?

这是我的索引

class CustomerIndex(CelerySearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True)
    first_name_auto = indexes.CharField(model_attr='first_name', default='')
    last_name_auto = indexes.CharField(model_attr='last_name', default='')
    full_name_auto = indexes.EdgeNgramField(model_attr='get_full_name', default='')
    address1 = indexes.CharField(model_attr='address1', indexed=False,
                                 default='')
    accounts_customer_auto = indexes.MultiValueField()

    def get_model(self):
        return Customer

    def prepare_accounts_customer_auto(self, obj):
        return [a.id for a in obj.accounts.all()]

    # def index_queryset(self, using=None):
    #     """Used when the entire index for model is updated."""
    #     return Customer.objects.all()

    def get_model(self):
        return Customer

这就是查询

sqs = SearchQuerySet().filter(
                full_name_auto__exact=query_text).order_by('-full_name_auto').models(Customer)

【问题讨论】:

  • 你能提供更多细节吗?查询样本,数据样本,你的期望是什么。

标签: elasticsearch django-haystack


【解决方案1】:

这似乎是一个干草堆默认功能

【讨论】:

    猜你喜欢
    • 2013-09-23
    • 2012-05-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-27
    • 2016-10-15
    • 2017-11-07
    • 2012-07-11
    相关资源
    最近更新 更多