Help/Topics
What is a keyword?
An keyword (Q12) is a keyword. We use keywords with keyword (P15) to describe, for example:
- what a document is about
- what a project focuses on
In Metabase, the label is all we need to tag documents. We do not describe how keywords relate to each other, for example which terms are broader or narrower. That information already exists in Wikidata, and you can get it with a federated query if you need it.
Creating a keyword
Before you create a new keyword, search Metabase to check that it does not already exist.
A keyword item only needs a label and these two statements:
- instance of (P5)
- Value: keyword (Q12)
- same as on Wikidata (P1)
- Value: the Q-ID of the matching Wikidata item
Examples:
Using other items as keywords
Sometimes you want to use an item that is already something else as a keyword, for example a location (Q66) or a Wikimedia content project (Q22). You do not need to create a separate keyword item for it. Instead, add one more statement to the existing item:
- instance of (P5)
- Value: keyword (Q12)
The item then has two instance of (P5) statements: its original one and keyword (Q12).
Examples:
SPARQL
All keywords, with labels in English and Swedish
PREFIX wb: <https://metabase.wikibase.cloud/entity/>
PREFIX wbt: <https://metabase.wikibase.cloud/prop/direct/>
SELECT ?item ?itemLabelEN ?itemLabelSV ?wikidata_iri
WHERE
{
?item wbt:P5 wb:Q12 .
OPTIONAL {?item wbt:P1 ?wikidataQ}
OPTIONAL {?item rdfs:label ?itemLabelEN filter (lang(?itemLabelEN) = "en")}.
OPTIONAL {?item rdfs:label ?itemLabelSV filter (lang(?itemLabelSV) = "sv")}.
BIND(URI(concat("http://www.wikidata.org/entity/", ?wikidataQ)) AS ?wikidata_iri)
}
Number of keywords
PREFIX wb: <https://metabase.wikibase.cloud/entity/>
PREFIX wbt: <https://metabase.wikibase.cloud/prop/direct/>
SELECT (COUNT(*) AS ?count_index_terms)
WHERE
{
?item wbt:P5 wb:Q12 .
}
Timeline of everything published or presented about Structured Data on Commons
This query shows how to use a keyword to find all items about one topic. Replace Q90 with another item to make a timeline for that topic.
#defaultView:Timeline
PREFIX wb: <https://metabase.wikibase.cloud/entity/>
PREFIX wbt: <https://metabase.wikibase.cloud/prop/direct/>
SELECT ?item ?itemLabel ?time
WHERE
{
?item wbt:P15 wb:Q90 # SDC
{?item wbt:P23 ?time} # point in time
UNION
{?item wbt:P18 ?time} # publication date
SERVICE wikibase:label { bd:serviceParam wikibase:language "en,sv". }
}