Problem/Motivation

While debugging an issue in the elasticsearch_connector queue (#3551591: Filter does not work with date range fields), I set up a date filter on a test view, and noticed a Negated regular expression (not_regular_expression) operator as an option.

I also notice that in \Drupal\search_api\Plugin\views\filter\SearchApiDate::operators(), we unset($operators['regular_expression']);, i.e.: removing regular_expression as an option.

We dropped support for regular_expression in #2601224: Add Views filters (and kept in #2695627: Add support for (NOT) IN and BETWEEN operators to Views when support for between and not between were added).

Given that regular_expression filtering for dates sounds like a non-trivial problem (i.e.: because dates can be expressed/stored/matched in various formats), I think it makes sense to also drop support for not_regular_expression.

Steps to reproduce

  1. Download the latest version of Drupal core (I got 11.3.6) and search_api (I cloned 8.x-1.x branch and got commit e96a1c88)
  2. Install Drupal with the minimal install profile.
  3. Log in as an administrator
  4. Go to /admin/modules, enable field_ui, views_ui, datetime, search_api, and search_api_db (other search backends will work too; I first noticed this issue with elasticsearch_connector).
  5. Go to /admin/structure/types/add and create a content type. I happened to give mine the machine name event.
  6. Go to /admin/structure/types/manage/event/fields/add-field, click Date and time. In the popup, enter Label = Event date (machine name field_event_date), Choose a field type = Date, click the Continue button, then click the Save button to accept the defaults on the second page.
  7. Go to /node/add/event, set Title = Sprints, Event date = 2026-04-10 09:45:00, then click the Save button.
  8. Go to /admin/config/search/search-api/add-server and add a Search API Server. I happened to give mine the machine name example_db_backend.
  9. Go to /admin/config/search/search-api/add-index, set Index name = Events, Datasources = Content, Server = example_db_backend, then click the Save button.
  10. Go to /admin/config/search/search-api/index/events/fields/add/nojs; and click the Add button next to the Event date (field_event_date) field. Then click the Done button. On the Manage fields for search index Events, in the field_event_date row, set Type = Date. Click the Save changes button.
  11. Go to /admin/config/search/search-api/index/events, and click the Index now button. 1 item is indexed.
  12. Go to /admin/structure/views/add. Set View name = Event search. Under View settings, "Show Index events sorted by Unsorted. Click the Save and edit button.
  13. You are taken to the view-edit page. Next to Filter critera, click the Add button. Check Event date in the Content datasource category. Click the Add and configure filter criteria button. On the second page, click the Operator select list.
    Expected behavior: You do not see a Regular expression option, nor a Negated regular expression option.
    Actual behavior: You do not see a Regular expression option; but you do see a Negated regular expression option.

Proposed resolution

Remove support for the Negated regular expression (not_regular_expression) operator in \Drupal\search_api\Plugin\views\filter\SearchApiDate::operators()

Remaining tasks

  1. Write a merge request with tests - merge request !321 created by @mparker17 in #6
  2. Community review
  3. Maintainer review
  4. Commit
  5. Release

Issue fork search_api-3577065

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mparker17 created an issue. See original summary.

mparker17’s picture

Issue summary: View changes
Status: Active » Needs review

Note that I was using Drupal core 11.3.3, search_api-8.x-1.40, and elasticsearch_connector-8.0.0-alpha6 when I noticed this (although the version of elasticsearch_connector should be irrelevant in this case).

Marking as Needs Review so I can get someone else's opinion on this.

mparker17’s picture

Also here's a Screenshot of the Negated regular expression option appearing in a Views filter configuration modal for a SearchApiDate filter plugin...

Screenshot of a views filter configuration modal for a SearchApiDate filter plugin, showing a Negated regular expression option in the operator

mparker17’s picture

Issue summary: View changes

(link to code where we unset the option)

mparker17’s picture

Title: Should we support not_regular_expression operator for search_api_date filter plugin? » Drop support for not_regular_expression operator for search_api_date views filter
Category: Support request » Feature request
Issue summary: View changes
Related issues: +#3551591: Filter does not work with date range fields

After thinking about it for a bit, I think we should just simply drop support for not_regular_expression for search_api_date filters, so I've re-written the issue title and summary a bit, and I'll submit a merge request shortly.

mparker17’s picture

Issue summary: View changes

Added merge request !321, reviews welcome!