Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function postprocessSearchResults(ResultSetInterface $results)
 {
     if (!$results->getResultCount() || !($keys = $this->getKeywords($results->getQuery()))) {
         return;
     }
     $result_items = $results->getResultItems();
     if ($this->configuration['excerpt']) {
         $this->addExcerpts($result_items, $keys);
     }
     if ($this->configuration['highlight'] != 'never') {
         $highlighted_fields = $this->highlightFields($result_items, $keys);
         if ($highlighted_fields) {
             // Maybe the backend or some other processor has already set highlighted
             // field values.
             foreach ($results->getExtraData('highlighted_fields', array()) as $item_id => $old_highlighting) {
                 $highlighted_fields += array($item_id => array());
                 $highlighted_fields[$item_id] += $old_highlighting;
             }
             $results->setExtraData('highlighted_fields', $highlighted_fields);
         }
     }
 }
 /**
  * Asserts that the search results contain the expected IDs.
  *
  * @param ResultSetInterface $result
  *   The search results.
  * @param int[][] $ids
  *   The expected entity IDs, grouped by entity type and with their indexes in
  *   this object's respective array properties as the values.
  */
 protected function assertResults(ResultSetInterface $result, array $expected)
 {
     $results = array_keys($result->getResultItems());
     sort($results);
     $ids = array();
     foreach ($expected as $entity_type => $items) {
         $datasource_id = "entity:{$entity_type}";
         foreach ($items as $i) {
             if ($entity_type == 'user') {
                 $id = $i . ':en';
             } else {
                 $id = $this->{"{$entity_type}s"}[$i]->id() . ':en';
             }
             $ids[] = Utility::createCombinedId($datasource_id, $id);
         }
     }
     sort($ids);
     $this->assertEqual($results, $ids);
 }