Skip to content

Uses similarity sort for projects query

Nick Leonard requested to merge nl-project-search-sort into master

What does this MR do and why?

Uses similarity sorting in the project search graphql query used for project selection in the group issue list and workspace setup in order to present more relevant results.

Current pain point: In gitlab-org, users cannot reach this project GitLab in the search results as it's after the 1st page and there's no pagination. The top result is "GitLab.org / Secure Stage / tools / Dependency Collection", which is unexpected given there is only a path match. This isn't a 100% solution but brings GitLab into the first page of a search for "GitLab", with only other identically named projects above. Users in other organizations with redundancy in group/project names should see similar benefits.

What this MR does not do

This does not affect issues dashboard which uses a different query, sorted by user activity. It may be useful to apply the same sorting there, but let's consider that separately.

Further consideration

Searching with the group included still does not work, e.g. "GitLab.org / GitLab" does not return anything before or after this MR, despite being a listed item.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

- Before After
Group issue list (scoped to namespace) image image
Test in prod

Query

  group(fullPath: $fullPath) {
    id
    projects(search: $search, withIssuesEnabled: true, includeSubgroups: true, sort:SIMILARITY) {
      nodes {
        id
        name
        nameWithNamespace
        webUrl
        __typename
      }
      __typename
    }
    __typename
  }
}
variables {
  "search": "GitLab",
  "fullPath": "gitlab-org"
}

Response: Showing only top results, truncating data that may be from of private projects. This project is rank 7.

{
"data": {
"group": {
"id": "gid://gitlab/Group/9970",
"projects": {
"nodes": [
{
"name": "GitLab",
"__typename": "Project"
},
{
"name": "🔒 gitlab",
"__typename": "Project"
},
{
"name": "GitLab",
"__typename": "Project"
},
{
"name": "GitLab",
"__typename": "Project"
},
{
"name": "GitLab",
"__typename": "Project"
},
{
"name": "GitLab",
"__typename": "Project"
},
{
"id": "gid://gitlab/Project/278964", <-- this project
"name": "GitLab",
"__typename": "Project"
},
{
"name": "GitLab-Git",
"__typename": "Project"
},
...

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

Edited by Nick Leonard

Merge request reports