From cd04037523c329b889a85d2652d8c058951a644a Mon Sep 17 00:00:00 2001 From: olaughter Date: Wed, 18 Sep 2024 12:02:51 +0100 Subject: [PATCH 1/2] Add `metadata` at the passage level Following on from the previous change that added the other fields to the passage object. This also surfaces metadata. --- src/cpr_sdk/models/search.py | 1 + tests/local_vespa/test_app/schemas/document_passage.sd | 2 ++ tests/test_search_adaptors.py | 1 + 3 files changed, 4 insertions(+) diff --git a/src/cpr_sdk/models/search.py b/src/cpr_sdk/models/search.py index 82b4a55..0d85933 100644 --- a/src/cpr_sdk/models/search.py +++ b/src/cpr_sdk/models/search.py @@ -404,6 +404,7 @@ def from_vespa_response(cls, response_hit: dict) -> "Passage": text_block_type=fields["text_block_type"], text_block_page=fields.get("text_block_page"), text_block_coords=fields.get("text_block_coords"), + metadata=fields.get("metadata"), ) diff --git a/tests/local_vespa/test_app/schemas/document_passage.sd b/tests/local_vespa/test_app/schemas/document_passage.sd index 69d2d9d..8f2f3df 100644 --- a/tests/local_vespa/test_app/schemas/document_passage.sd +++ b/tests/local_vespa/test_app/schemas/document_passage.sd @@ -64,6 +64,7 @@ schema document_passage { import field family_document_ref.document_source_url as document_source_url {} import field family_document_ref.corpus_import_id as corpus_import_id {} import field family_document_ref.corpus_type_name as corpus_type_name {} + import field family_document_ref.metadata as metadata {} import field search_weights_ref.passage_weight as passage_weight {} fieldset default { @@ -88,6 +89,7 @@ schema document_passage { summary document_source_url {} summary corpus_import_id {} summary corpus_type_name {} + summary metadata {} summary text_block {} summary text_block_id {} summary text_block_type {} diff --git a/tests/test_search_adaptors.py b/tests/test_search_adaptors.py index 4505914..0e57673 100644 --- a/tests/test_search_adaptors.py +++ b/tests/test_search_adaptors.py @@ -523,6 +523,7 @@ def test_vespa_search_adaptor__metadata(test_vespa, query_string, metadata_filte response = vespa_search(test_vespa, request) assert response.total_family_hits > 0 for family in response.families: + assert len(family.hits) > 0 for hit in family.hits: assert hit.metadata not in [None, []] for metadata_filter in metadata_filters: From 289bb806e59a0fbe74c316a17045847e2510b82a Mon Sep 17 00:00:00 2001 From: olaughter Date: Wed, 18 Sep 2024 12:05:57 +0100 Subject: [PATCH 2/2] version bump --- src/cpr_sdk/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cpr_sdk/version.py b/src/cpr_sdk/version.py index 26f57ad..3fba0a6 100644 --- a/src/cpr_sdk/version.py +++ b/src/cpr_sdk/version.py @@ -1,6 +1,6 @@ _MAJOR = "1" _MINOR = "6" -_PATCH = "0" +_PATCH = "1" _SUFFIX = "" VERSION_SHORT = "{0}.{1}".format(_MAJOR, _MINOR)