This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Forums » Extensions » ez Find filter by date

ez Find filter by date

ez Find filter by date

Friday 08 October 2010 5:35:29 pm - 8 replies


I would like to be able to only show upcoming events, not the once that have already taken place.

i have tried to use the following in the hash using ezfind search.

filter','event/from_time:[NOW-60DAY TO NOW/DAY+20DAY]

I am unable to get this to work for me.

When i however run 'filter','published[NOW......] it works.

How should i go about handling filtering for my dates?

Any example is greatly appreciated.

Friday 08 October 2010 7:03:55 pm

Hy Lars,

try this to implement a range match...

{... , hash( ...,
            'filter', array( 'and',
                             'event/from_time:[xxx TO *]',
                             'event/from_time:[* TO xxx]' ) ) )}

But this still leaves you to determine the xxx variables (now - xx days).

I'm still looking for some documentation on solr date/time fields. I guess date and datetime fields in ezpublish are translated into unix timestamps which are also timestamps in solr. So instead of writing 'NOW-60DAYs' you could use some timestamp value? But thats just a guess. I am looking throu the solr documentation which ezfind relies on.



Friday 08 October 2010 7:19:48 pm

ok, found the page:

I think it should be:

... 'filter','event/from_time:[-60DAY TO +20DAY]' ...

because the solr documentation says:

 -1DAY      ... Exactly 1 day prior to now

Thats interesting. Can you verify/check that please? Well... you got that already according to this link here:

timestamp:[* TO NOW]
createdate:[1976-03-06T23:59:59.999Z TO *]
createdate:[1995-12-31T23:59:59.999Z TO 2007-03-06T00:00:00Z]
createdate:[1976-03-06T23:59:59.999Z TO 1976-03-06T23:59:59.999Z+1YEAR]
createdate:[1976-03-06T23:59:59.999Z/YEAR TO 1976-03-06T23:59:59.999Z]

You are already using the correct syntax. Are there any solr-parser errors in the error.log ?

Modified on Friday 08 October 2010 7:23:00 pm by Christian Rößler

Friday 08 October 2010 7:57:09 pm

gnaaahhh, I feel so noobish - sorry for spamming such posts here.

I managed to create a demo search on my current data with this tempalte code snippet:

{def $x = fetch( 'ezfind', 'search', hash( 'class_id', 'product',                                  
                                           'filter', array( 'product/publish_date:[NOW-60DAY TO NOW+20DAY]' ) ) )}

And it works and returns the articles/objects/products i need.

What does NOT work and returns errors:

[-60DAY TO +20DAY]  ->   Invalid Date String:'-1DAY'

So hopefully it could help you!


Modified on Friday 08 October 2010 7:58:07 pm by Christian Rößler

Monday 11 October 2010 8:40:28 am

{def $results =fetch(ezfind, search, hash('query','',
'filter',array('event/from_time:[NOW-2DAY TO NOW+20DAY]')

I tried the following now, and i get no result nodes, although they should exist.

Please anyone else have experience with using a date_time attribute and doing search with ezfind?

Thanks for all the help Christian.

Monday 11 October 2010 9:12:39 am

Well, but now the date/time filter is correct. If you still don't get results, check the following:

  • ezpublish errorlog
  • is ezfind up and running
  • has ezfind an up-to-date index on your contentobjects
  • what is in the variable $subtree_array you pass to the fetch-function
  • are your event-objects filled with from_time values


Monday 11 October 2010 10:11:29 am

Thanks again Christian. Just had a look at this installation. I am new on this existing project, and it turns out that the from_time attribute is not indicated to be searchable.. Waiting for the reindexing to take place..

Could this be the reason why is has ignored my search?

Will post follow up soon.

Monday 11 October 2010 10:37:12 am

I would like to extend my gratitude to Christianhappy.gif Emoticon

It turned out that the old site was not configured to allow searching for the datatfield i was referring to. This was because it was a pre-ezfind installation originally. I have now upgraded this to ezpublishenterprise4.4 and the field is now searchable and it now works like expectedhappy.gif Emoticon

Monday 11 October 2010 11:11:10 am

Awesome! I'm glad it works now.

Indeed, any class-attribute that is not marked as 'is searchable' ezFind ignores and thus you cannot search for those attributes.

You did right: enabling the search for this attribute and re-index the content.

And this is a common problem I face often: attributes not marked as 'is searchable' and I always spend hours to figure out why my code does not find anything blunk.gif Emoticon


You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from