search.json time stamp query

402 views
Skip to first unread message

Marcel Gleeson

unread,
Aug 10, 2012, 11:43:09 PM8/10/12
to mandrill-a...@googlegroups.com
I'm very new to mandrill, but I seem to have it all working for the most part.

I just want to run query using mandrill /message/search.json API
Ultimately I'd like to query a time stamp range , from the current time to 1 hour ago is that possible?

I've tried Date_From / Date_To but I'm not sure what time format to use (Unix Timestamp, YYYY-MM-DD  HH:MM:SS), or if they are even the right parameters to use

Many thanks

Kaitlin

unread,
Sep 20, 2012, 1:41:52 PM9/20/12
to mandrill-a...@googlegroups.com
Hi Marcel,

Sorry for the delay in responding here. 

For messages/search.json, the date format accepts a variety of parameters, but the best is to use YYYY-MM-DD.  If you want to search more granularly, you can use the query option to search message timestamps.  We're working to add some additional documentation about the search syntax, but in general you can use Lucene queries, and we support all the boolean operators like AND, OR, and NOT, along with wildcards (* for multiple character and ? for single-character wildcards - just don't start a search with a wildcard). There's some documentation here that goes over some examples of this type of query:http://lucene.apache.org/core/old_versioned_docs/versions/3_5_0/queryparsersyntax.html

To search by timestamps, use the field name 'ts', followed by a colon, and then a time range enclosed in brackets.  Timestamps should be Unix timestamps for this query.  So you could search like this:

ts:[1347989975 TO 1348162776]

Other fields you can search include custom metadata, subject line, recipient address and urls.

If you've got user metadata, you can search specific fields by using a fieldname like u_yourfield. So if you've got a metadata field being indexed called "userid", you could search that by using a query such as this:

u_userid:111*

To search by sender address, you can use "sender" as the field name; to search by recipient, use "full_email" as the field name; Subject line is "subject". If you want to search for people who clicked on a specific URL, you can use something like url:twitter.com* to get results for people who clicked on URLs that start with twitter.com.

--Kaitlin

Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages