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>>)
| 477 | /// If it starts with `$`, extract vault paths from the bound nodes |
| 478 | /// (using the node label or metadata path field). |
| 479 | fn resolve_paths(source: &str, bindings: &HashMap<String, Vec<KgNode>>) -> Vec<String> { |
| 480 | if let Some(var_name) = source.strip_prefix('$') { |
| 481 | bindings |
| 482 | .get(var_name) |
| 483 | .map(|nodes| { |
| 484 | nodes |
| 485 | .iter() |
| 486 | .filter_map(|n| { |
| 487 | // Try metadata.path first (from vector search results) |
| 488 | n.metadata |
| 489 | .as_ref() |
| 490 | .and_then(|m| m.get("path")) |
| 491 | .and_then(|p| p.as_str()) |
| 492 | .map(String::from) |
| 493 | .or_else(|| { |
| 494 | // Fall back to node label if it looks like a path |
| 495 | if n.label.contains('/') || n.label.contains('.') { |
| 496 | Some(n.label.clone()) |
| 497 | } else { |
| 498 | None |
| 499 | } |
| 500 | }) |
| 501 | }) |
| 502 | .collect() |
| 503 | }) |
| 504 | .unwrap_or_default() |
| 505 | } else { |
| 506 | vec![source.to_string()] |
| 507 | } |
| 508 | } |
| 509 | |
| 510 | /// Get a field value from a KgNode for filtering. |
| 511 | fn get_node_field(node: &KgNode, field: &str) -> Option<String> { |