Skip to content

Commit 730e9ed

Browse files
Add indices to MatchRange (v1.12 feature)
See meilisearch/meilisearch#5005
1 parent 40f9402 commit 730e9ed

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/search.rs

Lines changed: 11 additions & 0 deletions
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)]

0 commit comments

Comments
 (0)