如何使用命令行向 Apache Fuseki 添加新数据集?

How can I add a new dataset to Apache Fuseki using the command line?

我正在按照 this Docker image 的说明进行操作,其中描述了如何使用 Apache Fuseki 设置新的容器化 RDF 三重存储。我想我可以使用 Dockerfile 为我的数据集自动执行这些说明中的所有步骤,但是在 "recognizing the dataset in Fuseki," 下有一个步骤让您进入 GUI 界面并在那里添加一个新数据集。由于我最终想自动执行此过程,因此我想找到一种命令行方式来添加新数据集。它不需要任何花哨的东西,只需添加一个具有给定名称的新数据集,例如 "db." 有没有办法做到这一点? (而且,我想,一种在 docker 容器中 运行 该命令的方法?)

这是您需要做的:

(1) 使用 docker run -p 3030:3030 -it stain/jena-fuseki 启动容器。

(2) 用 docker ps 找到容器的 id $$$。

(3) 使用 docker container cp config.ttl $$$:config.ttlconfig.ttl 文件复制到您的 docker 容器中。示例 config.ttl 如下所示:

@prefix fuseki:  <http://jena.apache.org/fuseki#> .
@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix tdb:     <http://jena.hpl.hp.com/2008/tdb#> .
@prefix ja:      <http://jena.hpl.hp.com/2005/11/Assembler#> .
@prefix :        <#> .

<#service1> rdf:type fuseki:Service ;
    fuseki:name                       "ds" ;       # http://host:port/ds
    fuseki:serviceQuery               "sparql" ;   # SPARQL query service
    fuseki:serviceQuery               "query" ;    # SPARQL query service (alt name)
    fuseki:serviceUpdate              "update" ;   # SPARQL update service
    fuseki:serviceUpload              "upload" ;   # Non-SPARQL upload service
    fuseki:serviceReadWriteGraphStore "data" ;     # SPARQL Graph store protocol (read and write)
    # A separate read-only graph store endpoint:
    fuseki:serviceReadGraphStore      "get" ;      # SPARQL Graph store protocol (read only)
    fuseki:dataset                   <#dataset> ;
    .

<#dataset> rdf:type      tdb:DatasetTDB ;
    tdb:location "DB" ;
    # Query timeout on this dataset (1s, 1000 milliseconds)
    ja:context [ ja:cxtName "arq:queryTimeout" ;  ja:cxtValue "1000" ] ;
    # Make the default graph be the union of all named graphs.
    ## tdb:unionDefaultGraph true ;
     .

(4) 使用 docker container commit $$$ Whosebug/jena-fuseki:latest.

提交对容器的更改

(5) 重启容器:docker run -p 3030:3030 -it Whosebug/jena-fuseki ./fuseki-server --config=/config.ttl.

(6) 如果您现在转到 http://localhost:3030,您应该会看到您的数据集。