使用 dotNetRDF 查询 AllegroGraph
Querying AllegroGraph using dotNetRDF
我有一个 AllegroGraph 服务器 运行ning,在查询远程数据存储时遇到问题,关于文档的信息很少。
这是我的小代码:
using System;
using VDS.RDF;
using VDS.RDF.Storage;
namespace PoC {
class Program {
static void Main(string[] args) {
string server = "http://server";
string repo = "repo";
string username = "username";
string password = "password";
AllegroGraphConnector agraph = new AllegroGraphConnector(server, repo, username, password);
Options.HttpDebugging = true;
Options.HttpFullDebugging = true;
agraph.Query("SELECT * WHERE { emid:_PCAT_0001 ?p ?o }");
Console.ReadLine();
}
}
}
MALFORMED QUERY: Parse error: namespace mapping for "emid" not defined
when expanding QName "emid:_PCAT_0001".
尽管在 AllegroGraph WebView 中我可以运行将完全相同的查询和命名空间加载到存储库中。
我该如何解决?
您需要在查询中声明前缀 emid:。据推测,AllegroGraph WebView UI 会自动为您执行此操作,但普通的 SPARQL 端点不会。
尝试使用这样的东西:
agraph.Query("PREFIX emid: <http://your.uri.goes/here> SELECT * WHERE { emid:_PCAT_0001 ?p ?o }");
显然你应该用你的 emid: 前缀映射到的真实 URI 替换那个假 URI!
我有一个 AllegroGraph 服务器 运行ning,在查询远程数据存储时遇到问题,关于文档的信息很少。
这是我的小代码:
using System;
using VDS.RDF;
using VDS.RDF.Storage;
namespace PoC {
class Program {
static void Main(string[] args) {
string server = "http://server";
string repo = "repo";
string username = "username";
string password = "password";
AllegroGraphConnector agraph = new AllegroGraphConnector(server, repo, username, password);
Options.HttpDebugging = true;
Options.HttpFullDebugging = true;
agraph.Query("SELECT * WHERE { emid:_PCAT_0001 ?p ?o }");
Console.ReadLine();
}
}
}
MALFORMED QUERY: Parse error: namespace mapping for "emid" not defined when expanding QName "emid:_PCAT_0001".
尽管在 AllegroGraph WebView 中我可以运行将完全相同的查询和命名空间加载到存储库中。
我该如何解决?
您需要在查询中声明前缀 emid:。据推测,AllegroGraph WebView UI 会自动为您执行此操作,但普通的 SPARQL 端点不会。
尝试使用这样的东西:
agraph.Query("PREFIX emid: <http://your.uri.goes/here> SELECT * WHERE { emid:_PCAT_0001 ?p ?o }");
显然你应该用你的 emid: 前缀映射到的真实 URI 替换那个假 URI!