Searcher

Struct Searcher 

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

A handle that permits searching IMDb media records with relevance ranking.

A searcher is constructed by providing it a handle to an IMDb Index. The Index is responsible for managing the lower level data access, while the Searcher provides high level routines for ranking results.

The primary interface to a Searcher is its search method, which takes as input a Query and returns a ranked list of MediaEntity as output.

Implementations§

Source§

impl Searcher

Source

pub fn new(idx: Index) -> Searcher

Create a new searcher for the given Index.

A single searcher can be used to execute many queries.

An existing Index can be opened with Index::open, and a new Index can be created with Index::create.

Source

pub fn search(&mut self, query: &Query) -> Result<SearchResults<MediaEntity>>

Execute a search with the given Query.

Generally, the results returned are ranked in relevance order, where each result has a score associated with it. The score is between 0 and 1.0 (inclusive), where a score of 1.0 means “most similar” and a score of 0 means “least similar.”

Depending on the query, the behavior of search can vary:

  • When the query specifies a similarity function, then the results are ranked by that function.
  • When the query contains a name to search by and a name scorer, then results are ranked by the name scorer. If the query specifies a similarity function, then results are first ranked by the name scorer, and then re-ranked by the similarity function.
  • When no name or no name scorer are specified by the query, then this search will do a (slow) exhaustive search over all media records in IMDb. As a special case, if the query contains a TV show ID, then only records in that TV show are searched, and this is generally fast.
  • If the query is empty, then no results are returned.

If there was a problem reading the underlying index or the IMDb data, then an error is returned.

Source

pub fn index(&mut self) -> &mut Index

Return a mutable reference to the underlying index for this searcher.

Trait Implementations§

Source§

impl Debug for Searcher

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> 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, 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.