Project:SPARQL/examples
Jump to navigation
Jump to search
Simple Queries
All Items
#prefix for selecting Q items, item (Q43) => wb:Q43
prefix wb: <https://mcje-data.wikibase.cloud/entity/>
#prefix for selecting properties, subclass of (P2) => wbt:P2
prefix wbt: <https://mcje-data.wikibase.cloud/prop/direct/>
#select all items that match, return ?item and ?rl
select ?item ?rl where {
#add restriction that items need to be a subclass of (P2) => item (Q43)
#the + means it can also be a subclass of anything thing that is a subclass of item (Q43)
#slab (Q1305) => subclass of (P2) => item (Q43)
#so all Q items that are subclasses of slabs will also be returned
?item wbt:P2+ wb:Q43.
#make ?rl the value of resource location (P4)
#this also makes sure the resource location (P4) property exists
?item wbt:P4 ?rl.
}
Q Item With Resource Location
prefix wb: <https://mcje-data.wikibase.cloud/entity/>
prefix wbt: <https://mcje-data.wikibase.cloud/prop/direct/>
select ?item ?itemLabel ?itemDescription where {
?item wbt:P4 "minecraft:dirt".
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Commands
Command Arguments
prefix wb: <https://mcje-data.wikibase.cloud/entity/>
prefix wbt: <https://mcje-data.wikibase.cloud/prop/direct/>
prefix wbp: <https://mcje-data.wikibase.cloud/prop/>
prefix wbps: <https://mcje-data.wikibase.cloud/prop/statement/>
prefix wbq: <https://mcje-data.wikibase.cloud/prop/qualifier/>
select ?command_name ?argument_name ?argument_type where {
?item wbt:P1 wb:Q1466.
?item rdfs:label ?command_name.
?item wbp:P15 ?argument_statement.
?argument_statement wbps:P15 ?argument_name.
?argument_statement wbq:P16 ?argument_type_item.
?argument_type_item wbt:P4 ?argument_type.
}
Entities
All Projectiles
prefix wb: <https://mcje-data.wikibase.cloud/entity/>
prefix wbt: <https://mcje-data.wikibase.cloud/prop/direct/>
#return ?item & ?rl
select ?item ?rl where {
?item wbt:P2 wb:Q1581. # subclass of => projectile
?item wbt:P20 wb:Q1300. # part of => entity registry
?item wbt:P4 ?rl. # resource location => ?rl
}
Effects
Given Effects
prefix wb: <https://mcje-data.wikibase.cloud/entity/>
prefix wbt: <https://mcje-data.wikibase.cloud/prop/direct/>
prefix wbp: <https://mcje-data.wikibase.cloud/prop/>
prefix wbpq: <https://mcje-data.wikibase.cloud/prop/qualifier/>
prefix wbps: <https://mcje-data.wikibase.cloud/prop/statement/>
SELECT ?item ?itemLabel ?effect ?effectLabel ?amplifier ?duration WHERE {
?item wbp:P68 ?effectStatement.
?effectStatement wbps:P68 ?effect; wbpq:P69 ?amplifier; wbpq:P70 ?duration.
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Items
All Armor
prefix wb: <https://mcje-data.wikibase.cloud/entity/>
prefix wbt: <https://mcje-data.wikibase.cloud/prop/direct/>
SELECT ?item ?itemLabel ?rl ?armorClassLabel ?equipmentClassLabel ?durability WHERE {
?item wbt:P2 ?armorClass. # subclass => ?armorClass
?armorClass wbt:P2 wb:Q1621. # ?armorClass => subclass => armor
optional {
?item wbt:P2 ?equipmentClass. # subclass => ?equipmentClass
?equipmentClass wbt:P2 wb:Q1620. # ?equipmentClass => subclass => equipment
}
?item wbt:P53 ?durability. # durability => ?durability
?item wbt:P4 ?rl. # resource location => ?rl
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Food
prefix wb: <https://mcje-data.wikibase.cloud/entity/>
prefix wbt: <https://mcje-data.wikibase.cloud/prop/direct/>
SELECT ?item ?itemLabel ?restoredHunger ?restoredSaturation ?effectiveQuality ?nourishment WHERE {
?item wbt:P2* wb:Q1689. #sublcass of => food
?item wbt:P51 ?restoredHunger.
?item wbt:P52 ?restoredSaturation.
#Nourishment is defined as the ratio of saturation to hunger points restored.
#Foods with higher nourishment values should be eaten when the hunger bar is more full.
#https://minecraft.fandom.com/wiki/Food#Nourishment_value
bind(?restoredSaturation / ?restoredHunger as ?nourishment).
#Hunger Points + Saturation that is restored, which gives roughly how long the food can last.
#This value is reduced if the player is near the food or saturation cap, as excess points of either type are wasted.
#https://minecraft.fandom.com/wiki/Hunger
bind(?restoredHunger + ?restoredSaturation as ?effectiveQuality).
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Content Packs
All Packs
prefix wb: <https://mcje-data.wikibase.cloud/entity/>
prefix wbt: <https://mcje-data.wikibase.cloud/prop/direct/>
SELECT DISTINCT ?pack ?packLabel ?packDescription ?packType ?packTypeLabel ?vanilla ?downloadURL WHERE {
?pack wbt:P1/wbt:P2* wb:Q5192. # instance of => pack
?pack wbt:P1 ?packType.
filter(?packType != wb:Q5195). # ?packType != vanilla pack
BIND(exists{?pack wbt:P1/wbt:P2* wb:Q5195} as ?vanilla) # instance of => vanilla pack
optional {?pack wbt:P73 ?downloadURL.}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Registries
Registry Entries
#defaultView:Tree
prefix wb: <https://mcje-data.wikibase.cloud/entity/>
prefix wbt: <https://mcje-data.wikibase.cloud/prop/direct/>
SELECT ?rootRegistry ?rootRegistryLabel ?rootRegistryRL ?registry ?registryLabel ?registryRL ?registryEntry ?registryEntryLabel ?registryEntryRL WHERE {
?rootRegistry wbt:P28 wb:Q1482; wbt:P4 ?rootRegistryOldRL.
BIND(CONCAT("(",STR(?rootRegistryOldRL),")") as ?rootRegistryRL).
?registry wbt:P20 ?rootRegistry; wbt:P4 ?registryOldRL.
BIND(CONCAT("(",STR(?registryOldRL),")") as ?registryRL).
?registryEntry wbt:P20 ?registry; wbt:P4 ?registryEntryOldRL.
BIND(CONCAT("(",STR(?registryEntryOldRL),")") as ?registryEntryRL).
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Units of Measure
All Units
prefix wb: <https://mcje-data.wikibase.cloud/entity/>
prefix wbt: <https://mcje-data.wikibase.cloud/prop/direct/>
SELECT DISTINCT ?unit ?unitLabel ?unitSymbol WHERE {
?unit wbt:P1/wbt:P2* wb:Q9.
OPTIONAL {
?unit wbt:P64 ?unitSymbol.
FILTER ( LANG(?unitSymbol) = "[AUTO_LANGUAGE]" )
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}