forked from LBRYCommunity/lbry-sdk
filter+fts and tests for edge cases
This commit is contained in:
parent
d9c746891d
commit
da8a8bd1ef
2 changed files with 7 additions and 5 deletions
|
@ -405,12 +405,12 @@ def expand_query(**kwargs):
|
||||||
query["minimum_should_match"] = 1
|
query["minimum_should_match"] = 1
|
||||||
query['should'].append({"bool": {"must_not": {"exists": {"field": "signature_digest"}}}})
|
query['should'].append({"bool": {"must_not": {"exists": {"field": "signature_digest"}}}})
|
||||||
query['should'].append({"term": {"signature_valid": bool(kwargs["signature_valid"])}})
|
query['should'].append({"term": {"signature_valid": bool(kwargs["signature_valid"])}})
|
||||||
if 'text' in kwargs:
|
if kwargs.get('text'):
|
||||||
return {"query":
|
query['must'].append(
|
||||||
{"simple_query_string":
|
{"simple_query_string":
|
||||||
{"query": kwargs["text"], "fields": [
|
{"query": kwargs["text"], "fields": [
|
||||||
"claim_name^4", "channel_name^8", "title^1", "description^.5", "author^1", "tags^.5"
|
"claim_name^4", "channel_name^8", "title^1", "description^.5", "author^1", "tags^.5"
|
||||||
]}}}
|
]}})
|
||||||
query = {
|
query = {
|
||||||
"_source": {"excludes": ["description", "title"]},
|
"_source": {"excludes": ["description", "title"]},
|
||||||
'query': {'bool': query},
|
'query': {'bool': query},
|
||||||
|
|
|
@ -175,6 +175,8 @@ class ClaimSearchCommand(ClaimTestCase):
|
||||||
await self.assertFindsClaims([], channel_ids=[channel_id2])
|
await self.assertFindsClaims([], channel_ids=[channel_id2])
|
||||||
# resolve by claim ids
|
# resolve by claim ids
|
||||||
await self.assertFindsClaims([three, two], claim_ids=[self.get_claim_id(three), self.get_claim_id(two)])
|
await self.assertFindsClaims([three, two], claim_ids=[self.get_claim_id(three), self.get_claim_id(two)])
|
||||||
|
await self.assertFindsClaims([three], claim_id=self.get_claim_id(three))
|
||||||
|
await self.assertFindsClaims([three], claim_id=self.get_claim_id(three), text='*')
|
||||||
|
|
||||||
async def test_source_filter(self):
|
async def test_source_filter(self):
|
||||||
no_source = await self.stream_create('no_source', data=None)
|
no_source = await self.stream_create('no_source', data=None)
|
||||||
|
@ -451,9 +453,9 @@ class ClaimSearchCommand(ClaimTestCase):
|
||||||
await self.assertFindsClaims([claim4], text='conspiracy')
|
await self.assertFindsClaims([claim4], text='conspiracy')
|
||||||
await self.assertFindsClaims([], text='conspiracy+history')
|
await self.assertFindsClaims([], text='conspiracy+history')
|
||||||
await self.assertFindsClaims([claim4, claim3], text='conspiracy|history')
|
await self.assertFindsClaims([claim4, claim3], text='conspiracy|history')
|
||||||
await self.assertFindsClaims([claim1, claim4, claim2, claim3], text='documentary')
|
await self.assertFindsClaims([claim1, claim4, claim2, claim3], text='documentary', order_by=[])
|
||||||
# todo: check why claim1 and claim2 order changed. used to be ...claim1, claim2...
|
# todo: check why claim1 and claim2 order changed. used to be ...claim1, claim2...
|
||||||
await self.assertFindsClaims([claim4, claim2, claim1, claim3], text='satoshi')
|
await self.assertFindsClaims([claim4, claim2, claim1, claim3], text='satoshi', order_by=[])
|
||||||
|
|
||||||
claim2 = await self.stream_update(
|
claim2 = await self.stream_update(
|
||||||
self.get_claim_id(claim2), clear_tags=True, tags=['cloud'],
|
self.get_claim_id(claim2), clear_tags=True, tags=['cloud'],
|
||||||
|
|
Loading…
Reference in a new issue