private function getRepositorySearch($keywords, $type, Composer $composer, $threshold)
    {
        $repositoryManager = $composer->getRepositoryManager();
        $localRepository   = $repositoryManager->getLocalRepository();

        $repositories = new CompositeRepository([$localRepository]);

        // If we do not search locally, add the other repositories now.
        if ('installed' !== $type) {
            $repositories->addRepository(new CompositeRepository($repositoryManager->getRepositories()));
        }

        $repositorySearch = new RepositorySearch($repositories);
        $repositorySearch->setSatisfactionThreshold($threshold);
        if (false !== strpos($keywords, '/')) {
            $repositorySearch->disableSearchType(RepositoryInterface::SEARCH_FULLTEXT);
        } else {
            $repositorySearch->disableSearchType(RepositoryInterface::SEARCH_NAME);
        }

        $searcher = new CompositeSearch(
            [
                $repositorySearch
            ]
        );
        $searcher->setSatisfactionThreshold($threshold);

        return $searcher;
    }