Re: [notmuch] strange behavior of indexing of and searching for strings containing '[]'

Subject: Re: [notmuch] strange behavior of indexing of and searching for strings containing '[]'

Date: Mon, 08 Feb 2010 12:24:06 -0500

To: Olly Betts, notmuch@notmuchmail.org

Cc:

From: Jameson Rollins


On Fri, 5 Feb 2010 23:48:03 +0000 (UTC), Olly Betts <olly@survex.com> wrote:
> On 2010-02-05, Jameson Rollins wrote:
> > Hey, folks.  I've been noticing some strange behavior of notmuch search
> > results for strings containing '[]'.  Here are some searches for some
> > exact strings in messages subjects:
> 
> The '[]' is a red herring.  Xapian's TermGenerator and QueryParser classes
> treat these two characters pretty much as if they were spaces.

Ah.  Thanks for the response, Olly.  This clears things up a lot.

> > servo:~ 0$ notmuch search subject:'emacs paned UI'
> 
> Note that the '' is quoting for the shell only here.  So Xapian sees:
> 
>     subject:emacs paned UI
> 
> Assuming you are defaulting to an AND search, that's `emacs in the subject'
> AND `paned anywhere in the indexed text' AND `UI anywhere in the indexed text'.

I don't think that this is exactly correct.  The quoting is interpreted
by the shell in order to construct a single string that is then passed
as an argument to the program.  Notmuch should then be seeing the single
string argument as the search parameter, and not breaking it up further.

Here's an example of what I mean:

servo:~/tmp/cdtemp.AYroUf 0$ cat parse 
#!/bin/bash
for arg; do echo "$arg"; done
servo:~/tmp/cdtemp.AYroUf 0$ ./parse subject:foo bar baz
subject:foo
bar
baz
servo:~/tmp/cdtemp.AYroUf 0$ ./parse subject:'foo bar' baz
subject:foo bar
baz
servo:~/tmp/cdtemp.AYroUf 0$ ./parse subject:"foo bar" baz
subject:foo bar
baz
servo:~/tmp/cdtemp.AYroUf 0$ 

As you can see in the last command, the argument "subject'foo bar'" is
passed as a single string by the shell, and should therefore be
interpreted as such by notmuch.

jamie.
part-000.sig (application/pgp-signature)

Thread: