fix search by channel
This commit is contained in:
parent
063be001b3
commit
21e023f0db
1 changed files with 4 additions and 8 deletions
|
@ -121,9 +121,6 @@ class SearchIndex:
|
||||||
touched.add(item['_id'])
|
touched.add(item['_id'])
|
||||||
await self.client.indices.refresh(self.index)
|
await self.client.indices.refresh(self.index)
|
||||||
await self.client.indices.flush(self.index)
|
await self.client.indices.flush(self.index)
|
||||||
for claim_id in touched:
|
|
||||||
if claim_id in self.claim_cache:
|
|
||||||
self.claim_cache.pop(claim_id)
|
|
||||||
self.logger.info("Indexing done.")
|
self.logger.info("Indexing done.")
|
||||||
|
|
||||||
async def apply_filters(self, blocked_streams, blocked_channels, filtered_streams, filtered_channels):
|
async def apply_filters(self, blocked_streams, blocked_channels, filtered_streams, filtered_channels):
|
||||||
|
@ -134,9 +131,6 @@ class SearchIndex:
|
||||||
update = expand_query(channel_id__in=list(blockdict.keys()), censor_type=f"<{censor_type}")
|
update = expand_query(channel_id__in=list(blockdict.keys()), censor_type=f"<{censor_type}")
|
||||||
else:
|
else:
|
||||||
update = expand_query(claim_id__in=list(blockdict.keys()), censor_type=f"<{censor_type}")
|
update = expand_query(claim_id__in=list(blockdict.keys()), censor_type=f"<{censor_type}")
|
||||||
for claim_id in blockdict:
|
|
||||||
if claim_id in self.claim_cache:
|
|
||||||
self.claim_cache.pop(claim_id)
|
|
||||||
key = 'channel_id' if channels else 'claim_id'
|
key = 'channel_id' if channels else 'claim_id'
|
||||||
update['script'] = {
|
update['script'] = {
|
||||||
"source": f"ctx._source.censor_type={censor_type}; ctx._source.censoring_channel_hash=params[ctx._source.{key}]",
|
"source": f"ctx._source.censor_type={censor_type}; ctx._source.censoring_channel_hash=params[ctx._source.{key}]",
|
||||||
|
@ -161,6 +155,7 @@ class SearchIndex:
|
||||||
await self.client.update_by_query(self.index, body=make_query(2, blocked_channels, True), slices=32)
|
await self.client.update_by_query(self.index, body=make_query(2, blocked_channels, True), slices=32)
|
||||||
await self.client.indices.refresh(self.index)
|
await self.client.indices.refresh(self.index)
|
||||||
self.search_cache.clear()
|
self.search_cache.clear()
|
||||||
|
self.claim_cache.clear()
|
||||||
self.resolution_cache.clear()
|
self.resolution_cache.clear()
|
||||||
|
|
||||||
async def delete_above_height(self, height):
|
async def delete_above_height(self, height):
|
||||||
|
@ -241,9 +236,10 @@ class SearchIndex:
|
||||||
|
|
||||||
async def search(self, **kwargs):
|
async def search(self, **kwargs):
|
||||||
if 'channel' in kwargs:
|
if 'channel' in kwargs:
|
||||||
result = await self.resolve_url(kwargs.pop('channel'))
|
results, _, _ = await self.resolve(kwargs.pop('channel'))
|
||||||
if not result or not isinstance(result, Iterable):
|
if not results or not isinstance(results, Iterable):
|
||||||
return [], 0, 0
|
return [], 0, 0
|
||||||
|
result = results[0] if results else None
|
||||||
kwargs['channel_id'] = result['claim_id']
|
kwargs['channel_id'] = result['claim_id']
|
||||||
try:
|
try:
|
||||||
result = await self.search_client.search(
|
result = await self.search_client.search(
|
||||||
|
|
Loading…
Reference in a new issue