You are here

public function ContentHubSearch::getReferenceFilters in Acquia Content Hub 8

Builds elasticsearch query to get filters name for auto suggestions.

Parameters

string $search_term: Given search term.

Return value

mixed Returns query result.

File

src/ContentHubSearch.php, line 120

Class

ContentHubSearch
Perform queries to the Content Hub "_search" endpoint [Elasticsearch].

Namespace

Drupal\acquia_contenthub

Code

public function getReferenceFilters($search_term) {
  if ($search_term) {
    $match[] = [
      'match' => [
        '_all' => $search_term,
      ],
    ];
    $query['query']['filtered']['query']['bool']['must'] = $match;
    $query['query']['filtered']['query']['bool']['must_not']['term']['data.type'] = 'taxonomy_term';
    $query['_source'] = TRUE;
    $query['highlight'] = [
      'fields' => [
        '*' => new \stdClass(),
      ],
    ];
    $result = $this
      ->executeSearchQuery($query);
    return $result ? $result['hits'] : FALSE;
  }
}