Query

Struct Query 

Source
pub struct Query { /* private fields */ }
Expand description

A query that can be used to search IMDb media records.

A query typically consists of a fuzzy name query along with zero or more filters. If a query lacks a fuzzy name query, then this will generally result in an exhaustive search of all IMDb media records, which can be slow.

Filters are matched conjunctively. That is, a search result must satisfy every filter on a query to match.

Empty queries always return no results.

The Serialize and Deserialize implementations for this type use the free-form query syntax.

Implementations§

Source§

impl Query

Source

pub fn new() -> Query

Create a new empty query.

Source

pub fn is_empty(&self) -> bool

Return true if and only if this query is empty.

Searching with an empty query always yields no results.

Source

pub fn name(self, name: &str) -> Query

Set the name to query by.

The name given here is normalized and broken down into components automatically to facilitate fuzzy searching.

Note that if no name is provided in a query, then it is possible that searching with the query will require exhaustively looking at every record in IMDb. This will be slower.

Source

pub fn name_scorer(self, scorer: Option<NameScorer>) -> Query

Set the scorer to use for name searches.

The name scorer is used to rank results from searching the IMDb name index. If no name query is given, then this scorer is not used.

If None is provided here, then the name index will not be used. This will likely cause an exhaustive search of all IMDb records, which can be slow. The use case for providing a name query without a name scorer is if you, for example, wanted to rank all of the records in IMDb by the Levenshtein distance between your query and every other record in IMDb. Normally, when the name index is used, only the (small number) of results returned by searching the name are ranked. Typically, these sorts of queries are useful for evaluation purposes, but not much else.

Source

pub fn similarity(self, sim: Similarity) -> Query

Set the similarity function.

The similarity function can be selected from a predefined set of choices defined by the Similarity type.

When a similarity function is used, then any results from searching the name index are re-ranked according to their similarity with the query.

By default, no similarity function is used.

Source

pub fn size(self, size: usize) -> Query

Set the maximum number of results to be returned by a search.

Note that setting this number too high (e.g., > 10,000) can impact performance. This is a normal restriction found in most information retrieval systems. That is, deep paging through result sets is expensive.

Source

pub fn kind(self, kind: TitleKind) -> Query

Add a title kind to filter by.

Multiple title kinds can be added to query, and search results must match at least one of them.

Note that it is not possible to remove title kinds from an existing query. Instead, build a new query from scratch.

Source

pub fn year_ge(self, year: u32) -> Query

Set the lower inclusive bound on a title’s year.

This applies to either the title’s start or end years.

Source

pub fn year_le(self, year: u32) -> Query

Set the upper inclusive bound on a title’s year.

This applies to either the title’s start or end years.

Source

pub fn votes_ge(self, votes: u32) -> Query

Set the lower inclusive bound on a title’s number of votes.

Source

pub fn votes_le(self, votes: u32) -> Query

Set the upper inclusive bound on a title’s number of votes.

Source

pub fn season_ge(self, season: u32) -> Query

Set the lower inclusive bound on a title’s season.

This automatically limits all results to episodes.

Source

pub fn season_le(self, season: u32) -> Query

Set the upper inclusive bound on a title’s season.

This automatically limits all results to episodes.

Source

pub fn episode_ge(self, episode: u32) -> Query

Set the lower inclusive bound on a title’s episode number.

This automatically limits all results to episodes.

Source

pub fn episode_le(self, episode: u32) -> Query

Set the upper inclusive bound on a title’s episode number.

This automatically limits all results to episodes.

Source

pub fn tvshow_id(self, tvshow_id: &str) -> Query

Restrict results to episodes belonging to the TV show given by its IMDb ID.

This automatically limits all results to episodes.

Trait Implementations§

Source§

impl Clone for Query

Source§

fn clone(&self) -> Query

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Query

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Query

Source§

fn default() -> Query

Returns the “default value” for a type. Read more
Source§

impl<'a> Deserialize<'a> for Query

Source§

fn deserialize<D>(d: D) -> Result<Query, D::Error>
where D: Deserializer<'a>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Query

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FromStr for Query

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

fn from_str(qstr: &str) -> Result<Query>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for Query

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Query

Source§

fn eq(&self, other: &Query) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Query

Source§

fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Query

Source§

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 UnwindSafe for Query

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,