From 8b91b38855966f483f5aa539e59f32a4ffd26f57 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Wed, 20 Jan 2021 03:03:39 -0300 Subject: [PATCH] update winners in one go --- lbry/wallet/server/db/elastic_search.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lbry/wallet/server/db/elastic_search.py b/lbry/wallet/server/db/elastic_search.py index 98b52c772..a73087e99 100644 --- a/lbry/wallet/server/db/elastic_search.py +++ b/lbry/wallet/server/db/elastic_search.py @@ -63,14 +63,18 @@ class SearchIndex: if not claims: return actions = [extract_doc(claim, self.index) for claim in claims] + names = [] for claim in claims: if claim['is_controlling']: - update = expand_query(name=claim['claim_name']) - update['script'] = { - "source": "ctx._source.is_controlling=false", - "lang": "painless" - } - await self.client.update_by_query(self.index, body=update) + names.append(claim['normalized']) + if names: + update = expand_query(name__in=names) + update['script'] = { + "source": "ctx._source.is_controlling=false", + "lang": "painless" + } + await self.client.update_by_query(self.index, body=update) + await self.client.indices.refresh(self.index) await async_bulk(self.client, actions) async def delete(self, claim_ids):