Skip to content

Commit

Permalink
Pass update_all_types=True to put_mapping on ES2 - workaround for wag…
Browse files Browse the repository at this point in the history
  • Loading branch information
gasman committed Oct 5, 2016
1 parent c471008 commit a9f14ca
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion wagtail/wagtailsearch/backends/elasticsearch2.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,17 @@ def get_document(self, obj):


class Elasticsearch2Index(ElasticsearchIndex):
pass
def add_model(self, model):
# Get mapping
mapping = self.mapping_class(model)

# Put mapping
self.es.indices.put_mapping(
# pass update_all_types=True as a workaround to avoid "Can't redefine search field" errors -
# see https://github.com/torchbox/wagtail/issues/2968
index=self.name, doc_type=mapping.get_document_type(), body=mapping.get_mapping(),
update_all_types=True
)


class Elasticsearch2SearchQuery(ElasticsearchSearchQuery):
Expand Down

0 comments on commit a9f14ca

Please sign in to comment.