finance_query/models/filings/full_text.rs
1//! Provider-neutral full-text filing search models.
2//!
3//! Served through the [`Capability::FILINGS`](crate::Capability::FILINGS)
4//! route; EDGAR is currently the only provider. Distinct from
5//! [`EdgarSearchResults`](super::EdgarSearchResults), which mirrors EDGAR's raw
6//! Elasticsearch envelope — this is the flattened shape the routed API returns.
7
8use serde::{Deserialize, Serialize};
9
10/// Which parts of a full-text search to constrain.
11#[derive(Debug, Clone, Default)]
12#[non_exhaustive]
13pub struct FilingSearchFilters {
14 /// Restrict to these form types (e.g. `["10-K", "8-K"]`).
15 pub forms: Option<Vec<String>>,
16 /// Earliest filing date, `YYYY-MM-DD`.
17 pub start_date: Option<String>,
18 /// Latest filing date, `YYYY-MM-DD`.
19 pub end_date: Option<String>,
20 /// Restrict to a single filer's CIK (zero-padded or not).
21 pub cik: Option<String>,
22 /// Maximum hits to return. Providers cap this; EDGAR's ceiling is 100.
23 pub limit: Option<u32>,
24}
25
26impl FilingSearchFilters {
27 /// Restrict the search to these form types.
28 pub fn forms<S: Into<String>, I: IntoIterator<Item = S>>(mut self, forms: I) -> Self {
29 self.forms = Some(forms.into_iter().map(Into::into).collect());
30 self
31 }
32
33 /// Restrict the search to filings on or after `date` (`YYYY-MM-DD`).
34 pub fn from(mut self, date: impl Into<String>) -> Self {
35 self.start_date = Some(date.into());
36 self
37 }
38
39 /// Restrict the search to filings on or before `date` (`YYYY-MM-DD`).
40 pub fn to(mut self, date: impl Into<String>) -> Self {
41 self.end_date = Some(date.into());
42 self
43 }
44
45 /// Restrict the search to one filer.
46 pub fn cik(mut self, cik: impl Into<String>) -> Self {
47 self.cik = Some(cik.into());
48 self
49 }
50
51 /// Cap the number of hits returned.
52 pub fn limit(mut self, limit: u32) -> Self {
53 self.limit = Some(limit);
54 self
55 }
56}
57
58/// One filing matching a full-text search.
59#[derive(Debug, Clone, Default, Serialize, Deserialize)]
60#[non_exhaustive]
61pub struct FilingSearchHit {
62 /// Accession number of the filing.
63 pub accession_number: Option<String>,
64 /// Form type (e.g. `"10-K"`).
65 pub form: Option<String>,
66 /// Filing date (`YYYY-MM-DD`).
67 pub filed_date: Option<String>,
68 /// Period the filing covers (`YYYY-MM-DD`).
69 pub period_ending: Option<String>,
70 /// Filer display names, as the provider spells them.
71 pub company_names: Vec<String>,
72 /// Filer CIKs.
73 pub ciks: Vec<String>,
74 /// Relevance score assigned by the provider's search index.
75 pub score: Option<f64>,
76 /// Direct URL to the matching document, when it can be derived.
77 pub url: Option<String>,
78}