SearchComposer

class OC\Search\SearchComposer
Queries individual \OCP\Search\IProvider implementations and composes a
unified search result for the user’s search term
The search process is generally split into two steps

1. Get a list of provider (`getProviders`)
2. Get search results of each provider (`search`)

The reasoning behind this is that the runtime complexity of a combined search
result would be O(n) and linearly grow with each provider added. This comes
from the nature of php where we can’t concurrently fetch the search results.
So we offload the concurrency the client application (e.g. JavaScript in the
browser) and let it first get the list of providers to then fetch all results
concurrently. The client is free to decide whether all concurrent search
results are awaited or shown as they come in.
Source:lib/private/Search/SearchComposer.php#61

Properties

Methods

public OC\Search\SearchComposer::__construct($bootstrapCoordinator, $container, $logger)
Source:lib/private/Search/SearchComposer.php#75
public OC\Search\SearchComposer::getProviders($route, $routeParameters)
Get a list of all provider IDs & Names for the consecutive calls to `search`
Sort the list by the order property
Source:

lib/private/Search/SearchComposer.php#121

Parameters:
  • $route (string) the route the user is currently at
  • $routeParameters (array) the parameters of the route the user is currently at
Returns:

array

public OC\Search\SearchComposer::search($user, $providerId, $query)
Query an individual search provider for results
Source:

lib/private/Search/SearchComposer.php#154

Parameters:
Returns:

\OCP\Search\SearchResult

Throws:

\InvalidArgumentException when the $providerId does not correspond to a registered provider