/**
  * Index wordIndex.
  *
  * Ported from the legacy code
  *
  * @see https://github.com/ezsystems/ezpublish-legacy/blob/master/kernel/search/plugins/ezsearchengine/ezsearchengine.php#L255
  *
  * @param \eZ\Publish\Core\Search\Legacy\Content\FullTextData $fullTextData
  * @param array $indexArray
  * @param array $wordIDArray
  * @param int $placement
  *
  * @return int last placement
  */
 private function indexWords(FullTextData $fullTextData, array $indexArray, array $wordIDArray, $placement = 0)
 {
     $contentId = $fullTextData->id;
     $prevWordId = 0;
     for ($i = 0; $i < count($indexArray); ++$i) {
         $indexWord = $indexArray[$i]['Word'];
         $contentFieldId = $indexArray[$i]['ContentClassAttributeID'];
         $identifier = $indexArray[$i]['identifier'];
         $integerValue = $indexArray[$i]['integer_value'];
         $wordId = $wordIDArray[$indexWord];
         if (isset($indexArray[$i + 1])) {
             $nextIndexWord = $indexArray[$i + 1]['Word'];
             $nextWordId = $wordIDArray[$nextIndexWord];
         } else {
             $nextWordId = 0;
         }
         $frequency = 0;
         $this->searchIndex->addObjectWordLink($wordId, $contentId, $frequency, $placement, $nextWordId, $prevWordId, $fullTextData->contentTypeId, $contentFieldId, $fullTextData->published, $fullTextData->sectionId, $identifier, $integerValue);
         $prevWordId = $wordId;
         ++$placement;
     }
     return $placement;
 }