-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #121 from ecmwf-projects/copds-1777-fts
COPDS-1777: custom ranking on catalogue search
- Loading branch information
Showing
13 changed files
with
162 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
"""fields for advanced fts. | ||
Revision ID: 63827287c182 | ||
Revises: 654a874249a8 | ||
Create Date: 2024-06-27 09:34:31.278052 | ||
""" | ||
|
||
import sqlalchemy as sa | ||
import sqlalchemy_utils | ||
|
||
from alembic import op | ||
from cads_catalogue import database | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "63827287c182" | ||
down_revision = "654a874249a8" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
op.add_column( | ||
"resources", | ||
sa.Column( | ||
"fts", | ||
sqlalchemy_utils.types.ts_vector.TSVectorType(regconfig="english"), | ||
sa.Computed( | ||
"to_tsvector('english', coalesce(high_priority_terms, ''))", | ||
persisted=True, | ||
), | ||
), | ||
) | ||
op.create_index( | ||
"idx_resources_fts", | ||
"resources", | ||
["fts"], | ||
postgresql_using="gin", | ||
) | ||
op.add_column("resources", sa.Column("popularity", sa.Integer, default=1)) | ||
op.execute(database.add_rank_function_sql) | ||
|
||
|
||
def downgrade() -> None: | ||
op.drop_column("resources", "fts") | ||
op.execute(database.drop_rank_function_sql) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.