Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
图形b+;Lucene索引:我可以得到匹配的谓词/文本吗?_Lucene_Graphdb - Fatal编程技术网

图形b+;Lucene索引:我可以得到匹配的谓词/文本吗?

图形b+;Lucene索引:我可以得到匹配的谓词/文本吗?,lucene,graphdb,Lucene,Graphdb,接下来,我设置了一个包含多个(文字)谓词的索引: PREFIX luc: <http://www.ontotext.com/owlim/lucene#> INSERT DATA { luc:index luc:setParam "uris" . luc:include luc:setParam "literals" . luc:moleculeSize luc:setParam "1" .

接下来,我设置了一个包含多个(文字)谓词的索引:

  PREFIX luc: <http://www.ontotext.com/owlim/lucene#>
  INSERT DATA {
    luc:index             luc:setParam "uris" .
    luc:include           luc:setParam "literals" .
    luc:moleculeSize      luc:setParam "1" .
    luc:includePredicates luc:setParam "http://purl.org/dc/terms/title http://www.w3.org/2000/01/rdf-schema#label http://www.w3.org/2004/02/skos/core#prefLabel http://www.w3.org/2004/02/skos/core#altLabel" .
  }
我想做这样的事情

SELECT *
WHERE {
  ?needle luc:labelIndex "title" ;
          luc:predicate  ?predicate ;
          ?predicate     ?label .
}

如果存在类似于
luc:predicate
的内容,则可以在匹配值旁边提供实际匹配的谓词。然而,我甚至不确定Lucene是否为谓词编制了索引,启用这样的函数需要这样做。

传统的FTS Lucene插件无法有效地做到这一点。但是,该应用程序很容易支持您的用例。下面是一个包含一些模拟数据的示例案例:

样本数据

<urn:a> a <http://www.w3.org/2004/02/skos/core#Concept> ;
    <http://purl.org/dc/terms/title> "title"; 
    <http://www.w3.org/2000/01/rdf-schema#label> "label" ; 
    <http://www.w3.org/2004/02/skos/core#prefLabel> "prefer label"; 
    <http://www.w3.org/2004/02/skos/core#altLabel> "alt label" .
返回匹配的字段和代码段

PREFIX : <http://www.ontotext.com/connectors/lucene#>
PREFIX inst: <http://www.ontotext.com/connectors/lucene/instance#>
SELECT ?entity ?snippetField ?snippetText {
    ?search a inst:fts ;
            :query "label" ;
            :entities ?entity .
    ?entity :snippets _:s .
    _:s :snippetField ?snippetField ;
        :snippetText ?snippetText .
}
前缀:
前缀inst:
选择?实体?代码段字段?代码段文本{
?搜索仪器:fts;
:查询“标签”;
:实体?实体。
?实体:代码段。
_:s:snippetField?snippetField;
:snippetText?snippetText。
}
其中在投影中:

  • ?实体是属性或属性链匹配的RDF资源,即
  • ?snippetField是与全文查询匹配的字段名
  • ?snippetText是匹配的代码段值
<urn:a> a <http://www.w3.org/2004/02/skos/core#Concept> ;
    <http://purl.org/dc/terms/title> "title"; 
    <http://www.w3.org/2000/01/rdf-schema#label> "label" ; 
    <http://www.w3.org/2004/02/skos/core#prefLabel> "prefer label"; 
    <http://www.w3.org/2004/02/skos/core#altLabel> "alt label" .
PREFIX : <http://www.ontotext.com/connectors/lucene#>
PREFIX inst: <http://www.ontotext.com/connectors/lucene/instance#>

INSERT DATA {
    inst:fts :createConnector '''
{
  "types": [
    "http://www.w3.org/2004/02/skos/core#Concept"
  ],
  "fields": [
    {
      "fieldName": "label",
      "propertyChain": [
        "http://www.w3.org/2000/01/rdf-schema#label"
      ]
    },
    {
      "fieldName": "prefLabel",
      "propertyChain": [
        "http://www.w3.org/2004/02/skos/core#prefLabel"
      ]
    },
    {
      "fieldName": "altLabel",
      "propertyChain": [
        "http://www.w3.org/2004/02/skos/core#altLabel"
      ]
    }
  ]
}
''' .
}
PREFIX : <http://www.ontotext.com/connectors/lucene#>
PREFIX inst: <http://www.ontotext.com/connectors/lucene/instance#>
SELECT ?entity ?snippetField ?snippetText {
    ?search a inst:fts ;
            :query "label" ;
            :entities ?entity .
    ?entity :snippets _:s .
    _:s :snippetField ?snippetField ;
        :snippetText ?snippetText .
}