如何使用Fuseki和Jena TDB [英] How I can use Fuseki with Jena TDB

查看:335
本文介绍了如何使用Fuseki和Jena TDB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题。

我有一个三元店Jena TDB,我读过我可以为
设置一个SPARQL端点本地存储的RDF数据。
特别是,我在文献中看到与Jena TDB一起使用的是Fuseki。
我以这种方式在Jena TDB中加载了我的文件rdf:

I have a triplestore "Jena TDB" and I have read that I can set up a SPARQL endpoint for locally stored RDF data. In particular, I saw that in the literature together with Jena TDB is used Fuseki. I loaded my files rdf in Jena TDB in this way:

public void store(){
    String directory = "C:\\tdb";
    String source = "C:\\file1.rdf";
    String source1 = "C:\\file2.rdf";
    Dataset dataset = openTDB(directory);
    Model tdb = loadModel(source, dataset);
    dataset.addNamedModel("File1", tdb);

    Model tdb1 = loadModel(source1, dataset);
    dataset.addNamedModel("File2", tdb1);

    tdb.close();
    tdb1.close();
    dataset.close();
}


public Dataset openTDB(String directory){
    // open TDB dataset
    Dataset dataset = TDBFactory.createDataset(directory);
    return dataset;
}


public Model loadModel(String source, Dataset dataset){

    Model tdb = ModelFactory.createDefaultModel();
    FileManager.get().readModel( tdb, source, "RDF/XML" );
    return tdb;
}

我正在阅读Apache网站上的Fuseki文档和这篇文章耶拿的桌面SPARQL客户端(TDB)?,但我遇到了问题。

I am reading the Fuseki documentation on Apache site and this post Desktop SPARQL client for Jena (TDB)?, but I have the problem.

特别是,我已经下载了Fuseki发行版并解压缩了它。然后,我打开命令提示符,然后我去了解压缩fuseki的文件夹。
然后,我启动了这个命令:

In particular, I have downloaded Fuseki distribution and unzipped it. Then, I opened the command prompt and I went to the folder where I unzipped fuseki. Then, I launched this command:

fuseki-server --update --mem /C://TDB

我在localhost:3030地址上打开浏览器。
在浏览器上,我可以选择数据集(在C:// TDB的情况下),我可以启动我的查询,例如:

and I opened the browser on localhost:3030 address. On the browser, I can choose the dataset (in the case C://TDB) and I can launch my query, for example:


select * {graph; {?s?p?o}}

select * {graph ; { ?s ?p ?o }}

查询结果为:

错误404:未找到

为什么?我做错了什么?

Why? What am I doing wrong?

On 耶拿桌面SPARQL客户端(TDB)?帖子,我已经读过我必须运行命令:

On Desktop SPARQL client for Jena (TDB)? post, I have read that I have to run the command:


java -jar fuseki-0.1.0-server.jar --update --loc data / dataset

java -jar fuseki-0.1.0-server.jar --update --loc data /dataset

但我不明白谁是数据和数据集。就我而言,我怎么知道这个价值观?这是我的错误吗?

but I don't understand who are data and dataset. In my case, how I can know this values? Is this my error?

推荐答案

你是对的,因为你没有理解每个论点的意图。使用您的命令您所做的是创建一个空的内存数据集,并为其分配数据集路径 / C:// TDB 这几乎肯定不是您的意图。

You are right in that you haven't understood the intent of each argument. With your command what you've done is create an empty in-memory dataset and assign it the dataset path /C://TDB which is almost certainly not what you intended.

- loc 参数用于传递包含TDB数据库的目录的路径,而 / dataset path是您想要通过Fuseki访问它的数据集路径

The --loc argument is used to pass in the path to a directory containing a TDB database while the /dataset path is the dataset path you want to use to access it via Fuseki

所以例如你可以做以下:

So for example you might do the following:

java -jar fuseki-VER-server.jar --update --loc /path/to/database /ds

注意我用过 VER 作为Fuseki版本的占位符,因为该值取决于您下载的Fuseki版本。在撰写本答案时作为参考,最新版本为 1.0.2

Note That I've used VER as a placeholder for the Fuseki version here since that value will depend on which version of Fuseki you have downloaded. For reference at time of writing this answer the latest version is 1.0.2

此命令针对TDB启动Fuseki数据库位于 / path / to / database ,数据集路径为 / ds 。因此,您可以将所选的SPARQL客户端指向 http:// localhost:3030 / ds / query 以进行查询,或者 http:// localhost:3030 / ds / update 进行更新。

This command launches Fuseki against the TDB database located in /path/to/database with the dataset path of /ds. Therefore you can point your chosen SPARQL client at http://localhost:3030/ds/query to make queries or http://localhost:3030/ds/update to make updates.

如果你在Windows上运行(你的问题似乎就是这种情况)那么你会执行以下操作:

If you are running on Windows (which appears to be the case from your question) then you would do the following:

java -jar fuseki-VER-server.jar --update --loc C:\TDB /ds

针对位于 C:\ TDB中的TDB数据库启动Fuseki ,数据集路径为 / ds ,因此将应用与上一示例相同的URL。

Which launches Fuseki against the TDB database located in C:\TDB with the dataset path of /ds so the same URLs as the previous example would apply.

这篇关于如何使用Fuseki和Jena TDB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆