On our server the facet_date facet data in $response is returning:

stdClass Object
(
    [2009-08-04T10:00:00Z] => 0
    [2009-09-04T10:00:00Z] => 9
    [2009-10-04T10:00:00Z] => 0
    [gap] => +1MONTH
    [end] => 2009-11-04T10:00:00Z
)

and the facet title is returning "September" for [2009-09-04T10:00:00Z]. With gap set at 1month, when this facet link is clicked, results from October are also returned.

Because solr is returning this facet data, and the query from apachesolr doesn't appear to contain any constraints that would cause this behaviour, I think the problem may be a bug with solr itself. However, should apachesolr be checking if date_facet data start and end points coincide with start and end times for a month, and amending the facet link if they are not?

Thanks

Stuart

Comments

pwolanin’s picture

All times are currently only in UTC, so depending on your time zone, you could be seeing it for that reason

anarchivist’s picture

Status: Active » Closed (duplicate)

This appears to be a duplicate of #558036: Date facet rounding bug.

stuzza’s picture

Status: Closed (duplicate) » Active

While this may well be a duplicate, I'm reluctant to post the following to #558036: Date facet rounding bug because it doesn't really follow from the specifics of the original bug. Apologies if this is aggravating.

Anyway, I have more information.

$start_iso is calculated in function apachesolr_search_date_range() -

    $start_iso = apachesolr_date_iso(db_result(db_query("SELECT MIN($facet_field) FROM {node} WHERE status = 1")));

As it happens the result of this query for my installation is

2009-08-04T10:00:00Z

GAP being 1 month, facets are returned for 2009-08-04T10:00:00Z to 2009-09-04T10:00:00Z (and so on).

When $start_iso is passed to apachesolr_date_format_iso_by_gap() for returning link text to display, 2009-09-04T10:00:00Z is turned into:

    $unix = strtotime($iso);

    switch ($gap) {
      case 'MONTH':
        return gmdate('F Y', $unix);
    }

or 'September 2009', even though the nodes returned by that facet will have creation dates ranging from September 4 10AM to October 4 at 10am.

If the $start_iso was manipulated to 2009-08-1T00:00:00Z (ie the very start of the month in which the first node on the site was created), the date faceting link would be more accurate, and the functionality would work as expected.

pwolanin’s picture

This looks like a duplicate to me - please consolidate everything to one issue.

anarchivist’s picture

Status: Active » Closed (duplicate)

Marking as duplicate; please continue discussion on #558036: Date facet rounding bug.

jpmckinney’s picture

Status: Closed (duplicate) » Active

Not duplicate. See #558036-4: Date facet rounding bug for possible patch.

jpmckinney’s picture

Status: Active » Postponed (maintainer needs more info)

I can't reproduce this. No matter what, $response->facet_counts->facet_dates->created looks like:

stdClass Object
(
    [2010-04-01T00:00:00Z] => 334
    [2010-05-01T00:00:00Z] => 1
    [gap] => +1MONTH
    [end] => 2010-06-01T00:00:00Z
)

That is, if the gap is +1MONTH, the keys are always the first of each month. My MIN created date is 2010-04-20T00:00:04Z, so there is no relation to that.

What version of Solr are you running?

jpmckinney’s picture

Category: bug » support
jpmckinney’s picture

No reply from OP in 7 months.

jpmckinney’s picture

Status: Postponed (maintainer needs more info) » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.