You are here

public function SearchApiQueryInterface::execute in Search API 7

Executes this search query.

Return value

array An associative array containing the search results. The following keys are standardized:

  • 'result count': The overall number of results for this query, without range restrictions. Might be approximated, for large numbers, or skipped entirely if the "skip result count" option was set on this query.
  • results: An array of results, ordered as specified. The array keys are the items' IDs, values are arrays containing the following keys:

    • id: The item's ID.
    • score: A float measuring how well the item fits the search.
    • fields: (optional) If set, an array containing some field values already ready-to-use. This allows search engines (or postprocessors) to store extracted fields so other modules don't have to extract them again. This fields should always be checked by modules that want to use field contents of the result items. The format of the array is field IDs (as used by the Search API internally) mapped to either the raw value of the field (scalar or array value), or an associative array with the following keys:

      • #value: The raw field value.
      • #sanitize_callback: The callback to use for sanitizing the field value for HTML output, or FALSE to state that the field value is already sanitized.

      In the simple form, it's assumed the field value should be sanitized with check_plain().

    • entity: (optional) If set, the fully loaded result item. This field should always be used by modules using search results, to avoid duplicate item loads.
    • excerpt: (optional) If set, an HTML text containing highlighted portions of the fulltext that match the query.
  • warnings: A numeric array of translated warning messages that may be displayed to the user.
  • ignored: A numeric array of search keys that were ignored for this search (e.g., because of being too short or stop words).
  • performance: An associative array with the time taken (as floats, in seconds) for specific parts of the search execution:

    • complete: The complete runtime of the query.
    • hooks: Hook invocations and other client-side preprocessing.
    • preprocessing: Preprocessing of the service class.
    • execution: The actual query to the search server, in whatever form.
    • postprocessing: Preparing the results for returning.

Additional metadata may be returned in other keys. Only 'result count' and 'results' always have to be set, all other entries are optional.

Throws

SearchApiException If an error prevented the search from completing.

1 method overrides SearchApiQueryInterface::execute()
SearchApiQuery::execute in includes/query.inc
Executes this search query.

File

includes/query.inc, line 236
Contains SearchApiQueryInterface and SearchApiQuery.

Class

SearchApiQueryInterface
Interface representing a search query on an Search API index.

Code

public function execute();