Docs

api-search

Source: crates/lvcs-api/src/search.rs.

/// `search` (decision 303): the lines of main's text files that hold
/// `query`, ignoring case, in path order, at most `limit` (and at most
/// `SEARCH_RESULTS_MAX`), optionally only under the path prefix `under`.
/// It reads the main mirror's files, which are the documents' text.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
pub struct SearchParams {
    pub query: String,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub under: Option<String>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub limit: Option<u32>,
}

/// `search` result. `truncated` when more lines matched than it lists.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SearchResult {
    #[serde(default)]
    pub matches: Vec<SearchMatch>,
    #[serde(default)]
    pub truncated: bool,
}

/// One matching line.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SearchMatch {
    pub address: String,
    /// Its line, 1-based.
    pub line: usize,
    /// The line, cut to `RANGE_CONTEXT_MAX_CHARS` code points around the
    /// first match.
    pub text: String,
}