SPARQL检索包含字符串的记录

SPARQL检索包含字符串的记录,sparql,contains,opendata,Sparql,Contains,Opendata,我从一个数据库中获得以下SPARQL查询: 前缀rdf: 前缀rdfs: 前缀owl: 前缀xsd: 前缀sr: 前缀ukhpi: 前缀lrppi: 前缀skos: 通用前缀: #从默认图形中返回每个交易记录的已付价格数据 #带有给定邮政编码的地址。 #要查询的邮政编码是使用SPARQL 1.1的“values”子句设置的 选择?宝?桑?街?镇?县?邮编?金额?日期?类别 哪里 { 值?邮政编码{“PL6 8RU”^^xsd:string} 地址:邮政编码?邮政编码。 ?transx lrppi

我从一个数据库中获得以下SPARQL查询:

前缀rdf:
前缀rdfs:
前缀owl:
前缀xsd:
前缀sr:
前缀ukhpi:
前缀lrppi:
前缀skos:
通用前缀:
#从默认图形中返回每个交易记录的已付价格数据
#带有给定邮政编码的地址。
#要查询的邮政编码是使用SPARQL 1.1的“values”子句设置的
选择?宝?桑?街?镇?县?邮编?金额?日期?类别
哪里
{
值?邮政编码{“PL6 8RU”^^xsd:string}
地址:邮政编码?邮政编码。
?transx lrppi:propertyAddress?地址;
lrppi:已付价格?金额;
lrppi:交易日期?日期;
lrppi:transactionCategory/skos:prefLabel?类别。
可选{地址:county?county}
可选{地址:paon?paon}
可选{?addr lrcomon:saon?saon}
可选{?地址:街道?街道}
可选{?地址:town?town}
}
按?金额订购

目前,它只检索邮政编码为PL6 8RU的记录。我想检索所有邮政编码以“PL6”开头的记录。有什么想法吗?

filter(strstarts(str(?postcode),“PL6”)
@AKSW WHERE子句中的WHERE应该使用filter函数吗?我需要取出VALUES语句吗?仅供参考:@alessandro是的,当然要替换
VALUES
子句
过滤器(strstarts(str(?postcode),“PL6”)
@AKSW在WHERE子句中我应该在哪里使用过滤器功能?我需要取出VALUES语句吗?仅供参考:@alessandro是的,当然要替换
VALUES
子句
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix sr: <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/>
prefix ukhpi: <http://landregistry.data.gov.uk/def/ukhpi/>
prefix lrppi: <http://landregistry.data.gov.uk/def/ppi/>
prefix skos: <http://www.w3.org/2004/02/skos/core#>
prefix lrcommon: <http://landregistry.data.gov.uk/def/common/>

# Returns the Price Paid data from the default graph for each transaction record having
# an address with the given postcode.
# The postcode to query is set using SPARQL 1.1's 'values' clause

SELECT ?paon ?saon ?street ?town ?county ?postcode ?amount ?date ?category
WHERE
{
  VALUES ?postcode {"PL6 8RU"^^xsd:string}

  ?addr lrcommon:postcode ?postcode.

  ?transx lrppi:propertyAddress ?addr ;
          lrppi:pricePaid ?amount ;
          lrppi:transactionDate ?date ;
          lrppi:transactionCategory/skos:prefLabel ?category.

  OPTIONAL {?addr lrcommon:county ?county}
  OPTIONAL {?addr lrcommon:paon ?paon}
  OPTIONAL {?addr lrcommon:saon ?saon}
  OPTIONAL {?addr lrcommon:street ?street}
  OPTIONAL {?addr lrcommon:town ?town}
}
ORDER BY ?amount