Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I would love something that handles dates to the solr/lucene format #58

Closed
stefanooldeman opened this issue Jan 11, 2012 · 2 comments
Closed

Comments

@stefanooldeman
Copy link
Contributor

This is the DateField that is handled in solr. But this is slightly different than the full RFC 3339. So this is how i convert my dates. see:

RFC 3339 :
2011-12-01T00:00:00+01:00
solr expects:
2000-05-23T22:00:00Z

// return everything but the 6 chars and add a Z (The trailing "Z" designates UTC time and is mandatory)
$date = new Zend_Date($input);
$dateValue = $date->toString(Zend_Date::RFC_3339);
$dateValue = substr($dateValue, 0, strlen($dateValue) -6) . 'Z';

I have a few questions:

  1. where should this be added eg. within a helper or intergrated in the Solarium_Query_Select etc.
  2. is this wanted functionality / how do other think about this feature
@basdenooijer
Copy link
Member

I think a date helper can be useful, this way users don't need to know to exact details of the format required by Solr.

Since dates can be used for all query types, so I think this should be placed in the Solarium_Query_Helper class. This is already available in all queries using the getHelper method.

Solarium should not depend on Zend Framework for the date conversion. Luckily the date conversion is not hard to implement. I've seen an example of this in a commit of Gasol, see:
https://github.com/Gasol/solarium/blob/a720c96cf39e0c01074fa89fce39ddbdb3d4cf8d/library/Solarium/Document/Helper.php
He has done several contributions to Solarium, but this code wasn't included.

The ISO8601 format is the right one. The DateTime class is part of the PHP core since 5.2 and Solarium requires PHP 5.2+ so this can safely be used. The method in the example would need to be moved to the query helper class.

stefanooldeman added a commit to stefanooldeman/solarium that referenced this issue Jan 12, 2012
@basdenooijer
Copy link
Member

I'm closing this issue, as the discussion is now ongoing in issue #62

basdenooijer added a commit that referenced this issue Jan 17, 2012
fix issue #58 add formatDate to query helper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants