Add keyword#
Keyword#
- metacatalog.api.add_keyword(session: Session, path: str, thesaurus: Union[int, dict]) List[Keyword] #
Add a new keyword to the database. The keyword is added by the full path.
- Parameters:
session (sqlalchemy.Session) – SQLAlchemy session connected to the database.
path (str) – A full path to the keyword, each element connected by a ‘ > ‘ sequence. E.g.: Topic > Term > Variable_level_1 etc.
thesaurus (dict, int) –
New in version 0.1.10.
Either a thesaurus entity, that distributes the controlled keywords, or an id of the an already existing thesaurusName. It is highly recommended to use an existing ID.
Note
This API endpoint is designed to add custom keywords to metacatalog. It will use the full path keywords and split them automatically for convenience.
Warning
Each keyword part will receive a new UUID, thus you have to use the metacatalog.models.Keyword interface to add existing keywords, that already contain a UUID.
- Returns:
List of the deconstructed Keyword entities
- Return type:
keywords, list of metacatalog.Keywords
Add keywords to entries#
- metacatalog.api.add_keywords_to_entries(session: Session, entries: List[Union[int, str, Entry]], keywords: List[Union[int, str, Keyword]], alias=None) None #
Associate keyword(s) to entrie(s)
Adds associations between entries and keywords. The Entry and Keyword instances have to already exist in the database. Keywords are usually prepopulated. You might want to alias an keyword or associate a value to it. Use the alias and value lists for this.
- Parameters:
session (sqlalchemy.Session) – SQLAlchemy session connected to the database.
entries (list) – List of identifier or single identifier to load entries. If int, the Entry.id is assumed. If str, title is assumed. Can also pass a metacatalog.Entry object.
keywords (list) – List of identifier or single identifier to load keywords. If int, Keyword.id is assumed, If str, Keyword.value is assumed. Can also pass a metacatalog.Keyword object.
alias (list) –
List of, or single alias names. The shape has to match the keywords parameter. These alias will rename the keywords on association. In case one instance should not recive an alias, pass None instead.
Deprecated since version 0.4.5: ‘alias’ will be removed with a future release
- Return type:
void
See also
metacatalog.Entry
,metacatalog.Keyword