Repository: chr1st1ank/narrow-down (language: python)

Issue:
exact_part should be stored together with document
When the storage level is set to "document" the exact_part is not stored, but only if the storage level is "fingerprint".
However, it is a usecase to use the document together with the exact_part for evaluation of search hits. For that the hashes in the fingerprint are not necessary to be stored.

So it would be better to store the exact part also on the storage level "document".


Discussion / hints:

Fix patch:
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 591d03a..3c4b4d8 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -13,11 +13,11 @@ repos:
   hooks:
     - id: isort
 - repo: https://github.com/psf/black
-  rev: 21.12b0
+  rev: 22.1.0
   hooks:
     - id: black
 - repo: https://github.com/asottile/blacken-docs
-  rev: v1.12.0
+  rev: v1.12.1
   hooks:
     - id: blacken-docs
       additional_dependencies: ["black==21.12b0"]
diff --git a/narrow_down/data_types.py b/narrow_down/data_types.py
index 39d19ec..d08f3c9 100644
--- a/narrow_down/data_types.py
+++ b/narrow_down/data_types.py
@@ -98,7 +98,7 @@ def without(self, *attributes: str) -> "StoredDocument":
 
 _FIELDS_FOR_STORAGE_LEVEL = {
     StorageLevel.Minimal: {"data"},
-    StorageLevel.Document: {"data", "document"},
+    StorageLevel.Document: {"data", "document", "exact_part"},
     StorageLevel.Fingerprint: {"data", "exact_part"},
     StorageLevel.Full: {"data", "document", "exact_part"},
 }
diff --git a/narrow_down/scylladb.py b/narrow_down/scylladb.py
index 60c837f..c758a5b 100644
--- a/narrow_down/scylladb.py
+++ b/narrow_down/scylladb.py
@@ -201,7 +201,7 @@ async def insert_document(self, document: bytes, document_id: int = None) -> int
                 return document_id
             else:
                 for _ in range(10):
-                    doc_id = random.randint(a=0, b=2 ** 32)
+                    doc_id = random.randint(a=0, b=2**32)
                     result = await self._execute(
                         session,
                         self._prepared_statements["set_doc_checked"],


Test patch:
diff --git a/tests/test_data_types.py b/tests/test_data_types.py
index fd90978..960391c 100644
--- a/tests/test_data_types.py
+++ b/tests/test_data_types.py
@@ -16,7 +16,7 @@
     "storage_level, expected_fields",
     [
         (StorageLevel.Minimal, {"data"}),
-        (StorageLevel.Document, {"data", "document"}),
+        (StorageLevel.Document, {"data", "document", "exact_part"}),
         (StorageLevel.Fingerprint, {"data", "exact_part", "fingerprint"}),
         (StorageLevel.Full, {"data", "document", "exact_part", "fingerprint"}),
     ],