mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-27 08:04:01 +00:00
Fix elasticsearch search backend tests broken by #5208
This commit is contained in:
parent
98d3ef4743
commit
73e07ba10d
2 changed files with 2 additions and 12 deletions
|
|
@ -439,19 +439,9 @@ class IndexView(WMABaseView):
|
|||
# database backends.
|
||||
pk_name = self.opts.pk.name
|
||||
|
||||
if hasattr(self.model, 'get_filterable_search_fields'):
|
||||
# The model is indexed, so let's be careful to only add
|
||||
# indexed fields to ordering where possible
|
||||
filterable_fields = self.model.get_filterable_search_fields()
|
||||
else:
|
||||
filterable_fields = None
|
||||
|
||||
if not (set(ordering) & {'pk', '-pk', pk_name, '-' + pk_name}):
|
||||
# ordering isn't already being applied to pk
|
||||
if filterable_fields is None or 'pk' in filterable_fields:
|
||||
ordering.append('-pk')
|
||||
else:
|
||||
ordering.append('-' + pk_name)
|
||||
ordering.append('-' + pk_name)
|
||||
|
||||
return ordering
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class Book(models.Model, index.Indexed):
|
|||
search_fields = [
|
||||
index.SearchField('title'),
|
||||
index.FilterField('title'),
|
||||
index.FilterField('pk'),
|
||||
index.FilterField('id'),
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
|
|
|
|||
Loading…
Reference in a new issue