Problem/Motivation

With SQL-based views, it's possible to define additional query tags to add to the view from the "Query settings" of the view. Currently, when editing a view based on a Search API index, this option isn't accessible, but it seems that the \Drupal\search_api\Query\QueryInterface supports the use of query tags.

Steps to reproduce

  1. Create a new view of content that does not use search API.
  2. While editing the view, click on the "Query settings" option under "Advanced" - "Other".
  3. Create a new view of search API results.
  4. While editing the view, click on the "Query settings" option under "Advanced" - "Other".
  5. Compare the options shown in step 2 to those in step 4.

There is no option to provide query tags on a Search API query

Proposed resolution

Add support for the option to Search API Views.

Remaining tasks

Issue fork search_api-3232736

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

GuyPaddock created an issue. See original summary.

guypaddock’s picture

Issue summary: View changes
guypaddock’s picture

Issue summary: View changes
guypaddock’s picture

Component: General code » Views integration
Assigned: Unassigned » guypaddock

Looking into this now.

guypaddock’s picture

Assigned: guypaddock » Unassigned
Status: Active » Needs review

I've submitted an MR to add this feature. This likely needs tests, but does work in manual testing.

drunken monkey’s picture

Thanks a lot for reporting this, this does look like a good idea!
The code looks also sensible, except that I think submitConfigurationForm() could be a lot more concise. Anyways, very good you already included the fix for this strange Core bug.

You are right, though, this definitely still needs tests. Are you willing/able to provide some?

Unfortunately, due to #3190024: Problem with test dependencies when testing issue forks, we cannot really use MRs in this project yet. We’ll have to stick with patches until this is fixed.
Consequently, I’m attaching a patch with my changes. Please test/review to see if this still works for you.

drunken monkey’s picture

Status: Needs review » Needs work

NW for the tests.

guypaddock’s picture

@drunken monkey Your changes LGTM! Unfortunately, I have been having a lot of issues with getting any kind of testing working locally; it's on our team's list of tech debt to tackle so we can author tests but right now it's a blocker for me.

idebr’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new2.81 KB
new5.68 KB

Attached patch adds a test that adds Query Tags through the Views UI and asserts the query tag is correctly added to the Search API query through SearchApiEvents::QUERY_PRE_EXECUTE.TAG

drunken monkey’s picture

StatusFileSize
new2.21 KB
new5.87 KB

Thanks a lot, great job!
I just changed a few details and will commit if the test bot is happy.

drunken monkey’s picture

Status: Needs review » Fixed

Committed.
Thanks again, everyone!

Status: Fixed » Closed (fixed)

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