aboutsummaryrefslogtreecommitdiff
path: root/lib/regexp-fields.cc
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2017-03-24 19:52:51 -0300
committerDavid Bremner <david@tethera.net>2017-03-29 20:44:32 -0300
commitcb84f8487833c19ce13edb769fa6421547077725 (patch)
tree23d688469092f86913bcd5eb75d111edd5b98153 /lib/regexp-fields.cc
parentbc0c051e042650106c5772d1817af1f7db32fb92 (diff)
lib: handle empty string in regexp field processors
The non-field processor behaviour is is convert the corresponding queries into a search for the unprefixed terms. This yields pretty surprising results so I decided to generate a query that would match the terms (i.e. none with that prefix) generated for an empty header.
Diffstat (limited to 'lib/regexp-fields.cc')
-rw-r--r--lib/regexp-fields.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/regexp-fields.cc b/lib/regexp-fields.cc
index 9dcf9732..1651677c 100644
--- a/lib/regexp-fields.cc
+++ b/lib/regexp-fields.cc
@@ -148,6 +148,11 @@ RegexpFieldProcessor::RegexpFieldProcessor (std::string prefix, Xapian::QueryPar
Xapian::Query
RegexpFieldProcessor::operator() (const std::string & str)
{
+ if (str.size () == 0)
+ return Xapian::Query(Xapian::Query::OP_AND_NOT,
+ Xapian::Query::MatchAll,
+ Xapian::Query (Xapian::Query::OP_WILDCARD, term_prefix));
+
if (str.at (0) == '/') {
if (str.at (str.size () - 1) == '/'){
RegexpPostingSource *postings = new RegexpPostingSource (slot, str.substr(1,str.size () - 2));