diff --git a/lbry/wallet/server/db/elasticsearch/constants.py b/lbry/wallet/server/db/elasticsearch/constants.py index cea87c225..7ba84117d 100644 --- a/lbry/wallet/server/db/elasticsearch/constants.py +++ b/lbry/wallet/server/db/elasticsearch/constants.py @@ -38,13 +38,13 @@ INDEX_DEFAULT_SETTINGS = { FIELDS = {'is_controlling', 'last_take_over_height', 'claim_id', 'claim_name', 'normalized', 'tx_position', 'amount', 'timestamp', 'creation_timestamp', 'height', 'creation_height', 'activation_height', 'expiration_height', 'release_time', 'short_url', 'canonical_url', 'title', 'author', 'description', 'claim_type', 'reposted', - 'stream_type', 'media_type', 'fee_amount', 'fee_currency', 'duration', 'reposted_claim_hash', 'censor_type', + 'stream_type', 'media_type', 'fee_amount', 'fee_currency', 'duration', 'censor_type', 'claims_in_channel', 'channel_join', 'signature_valid', 'effective_amount', 'support_amount', 'trending_group', 'trending_mixed', 'trending_local', 'trending_global', 'channel_id', 'tx_id', 'tx_nout', - 'signature', 'signature_digest', 'public_key_bytes', 'public_key_hash', 'public_key_id', '_id', 'tags', + 'signature', 'signature_digest', 'public_key_bytes', 'public_key_id', '_id', 'tags', 'censoring_channel_id', 'reposted_claim_id'} TEXT_FIELDS = {'author', 'canonical_url', 'channel_id', 'claim_name', 'description', 'claim_id', - 'media_type', 'normalized', 'public_key_bytes', 'public_key_hash', 'short_url', 'signature', + 'media_type', 'normalized', 'public_key_bytes', 'public_key_id', 'short_url', 'signature', 'signature_digest', 'stream_type', 'title', 'tx_id', 'fee_currency', 'reposted_claim_id', 'tags'} RANGE_FIELDS = { 'height', 'creation_height', 'activation_height', 'expiration_height', @@ -54,8 +54,8 @@ RANGE_FIELDS = { 'trending_group', 'trending_mixed', 'censor_type', 'trending_local', 'trending_global', } +ALL_FIELDS = RANGE_FIELDS | TEXT_FIELDS | FIELDS REPLACEMENTS = { 'name': 'normalized', - 'txid': 'tx_id', - 'claim_hash': '_id' + 'txid': 'tx_id' } diff --git a/lbry/wallet/server/db/elasticsearch/search.py b/lbry/wallet/server/db/elasticsearch/search.py index 3b98999b5..cc26c286c 100644 --- a/lbry/wallet/server/db/elasticsearch/search.py +++ b/lbry/wallet/server/db/elasticsearch/search.py @@ -17,7 +17,7 @@ from lbry.schema.url import URL, normalize_name from lbry.utils import LRUCache from lbry.wallet.server.db.common import CLAIM_TYPES, STREAM_TYPES from lbry.wallet.server.db.elasticsearch.constants import INDEX_DEFAULT_SETTINGS, REPLACEMENTS, FIELDS, TEXT_FIELDS, \ - RANGE_FIELDS + RANGE_FIELDS, ALL_FIELDS from lbry.wallet.server.util import class_logger @@ -133,7 +133,7 @@ class SearchIndex: update = expand_query(claim_id__in=list(blockdict.keys()), censor_type=f"<{censor_type}") key = 'channel_id' if channels else 'claim_id' 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_id=params[ctx._source.{key}]", "lang": "painless", "params": blockdict } @@ -208,7 +208,7 @@ class SearchIndex: censored = [ result if not isinstance(result, dict) or not censor.censor(result) - else ResolveCensoredError(url, result['censoring_channel_hash']) + else ResolveCensoredError(url, result['censoring_channel_id']) for url, result in zip(urls, results) ] return results, censored, censor @@ -411,7 +411,7 @@ class SearchIndex: txo_rows = [row for row in txo_rows if isinstance(row, dict)] referenced_ids = set(filter(None, map(itemgetter('reposted_claim_id'), txo_rows))) referenced_ids |= set(filter(None, (row['channel_id'] for row in txo_rows))) - referenced_ids |= set(map(parse_claim_id, filter(None, (row['censoring_channel_hash'] for row in txo_rows)))) + referenced_ids |= set(map(parse_claim_id, filter(None, (row['censoring_channel_id'] for row in txo_rows)))) referenced_txos = [] if referenced_ids: @@ -432,8 +432,7 @@ def extract_doc(doc, index): doc['reposted_claim_id'] = None channel_hash = doc.pop('channel_hash') doc['channel_id'] = channel_hash[::-1].hex() if channel_hash else channel_hash - channel_hash = doc.pop('censoring_channel_hash') - doc['censoring_channel_hash'] = channel_hash[::-1].hex() if channel_hash else channel_hash + doc['censoring_channel_id'] = doc.get('censoring_channel_id') txo_hash = doc.pop('txo_hash') doc['tx_id'] = txo_hash[:32][::-1].hex() doc['tx_nout'] = struct.unpack('