Full text search for repository name and description
Adds support for searching full text against the name and description of a repository [Delivers #134867401]
This commit is contained in:
parent
d65d32b284
commit
973a110ac7
5 changed files with 73 additions and 12 deletions
|
@ -21,7 +21,8 @@ from sqlalchemy.engine.url import make_url
|
|||
|
||||
import resumablehashlib
|
||||
|
||||
from data.fields import ResumableSHA256Field, ResumableSHA1Field, JSONField, Base64BinaryField
|
||||
from data.fields import (ResumableSHA256Field, ResumableSHA1Field, JSONField, Base64BinaryField,
|
||||
FullIndexedTextField, FullIndexedCharField)
|
||||
from data.text import match_mysql, match_like
|
||||
from data.read_slave import ReadSlaveModel
|
||||
from util.names import urn_generator
|
||||
|
@ -31,10 +32,12 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
DEFAULT_DB_CONNECT_TIMEOUT = 10 # seconds
|
||||
|
||||
|
||||
# IMAGE_NOT_SCANNED_ENGINE_VERSION is the version found in security_indexed_engine when the
|
||||
# image has not yet been scanned.
|
||||
IMAGE_NOT_SCANNED_ENGINE_VERSION = -1
|
||||
|
||||
|
||||
_SCHEME_DRIVERS = {
|
||||
'mysql': MySQLDatabase,
|
||||
'mysql+pymysql': MySQLDatabase,
|
||||
|
@ -43,6 +46,7 @@ _SCHEME_DRIVERS = {
|
|||
'postgresql+psycopg2': PostgresqlDatabase,
|
||||
}
|
||||
|
||||
|
||||
SCHEME_MATCH_FUNCTION = {
|
||||
'mysql': match_mysql,
|
||||
'mysql+pymysql': match_mysql,
|
||||
|
@ -51,6 +55,7 @@ SCHEME_MATCH_FUNCTION = {
|
|||
'postgresql+psycopg2': match_like,
|
||||
}
|
||||
|
||||
|
||||
SCHEME_RANDOM_FUNCTION = {
|
||||
'mysql': fn.Rand,
|
||||
'mysql+pymysql': fn.Rand,
|
||||
|
@ -59,6 +64,7 @@ SCHEME_RANDOM_FUNCTION = {
|
|||
'postgresql+psycopg2': fn.Random,
|
||||
}
|
||||
|
||||
|
||||
def pipes_concat(arg1, arg2, *extra_args):
|
||||
""" Concat function for sqlite, since it doesn't support fn.Concat.
|
||||
Concatenates clauses with || characters.
|
||||
|
@ -482,9 +488,9 @@ class Visibility(BaseModel):
|
|||
|
||||
class Repository(BaseModel):
|
||||
namespace_user = QuayUserField(null=True)
|
||||
name = CharField()
|
||||
name = FullIndexedCharField(match_function=db_match_func)
|
||||
visibility = ForeignKeyField(Visibility)
|
||||
description = TextField(null=True)
|
||||
description = FullIndexedTextField(match_function=db_match_func, null=True)
|
||||
badge_token = CharField(default=uuid_generator)
|
||||
|
||||
class Meta:
|
||||
|
|
Reference in a new issue