我已经编写了一个如下形式的查询来从 schema.org/Product 中提取数据,但是有一个isSimilarTo
与 schema.org/Product 关联的属性可能有多个值,我需要提取isSimilarTo
数组中属性的所有值对于每个产品。我怎么能做到这一点?
我正在使用如下类似的查询:
PREFIX schema: <http://schema.org/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?productName ?modelNumber ?price ?sellerName
WHERE {
?product a schema:Product .
?product schema:name ?productNameVal .
# str() to strip any language tags
BIND(str(?productNameVal) AS ?productName)
?product schema:model ?modelNumberVal .
BIND(str(?modelNumberVal) AS ?modelNumber)
?product schema:offers ?offer .
?offer a schema:Offer .
?offer schema:price ?priceVal .
# Remove $ and cast to decimal
BIND(xsd:decimal(replace(?priceVal,"\\$","")) AS ?price)
?offer schema:seller ?seller.
# In case there's a level of indirection for seller name
OPTIONAL {
?seller schema:name ?sellerSchemaName .
}
BIND(str(coalesce(?sellerSchemaName,?seller)) AS ?sellerName )
}
ORDER BY ?modelNumber ?price