shared::domain::image

Struct ImageSearchQuery

Source
pub struct ImageSearchQuery {
    pub q: String,
    pub size: Option<ImageSize>,
    pub page: Option<u32>,
    pub styles: Vec<ImageStyleId>,
    pub age_ranges: Vec<AgeRangeId>,
    pub affiliations: Vec<AffiliationId>,
    pub categories: Vec<CategoryId>,
    pub tags: Vec<ImageTagIndex>,
    pub tags_priority: Vec<ImageTagIndex>,
    pub is_premium: Option<bool>,
    pub is_published: Option<bool>,
    pub page_limit: Option<u32>,
}
Expand description

Search for images via the given query string.

  • kind field must match the case as represented in the returned json body (PascalCase?).
  • Vector fields, such as age_ranges should be given as a comma separated vector (CSV).

Fields§

§q: String

The query string.

§size: Option<ImageSize>

Optionally filter by kind

§page: Option<u32>

The page number of the images to get.

§styles: Vec<ImageStyleId>

Optionally filter by image_styles

§age_ranges: Vec<AgeRangeId>

Optionally filter by age_ranges

§affiliations: Vec<AffiliationId>

Optionally filter by affiliations

§categories: Vec<CategoryId>

Optionally filter by categories

§tags: Vec<ImageTagIndex>

Optionally filter by tags

§tags_priority: Vec<ImageTagIndex>

Optionally order by tags, given in decreasing priority.

§Notes on priority

Consider a request with 4 tags, [clothing, food, red, sports].

“Priority ordering” means that all items tagged as clothing will appear before those without it, and that [clothing, food] will appear before [clothing] or [clothing, red].

§Assigning scores

The priority is achieved by using Algolia’s filter scoring feature with "sumOrFiltersScore": true.

Scores are weighted exponentially by a factor of 2. The lowest priority tag is given a score of 1, and the ith highest priority tag is given a score of 2.pow(i). This assignment is provably correct that we get the desired ranking. This can also be interpreted as bit vector with comparison.

NOTE: this means that with i64 range supported by Algolia, we can only assign priority for the first 62 tags. The remaining are all given a score of 1.

§Example

For an example request [clothing, food, red, sports], we assign the scores:

tag namescore(truncated) bit vector score
clothing80b_1000
food40b_0100
red20b_0010
sports10b_0001

This means that the entries will be returned in the following order, based on their tags:

positionentry nametag namesscore(truncated) bit vector score
0hatclothing80b_1000
1cherryred, food60b_0110
2cucumbergreen, food40b_0100
3stop signred20b_0010
4basketballsports10b_0001
5wallet[no tags]00b_0000
§is_premium: Option<bool>

Optionally filter by is_premium

§is_published: Option<bool>

Optionally filter by is_published

§page_limit: Option<u32>

The limit of results per page.

Trait Implementations§

Source§

impl Clone for ImageSearchQuery

Source§

fn clone(&self) -> ImageSearchQuery

Returns a copy 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 ImageSearchQuery

Source§

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

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

impl Default for ImageSearchQuery

Source§

fn default() -> ImageSearchQuery

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

impl<'de> Deserialize<'de> for ImageSearchQuery

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

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

impl Serialize for ImageSearchQuery

Source§

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

Serialize this value into the given Serde serializer. 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> CloneToUninit for T
where T: Clone,

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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, 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>,

Source§

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

Source§

impl<T> MaybeSendSync for T