pub struct WorksQuery {
pub free_form_queries: Vec<String>,
pub field_queries: Vec<FieldQuery>,
pub filter: Vec<WorksFilter>,
pub sort: Option<Sort>,
pub order: Option<Order>,
pub elements: Vec<WorkElement>,
pub facets: Vec<FacetCount>,
pub result_control: Option<WorkResultControl>,
pub sample: Option<usize>,
}Expand description
Used to construct a query that targets crossref Works elements
§Example
use crossref_client::{Order, WorksQuery};
// create a new query for topcis machine+learning ordered desc
let query = WorksQuery::new("machine learning").order(Order::Desc);Each query parameter is ANDed
Fields§
§free_form_queries: Vec<String>search by non specific query
field_queries: Vec<FieldQuery>match only particular fields of metadata
filter: Vec<WorksFilter>filter to apply while querying
sort: Option<Sort>sort results by a certain field and
order: Option<Order>set the sort order to asc or desc
elements: Vec<WorkElement>elements to return
facets: Vec<FacetCount>enable facet information in responses
result_control: Option<WorkResultControl>deep page through /works result sets
sample: Option<usize>request random dois if set all other parameters are ignored
Implementations§
Source§impl WorksQuery
impl WorksQuery
Sourcepub fn random(len: usize) -> Self
pub fn random(len: usize) -> Self
creates an new WorksQuery with the desired sample size that will result in
a request for random dois
Sourcepub fn new<T: ToString>(query: T) -> Self
pub fn new<T: ToString>(query: T) -> Self
Convenience method to create a new WorksQuery with a term directly
Sourcepub fn sample(self, len: impl Into<Option<usize>>) -> Self
pub fn sample(self, len: impl Into<Option<usize>>) -> Self
Ask for len random works instead of a search, or for a search if
given None. Crossref ignores every other parameter when it is set.
Sourcepub fn queries<T: ToString>(self, queries: &[T]) -> Self
pub fn queries<T: ToString>(self, queries: &[T]) -> Self
Create a new query for the topics renear+ontologies
§Example
use crossref_client::WorksQuery;
let query = WorksQuery::default().queries(&["renear", "ontologies"]);add a bunch of free form query terms
Sourcepub fn field_query(self, query: FieldQuery) -> Self
pub fn field_query(self, query: FieldQuery) -> Self
add a new field query form query
Sourcepub fn elements(self, element: Vec<WorkElement>) -> Self
pub fn elements(self, element: Vec<WorkElement>) -> Self
Narrow the response to the given fields.
Crossref returns only what is selected, so every field left out is
None on the resulting Work.
WorkElement::DOI is always sent, whether or not it is asked for: it
is the one field Work requires, so a response without
it could not be read back at all.
Sourcepub fn field_queries(self, queries: Vec<FieldQuery>) -> Self
pub fn field_queries(self, queries: Vec<FieldQuery>) -> Self
use crossref_client::{FieldQuery,WorksQuery};
let query = WorksQuery::default().field_queries(vec![FieldQuery::title("room at the bottom"), FieldQuery::author("richard feynman")]);add a bunch of free form query terms
Sourcepub fn filter(self, filter: WorksFilter) -> Self
pub fn filter(self, filter: WorksFilter) -> Self
add a new filter to the query
Sourcepub fn sort(self, sort: impl Into<Option<Sort>>) -> Self
pub fn sort(self, sort: impl Into<Option<Sort>>) -> Self
Sort the results by a field, or by relevance if given None.
Sourcepub fn order(self, order: impl Into<Option<Order>>) -> Self
pub fn order(self, order: impl Into<Option<Order>>) -> Self
Order the results, or leave the order to crossref if given None.
Sourcepub fn facet(self, facet: FacetCount) -> Self
pub fn facet(self, facet: FacetCount) -> Self
add another facet to query
Sourcepub fn next_cursor(self, cursor: &str) -> Self
pub fn next_cursor(self, cursor: &str) -> Self
set the cursor for result control deep paging
Sourcepub fn new_cursor(self) -> Self
pub fn new_cursor(self) -> Self
set an empty cursor
Sourcepub fn result_control(
self,
result_control: impl Into<Option<WorkResultControl>>,
) -> Self
pub fn result_control( self, result_control: impl Into<Option<WorkResultControl>>, ) -> Self
Limit the results, or take crossref’s default page if given None.
Sourcepub fn into_combined<W: WorksCombiner>(self, id: &str) -> W
pub fn into_combined<W: WorksCombiner>(self, id: &str) -> W
Wrap the query in a combined query.
§Example
Create a Funders Query that targets all works of a funder with id funder id.
let funders: Funders = WorksQuery::default().into_combined("funder id");Sourcepub fn into_ident(self, id: &str) -> WorksIdentQuery
pub fn into_ident(self, id: &str) -> WorksIdentQuery
Bind the query to a specific id of a primary endpoint element
Sourcepub fn into_combined_query<W: WorksCombiner>(self, id: &str) -> WorkListQuery
pub fn into_combined_query<W: WorksCombiner>(self, id: &str) -> WorkListQuery
wrap this query in new WorkListQuery that targets the /works route of a primary component with an id.
The query will evaluate to the same as WorksQuery::into_combined
§Example
Create a query that targets all Works of a funder with id funder id
let query = WorksQuery::default()
.into_combined_query::<Funders>("funder id");