Re: [PATCH 2/4] lib: handle empty string in regexp field processors

2017-03-23 Thread David Bremner
David Bremner  writes:

> The non-field processor behaviour is is convert the corresponding
> queries into a search for the unprefixed terms. This yields pretty
> surprising results so decided to match any message.
> ---
>  lib/regexp-fields.cc  | 3 +++
>  test/T650-regexp-query.sh | 2 --
>  2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/lib/regexp-fields.cc b/lib/regexp-fields.cc
> index 8e740a81..42239a66 100644
> --- a/lib/regexp-fields.cc
> +++ b/lib/regexp-fields.cc
> @@ -148,6 +148,9 @@ RegexpFieldProcessor::RegexpFieldProcessor (std::string 
> prefix, Xapian::QueryPar
>  Xapian::Query
>  RegexpFieldProcessor::operator() (const std::string & str)
>  {
> +if (str.size () == 0)
> + return Xapian::Query::MatchAll;
> +

For things like file:, it actually makes more sense to return
Xapian::Query(term_prefix). I'm leaning towards something like the following

if (str.size () == 0) {
   if (options & NOTMUCH_FIELD_PROBABILISTIC)
   return Xapian::Query::MatchAll;
   else
   return Xapian::Query(term_prefix);
}
 

but this patch can stay as is for now, as there are not yet any boolean
fields being matched (mid would be the first).

I thought a bit about unconditionalling returning Xapian::Query
(term_prefix), but I think for the probabilistic (term based) fields,
we'll never add terms for only the prefix, i.e. and empty subject would
just not add any XSUBJECT terms. So that would effectively match no
messages.

d
___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch


[PATCH 2/4] lib: handle empty string in regexp field processors

2017-03-17 Thread David Bremner
The non-field processor behaviour is is convert the corresponding
queries into a search for the unprefixed terms. This yields pretty
surprising results so decided to match any message.
---
 lib/regexp-fields.cc  | 3 +++
 test/T650-regexp-query.sh | 2 --
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/regexp-fields.cc b/lib/regexp-fields.cc
index 8e740a81..42239a66 100644
--- a/lib/regexp-fields.cc
+++ b/lib/regexp-fields.cc
@@ -148,6 +148,9 @@ RegexpFieldProcessor::RegexpFieldProcessor (std::string 
prefix, Xapian::QueryPar
 Xapian::Query
 RegexpFieldProcessor::operator() (const std::string & str)
 {
+if (str.size () == 0)
+   return Xapian::Query::MatchAll;
+
 if (str.at (0) == '/') {
if (str.at (str.size () - 1) == '/'){
RegexpPostingSource *postings = new RegexpPostingSource (slot, 
str.substr(1,str.size () - 2));
diff --git a/test/T650-regexp-query.sh b/test/T650-regexp-query.sh
index b1d84439..049477b4 100755
--- a/test/T650-regexp-query.sh
+++ b/test/T650-regexp-query.sh
@@ -12,12 +12,10 @@ fi
 notmuch search --output=messages from:cworth > cworth.msg-ids
 
 test_begin_subtest "empty from: search"
-test_subtest_known_broken
 notmuch search --output=messages 'from:""' and from:cworth > OUTPUT
 test_expect_equal_file cworth.msg-ids OUTPUT
 
 test_begin_subtest "empty subject: search"
-test_subtest_known_broken
 notmuch search --output=messages 'subject:""' and from:cworth > OUTPUT
 test_expect_equal_file cworth.msg-ids OUTPUT
 test_begin_subtest "regexp from search, case sensitive"
-- 
2.11.0

___
notmuch mailing list
notmuch@notmuchmail.org
https://notmuchmail.org/mailman/listinfo/notmuch