Currently, when adding new items for indexing in a processor or hook (cf. #2230917: Check if the post processing method at index time is powerful enough to support the multi document generation functionality as apachesolr had), this has to happen in the first processor(s), since otherwise those items' fields wouldn't be preprocessed by the other processors. Furthermore, when removing items to be indexed in a processor, we needlessly extract the items' fields beforehand.

All of these problems could be mitigated or solved by having an additional preprocessing step, before field extraction.

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: 8

Comments

drunken monkey’s picture

Issue summary: View changes

Clarified task. This is by no means one we have to implement soon (i.e., while still in the sandbox), though, I think.

drunken monkey’s picture

drunken monkey’s picture

Project: Search API (8.x) » Search API
Version: » 8.x-1.x-dev
Component: Backend » Framework
nick_vh’s picture

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

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new11.2 KB

This patch implements that and seems to work fine.
I'd also like to add some tests for this (and all other processor methods) to our HooksTest, but this depends on #2752749: Make handling of index plugins/fields consistent and #2134803: Add a "processing level" setting to search queries to avoid conflicts.

borisson_’s picture

Status: Needs review » Needs work

Only one thing I'd like to see changed, as well as the additional tests is the following:

  1. +++ b/src/Tests/HooksTest.php
    @@ -41,7 +45,13 @@ public function setUp() {
    +//    /** @var \Drupal\search_api\Processor\ProcessorInterface $processor */
    +//    $processor = $index->createPlugin('processor', 'search_api_test');
    +//    $index->addProcessor($processor)->save();
    

    @drunken monkey--

drunken monkey’s picture

Status: Needs work » Needs review
Issue tags: +DevDaysMilan
StatusFileSize
new5.72 KB
new16.12 KB

@drunken monkey--

:(
That was already part of said tests, I just wanted to keep it for them.
See the attached patch.

Status: Needs review » Needs work

The last submitted patch, 7: 2230915-6--processor_alter_items_method.patch, failed testing.

drunken monkey’s picture

Status: Needs work » Needs review
StatusFileSize
new663 bytes
new16.43 KB

Is this already enough?

Status: Needs review » Needs work

The last submitted patch, 9: 2230915-9--processor_alter_items_method.patch, failed testing.

drunken monkey’s picture

Status: Needs work » Needs review
StatusFileSize
new2.26 KB
new17.84 KB

A bit worrying that we didn't spot this config schema issue before – but then again, it's just in the test processor, so not really relevant.

And finally figured out what's wrong with the new hook test.

borisson_’s picture

Status: Needs review » Needs work
+++ b/src/Entity/Index.php
@@ -962,7 +968,13 @@ public function indexSpecificItems(array $search_objects) {
+      // This will cache the extracted fields so processors, etc., can retrieve
+      // them directly.

Lets rewrite this comment, I'd suggest: Get all the extracted fields for the item. The fact that this is cached is an implementation of the method and shouldn't matter for this comment.

If you disagree, than I feel this is RTBC, but setting back to NW for the comment update.

drunken monkey’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new17.99 KB

Thanks for your thorough review!

Lets rewrite this comment, I'd suggest: Get all the extracted fields for the item. The fact that this is cached is an implementation of the method and shouldn't matter for this comment.

No, I disagree. If this didn't cache the field values, than calling this method here would be pointless and just a waste of ressources. Also, if the method didn't store the extracted values, processors wouldn't work, since the server would always receive newly extracted, unprocessed field values anyways. So it's not an implementation detail at all, it's a basic characteristic of the framework.

The patch needed a re-roll, but if tests pass I'll then treat it as RTBC, in accordance with your comment.

  • drunken monkey committed 895b507 on 8.x-1.x
    Issue #2230915 by drunken monkey: Add additional preprocessing method at...
drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Committed.

mpp’s picture

-  public function preprocessIndexItems(array &$items);
+  public function preprocessIndexItems(array $items);

This is causing a fatal error ::preprocessIndexItems(array &$items) must be compatible with Drupal\search_api\Processor\ProcessorInterface::preprocessIndexItems(array $items)

See https://www.drupal.org/node/2230915

drunken monkey’s picture

This is causing a fatal error ::preprocessIndexItems(array &$items) must be compatible with Drupal\search_api\Processor\ProcessorInterface::preprocessIndexItems(array $items)

In which class, or which module? I'm positive we changed this in all our classes (and the tests would surely report it, otherwise) and we're not responsible for updating other modules.
Your link leads to this same issue.

mpp’s picture

StatusFileSize
new505 bytes

Sorry for the wrong copy paste but I still see it in UnsavedIndexConfiguration:

  /**
   * {@inheritdoc}
   */
  public function preprocessIndexItems(array &$items) {
    return $this->entity->preprocessIndexItems($items);
  }
drunken monkey’s picture

And that produces actual fails anywhere on your site? As said in the other issue (I think), we currently don't use that class.

Status: Fixed » Closed (fixed)

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