Problem/Motivation

Currently the only filters available for the ViewsFilter plugin search_api_text are:

  • contains
  • doesn't contain

In comparison, the default @ViewsFilter("string") supports more operators:

  • Is equal to
  • Is not equal to
  • Contains
  • Contains any word
  • Contains all words
  • Starts with
  • Does not start with
  • Ends with
  • Does not end with
  • Does not containLength is shorter than
  • Length is longer than
  • Regular expression
  • Is empty (NULL)
  • Is not empty (NOT NULL)

Proposed resolution

Let's work towards supporting the same operators as Views textfields, starting with empty/not empty.

Remaining tasks

  1. Write a patch
  2. Review
  3. Commit

User interface changes

Filter options for 'empty'/'not empty' are available when filtering textfields in Views.

API changes

None.

Data model changes

None.

Comments

idebr created an issue. See original summary.

idebr’s picture

Status: Active » Needs review
StatusFileSize
new1.07 KB

Attached patch adds options for 'empty' and 'not empty' in the views filter for search api textfields. The query on = NULL, <> NULL already works.

drunken monkey’s picture

I don't think it will be possible to support any of the other operators (well, maybe "contains any word"), but you're right, there's no reason why we can't have "is (not) empty". Patch looks good, too. However, we should also have a test for this – patch attached.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

Tests look good, great work Thomas! I think this is a good start, we can try adding followups for the other types of queries if those are requested heavily.

I think this is good to go in.

  • drunken monkey committed 1a72199 on 8.x-1.x authored by idebr
    Issue #2942846 by idebr, drunken monkey, borisson_: Added empty/not...
drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Good to hear, thanks a lot for reviewing!
Committed.
Thanks again also to idebr!

Status: Fixed » Closed (fixed)

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