mod common;
use crate::common::*;
#[test]
fn test_config_stopwords_allow() {
init_logging();
let executor = make_test_executor(|app_conf| {
app_conf.stopwords.allow = ["microsoft"].into_iter().map(ToOwned::to_owned).collect();
});
exec!(
executor -> PUSH "articles" "default" "article:1"
"Microsoft shouldn’t be a stopword."
);
exec!(
executor -> PUSH "articles" "default" "article:2"
"But now there’s a way to allow “Microsoft” to be indexed :)"
);
exec!(executor -> TRIGGER consolidate);
{
let response = exec!(executor -> QUERY "articles" "default" "Microsoft");
assert_eq!(response, ["article:2", "article:1"]);
}
}
#[test]
fn test_config_stopwords_deny() {
init_logging();
let executor = make_test_executor(|app_conf| {
app_conf.stopwords.deny = ["foobar"].into_iter().map(ToOwned::to_owned).collect();
});
exec!(
executor -> PUSH "articles" "default" "article:1"
"You can also prevent foobar from being indexed, if you really don’t \
like the word or it comes up too frequently."
);
exec!(executor -> TRIGGER consolidate);
{
let response = exec!(executor -> QUERY "articles" "default" "foobar");
assert_eq!(response, [] as [&str; 0]);
}
}
#[test]
fn test_minimum_term_idf() {
init_logging();
let executor = make_test_executor(|app_conf| {
app_conf.search.query_minimum_term_idf_default = 0.5;
app_conf.search.query_minimum_term_idf_minimum_object_count = 4;
app_conf.normalization.stemming_enabled = false;
});
exec!(executor -> PUSH "articles" "default" "article:1" "example");
exec!(executor -> PUSH "articles" "default" "article:2" "foo");
exec!(executor -> PUSH "articles" "default" "article:3" "foo bar");
exec!(executor -> PUSH "articles" "default" "article:4" "foo bar baz");
exec!(executor -> TRIGGER consolidate);
{
let response = exec!(executor -> QUERY "articles" "default" "foo bar baz");
assert_eq!(response, ["article:4", "article:3"]);
}
}