Skip to content

Single-value datetime fields duplicating on index #235

@katherine-boost

Description

@katherine-boost

Schema block:

datetime :syndication_date do
    store false
    solr_name 'syndication_date_ds'
    search_as %i[filter]
    search_value do |record|
      syndication_date = record.dates.select(&:syndication_date?)
      syndication_date = syndication_date.first.parse_as_solr_date_range if syndication_date.present?
      syndication_date.present? ? DateTime.parse(syndication_date) : record.created_at
    end
  end

The value delivered by the search_value block is a single DateTime, e.g. Fri, 05 Jun 2020 15:41:42 NZST +12:00.

When calling .index! on that record, this error message:

Error: {
  "responseHeader": {
    "status":400,
    "QTime":4},
  "error": {
    "metadata": [
      "error-class","org.apache.solr.common.SolrException",
      "root-error-class","org.apache.solr.common.SolrException"],
    "msg": "ERROR: [doc=SupplejackApi::Record 5ed9bef6400382484286ff9b] 
            multiple values encountered for non multiValued field syndication_date_ds: 
           [2020-06-05T03:41:42Z, 2020-06-05 15:41:42 +1200]",
    "code":400
    }
}

Both the UTC and NZST varieties of the DateTime are being delivered.

Removing search_as %[filter] fixes the problem.

It looks like a bug was introduced in #223.
Prior to that (and when rolling back to there), it was working fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions