Currently, there is no way (without circumventing the framework) to keep a search query from executing all associated preprocessors, hooks, etc., when executing a query. This is sometimes not desired, e.g., when executing a search for internal purposes (I mostly think of saved searches here, but there are of course others). You don't want facets, etc., for those. In some cases, even running the processors on the query will be undesired.

To support this better in the framework, I suggest adding a "processing level" setting (probably via methods, not just as a normal query option) to search queries, with the following settings:

Full query (default)
As we do now, just call all enabled preprocessors (possibly taking into account the changes of #2044311: Change workflow plugin system, of course) and invoke the query alter hook before searching, then postprocess afterwards.
Basic query
Basic processing on the query (lowercase, stopwords, etc.) should still happen, but "extra features" should be skipped – those "features" being responsible for whether they should ignore this query or not. For example, facets, spellchecking and highlighting should probably all be skipped for this level.
For processors, it might be a good idea to provide an annotation property for this (skip_basic = true or similar) to a) easily specify this and b) make it instantly clear for developers looking at the processor.
None
Completely bypass any (non-required) pre- and postprocessing – i.e., don't use any processors and also skip all hooks (I think).

There will have to be extensive documentation for this so developers will have a good understanding of what setting a certain processing level will actually mean.

I don't think we can really make this extensible, since processors and contrib modules will have to know which levels to expect, but those three should at least be a large improvement.

Estimated Value and Story Points

This issue was identified as a Beta Blocker for Drupal 8. We sat down and figured out the value proposition and amount of work (story points) for this issue.

Value and Story points are in the scale of fibonacci. Our minimum is 1, our maximum is 21. The higher, the more value or work a certain issue has.

Value : 2
Story Points: 13

Comments

nick_vh’s picture

Issue summary: View changes
Issue tags: +beta blocker
drunken monkey’s picture

Issue summary: View changes
drunken monkey’s picture

Status: Active » Needs review
StatusFileSize
new23.37 KB

Here is a patch that should do this. As discussed, the "Highlight" processor skips "basic" queries. Anything else in this module that should do that?
I'd also be glad about reviews of the documentation, whether that's clear enough already.

borisson_’s picture

This looks pretty good, I only found one small thing.

+++ b/src/Plugin/search_api/processor/Highlight.php
@@ -168,7 +170,10 @@ public function submitConfigurationForm(array &$form, FormStateInterface $form_s
+      || $query->getProcessingLevel() != QueryInterface::PROCESSING_FULL

can we use $query->getPrcoessingLevel < QueryInterface::PROCESSING_FULL, this might make more sense?

drunken monkey’s picture

Issue tags: +DevDaysMilan
drunken monkey’s picture

Not sure about that. We don't really "guarantee" anywhere that "full" will have the highest numeric value, so I'd say that proper use of the constants doesn't involve such comparisons.
But thanks for the review, in any case!

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

Ok, makes sense.

  • drunken monkey committed a98914b on 8.x-1.x
    Issue #2134803 by drunken monkey: Added a "processing level" setting to...
drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Good to hear you agree.
Then: committed.
Thanks again for reviewing!

drunken monkey’s picture

Status: Fixed » Needs review
StatusFileSize
new4.88 KB

I actually forgot the whole point of the exercise, or at least a significant part of it.

borisson_’s picture

Status: Needs review » Needs work

Back to NW for sqlite fails.

drunken monkey’s picture

Status: Needs work » Needs review
StatusFileSize
new4.88 KB

Can't reproduce those locally. Re-attaching the same patch from #10.

drunken monkey’s picture

Looks good.
Is this otherwise RTBC in your opinion, Joris?

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

yes

  • drunken monkey committed fd9a0bf on 8.x-1.x
    Issue #2134803 by drunken monkey: Added a "processing level" setting to...
drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

OK, thanks!
Committed.

Status: Fixed » Closed (fixed)

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