From fafe5b67b720f8ebcde9eb37612802b060409e00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Lenksj=C3=B6?= <5889538+lenkan@users.noreply.github.com> Date: Tue, 13 Feb 2024 15:27:02 +0100 Subject: [PATCH] feat: add index for registry field (#188) --- src/keria/db/basing.py | 1 + tests/app/test_basing.py | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/keria/db/basing.py b/src/keria/db/basing.py index ba3d6f9c..7a39a264 100644 --- a/src/keria/db/basing.py +++ b/src/keria/db/basing.py @@ -241,6 +241,7 @@ def generateIndexes(self, said): # Assign single field Schema and ISSUER index and ISSUER/SCHEMA: self.schIdx.add(keys=(said,), val=SCHEMA_FIELD.qb64b) self.schIdx.add(keys=(said,), val=ISSUER_FIELD.qb64b) + self.schIdx.add(keys=(said,), val=REGISTRY_FIELD.qb64b) subkey = f"{ISSUER_FIELD.qb64}.{SCHEMA_FIELD.qb64}" self.schIdx.add(keys=(said,), val=subkey.encode("UTF-8")) diff --git a/tests/app/test_basing.py b/tests/app/test_basing.py index 04e4b98b..8b5ac1f8 100644 --- a/tests/app/test_basing.py +++ b/tests/app/test_basing.py @@ -38,6 +38,7 @@ def test_seeker(helpers, seeder, mockHelpingNowUTC): # Verify the indexes created for the QVI schema assert indexes == ['5AABAA-s', '5AABAA-i', + '4AABA-ri', '5AABAA-i.5AABAA-s', '4AAB-a-i', '4AAB-a-i.5AABAA-s', @@ -73,6 +74,7 @@ def test_seeker(helpers, seeder, mockHelpingNowUTC): # Test the indexes assigned to the LE schema assert indexes == ['5AABAA-s', '5AABAA-i', + '4AABA-ri', '5AABAA-i.5AABAA-s', '4AAB-a-i', '4AAB-a-i.5AABAA-s', @@ -122,6 +124,12 @@ def test_seeker(helpers, seeder, mockHelpingNowUTC): saids = seeker.find({}).limit(50) assert len(list(saids)) == 50 + saids = seeker.find({ '-ri': "EACehJRd0wfteUAJgaTTJjMSaQqWvzeeHqAMMqxuqxU4" }) + assert len(list(saids)) == 25 + + saids = seeker.find({ '-ri': "EAzc9zFLaK22zbrKDGIgKtrpDBNKWKvl8B0FKYAo19z_" }) + assert len(list(saids)) == 0 + saids = seeker.find({'-d': "EAzc9zFLaK22zbrKDGIgKtrpDBNKWKvl8B0FKYAo19z_"}) assert list(saids) == ['EAzc9zFLaK22zbrKDGIgKtrpDBNKWKvl8B0FKYAo19z_']