dzenzzz commited on
Commit
c5df8ab
·
verified ·
1 Parent(s): 8f8e3ca

Update doc_searcher.py

Browse files
Files changed (1) hide show
  1. doc_searcher.py +34 -12
doc_searcher.py CHANGED
@@ -19,18 +19,27 @@ class DocSearcher:
19
  dense_query = self.dense_model.encode(text).tolist()
20
  sparse_query = next(self.sparse_model.query_embed(text))
21
 
22
- prefetch = [
23
- models.Prefetch(
24
- query=dense_query,
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(
@@ -54,6 +63,19 @@ class DocSearcher:
54
  )
55
  ]
56
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  else:
58
  return []
59
 
 
19
  dense_query = self.dense_model.encode(text).tolist()
20
  sparse_query = next(self.sparse_model.query_embed(text))
21
 
22
+ if type == 0:
23
+ prefetch = [
24
+ models.Prefetch(
25
+ query=dense_query,
26
+ using=DENSE_MODEL,
27
+ limit=100
28
+ ),
29
+ models.Prefetch(
30
+ query=models.SparseVector(**sparse_query.as_object()),
31
+ using=SPARSE_MODEL,
32
+ limit=100
33
+ )
34
+ ]
35
+ else:
36
+ prefetch = [
37
+ models.Prefetch(
38
+ query=dense_query,
39
+ using=DENSE_MODEL,
40
+ limit=100
41
+ )
42
+ ]
43
 
44
  if type == 0 and law_type is not None:
45
  filter = Filter(
 
63
  )
64
  ]
65
  )
66
+ elif type == 1 and law_type is not None:
67
+ filter = Filter(
68
+ must=[
69
+ FieldCondition(
70
+ key="tip_dokumenta",
71
+ match=MatchValue(value=type)
72
+ ),
73
+ FieldCondition(
74
+ key="vrsta_akta",
75
+ match=MatchValue(value=law_type)
76
+ ),
77
+ ]
78
+ )
79
  else:
80
  return []
81