mirror of https://github.com/djcb/mu.git
query-processor: only phrasify indexable terms
This commit is contained in:
parent
8c5f92bacc
commit
2357db5bf1
|
@ -316,7 +316,8 @@ basify(Element&& element)
|
||||||
auto val{str->substr(pos + 1)};
|
auto val{str->substr(pos + 1)};
|
||||||
if (field == Field::Id::Flags) {
|
if (field == Field::Id::Flags) {
|
||||||
if (auto&& finfo{flag_info(val)}; finfo)
|
if (auto&& finfo{flag_info(val)}; finfo)
|
||||||
element.value = Element::Basic{field->name, std::string{finfo->name}};
|
element.value = Element::Basic{field->name,
|
||||||
|
std::string{finfo->name}};
|
||||||
else
|
else
|
||||||
Element::Basic{*str};
|
Element::Basic{*str};
|
||||||
} else if (field == Field::Id::Priority) {
|
} else if (field == Field::Id::Priority) {
|
||||||
|
@ -343,9 +344,12 @@ phrasify(Element&& element)
|
||||||
if (!basic)
|
if (!basic)
|
||||||
return element;
|
return element;
|
||||||
|
|
||||||
auto&& val{basic->value};
|
auto&& field = field_from_name(*basic->field);
|
||||||
if (val.find(' ') != std::string::npos)
|
if (!field || field->is_indexable_term()) {
|
||||||
element.value = Element::Phrase{basic->field, val};
|
auto&& val{basic->value};
|
||||||
|
if (val.find(' ') != std::string::npos)
|
||||||
|
element.value = Element::Phrase{basic->field, val};
|
||||||
|
}
|
||||||
|
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
@ -521,10 +525,13 @@ static void
|
||||||
test_processor()
|
test_processor()
|
||||||
{
|
{
|
||||||
std::vector<TestCase> cases = {
|
std::vector<TestCase> cases = {
|
||||||
|
// basics
|
||||||
TestCase{R"(hello world)", R"(((_ "hello") (_ "world")))"},
|
TestCase{R"(hello world)", R"(((_ "hello") (_ "world")))"},
|
||||||
TestCase{R"("hello world")", R"(((_ (phrase "hello world"))))"},
|
TestCase{R"("hello world")", R"(((_ (phrase "hello world"))))"},
|
||||||
TestCase{R"(subject:"hello world")", R"(((subject (phrase "hello world"))))"},
|
TestCase{R"(subject:"hello world")", R"(((subject (phrase "hello world"))))"},
|
||||||
// TODO: add more...
|
|
||||||
|
// maildir must _not_ be phrasified
|
||||||
|
TestCase{R"(maildir:/"hello world")", R"(((maildir "/hello world")))"},
|
||||||
};
|
};
|
||||||
|
|
||||||
for (auto&& test: cases) {
|
for (auto&& test: cases) {
|
||||||
|
@ -533,8 +540,6 @@ test_processor()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char* argv[])
|
main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue