Skip to content

Commit

Permalink
claim_ids query
Browse files Browse the repository at this point in the history
  • Loading branch information
shyba committed Feb 10, 2021
1 parent 16a63c3 commit 6df94cb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lbry/wallet/server/db/elastic_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ async def start(self):
"default": {"tokenizer": "whitespace", "filter": ["lowercase", "porter_stem"]}}},
"index":
{"refresh_interval": -1,
"number_of_shards": 1}
"number_of_shards": 1,
"number_of_replicas": 0}
},
"mappings": {
"properties": {
Expand Down Expand Up @@ -89,6 +90,7 @@ async def sync_queue(self, claim_queue):
for bulk in range(0, len(to_update), 400):
await self.update(to_update[bulk:bulk+400])
await self.client.indices.refresh(self.index)
await self.client.indices.flush(self.index)

async def apply_filters(self, blocked_streams, blocked_channels, filtered_streams, filtered_channels):
def make_query(censor_type, blockdict, channels=False):
Expand Down Expand Up @@ -290,7 +292,7 @@ def extract_doc(doc, index):
'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',
'reposted_claim_id'}
TEXT_FIELDS = {'author', 'canonical_url', 'channel_id', 'claim_name', 'description',
TEXT_FIELDS = {'author', 'canonical_url', 'channel_id', 'claim_name', 'description', 'claim_id',
'media_type', 'normalized', 'public_key_bytes', 'public_key_hash', 'short_url', 'signature',
'signature_digest', 'stream_type', 'title', 'tx_id', 'fee_currency', 'reposted_claim_id', 'tags'}
RANGE_FIELDS = {
Expand Down Expand Up @@ -367,6 +369,8 @@ def expand_query(**kwargs):
query['must_not'].append({"term": {'_id': channel_id}})
elif key == 'channel_ids':
query['must'].append({"terms": {'channel_id.keyword': value}})
elif key == 'claim_ids':
query['must'].append({"terms": {'claim_id.keyword': value}})
elif key == 'media_types':
query['must'].append({"terms": {'media_type.keyword': value}})
elif key == 'stream_types':
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/blockchain/test_claim_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ async def test_basic_claim_search(self):
# abandoned stream won't show up for streams in channel search
await self.stream_abandon(txid=signed2['txid'], nout=0)
await self.assertFindsClaims([], channel_ids=[channel_id2])
# resolve by claim ids
await self.assertFindsClaims([three, two], claim_ids=[self.get_claim_id(three), self.get_claim_id(two)])

async def test_pagination(self):
await self.create_channel()
Expand Down

0 comments on commit 6df94cb

Please sign in to comment.