Commonly used public procurement SPARQL Snippets
Introduction
Some SPARQL code snippets are provided below for classes that are used often in public procurement SPARQL queries. These are classes such as winner country, lot value, currency, date, winner business size, etc.
Sample Snippets
These snippets will go into the WHERE section of the query (after the list of fields you wish the query to return under SELECT).
Limit/ filter results by language (EN)
This snippet shows how to limit the results to those in English. This can be done for any language.
FILTER(LANG(?WinnerLegalName) = 'en')
Limit the results to a specified date
This snippet shows limiting the results to a specified date. Change this as required.
VALUES ?NoticePublicationDate {
"20230921"
}
Limit the results to a date range
FILTER (?NoticePublicationDate < "2023-09-01"^^xsd:dateTime && ?NoticePublicationDate > "2024-01-01"^^xsd:dateTime)
?LotURI and ?NoticePublicationDate derived from ?Notice:
?Notice epo:hasPublicationDate ?NoticePublicationDate ;
epo:refersToLot ?LotURI.
?LotURI, ?MonetaryValue and ?TenderAwardOutcome derived from from ?LotAwardOutcome:
?LotAwardOutcome epo:describesLot ?LotURI ;
epo:hasAwardedValue ?MonetaryValue ;
epo:comprisesTenderAwardOutcome ?TenderAwardOutcome.
?Winner derived from ?TenderAwardOutcome:
?TenderAwardOutcome a epo:TenderAwardOutcome;
epo:indicatesAwardOfLotToWinner / epo:playedBy ?Winner.
?WinnerLegalName derived from ?Winner:
?Winner a org:Organization;
epo:hasLegalName ?WinnerLegalName.
?WinnerCountryCode derived from ?Winner:
Not all records have a country code so if this was mandatory, the records without a code would not be returned. Therefore this is optional. |
OPTIONAL {
?Winner cccev:registeredAddress / epo:hasCountryCode ?WinnerCountryCode.
}
?LotAwardedValue and ?LotAwardedValueCurrency derived from ?MonetaryValue:
?MonetaryValue a epo:MonetaryValue;
epo:hasAmountValue ?LotAwardedValue;
epo:hasCurrency ?LotAwardedValueCurrency .
?Organization and ?LegalName are derived from ?Notice
?Notice epo:announcesRole ?Buyer .
?Buyer epo:playedBy ?Organization .
?Organization cccev:registeredAddress / epo:hasCountryCode ?countryCode .
?Organization epo:hasLegalName ?LegalName .
?BusinessSize derived from ?Notice
?Notice epo:announcesRole ?Buyer .
?Buyer epo:playedBy ?Organization .
?Organization epo:hasBusinessSize ?BusinessSize .
Contract Value and currency (?AwardedValue and ?LotAwardedValueCurrencyURI) derived from ?Notice
?Notice epo:refersToLot ?Lot .
?LotAwardOutcome epo:describesLot ?Lot ;
epo:hasAwardedValue / epo:hasAmountValue ?AwardedValue;
epo:hasAwardedValue / epo:hasCurrency ?LotAwardedValueCurrencyURI.
Procurement object by common procurement vocabulary (CPV) code.
Search for a procurement object (type of goods supplied) by common procurement vocabulary (CPV) code: ?MainClassification from ?ProcurementObject. This example searches for CPV 0341xxxx: wood.
?ProcurementObject epo:hasPurpose ?Purpose .
?Purpose epo:hasMainClassification ?MainClassification .
FILTER(strstarts(str(?MainClassification), 'http://data.europa.eu/cpv/cpv/0341')) .
Note: the code above can be substituted for any other CPV code that contains subcodes.
Subtypes of the ?MainClassification CPV code
(This adds the subtype of wood for each record: logs, soft wood, hard wood, etc.)
?childMainClassification skos:broader+ ?MainClassification .
?childMainClassification skos:inScheme <http://data.europa.eu/cpv/cpv> .
?MainClassification skos:inScheme <http://data.europa.eu/cpv/cpv> .
OPTIONAL { ?childMainClassification skos:prefLabel ?childMainClassificationLabel .
FILTER (lang(?childMainClassificationLabel) = "en") }
You can search through the CPV codes on the ted.europa.eu website using the Advanced Search and drilling down in the CPV field. |