代码之家  ›  专栏  ›  技术社区  ›  loretoparisi

带并集和过滤器的慢速BlazeGraph SPARQL查询

  •  1
  • loretoparisi  · 技术社区  · 7 年前

    我在做SPARQL查询 Blazegraph RDF图形数据库 Wikidata query service

    SELECT DISTINCT ?music_track ?music_trackLabel ?artist ?artistLabel ?album ?albumLabel ?publication_date WHERE {
          SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
    
          { ?music_track wdt:P31 wd:Q134556. }
          UNION
          { ?music_track wdt:P31 wd:Q7366. }
          UNION
          { ?music_track wdt:P31 wd:Q2188189. }
          UNION
          { ?music_track wdt:P31 wd:Q207628. }
          UNION
          { ?music_track wdt:P31 wd:Q7302866. }
          UNION
          { ?music_track wdt:P31 wd:Q9748. }
          UNION
          { ?music_track wdt:P2207 ?_spotifyTrackID_. }
    
          ?music_track rdfs:label ?music_trackLabel.
    
          ?music_track wdt:P175 ?artist. 
          ?artist rdfs:label ?artistLabel.
    
          OPTIONAL { ?music_track wdt:P361 ?album.}
          OPTIONAL { ?music_track wdt:P577 ?publication_date. }
    
          FILTER regex(?music_trackLabel, "^Castle on the Hill$", "i")
          FILTER (regex(?artistLabel, "ed sheeran", "i"))
        }
        LIMIT 10
    

    或类似

    SELECT DISTINCT ?artist ?artistLabel ?birth_nameLabel  ?date ?website ?instagramID ?facebookID ?twitterID ?musicBrainzArtistID WHERE {
        SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
    
        { ?artist wdt:P31 wd:Q215380. }
        UNION
        { ?artist wdt:P31 wd:Q2088357. }
        UNION
        { ?artist wdt:P31 wd:Q5741069. }
        UNION
        { ?artist wdt:P31 wd:Q641066. }
         UNION
        { ?artist wdt:P1902 ?_spotifyArtistID_. }
        UNION
        { ?artist wdt:P2850 ?_itunesArtistID_. }
        UNION
        { ?artist wdt:P434 ?musicBrainzArtistID. } 
    
          FILTER(REGEX(?artistLabel, "^Fall Out Boy$", "i"))
          ?artist rdfs:label ?artistLabel.
    
          OPTIONAL { ?artist wdt:P571 ?date. }
          OPTIONAL { ?artist wdt:P1477 ?birth_nameLabel. }
          OPTIONAL { ?artist wdt:P856 ?website. }
          OPTIONAL { ?artist wdt:P2003 ?instagramID. }
          OPTIONAL { ?artist wdt:P2013 ?facebookID. }
          OPTIONAL { ?artist wdt:P2002 ?twitterID. }
    
    
      }
      LIMIT 10
    

    这些查询非常慢(从几秒到十几秒不等),我想优化这些查询。

    0 回复  |  直到 7 年前