Skip to content

Improvement to search in Project

Ramya Authappan requested to merge github/fork/zenati/patch-4 into master

Created by: zenati

This commit improves searching projects with multiple tokens by splitting tokens against searchable columns.

Before
Project.search("hello world") runs the following sql:
    SELECT "projects".* FROM "projects"
    INNER JOIN "namespaces" ON "namespaces"."id" = "projects"."namespace_id"
    WHERE (projects.archived = 'f')
    AND (LOWER(projects.name) LIKE '%hello world%'
      OR LOWER(projects.path) LIKE '%hello world%'
      OR LOWER(namespaces.name) LIKE '%hello world%'
      OR LOWER(projects.description) LIKE '%hello world%')
Project(name='hello', description='world') Will not be found
After
Project.search("hello world") runs the following sql:
    SELECT "projects".* FROM "projects"
    INNER JOIN "namespaces"
    ON "namespaces"."id" = "projects"."namespace_id"
    WHERE (projects.archived = 'f')
    AND (LOWER(projects.name) LIKE '%hello%'
      OR LOWER(projects.description) LIKE '%hello%'
      OR LOWER(projects.path) LIKE '%hello%'
      OR LOWER(namespaces.name) LIKE '%hello%')
    AND (LOWER(projects.name) LIKE '%world%'
      OR LOWER(projects.description) LIKE '%world%'
      OR LOWER(projects.path) LIKE '%world%'
      OR LOWER(namespaces.name) LIKE '%world%')
Project(name='hello', description='world') Will be found

Merge request reports

Loading