pub struct SearchBuilder<Q, E, L> { /* private fields */ }
Expand description
A SearchBuilder
can be used to configure and perform a search
Implementations§
Source§impl<E, L> SearchBuilder<NoQuery, E, L>
impl<E, L> SearchBuilder<NoQuery, E, L>
Sourcepub fn query(self, query: impl Into<String>) -> SearchBuilder<WithQuery, E, L>
pub fn query(self, query: impl Into<String>) -> SearchBuilder<WithQuery, E, L>
Search for page titles or content matching this value
Source§impl<Q, L> SearchBuilder<Q, NoEndpoint, L>
impl<Q, L> SearchBuilder<Q, NoEndpoint, L>
Sourcepub fn endpoint(self, endpoint: Endpoint) -> SearchBuilder<Q, WithEndpoint, L>
pub fn endpoint(self, endpoint: Endpoint) -> SearchBuilder<Q, WithEndpoint, L>
API endpoint for the MediaWiki site to perform the search on
Source§impl<Q, E> SearchBuilder<Q, E, NoLanguage>
impl<Q, E> SearchBuilder<Q, E, NoLanguage>
Sourcepub fn language(self, language: Language) -> SearchBuilder<Q, E, WithLanguage>
pub fn language(self, language: Language) -> SearchBuilder<Q, E, WithLanguage>
Language where the search will be performed in
Source§impl<Q, E, L> SearchBuilder<Q, E, L>
impl<Q, E, L> SearchBuilder<Q, E, L>
Sourcepub fn limit(self, limit: usize) -> Self
pub fn limit(self, limit: usize) -> Self
How many total pages to return. The value must be between 1 and 500
Default: 10
Sourcepub fn offset(self, offset: usize) -> Self
pub fn offset(self, offset: usize) -> Self
When more results are available, use the offset to continue
Default: 0
Sourcepub fn qiprofile(self, qiprofile: QiProfile) -> Self
pub fn qiprofile(self, qiprofile: QiProfile) -> Self
Query independent profile to use which affects the ranking algorithm
Default: QiProfile::EngineAutoselect
Sourcepub fn search_type(self, search_type: SearchType) -> Self
pub fn search_type(self, search_type: SearchType) -> Self
Which search to perform
Default: SearchType::Text
Sourcepub fn info(self, info: Info) -> Self
pub fn info(self, info: Info) -> Self
Which metadata to return
Default: [Info::TotalHits
, Info::Suggestion
, Info::RewrittenQuery
]
Sourcepub fn properties(self, properties: Vec<Property>) -> Self
pub fn properties(self, properties: Vec<Property>) -> Self
Which properties about the search results to return
Default: [Property::Size
, Property::WordCount
, Property::Timestamp
,
Property::Snippet
]
Sourcepub fn interwiki(self, interwiki: bool) -> Self
pub fn interwiki(self, interwiki: bool) -> Self
Include interwiki results in the search, if available
Default: false
Sourcepub fn rewrites(self, rewrites: bool) -> Self
pub fn rewrites(self, rewrites: bool) -> Self
Enable internal query rewriting. Some search backends can rewrite the query into another which is thought to provide better results, for instance by correcting spelling errors
Default: false
Sourcepub fn sort_order(self, sort_order: SortOrder) -> Self
pub fn sort_order(self, sort_order: SortOrder) -> Self
Set the sort order of returend results
Default: SortOrder::Relevance
Source§impl SearchBuilder<WithQuery, WithEndpoint, WithLanguage>
impl SearchBuilder<WithQuery, WithEndpoint, WithLanguage>
Sourcepub async fn search(self) -> Result<Search>
pub async fn search(self) -> Result<Search>
Performes the search and returns the result. The search can only be made when the query, endpoint and language are set
§Example
// This searches for the pages containing 'meaning' in the english wikipedia
let search = Search::builder()
.query("meaning")
.endpoint(Url::from("https://en.wikipedia.org/w/api.php")?)
.language(Language::English)
.search()?;
§Error
This function returns an error when one of the following things happens:
- The request to the server could not be made
- The server returned an error
- The returned result could not interpreted as a
Search