Filter for field type date is not working

Created on 10 April 2024, 9 months ago

Problem/Motivation

Filter for date field is not sending the format parameter, that is why the default format is used, see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-ds...

format

(Optional, string) Date format used to convert date values in the query.

By default, Elasticsearch uses the date format provided in the 's mapping. This value overrides that mapping format.

When the index is created the format that is used for date field in mapping by search api is strict_date_optional_time||epoch_second. So it means the filter is using by default strict_date_optional_time, but search api uses timestamps when setting values for placeholders in filter queries, so it means that format in filters should be set to epoch_second instead

Steps to reproduce

  1. Create index with search api for node
  2. Add created field
  3. Observe that "Date" type is set for it
  4. Create a view that uses the newly created index
  5. Create a filter by created field: Between, greater(than) or lower(than)
  6. Observe that query doesn't give any results.

Proposed resolution

Add 'format' => 'epoch_second' to all filters in case field is of type 'date'

Remaining tasks

Create patch or MR

User interface changes

None

API changes

None

Data model changes

None

🐛 Bug report
Status

Needs review

Version

7.0

Component

Elasticsearch Connector Search API

Created by

🇩🇪Germany a.dmitriiev

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024