pub struct Query {
pub search: Option<Search>,
pub id_list: Vec<ArticleId>,
pub start: Option<usize>,
pub max_results: Option<usize>,
pub sort_by: Option<SortBy>,
pub sort_order: Option<SortOrder>,
}Expand description
One request to arXiv’s /api/query route.
let query = Query::new(Search::category("cs.LG").and(Search::title("transformer")))
.max_results(50)
.sort_by(SortBy::SubmittedDate);A Search, a &str (read as a search of every field) and an
ArticleId all convert into a Query, so the common cases need no
builder at all.
Fields§
§search: Option<Search>the expression to match, sent as search_query
id_list: Vec<ArticleId>the articles to fetch, sent as id_list
With a search beside it these are narrowed to the ones that also
match; on their own they are returned as they are.
start: Option<usize>the offset into the result set to start at, sent as start
max_results: Option<usize>how many results to return, sent as max_results
sort_by: Option<SortBy>what to order the results by, sent as sortBy
sort_order: Option<SortOrder>which end of that ordering comes first, sent as sortOrder
Implementations§
Source§impl Query
impl Query
Sourcepub const MAX_RESULTS: usize = 2_000
pub const MAX_RESULTS: usize = 2_000
The most results arXiv’s user manual says it serves in one request.
Query::route refuses more, and Arxiv::paginate
is how to reach the rest. The api does not police the number itself –
asked for 2100 it currently answers with 2100 – but that is undocumented
behaviour of a request arXiv already describes as slow, and it gives out
entirely, with a 500, not far above.
Sourcepub const MAX_REACHABLE: usize = 30_000
pub const MAX_REACHABLE: usize = 30_000
The deepest arXiv lets a query page.
A start at or near this is answered with a 500, whatever
totalResults said, so a search that has to reach further has to be
split into narrower ones – by date range, or by category.
Arxiv::paginate stops here rather than
walking into it.
Sourcepub fn ids<I>(ids: I) -> Result<Self>
pub fn ids<I>(ids: I) -> Result<Self>
A query for the articles with these identifiers.
let query = Query::ids(["2101.00001", "hep-ex/0307015"])?;Sourcepub fn search(self, search: impl Into<Option<Search>>) -> Self
pub fn search(self, search: impl Into<Option<Search>>) -> Self
Narrow this query to articles matching search as well.
Sourcepub fn start(self, start: impl Into<Option<usize>>) -> Self
pub fn start(self, start: impl Into<Option<usize>>) -> Self
Start at the startth result rather than the first.
Sourcepub fn max_results(self, max_results: impl Into<Option<usize>>) -> Self
pub fn max_results(self, max_results: impl Into<Option<usize>>) -> Self
Return at most max_results results, at most Query::MAX_RESULTS of
them. Defaults to the 10 arXiv returns when not asked.
Sourcepub fn sort_by(self, sort_by: impl Into<Option<SortBy>>) -> Self
pub fn sort_by(self, sort_by: impl Into<Option<SortBy>>) -> Self
Order the results by sort_by. Defaults to arXiv’s own relevance order.
Sourcepub fn sort_order(self, sort_order: impl Into<Option<SortOrder>>) -> Self
pub fn sort_order(self, sort_order: impl Into<Option<SortOrder>>) -> Self
Return the results ascending or descending.
Sourcepub fn route(&self) -> Result<String>
pub fn route(&self) -> Result<String>
The route this query renders to, /api/query?….
§Errors
Refuses a query arXiv would answer with an error feed rather than
results: one that names neither a search nor an identifier, one whose
max_results is over Query::MAX_RESULTS, and one carrying a term
that cannot survive the query syntax – see
Error::UnsendableTerm.
Trait Implementations§
impl Eq for Query
Source§impl From<&str> for Query
Reads free form text as a search of every field, so
client.search("electron") means what it looks like.
impl From<&str> for Query
Reads free form text as a search of every field, so
client.search("electron") means what it looks like.
impl StructuralPartialEq for Query
Auto Trait Implementations§
impl Freeze for Query
impl RefUnwindSafe for Query
impl Send for Query
impl Sync for Query
impl Unpin for Query
impl UnsafeUnpin for Query
impl UnwindSafe for Query
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.