Resolve a source path that may be a `$variable` reference. If it starts with `$`, extract vault paths from the bound nodes (using the node label or metadata path field).
(source: &str, bindings: &HashMap<String, Vec<KgNode>>)
| 394 | /// If it starts with `$`, extract vault paths from the bound nodes |
| 395 | /// (using the node label or metadata path field). |
| 396 | fn resolve_paths(source: &str, bindings: &HashMap<String, Vec<KgNode>>) -> Vec<String> { |
| 397 | if let Some(var_name) = source.strip_prefix('$') { |
| 398 | bindings |
| 399 | .get(var_name) |
| 400 | .map(|nodes| { |
| 401 | nodes |
| 402 | .iter() |
| 403 | .filter_map(|n| { |
| 404 | // Try metadata.path first (from vector search results) |
| 405 | n.metadata |
| 406 | .as_ref() |
| 407 | .and_then(|m| m.get("path")) |
| 408 | .and_then(|p| p.as_str()) |
| 409 | .map(String::from) |
| 410 | .or_else(|| { |
| 411 | // Fall back to node label if it looks like a path |
| 412 | if n.label.contains('/') || n.label.contains('.') { |
| 413 | Some(n.label.clone()) |
| 414 | } else { |
| 415 | None |
| 416 | } |
| 417 | }) |
| 418 | }) |
| 419 | .collect() |
| 420 | }) |
| 421 | .unwrap_or_default() |
| 422 | } else { |
| 423 | vec![source.to_string()] |
| 424 | } |
| 425 | } |
| 426 | |
| 427 | /// Get a field value from a KgNode for filtering. |
| 428 | fn get_node_field(node: &KgNode, field: &str) -> Option<String> { |