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.
kindfield must match the case as represented in the returned json body (PascalCase?).- Vector fields, such as
age_rangesshould be given as a comma separated vector (CSV).
Fields§
§q: StringThe 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
Optionally filter by tags
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 name | score | (truncated) bit vector score |
|---|---|---|
| clothing | 8 | 0b_1000 |
| food | 4 | 0b_0100 |
| red | 2 | 0b_0010 |
| sports | 1 | 0b_0001 |
This means that the entries will be returned in the following order, based on their tags:
| position | entry name | tag names | score | (truncated) bit vector score |
|---|---|---|---|---|
| 0 | hat | clothing | 8 | 0b_1000 |
| 1 | cherry | red, food | 6 | 0b_0110 |
| 2 | cucumber | green, food | 4 | 0b_0100 |
| 3 | stop sign | red | 2 | 0b_0010 |
| 4 | basketball | sports | 1 | 0b_0001 |
| 5 | wallet | [no tags] | 0 | 0b_0000 |
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
impl Clone for ImageSearchQuery
Source§fn clone(&self) -> ImageSearchQuery
fn clone(&self) -> ImageSearchQuery
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more