Struct SearchBuilder

Source
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>

Source

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>

Source

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>

Source

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>

Source

pub fn namespace(self, namespace: Namespace) -> Self

Search only in this specific namespace

Source

pub fn limit(self, limit: usize) -> Self

How many total pages to return. The value must be between 1 and 500

Default: 10

Source

pub fn offset(self, offset: usize) -> Self

When more results are available, use the offset to continue Default: 0

Source

pub fn qiprofile(self, qiprofile: QiProfile) -> Self

Query independent profile to use which affects the ranking algorithm

Default: QiProfile::EngineAutoselect

Source

pub fn search_type(self, search_type: SearchType) -> Self

Which search to perform

Default: SearchType::Text

Source

pub fn info(self, info: Info) -> Self

Which metadata to return

Default: [Info::TotalHits, Info::Suggestion, Info::RewrittenQuery]

Source

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]

Source

pub fn interwiki(self, interwiki: bool) -> Self

Include interwiki results in the search, if available

Default: false

Source

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

Source

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>

Source

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

Trait Implementations§

Source§

impl<Q: Default, E: Default, L: Default> Default for SearchBuilder<Q, E, L>

Source§

fn default() -> SearchBuilder<Q, E, L>

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

Auto Trait Implementations§

§

impl<Q, E, L> Freeze for SearchBuilder<Q, E, L>
where Q: Freeze, E: Freeze, L: Freeze,

§

impl<Q, E, L> RefUnwindSafe for SearchBuilder<Q, E, L>

§

impl<Q, E, L> Send for SearchBuilder<Q, E, L>
where Q: Send, E: Send, L: Send,

§

impl<Q, E, L> Sync for SearchBuilder<Q, E, L>
where Q: Sync, E: Sync, L: Sync,

§

impl<Q, E, L> Unpin for SearchBuilder<Q, E, L>
where Q: Unpin, E: Unpin, L: Unpin,

§

impl<Q, E, L> UnwindSafe for SearchBuilder<Q, E, L>
where Q: UnwindSafe, E: UnwindSafe, L: UnwindSafe,

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,