forked from LBRYCommunity/lbry-sdk
update winners in one go
This commit is contained in:
parent
1098f0d2a3
commit
8b91b38855
1 changed files with 10 additions and 6 deletions
|
@ -63,14 +63,18 @@ class SearchIndex:
|
||||||
if not claims:
|
if not claims:
|
||||||
return
|
return
|
||||||
actions = [extract_doc(claim, self.index) for claim in claims]
|
actions = [extract_doc(claim, self.index) for claim in claims]
|
||||||
|
names = []
|
||||||
for claim in claims:
|
for claim in claims:
|
||||||
if claim['is_controlling']:
|
if claim['is_controlling']:
|
||||||
update = expand_query(name=claim['claim_name'])
|
names.append(claim['normalized'])
|
||||||
|
if names:
|
||||||
|
update = expand_query(name__in=names)
|
||||||
update['script'] = {
|
update['script'] = {
|
||||||
"source": "ctx._source.is_controlling=false",
|
"source": "ctx._source.is_controlling=false",
|
||||||
"lang": "painless"
|
"lang": "painless"
|
||||||
}
|
}
|
||||||
await self.client.update_by_query(self.index, body=update)
|
await self.client.update_by_query(self.index, body=update)
|
||||||
|
await self.client.indices.refresh(self.index)
|
||||||
await async_bulk(self.client, actions)
|
await async_bulk(self.client, actions)
|
||||||
|
|
||||||
async def delete(self, claim_ids):
|
async def delete(self, claim_ids):
|
||||||
|
|
Loading…
Reference in a new issue