mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-01 20:14:55 +00:00
Rename "fields" search parameter to "stored_fields"
https://www.elastic.co/guide/en/elasticsearch/reference/5.x/breaking_50_search_changes.html#_literal_fields_literal_parameter
This commit is contained in:
parent
736138ae0e
commit
906201d5ae
3 changed files with 16 additions and 7 deletions
|
|
@ -416,6 +416,8 @@ class ElasticsearchSearchQuery(BaseSearchQuery):
|
|||
|
||||
|
||||
class ElasticsearchSearchResults(BaseSearchResults):
|
||||
fields_param_name = 'fields'
|
||||
|
||||
def _get_es_body(self, for_count=False):
|
||||
body = {
|
||||
'query': self.query.get_query()
|
||||
|
|
@ -435,10 +437,11 @@ class ElasticsearchSearchResults(BaseSearchResults):
|
|||
index=self.backend.get_index_for_model(self.query.queryset.model).name,
|
||||
body=self._get_es_body(),
|
||||
_source=False,
|
||||
fields='pk',
|
||||
from_=self.start,
|
||||
)
|
||||
|
||||
params[self.fields_param_name] = 'pk'
|
||||
|
||||
# Add size if set
|
||||
if self.stop is not None:
|
||||
params['size'] = self.stop - self.start
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
from .elasticsearch2 import (
|
||||
Elasticsearch2Mapping, Elasticsearch2SearchBackend, Elasticsearch2SearchQuery)
|
||||
Elasticsearch2Mapping, Elasticsearch2SearchBackend, Elasticsearch2SearchQuery,
|
||||
Elasticsearch2SearchResults)
|
||||
|
||||
|
||||
class Elasticsearch5Mapping(Elasticsearch2Mapping):
|
||||
|
|
@ -14,9 +15,14 @@ class Elasticsearch5SearchQuery(Elasticsearch2SearchQuery):
|
|||
mapping_class = Elasticsearch5Mapping
|
||||
|
||||
|
||||
class Elasticsearch5SearchResults(Elasticsearch2SearchResults):
|
||||
fields_param_name = 'stored_fields'
|
||||
|
||||
|
||||
class Elasticsearch5SearchBackend(Elasticsearch2SearchBackend):
|
||||
mapping_class = Elasticsearch5Mapping
|
||||
query_class = Elasticsearch5SearchQuery
|
||||
results_class = Elasticsearch5SearchResults
|
||||
|
||||
|
||||
SearchBackend = Elasticsearch5SearchBackend
|
||||
|
|
|
|||
|
|
@ -603,7 +603,7 @@ class TestElasticsearch5SearchResults(TestCase):
|
|||
from_=0,
|
||||
body={'query': 'QUERY'},
|
||||
_source=False,
|
||||
fields='pk',
|
||||
stored_fields='pk',
|
||||
index='wagtail__searchtests_searchtest'
|
||||
)
|
||||
|
||||
|
|
@ -619,7 +619,7 @@ class TestElasticsearch5SearchResults(TestCase):
|
|||
from_=10,
|
||||
body={'query': 'QUERY'},
|
||||
_source=False,
|
||||
fields='pk',
|
||||
stored_fields='pk',
|
||||
index='wagtail__searchtests_searchtest',
|
||||
size=1
|
||||
)
|
||||
|
|
@ -635,7 +635,7 @@ class TestElasticsearch5SearchResults(TestCase):
|
|||
from_=1,
|
||||
body={'query': 'QUERY'},
|
||||
_source=False,
|
||||
fields='pk',
|
||||
stored_fields='pk',
|
||||
index='wagtail__searchtests_searchtest',
|
||||
size=3
|
||||
)
|
||||
|
|
@ -651,7 +651,7 @@ class TestElasticsearch5SearchResults(TestCase):
|
|||
from_=10,
|
||||
body={'query': 'QUERY'},
|
||||
_source=False,
|
||||
fields='pk',
|
||||
stored_fields='pk',
|
||||
index='wagtail__searchtests_searchtest',
|
||||
size=10
|
||||
)
|
||||
|
|
@ -668,7 +668,7 @@ class TestElasticsearch5SearchResults(TestCase):
|
|||
from_=20,
|
||||
body={'query': 'QUERY'},
|
||||
_source=False,
|
||||
fields='pk',
|
||||
stored_fields='pk',
|
||||
index='wagtail__searchtests_searchtest',
|
||||
size=1
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue