mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-30 00:55:00 +08:00
Feat(Analytics): Add analytics for search format options
This commit is contained in:
parent
31584f34e8
commit
0990e95830
@ -8,7 +8,10 @@ use actix_web::http::header::USER_AGENT;
|
|||||||
use actix_web::HttpRequest;
|
use actix_web::HttpRequest;
|
||||||
use http::header::CONTENT_TYPE;
|
use http::header::CONTENT_TYPE;
|
||||||
use meilisearch_auth::SearchRules;
|
use meilisearch_auth::SearchRules;
|
||||||
use meilisearch_lib::index::{SearchQuery, SearchResult};
|
use meilisearch_lib::index::{
|
||||||
|
SearchQuery, SearchResult, DEFAULT_CROP_LENGTH, DEFAULT_CROP_MARKER,
|
||||||
|
DEFAULT_HIGHLIGHT_POST_TAG, DEFAULT_HIGHLIGHT_PRE_TAG,
|
||||||
|
};
|
||||||
use meilisearch_lib::index_controller::Stats;
|
use meilisearch_lib::index_controller::Stats;
|
||||||
use meilisearch_lib::MeiliSearch;
|
use meilisearch_lib::MeiliSearch;
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
@ -355,6 +358,13 @@ pub struct SearchAggregator {
|
|||||||
// pagination
|
// pagination
|
||||||
max_limit: usize,
|
max_limit: usize,
|
||||||
max_offset: usize,
|
max_offset: usize,
|
||||||
|
|
||||||
|
// formatting
|
||||||
|
highlight_pre_tag: bool,
|
||||||
|
highlight_post_tag: bool,
|
||||||
|
crop_marker: bool,
|
||||||
|
matches: bool,
|
||||||
|
crop_length: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SearchAggregator {
|
impl SearchAggregator {
|
||||||
@ -405,6 +415,12 @@ impl SearchAggregator {
|
|||||||
ret.max_limit = query.limit;
|
ret.max_limit = query.limit;
|
||||||
ret.max_offset = query.offset.unwrap_or_default();
|
ret.max_offset = query.offset.unwrap_or_default();
|
||||||
|
|
||||||
|
ret.highlight_pre_tag = query.highlight_pre_tag != DEFAULT_HIGHLIGHT_PRE_TAG;
|
||||||
|
ret.highlight_post_tag = query.highlight_post_tag != DEFAULT_HIGHLIGHT_POST_TAG;
|
||||||
|
ret.crop_marker = query.crop_marker != DEFAULT_CROP_MARKER;
|
||||||
|
ret.crop_length = query.crop_length != DEFAULT_CROP_LENGTH;
|
||||||
|
ret.matches = query.matches;
|
||||||
|
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -452,6 +468,12 @@ impl SearchAggregator {
|
|||||||
// pagination
|
// pagination
|
||||||
self.max_limit = self.max_limit.max(other.max_limit);
|
self.max_limit = self.max_limit.max(other.max_limit);
|
||||||
self.max_offset = self.max_offset.max(other.max_offset);
|
self.max_offset = self.max_offset.max(other.max_offset);
|
||||||
|
|
||||||
|
self.highlight_pre_tag |= other.highlight_pre_tag;
|
||||||
|
self.highlight_post_tag |= other.highlight_post_tag;
|
||||||
|
self.crop_marker |= other.crop_marker;
|
||||||
|
self.matches |= other.matches;
|
||||||
|
self.crop_length |= other.crop_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn into_event(self, user: &User, event_name: &str) -> Option<Track> {
|
pub fn into_event(self, user: &User, event_name: &str) -> Option<Track> {
|
||||||
@ -489,6 +511,13 @@ impl SearchAggregator {
|
|||||||
"max_limit": self.max_limit,
|
"max_limit": self.max_limit,
|
||||||
"max_offset": self.max_offset,
|
"max_offset": self.max_offset,
|
||||||
},
|
},
|
||||||
|
"formatting": {
|
||||||
|
"highlight_pre_tag": self.highlight_pre_tag,
|
||||||
|
"highlight_post_tag": self.highlight_post_tag,
|
||||||
|
"crop_marker": self.crop_marker,
|
||||||
|
"matches": self.matches,
|
||||||
|
"crop_length": self.crop_length,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
Some(Track {
|
Some(Track {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
pub use search::{
|
pub use search::{
|
||||||
default_crop_length, default_crop_marker, default_highlight_post_tag,
|
default_crop_length, default_crop_marker, default_highlight_post_tag,
|
||||||
default_highlight_pre_tag, SearchQuery, SearchResult, DEFAULT_SEARCH_LIMIT,
|
default_highlight_pre_tag, SearchQuery, SearchResult, DEFAULT_CROP_LENGTH, DEFAULT_CROP_MARKER,
|
||||||
|
DEFAULT_HIGHLIGHT_POST_TAG, DEFAULT_HIGHLIGHT_PRE_TAG, DEFAULT_SEARCH_LIMIT,
|
||||||
};
|
};
|
||||||
pub use updates::{apply_settings_to_builder, Checked, Facets, Settings, Unchecked};
|
pub use updates::{apply_settings_to_builder, Checked, Facets, Settings, Unchecked};
|
||||||
|
|
||||||
|
@ -35,17 +35,17 @@ pub const fn default_crop_length() -> usize {
|
|||||||
DEFAULT_CROP_LENGTH
|
DEFAULT_CROP_LENGTH
|
||||||
}
|
}
|
||||||
|
|
||||||
const DEFAULT_CROP_MARKER: &str = "…";
|
pub const DEFAULT_CROP_MARKER: &str = "…";
|
||||||
pub fn default_crop_marker() -> String {
|
pub fn default_crop_marker() -> String {
|
||||||
DEFAULT_CROP_MARKER.to_string()
|
DEFAULT_CROP_MARKER.to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
const DEFAULT_HIGHLIGHT_PRE_TAG: &str = "<em>";
|
pub const DEFAULT_HIGHLIGHT_PRE_TAG: &str = "<em>";
|
||||||
pub fn default_highlight_pre_tag() -> String {
|
pub fn default_highlight_pre_tag() -> String {
|
||||||
DEFAULT_HIGHLIGHT_PRE_TAG.to_string()
|
DEFAULT_HIGHLIGHT_PRE_TAG.to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
const DEFAULT_HIGHLIGHT_POST_TAG: &str = "</em>";
|
pub const DEFAULT_HIGHLIGHT_POST_TAG: &str = "</em>";
|
||||||
pub fn default_highlight_post_tag() -> String {
|
pub fn default_highlight_post_tag() -> String {
|
||||||
DEFAULT_HIGHLIGHT_POST_TAG.to_string()
|
DEFAULT_HIGHLIGHT_POST_TAG.to_string()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user