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
impl Searcher
Sourcepub fn new(idx: Index) -> Searcher
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.
Sourcepub fn search(&mut self, query: &Query) -> Result<SearchResults<MediaEntity>>
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.