MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / extract_index_values

Function extract_index_values

nodedb/src/engine/document/store/extract.rs:13–24  ·  view source on GitHub ↗

Extract scalar values at a JSON path for secondary indexing.

(doc: &serde_json::Value, path: &str, is_array: bool)

Source from the content-addressed store, hash-verified

11
12/// Extract scalar values at a JSON path for secondary indexing.
13pub fn extract_index_values(doc: &serde_json::Value, path: &str, is_array: bool) -> Vec<String> {
14 let path = normalize_path(path);
15 let target = navigate_json(doc, path);
16
17 match target {
18 Some(serde_json::Value::Array(arr)) if is_array => {
19 arr.iter().filter_map(json_scalar_to_string).collect()
20 }
21 Some(val) => json_scalar_to_string(val).into_iter().collect(),
22 None => Vec::new(),
23 }
24}
25
26/// Extract values from an rmpv::Value at a path.
27pub(crate) fn extract_index_values_rmpv(

Callers 6

apply_point_putMethod · 0.85
check_unique_constraintsFunction · 0.85
execute_point_deleteMethod · 0.85

Calls 5

normalize_pathFunction · 0.85
navigate_jsonFunction · 0.85
json_scalar_to_stringFunction · 0.85
collectMethod · 0.80
iterMethod · 0.45

Tested by

no test coverage detected