Email query and thread merge tests passing
This commit is contained in:
@@ -69,6 +69,10 @@ impl ReadTransaction<'_> {
|
||||
)
|
||||
.await?
|
||||
}
|
||||
TextMatch::Raw => {
|
||||
self.get_bitmap(BitmapKey::hash(&text, account_id, collection, 0, field))
|
||||
.await?
|
||||
}
|
||||
},
|
||||
Filter::InBitmap { family, field, key } => {
|
||||
self.get_bitmap(BitmapKey {
|
||||
|
||||
@@ -49,6 +49,7 @@ pub enum TextMatch {
|
||||
Exact(Language),
|
||||
Stemmed(Language),
|
||||
Tokenized,
|
||||
Raw,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -129,27 +130,32 @@ impl Filter {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn has_text(field: impl Into<u8>, text: impl Into<String>, mut language: Language) -> Self {
|
||||
pub fn has_text_detect(
|
||||
field: impl Into<u8>,
|
||||
text: impl Into<String>,
|
||||
default_language: Language,
|
||||
) -> Self {
|
||||
let mut text = text.into();
|
||||
let language = if let Some((l, t)) = text
|
||||
.split_once(':')
|
||||
.and_then(|(l, t)| (Language::from_iso_639(l)?, t.to_string()).into())
|
||||
{
|
||||
text = t;
|
||||
l
|
||||
} else {
|
||||
LanguageDetector::detect_single(&text)
|
||||
.and_then(|(l, c)| if c > 0.3 { Some(l) } else { None })
|
||||
.unwrap_or(default_language)
|
||||
};
|
||||
Self::has_text(field, text, language)
|
||||
}
|
||||
|
||||
pub fn has_text(field: impl Into<u8>, text: impl Into<String>, language: Language) -> Self {
|
||||
let text = text.into();
|
||||
let op = if !matches!(language, Language::None) {
|
||||
let match_phrase = (text.starts_with('"') && text.ends_with('"'))
|
||||
|| (text.starts_with('\'') && text.ends_with('\''));
|
||||
|
||||
if !match_phrase && language == Language::Unknown {
|
||||
language = if let Some((l, t)) = text
|
||||
.split_once(':')
|
||||
.and_then(|(l, t)| (Language::from_iso_639(l)?, t.to_string()).into())
|
||||
{
|
||||
text = t;
|
||||
l
|
||||
} else {
|
||||
LanguageDetector::detect_single(&text)
|
||||
.and_then(|(l, c)| if c > 0.3 { Some(l) } else { None })
|
||||
.unwrap_or(Language::Unknown)
|
||||
};
|
||||
}
|
||||
|
||||
if match_phrase {
|
||||
if (text.starts_with('"') && text.ends_with('"'))
|
||||
|| (text.starts_with('\'') && text.ends_with('\''))
|
||||
{
|
||||
TextMatch::Exact(language)
|
||||
} else {
|
||||
TextMatch::Stemmed(language)
|
||||
@@ -165,6 +171,14 @@ impl Filter {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn has_raw_text(field: impl Into<u8>, text: impl Into<String>) -> Self {
|
||||
Filter::HasText {
|
||||
field: field.into(),
|
||||
text: text.into(),
|
||||
op: TextMatch::Raw,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn has_english_text(field: impl Into<u8>, text: impl Into<String>) -> Self {
|
||||
Self::has_text(field, text, Language::English)
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use std::cmp::Ordering;
|
||||
|
||||
use ahash::{AHashMap, AHashSet};
|
||||
|
||||
use crate::{ReadTransaction, Store, ValueKey};
|
||||
@@ -155,7 +157,10 @@ impl ReadTransaction<'_> {
|
||||
|
||||
let mut seen_prefixes = AHashSet::new();
|
||||
let mut sorted_ids = sorted_ids.into_iter().collect::<Vec<_>>();
|
||||
sorted_ids.sort_by(|a, b| a.1.cmp(&b.1));
|
||||
sorted_ids.sort_by(|a, b| match a.1.cmp(&b.1) {
|
||||
Ordering::Equal => a.0.cmp(&b.0),
|
||||
other => other,
|
||||
});
|
||||
for (document_id, _) in sorted_ids {
|
||||
// Obtain document prefixId
|
||||
let prefix_id = if let Some(prefix_key) = &paginate.prefix_key {
|
||||
@@ -252,13 +257,17 @@ impl Pagination {
|
||||
|
||||
// Pagination
|
||||
if !self.has_anchor {
|
||||
if self.position > 0 {
|
||||
self.position -= 1;
|
||||
if self.position >= 0 {
|
||||
if self.position > 0 {
|
||||
self.position -= 1;
|
||||
} else {
|
||||
self.ids.push(id);
|
||||
if self.ids.len() == self.limit {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
self.ids.push(id);
|
||||
if self.ids.len() == self.limit {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else if self.anchor_offset >= 0 {
|
||||
if !self.anchor_found {
|
||||
|
||||
Reference in New Issue
Block a user