query-parser: special-case wildcards

We were transforming wild-card searches into regular-expression
searches; while that works, it's also significantly slower.

So, instead, special-case wildcards, and use the Xapian machinery for
wildcard queries.
This commit is contained in:
djcb
2018-05-18 15:55:40 +03:00
parent 84376b4aa7
commit 6290e4ad9a
2 changed files with 16 additions and 9 deletions

View File

@ -167,14 +167,9 @@ data (Mux::Tokens& tokens, ProcPtr proc, WarningVec& warnings)
}
// does it look like a regexp?
if (val.length()>=2) {
if (val[0]=='/' && val[val.length()-1] == '/')
if (val.length() >=2 )
if (val[0] == '/' && val[val.length()-1] == '/')
return regex (fields, val, token.pos, proc, warnings);
else if (val[val.length()-1] == '*')
return regex (fields, // transfrom wildcard into regexp
"/" + val.substr(0, val.length()-1) + ".*/",
token.pos, proc, warnings);
}
// does it look like a range?
const auto dotdot = val.find("..");