/**
  * Produces a snippet with the first match result for the search term.
  *
  * @param string $searchword The search word
  * @param integer $resultTokens The amount of tokens (words) to get surrounding the match hit. (defaults to 60)
  * @param string $ellipsis added to the end of the string if the text was longer than the snippet produced. (defaults to "...")
  * @param string $beginModifier added immediately before the searchword in the snippet (defaults to <b>)
  * @param string $endModifier added immediately after the searchword in the snippet (defaults to </b>)
  * @return string
  */
 public function fulltextMatchResult($searchword, $resultTokens = 60, $ellipsis = '...', $beginModifier = '<b>', $endModifier = '</b>')
 {
     $query = $this->buildQueryString();
     $results = $this->indexClient->query($query);
     $queryParameters = array();
     $identifierParameters = array();
     foreach ($results as $key => $result) {
         $parameterName = ':possibleIdentifier' . $key;
         $identifierParameters[] = $parameterName;
         $queryParameters[$parameterName] = $result['__identifier__'];
     }
     $queryParameters[':beginModifier'] = $beginModifier;
     $queryParameters[':endModifier'] = $endModifier;
     $queryParameters[':ellipsis'] = $ellipsis;
     $queryParameters[':resultTokens'] = $resultTokens * -1;
     $matchQuery = 'SELECT snippet(fulltext, :beginModifier, :endModifier, :ellipsis, -1, :resultTokens) as snippet FROM fulltext WHERE fulltext MATCH :searchword AND __identifier__ IN (' . implode(',', $identifierParameters) . ') LIMIT 1;';
     $queryParameters[':searchword'] = $searchword;
     $matchSnippet = $this->indexClient->executeStatement($matchQuery, $queryParameters);
     if (isset($matchSnippet[0]['snippet']) && $matchSnippet[0]['snippet'] !== '') {
         $match = $matchSnippet[0]['snippet'];
     } else {
         $match = '';
     }
     return $match;
 }
 /**
  * @param NodeInterface $node
  * @return void
  */
 protected function indexAllNodeVariants(NodeInterface $node)
 {
     $nodeIdentifier = $node->getIdentifier();
     $allIndexedVariants = $this->indexClient->query('SELECT __identifier__ FROM objects WHERE __identifier = "' . $nodeIdentifier . '"');
     foreach ($allIndexedVariants as $nodeVariant) {
         $this->indexClient->removeData($nodeVariant['__identifier__']);
     }
     foreach ($this->workspaceRepository->findAll() as $workspace) {
         $this->indexNodeInWorkspace($nodeIdentifier, $workspace->getName());
     }
 }
 /**
  * Utility to check the content of the index.
  *
  * @param string $queryString
  */
 public function findCommand($queryString)
 {
     $result = $this->indexClient->query($queryString);
     $this->output->outputTable($result);
 }