10up / ElasticPress

A fast and flexible search and query engine for WordPress.
https://elasticpress.io
GNU General Public License v2.0
1.24k stars 312 forks source link

Filter date format is not correct #3859

Closed Swaraj088 closed 5 months ago

Swaraj088 commented 6 months ago

Describe your question

Hi

I am trying Filters in my ElasticPress. I have added the Filter by meta and selected meta keys "webinar_start_date" and "webinar_start_date". These both are ACF date fields linked with custom post type, however, the date is shown in as raw or value instead of date.

Type: Main query Host: http://localhost:9200/ Time Taken: 51 ms URL: http://localhost:9200/wp64local-post-1/_search Method: POST Headers: Query Args: Query Body: Query Response Code: HTTP 200 Query Result: { "took": 37, "timed_out": false, "_shards": { "total": 5, "successful": 5, "skipped": 0, "failed": 0 }, "hits": { "total": { "value": 1, "relation": "eq" }, "max_score": 2.3690297999999999, "hits": [ { "_index": "wp64local-post-1", "_type": "_doc", "_id": "83", "_score": 2.3690297999999999, "_source": { "post_id": 83, "ID": 83, "post_author": { "raw": "admin", "login": "admin", "display_name": "admin", "id": 1 }, "post_date": "2024-03-09 19:21:28", "post_date_gmt": "2024-03-09 19:21:28", "post_title": "Webinar March", "post_excerpt": "", "post_content_filtered": "", "post_content": "", "post_status": "publish", "post_name": "webinar-march", "post_modified": "2024-03-09 19:23:10", "post_modified_gmt": "2024-03-09 19:23:10", "post_parent": 0, "post_type": "webinar", "post_mime_type": "", "permalink": "http:\/\/wp6-4.local\/webinar\/webinar-march\/", "terms": [], "meta": { "ep_exclude_from_search": [ { "value": "", "raw": "", "boolean": false } ], "**webinar_start_date**": [ { "value": "20250313", "raw": "20250313", "long": 20250313, "double": 20250313, "boolean": false, "date": "2025-03-13", "datetime": "2025-03-13 00:00:00", "time": "00:00:00" } ], "**webinar_end_date**": [ { "value": "20250317", "raw": "20250317", "long": 20250317, "double": 20250317, "boolean": false, "date": "2025-03-17", "datetime": "2025-03-17 00:00:00", "time": "00:00:00" } ], "webinar_salary_range": [ { "value": "50K-59K USD: 50000", "raw": "50K-59K USD: 50000", "boolean": false, "date": "1970-01-01", "datetime": "1970-01-01 00:00:01", "time": "00:00:01" } ], "webinar_location": [ { "value": "Calgary", "raw": "Calgary", "boolean": false, "date": "1970-01-01", "datetime": "1970-01-01 00:00:01", "time": "00:00:01" } ] }, "date_terms": { "year": 2024, "month": 3, "week": 10, "dayofyear": 68, "day": 9, "dayofweek": 6, "dayofweek_iso": 6, "hour": 19, "minute": 21, "second": 28, "m": 202403 }, "comment_count": 0, "comment_status": "closed", "ping_status": "closed", "menu_order": 0, "guid": "http:\/\/wp6-4.local\/?post_type=webinar&p=83", "thumbnail": null } } ] }, "aggregations": { "terms": { "doc_count": 1, "ep_meta_filter_webinar_location": { "doc_count_error_upper_bound": 0, "sum_other_doc_count": 0, "buckets": [ { "key": "Calgary", "doc_count": 1 } ] }, "ep_meta_filter_webinar_start_date": { "doc_count_error_upper_bound": 0, "sum_other_doc_count": 0, "buckets": [ { "key": "20250313", "doc_count": 1 } ] }, "ep_meta_filter_webinar_end_date": { "doc_count_error_upper_bound": 0, "sum_other_doc_count": 0, "buckets": [ { "key": "20250317", "doc_count": 1 } ] }, "ep_meta_filter_webinar_salary_range": { "doc_count_error_upper_bound": 0, "sum_other_doc_count": 0, "buckets": [ { "key": "50K-59K USD: 50000", "doc_count": 1 } ] }, "post_type": { "doc_count_error_upper_bound": 0, "sum_other_doc_count": 0, "buckets": [ { "key": "webinar", "doc_count": 1 } ] }, "category": { "doc_count_error_upper_bound": 0, "sum_other_doc_count": 0, "buckets": [] }, "post_tag": { "doc_count_error_upper_bound": 0, "sum_other_doc_count": 0, "buckets": [] } } } }

How i can fix this? Thank you

Code of Conduct

Swaraj088 commented 6 months ago
Screenshot 2024-03-09 at 4 32 33 PM
felipeelia commented 5 months ago

Hi @Swaraj088, you can use the ep_facet_meta_value_label filter to format that the way you need. See it here.