Skip to main content

paper/core/search/
hit.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize)]
4pub struct Hit {
5    pub source_id: i64,
6    pub path: String,
7    /// The file on disk this chunk came from. Differs from `path` for archive
8    /// members, which are addressed as `outer.zip!/inner/path`.
9    #[serde(default)]
10    pub source_path: String,
11    /// 1-based page for paged formats, 0 when the format has no pages.
12    pub page: i64,
13    pub line_start: i64,
14    pub line_end: i64,
15    /// Format-specific citation anchor: `page 3`, `Sheet1!A5:H5`, `slide 2`,
16    /// `para 4-9`, `spine 1: chapter.xhtml`, `message <id>`.
17    #[serde(skip_serializing_if = "Option::is_none")]
18    pub anchor: Option<String>,
19    /// Heading path the chunk sits under, as the parser reported it.
20    #[serde(default, skip_serializing_if = "Option::is_none")]
21    pub section: Option<String>,
22    pub snippet: String,
23    /// Full chunk text. Kept separate from `snippet` (which is truncated for
24    /// display) because confidence checks and the cross-encoder need the whole
25    /// passage, not the first 240 characters.
26    pub content: String,
27    pub score: f32,
28    pub why_matched: String,
29    pub confidence: Confidence,
30    pub engine: Engine,
31}
32
33#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
34pub enum Confidence {
35    High,
36    Medium,
37    Low,
38}
39
40#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
41pub enum Engine {
42    Local,
43}