Spaces:
Sleeping
Sleeping
Update doc_searcher.py
Browse files- doc_searcher.py +14 -16
doc_searcher.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
from qdrant_client import QdrantClient
|
| 2 |
-
from qdrant_client.models import Filter, FieldCondition, MatchValue
|
| 3 |
from fastembed import SparseTextEmbedding, LateInteractionTextEmbedding
|
| 4 |
from qdrant_client import QdrantClient, models
|
| 5 |
from sentence_transformers import SentenceTransformer
|
|
@@ -25,16 +25,14 @@ class DocSearcher:
|
|
| 25 |
using=DENSE_MODEL,
|
| 26 |
limit=100
|
| 27 |
),
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
]
|
| 34 |
|
| 35 |
-
if type ==
|
| 36 |
-
filter = None
|
| 37 |
-
elif type == 1 and law_type is not None:
|
| 38 |
filter = Filter(
|
| 39 |
must=[
|
| 40 |
FieldCondition(
|
|
@@ -42,23 +40,23 @@ class DocSearcher:
|
|
| 42 |
match=MatchValue(value=type)
|
| 43 |
),
|
| 44 |
FieldCondition(
|
| 45 |
-
key="
|
| 46 |
-
match=
|
| 47 |
),
|
| 48 |
-
],
|
| 49 |
-
must_not=[
|
| 50 |
-
FieldCondition(key="status", match=MatchValue(value="Nevažeći")),
|
| 51 |
]
|
| 52 |
)
|
| 53 |
-
|
| 54 |
filter = Filter(
|
| 55 |
must=[
|
| 56 |
FieldCondition(
|
| 57 |
key="tip_dokumenta",
|
| 58 |
match=MatchValue(value=type)
|
| 59 |
-
)
|
| 60 |
]
|
| 61 |
)
|
|
|
|
|
|
|
|
|
|
| 62 |
search_result = self.qdrant_client.query_points(
|
| 63 |
collection_name= self.collection_name,
|
| 64 |
query_filter=filter,
|
|
|
|
| 1 |
from qdrant_client import QdrantClient
|
| 2 |
+
from qdrant_client.models import Filter, FieldCondition, MatchValue, MatchText
|
| 3 |
from fastembed import SparseTextEmbedding, LateInteractionTextEmbedding
|
| 4 |
from qdrant_client import QdrantClient, models
|
| 5 |
from sentence_transformers import SentenceTransformer
|
|
|
|
| 25 |
using=DENSE_MODEL,
|
| 26 |
limit=100
|
| 27 |
),
|
| 28 |
+
models.Prefetch(
|
| 29 |
+
query=models.SparseVector(**sparse_query.as_object()),
|
| 30 |
+
using=SPARSE_MODEL,
|
| 31 |
+
limit=100
|
| 32 |
+
)
|
| 33 |
]
|
| 34 |
|
| 35 |
+
if type == 0 and law_type is not None:
|
|
|
|
|
|
|
| 36 |
filter = Filter(
|
| 37 |
must=[
|
| 38 |
FieldCondition(
|
|
|
|
| 40 |
match=MatchValue(value=type)
|
| 41 |
),
|
| 42 |
FieldCondition(
|
| 43 |
+
key="naziv_suda",
|
| 44 |
+
match=MatchText(text=law_type)
|
| 45 |
),
|
|
|
|
|
|
|
|
|
|
| 46 |
]
|
| 47 |
)
|
| 48 |
+
elif type == 0:
|
| 49 |
filter = Filter(
|
| 50 |
must=[
|
| 51 |
FieldCondition(
|
| 52 |
key="tip_dokumenta",
|
| 53 |
match=MatchValue(value=type)
|
| 54 |
+
)
|
| 55 |
]
|
| 56 |
)
|
| 57 |
+
else:
|
| 58 |
+
return []
|
| 59 |
+
|
| 60 |
search_result = self.qdrant_client.query_points(
|
| 61 |
collection_name= self.collection_name,
|
| 62 |
query_filter=filter,
|