12
12
)
13
13
14
14
15
- def siaes_similarity_search (search_text : str , search_filter : dict = {} ):
15
+ def siaes_similarity_search (search_text : str , search_filter : list = [], siae_kinds : list = [] ):
16
16
"""Performs semantic search with Elasticsearch as a vector db
17
17
18
18
Args:
@@ -21,6 +21,10 @@ def siaes_similarity_search(search_text: str, search_filter: dict = {}):
21
21
Returns:
22
22
list: list of siaes id that match the search query
23
23
"""
24
+
25
+ if siae_kinds :
26
+ search_filter .append ({"terms" : {"metadata.kind.keyword" : siae_kinds }})
27
+
24
28
db = ElasticsearchStore (
25
29
embedding = OpenAIEmbeddings (),
26
30
es_user = settings .ELASTICSEARCH_USERNAME ,
@@ -40,7 +44,7 @@ def siaes_similarity_search(search_text: str, search_filter: dict = {}):
40
44
41
45
42
46
def siaes_similarity_search_with_geo_distance (
43
- search_text : str , geo_distance : int = None , geo_lat : float = None , geo_lon : float = None
47
+ search_text : str , geo_distance : int = None , geo_lat : float = None , geo_lon : float = None , siae_kinds : list = []
44
48
):
45
49
search_filter = []
46
50
if geo_distance and geo_lat and geo_lon :
@@ -56,10 +60,10 @@ def siaes_similarity_search_with_geo_distance(
56
60
}
57
61
]
58
62
59
- return siaes_similarity_search (search_text , search_filter )
63
+ return siaes_similarity_search (search_text , search_filter , siae_kinds )
60
64
61
65
62
- def siaes_similarity_search_with_city (search_text : str , city : Perimeter ):
66
+ def siaes_similarity_search_with_city (search_text : str , city : Perimeter , siae_kinds : list = [] ):
63
67
search_filter = [
64
68
{
65
69
"bool" : {
@@ -88,4 +92,4 @@ def siaes_similarity_search_with_city(search_text: str, city: Perimeter):
88
92
}
89
93
}
90
94
]
91
- return siaes_similarity_search (search_text , search_filter )
95
+ return siaes_similarity_search (search_text , search_filter , siae_kinds )
0 commit comments