Module: Gitlab::Client::Search

Included in:
Gitlab::Client
Defined in:
lib/gitlab/client/search.rb

Overview

Defines methods related to global searches, searching in projects and searching in groups.

Instance Method Summary collapse

Instance Method Details

#search_globally(scope, search) ⇒ Array<Gitlab::ObjectifiedHash>

Search globally across the GitLab instance.

Examples:

Gitlab.search_globally('projects', 'gitlab')
Gitlab.search_globally('issues', 'gitlab')
Gitlab.search_globally('merge_requests', 'gitlab')
Gitlab.search_globally('milestones', 'gitlab')
Gitlab.search_globally('snippet_titles', 'gitlab')
Gitlab.search_globally('snippet_blobs', 'gitlab')

Parameters:

  • scope (String)

    The scope to search in. Currently these scopes are supported: projects, issues, merge_requests, milestones, snippet_titles, snippet_blobs.

  • search (String)

    The search query.

Returns:



20
21
22
23
# File 'lib/gitlab/client/search.rb', line 20

def search_globally(scope, search)
  options = { scope: scope, search: search }
  get('/search', query: options)
end

#search_in_group(group, scope, search) ⇒ Array<Gitlab::ObjectifiedHash>

Search within the specified group.

Examples:

Gitlab.search_in_group(1, 'projects', 'gitlab')
Gitlab.search_in_group(1, 'issues', 'gitlab')
Gitlab.search_in_group(1, 'merge_requests', 'gitlab')
Gitlab.search_in_group(1, 'milestones', 'gitlab')

Parameters:

  • group (Integer, String)

    The ID or name of a group.

  • scope (String)

    The scope to search in. Currently these scopes are supported: projects, issues, merge_requests, milestones.

  • search (String)

    The search query.

Returns:



37
38
39
40
# File 'lib/gitlab/client/search.rb', line 37

def search_in_group(group, scope, search)
  options = { scope: scope, search: search }
  get("/groups/#{url_encode group}/search", query: options)
end

#search_in_project(project, scope, search, ref = nil) ⇒ Array<Gitlab::ObjectifiedHash>

Search within the specified project.

Examples:

Gitlab.search_in_project(1, 'issues', 'gitlab')
Gitlab.search_in_project(1, 'merge_requests', 'gitlab')
Gitlab.search_in_project(1, 'milestones', 'gitlab')
Gitlab.search_in_project(1, 'notes', 'gitlab')
Gitlab.search_in_project(1, 'wiki_blobs', 'gitlab')
Gitlab.search_in_project(1, 'commits', 'gitlab')
Gitlab.search_in_project(1, 'blobs', 'gitlab')

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • scope (String)

    The scope to search in. Currently these scopes are supported: issues, merge_requests, milestones, notes, wiki_blobs, commits, blobs.

  • search (String)

    The search query.

Returns:



57
58
59
60
61
62
63
64
# File 'lib/gitlab/client/search.rb', line 57

def search_in_project(project, scope, search, ref = nil)
  options = { scope: scope, search: search }

  # Add ref filter if provided - backward compatible with main project
  options[:ref] = ref unless ref.nil?

  get("/projects/#{url_encode project}/search", query: options)
end