updateWordWeights example

return;
    }

    $node_storage = $this->entityTypeManager->getStorage('node');
    $words = [];
    try {
      foreach ($node_storage->loadMultiple($nids) as $node) {
        $words += $this->indexNode($node);
      }
    }
    finally {
      $this->searchIndex->updateWordWeights($words);
    }
  }

  /** * Indexes a single node. * * @param \Drupal\node\NodeInterface $node * The node to index. * * @return array * An array of words to update after indexing. */
->fields(['score' => $score])
          ->expression('score', '[score] + :score', [':score' => $score])
          ->execute();
        $current_words[$word] = TRUE;
      }
    }
    catch (\Exception $e) {
      throw new SearchIndexException("Failed to insert dataset in index for type '$type', sid '$sid' and langcode '$langcode'", 0, $e);
    }
    finally {
      if ($update_weights) {
        $this->updateWordWeights($current_words);
      }
    }
    return $current_words;
  }

  /** * {@inheritdoc} */
  public function clear($type = NULL, $sid = NULL, $langcode = NULL) {

    try {
      
foreach ($language_list as $langcode => $language) {
          $topic = $section_plugin->renderTopicForSearch($item->topic_id, $language);
          if ($topic) {
            // Index the title plus body text.             $text = '<h1>' . $topic['title'] . '</h1>' . "\n" . $topic['text'];
            $words += $this->searchIndex->index($this->getType()$item->sid, $langcode$text, FALSE);
          }
        }
      }
    }
    finally {
      $this->searchIndex->updateWordWeights($words);
      $this->updateIndexState();
    }
  }

  /** * {@inheritdoc} */
  public function indexClear() {
    $this->searchIndex->clear($this->getType());
  }

  
Home | Imprint | This part of the site doesn't use cookies.