kopia lustrzana https://github.com/wagtail/wagtail
Fix deprecation warnings from Elasticsearch 8
rodzic
06df4a66e1
commit
ea5efb79ac
|
@ -1052,6 +1052,7 @@ class Elasticsearch5SearchBackend(BaseSearchBackend):
|
|||
basic_rebuilder_class = ElasticsearchIndexRebuilder
|
||||
atomic_rebuilder_class = ElasticsearchAtomicIndexRebuilder
|
||||
catch_indexing_errors = True
|
||||
timeout_kwarg_name = "timeout"
|
||||
|
||||
settings = {
|
||||
"settings": {
|
||||
|
@ -1146,7 +1147,9 @@ class Elasticsearch5SearchBackend(BaseSearchBackend):
|
|||
self.hosts = [self._get_host_config_from_url(url) for url in parsed_urls]
|
||||
options.update(self._get_options_from_host_urls(parsed_urls))
|
||||
|
||||
self.es = Elasticsearch(hosts=self.hosts, timeout=self.timeout, **options)
|
||||
options[self.timeout_kwarg_name] = self.timeout
|
||||
|
||||
self.es = Elasticsearch(hosts=self.hosts, **options)
|
||||
|
||||
def get_index_for_model(self, model):
|
||||
# Split models up into separate indices based on their root model.
|
||||
|
|
|
@ -15,7 +15,12 @@ class Elasticsearch8Mapping(Elasticsearch7Mapping):
|
|||
|
||||
|
||||
class Elasticsearch8Index(Elasticsearch7Index):
|
||||
pass
|
||||
def add_model(self, model):
|
||||
# Get mapping
|
||||
mapping = self.mapping_class(model)
|
||||
|
||||
# Put mapping
|
||||
self.es.indices.put_mapping(index=self.name, **mapping.get_mapping())
|
||||
|
||||
|
||||
class Elasticsearch8SearchQueryCompiler(Elasticsearch7SearchQueryCompiler):
|
||||
|
@ -36,6 +41,7 @@ class Elasticsearch8SearchBackend(Elasticsearch7SearchBackend):
|
|||
query_compiler_class = Elasticsearch8SearchQueryCompiler
|
||||
autocomplete_query_compiler_class = Elasticsearch8AutocompleteQueryCompiler
|
||||
results_class = Elasticsearch8SearchResults
|
||||
timeout_kwarg_name = "request_timeout"
|
||||
|
||||
def _get_host_config_from_url(self, url):
|
||||
"""Given a parsed URL, return the host configuration to be added to self.hosts"""
|
||||
|
@ -46,8 +52,8 @@ class Elasticsearch8SearchBackend(Elasticsearch7SearchBackend):
|
|||
return {
|
||||
"host": url.hostname,
|
||||
"port": port,
|
||||
"url_prefix": url.path,
|
||||
"use_ssl": use_ssl,
|
||||
"path_prefix": url.path,
|
||||
"scheme": url.scheme,
|
||||
}
|
||||
|
||||
def _get_options_from_host_urls(self, urls):
|
||||
|
|
Ładowanie…
Reference in New Issue