我正在尝试使用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)
答案 0 :(得分:0)
这似乎是一个大海捞针默认功能