unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* Searching for an Exact Email Address
@ 2020-02-01 21:29 Kevin Foley
  2020-02-02  0:38 ` David Bremner
  2020-02-02  6:12 ` Teemu Likonen
  0 siblings, 2 replies; 6+ messages in thread
From: Kevin Foley @ 2020-02-01 21:29 UTC (permalink / raw)
  To: notmuch

Hi,

I'm getting unexpected results when trying to search for messages
associated with an email address.

An example search is:

$ notmuch search to:"example@email.com"

which is returning messages that seem to have nothing to do with the
address I'm looking for.

My understanding is this should be treated as a phrase which means that
exact phrase will be searched for, is this correct?  If not is there a
way to search for an exact email address in the to field?

Thanks,
Kevin

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Searching for an Exact Email Address
  2020-02-01 21:29 Searching for an Exact Email Address Kevin Foley
@ 2020-02-02  0:38 ` David Bremner
  2020-02-02  6:12 ` Teemu Likonen
  1 sibling, 0 replies; 6+ messages in thread
From: David Bremner @ 2020-02-02  0:38 UTC (permalink / raw)
  To: Kevin Foley, notmuch

Kevin Foley <kevin@kevinjfoley.me> writes:

> Hi,
>
> I'm getting unexpected results when trying to search for messages
> associated with an email address.
>
> An example search is:
>
> $ notmuch search to:"example@email.com"

See the subsection Quoting in notmuch-search-terms(7). I suspect you
need to double-quote your query, as the examples in the documentation are.

>
> which is returning messages that seem to have nothing to do with the
> address I'm looking for.
>
> My understanding is this should be treated as a phrase which means that
> exact phrase will be searched for, is this correct?  If not is there a
> way to search for an exact email address in the to field?
>

You can also do regex searches, although they are are measurably
slower. The syntax is also discussed in notmuch-search-terms(7).

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Searching for an Exact Email Address
  2020-02-01 21:29 Searching for an Exact Email Address Kevin Foley
  2020-02-02  0:38 ` David Bremner
@ 2020-02-02  6:12 ` Teemu Likonen
  2020-02-02 12:17   ` David Bremner
  1 sibling, 1 reply; 6+ messages in thread
From: Teemu Likonen @ 2020-02-02  6:12 UTC (permalink / raw)
  To: Kevin Foley, notmuch

[-- Attachment #1: Type: text/plain, Size: 958 bytes --]

Kevin Foley [2020-02-01T16:29:25-05] wrote:

> I'm getting unexpected results when trying to search for messages
> associated with an email address.

> $ notmuch search to:"example@email.com"

> My understanding is this should be treated as a phrase which means
> that exact phrase will be searched for, is this correct?

Double quotes are special characters in your shell and it interprets
them so that notmuch doesn't get them. There are different ways in shell
to escape special characters:

    to:\"example@email.com\"
    'to:"example@email.com"'

The shell built-in "set" is useful for testing parameters:

    $ set -- to:"example@email.com" to:\"example@email.com\"
    $ printf '%s\n' "$@"
    to:example@email.com
    to:"example@email.com"

-- 
///  OpenPGP key: 4E1055DC84E9DFF613D78557719D69D324539450
//  https://keys.openpgp.org/search?q=tlikonen@iki.fi
/  https://keybase.io/tlikonen  https://github.com/tlikonen

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 694 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Searching for an Exact Email Address
  2020-02-02  6:12 ` Teemu Likonen
@ 2020-02-02 12:17   ` David Bremner
  2020-02-02 15:05     ` Kevin Foley
  0 siblings, 1 reply; 6+ messages in thread
From: David Bremner @ 2020-02-02 12:17 UTC (permalink / raw)
  To: Teemu Likonen, Kevin Foley, notmuch

Teemu Likonen <tlikonen@iki.fi> writes:

> The shell built-in "set" is useful for testing parameters:
>
>     $ set -- to:"example@email.com" to:\"example@email.com\"
>     $ printf '%s\n' "$@"
>     to:example@email.com
>     to:"example@email.com"


Also useful is setting NOTMUCH_DEBUG_QUERY in the environment. This will
show the parsed Xapian query. In my case this shows both
'to:"example@email.com"' and to:"example@email.com" end up parsed the
same way, so I guess the problem is elsewhere.  Maybe you can try it
with your actual query.

d

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Searching for an Exact Email Address
  2020-02-02 12:17   ` David Bremner
@ 2020-02-02 15:05     ` Kevin Foley
  2020-02-02 17:00       ` David Bremner
  0 siblings, 1 reply; 6+ messages in thread
From: Kevin Foley @ 2020-02-02 15:05 UTC (permalink / raw)
  To: David Bremner, Teemu Likonen, notmuch


David Bremner <david@tethera.net> writes:

> Also useful is setting NOTMUCH_DEBUG_QUERY in the environment. This will
> show the parsed Xapian query. In my case this shows both
> 'to:"example@email.com"' and to:"example@email.com" end up parsed the
> same way, so I guess the problem is elsewhere.

I should have mentioned that I tried using NOTMUCH_DEBUG_QUERY with many
different quoting variations and kept getting the same final query:

Query((Tmail AND (XTOexample@1 PHRASE 3 XTOemail@2 PHRASE 3 XTOcom@3)))

It looks like the punctuation is being stripped; I get the same final
query for `notmuch search 'to:"example email com"'`.  Is this the
expected behavior?

David Bremner <david@tethera.net> writes:

>  You can also do regex searches, although they are are measurably
>  slower. The syntax is also discussed in notmuch-search-terms(7).

I tried this as well but per notmuch-search-terms(7) it looks like regex
isn't supported for the "to" field.

Also as a side note, I don't think the quoting is necessary as per the
"searching" documentation [0], "... e-mail addresses are also treated as
phrases.".

Kevin

[0] https://notmuchmail.org/searching/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Searching for an Exact Email Address
  2020-02-02 15:05     ` Kevin Foley
@ 2020-02-02 17:00       ` David Bremner
  0 siblings, 0 replies; 6+ messages in thread
From: David Bremner @ 2020-02-02 17:00 UTC (permalink / raw)
  To: Kevin Foley, Teemu Likonen, notmuch

Kevin Foley <kevin@kevinjfoley.me> writes:

> David Bremner <david@tethera.net> writes:
>
>> Also useful is setting NOTMUCH_DEBUG_QUERY in the environment. This will
>> show the parsed Xapian query. In my case this shows both
>> 'to:"example@email.com"' and to:"example@email.com" end up parsed the
>> same way, so I guess the problem is elsewhere.
>
> I should have mentioned that I tried using NOTMUCH_DEBUG_QUERY with many
> different quoting variations and kept getting the same final query:
>
> Query((Tmail AND (XTOexample@1 PHRASE 3 XTOemail@2 PHRASE 3 XTOcom@3)))
>
> It looks like the punctuation is being stripped; I get the same final
> query for `notmuch search 'to:"example email com"'`.  Is this the
> expected behavior?

Yes, that's how phrases work.

> I tried this as well but per notmuch-search-terms(7) it looks like regex
> isn't supported for the "to" field.

Ah right. it's really an implimentation quirk that that From: addresses
are stored in the form needed for regex searching.

> Also as a side note, I don't think the quoting is necessary as per the
> "searching" documentation [0], "... e-mail addresses are also treated as
> phrases.".

Quoting is certainly necessary for phrases containing spaces, but yes,
as documented phrases can also be built with punctuation.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-02-02 17:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-01 21:29 Searching for an Exact Email Address Kevin Foley
2020-02-02  0:38 ` David Bremner
2020-02-02  6:12 ` Teemu Likonen
2020-02-02 12:17   ` David Bremner
2020-02-02 15:05     ` Kevin Foley
2020-02-02 17:00       ` David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).