@@ -65,14 +65,15 @@ async def edge_fulltext_search(
65
65
group_ids : list [str | None ] | None = None ,
66
66
limit = RELEVANT_SCHEMA_LIMIT ,
67
67
) -> list [EntityEdge ]:
68
- group_ids = group_ids if group_ids is not None else [None ]
69
-
70
68
# fulltext search over facts
71
69
cypher_query = Query ("""
72
70
CALL db.index.fulltext.queryRelationships("name_and_fact", $query)
73
71
YIELD relationship AS rel, score
74
72
MATCH (n:Entity {uuid: $source_uuid})-[r {uuid: rel.uuid}]-(m:Entity {uuid: $target_uuid})
75
- WHERE r.group_id IN $group_ids
73
+ WHERE CASE
74
+ WHEN $group_ids IS NULL THEN n.group_id IS NULL
75
+ ELSE n.group_id IN $group_ids
76
+ END
76
77
RETURN
77
78
r.uuid AS uuid,
78
79
r.group_id AS group_id,
@@ -94,7 +95,10 @@ async def edge_fulltext_search(
94
95
CALL db.index.fulltext.queryRelationships("name_and_fact", $query)
95
96
YIELD relationship AS rel, score
96
97
MATCH (n:Entity)-[r {uuid: rel.uuid}]-(m:Entity)
97
- WHERE r.group_id IN $group_ids
98
+ WHERE CASE
99
+ WHEN $group_ids IS NULL THEN r.group_id IS NULL
100
+ ELSE r.group_id IN $group_ids
101
+ END
98
102
RETURN
99
103
r.uuid AS uuid,
100
104
r.group_id AS group_id,
@@ -115,7 +119,10 @@ async def edge_fulltext_search(
115
119
CALL db.index.fulltext.queryRelationships("name_and_fact", $query)
116
120
YIELD relationship AS rel, score
117
121
MATCH (n:Entity)-[r {uuid: rel.uuid}]-(m:Entity {uuid: $target_uuid})
118
- WHERE r.group_id IN $group_ids
122
+ WHERE CASE
123
+ WHEN $group_ids IS NULL THEN r.group_id IS NULL
124
+ ELSE r.group_id IN $group_ids
125
+ END
119
126
RETURN
120
127
r.uuid AS uuid,
121
128
r.group_id AS group_id,
@@ -136,7 +143,10 @@ async def edge_fulltext_search(
136
143
CALL db.index.fulltext.queryRelationships("name_and_fact", $query)
137
144
YIELD relationship AS rel, score
138
145
MATCH (n:Entity {uuid: $source_uuid})-[r {uuid: rel.uuid}]-(m:Entity)
139
- WHERE r.group_id IN $group_ids
146
+ WHERE CASE
147
+ WHEN $group_ids IS NULL THEN r.group_id IS NULL
148
+ ELSE r.group_id IN $group_ids
149
+ END
140
150
RETURN
141
151
r.uuid AS uuid,
142
152
r.group_id AS group_id,
@@ -177,13 +187,15 @@ async def edge_similarity_search(
177
187
group_ids : list [str | None ] | None = None ,
178
188
limit : int = RELEVANT_SCHEMA_LIMIT ,
179
189
) -> list [EntityEdge ]:
180
- group_ids = group_ids if group_ids is not None else [None ]
181
190
# vector similarity search over embedded facts
182
191
query = Query ("""
183
192
CALL db.index.vector.queryRelationships("fact_embedding", $limit, $search_vector)
184
193
YIELD relationship AS rel, score
185
194
MATCH (n:Entity {uuid: $source_uuid})-[r {uuid: rel.uuid}]-(m:Entity {uuid: $target_uuid})
186
- WHERE r.group_id IN $group_ids
195
+ WHERE CASE
196
+ WHEN $group_ids IS NULL THEN r.group_id IS NULL
197
+ ELSE r.group_id IN $group_ids
198
+ END
187
199
RETURN
188
200
r.uuid AS uuid,
189
201
r.group_id AS group_id,
@@ -205,7 +217,10 @@ async def edge_similarity_search(
205
217
CALL db.index.vector.queryRelationships("fact_embedding", $limit, $search_vector)
206
218
YIELD relationship AS rel, score
207
219
MATCH (n:Entity)-[r {uuid: rel.uuid}]-(m:Entity)
208
- WHERE r.group_id IN $group_ids
220
+ WHERE CASE
221
+ WHEN $group_ids IS NULL THEN r.group_id IS NULL
222
+ ELSE r.group_id IN $group_ids
223
+ END
209
224
RETURN
210
225
r.uuid AS uuid,
211
226
r.group_id AS group_id,
@@ -226,7 +241,10 @@ async def edge_similarity_search(
226
241
CALL db.index.vector.queryRelationships("fact_embedding", $limit, $search_vector)
227
242
YIELD relationship AS rel, score
228
243
MATCH (n:Entity)-[r {uuid: rel.uuid}]-(m:Entity {uuid: $target_uuid})
229
- WHERE r.group_id IN $group_ids
244
+ WHERE CASE
245
+ WHEN $group_ids IS NULL THEN r.group_id IS NULL
246
+ ELSE r.group_id IN $group_ids
247
+ END
230
248
RETURN
231
249
r.uuid AS uuid,
232
250
r.group_id AS group_id,
@@ -247,7 +265,10 @@ async def edge_similarity_search(
247
265
CALL db.index.vector.queryRelationships("fact_embedding", $limit, $search_vector)
248
266
YIELD relationship AS rel, score
249
267
MATCH (n:Entity {uuid: $source_uuid})-[r {uuid: rel.uuid}]-(m:Entity)
250
- WHERE r.group_id IN $group_ids
268
+ WHERE CASE
269
+ WHEN $group_ids IS NULL THEN r.group_id IS NULL
270
+ ELSE r.group_id IN $group_ids
271
+ END
251
272
RETURN
252
273
r.uuid AS uuid,
253
274
r.group_id AS group_id,
@@ -284,15 +305,16 @@ async def node_fulltext_search(
284
305
group_ids : list [str | None ] | None = None ,
285
306
limit = RELEVANT_SCHEMA_LIMIT ,
286
307
) -> list [EntityNode ]:
287
- group_ids = group_ids if group_ids is not None else [None ]
288
-
289
308
# BM25 search to get top nodes
290
309
fuzzy_query = re .sub (r'[^\w\s]' , '' , query ) + '~'
291
310
records , _ , _ = await driver .execute_query (
292
311
"""
293
312
CALL db.index.fulltext.queryNodes("name_and_summary", $query)
294
313
YIELD node AS n, score
295
- MATCH (n WHERE n.group_id in $group_ids)
314
+ WHERE CASE
315
+ WHEN $group_ids IS NULL THEN n.group_id IS NULL
316
+ ELSE n.group_id IN $group_ids
317
+ END
296
318
RETURN
297
319
n.uuid AS uuid,
298
320
n.group_id AS group_id,
0 commit comments