Skip to content

Commit fb45587

Browse files
Merge branch 'main' into vector-search-embedder
2 parents 279e974 + 548ec19 commit fb45587

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/search.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ use std::collections::HashMap;
1010
pub struct MatchRange {
1111
pub start: usize,
1212
pub length: usize,
13+
14+
/// If the match is somewhere inside a (potentially nested) array, this
15+
/// field is set to the index/indices of the matched element(s).
16+
///
17+
/// In the simple case, if the field has the value `["foo", "bar"]`, then
18+
/// searching for `ba` will return `indices: Some([1])`. If the value
19+
/// contains multiple nested arrays, the first index describes the most
20+
/// top-level array, and descending from there. For example, if the value is
21+
/// `[{ x: "cat" }, "bear", { y: ["dog", "fox"] }]`, searching for `dog`
22+
/// will return `indices: Some([2, 0])`.
23+
pub indices: Option<Vec<usize>>,
1324
}
1425

1526
#[derive(Serialize, Debug, Eq, PartialEq, Clone)]
@@ -1229,7 +1240,8 @@ mod tests {
12291240
.unwrap(),
12301241
&vec![MatchRange {
12311242
start: 0,
1232-
length: 5
1243+
length: 5,
1244+
indices: None,
12331245
}]
12341246
);
12351247
Ok(())

0 commit comments

Comments
 (0)