Pass index name in URL to Bulk API

We currently index all items in Elasticsearch using the root bulk api
(at ``/_bulk``). This API is to allow multiple indices to be inserted
into at once. However, Wagtail inserts into one index at a time so this
is not needed. If we pass the index name as a parameter in the call to
``bulk()``, the index-specific bulk API will be used instead (at
``/<index name>/_bulk``.

The advantage of this change is it makes it possible to implement access
control by checking the URL an application is using. This is required in
order for the Bulk API to work on certain hosts (such as Divio).
pull/4322/merge
Karl Hobley 2018-02-28 14:04:46 +00:00 zatwierdzone przez Matt Westcott
rodzic 0aced66fe3
commit 1849f0d54a
3 zmienionych plików z 3 dodań i 2 usunięć

Wyświetl plik

@ -57,6 +57,7 @@ Changelog
* Fix: Restored ability to use non-model fields with FieldPanel (Matt Westcott, LB (Ben Johnston))
* Fix: Stop revision comparison view from crashing when non-model FieldPanels are in use (LB (Ben Johnston))
* Fix: Ordering in the page explorer now respects custom `get_admin_display_title` methods when sorting <100 pages (Matt Westcott)
* Fix: Use index-specific Elasticsearch endpoints for bulk insertion, for compatibility with providers that lock down the root endpoint (Karl Hobley)
2.0.2 (xx.xx.xxxx) - IN DEVELOPMENT

Wyświetl plik

@ -86,6 +86,7 @@ Bug fixes
* Restored ability to use non-model fields with FieldPanel (Matt Westcott, LB (Ben Johnston))
* Stop revision comparison view from crashing when non-model FieldPanels are in use (LB (Ben Johnston))
* Ordering in the page explorer now respects custom ``get_admin_display_title`` methods when sorting <100 pages (Matt Westcott)
* Use index-specific Elasticsearch endpoints for bulk insertion, for compatibility with providers that lock down the root endpoint (Karl Hobley)
Upgrade considerations

Wyświetl plik

@ -806,7 +806,6 @@ class Elasticsearch2Index:
for item in items:
# Create the action
action = {
'_index': self.name,
'_type': doc_type,
'_id': mapping.get_document_id(item),
}
@ -814,7 +813,7 @@ class Elasticsearch2Index:
actions.append(action)
# Run the actions
bulk(self.es, actions)
bulk(self.es, actions, index=self.name)
def delete_item(self, item):
# Make sure the object can be indexed