【问题标题】:GraphDB + Lucene Index: can I get the matched predicate / literal?GraphDB + Lucene 索引:我可以获得匹配的谓词/文字吗?
【发布时间】:2018-11-18 14:44:51
【问题描述】:

the instructions 之后,我设置了一个涵盖多个(文字)谓词的索引:

  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" .
  }

PREFIX luc: <http://www.ontotext.com/owlim/lucene#>
INSERT DATA {
  luc:${Cfg.literalIndex}   luc:createIndex   "true" .
}

这部分似乎工作得很好。我现在的问题是,有什么方法可以在我的 SPARQL 查询中获取匹配的谓词或文字

所以假设以下数据:

:exA rdfs:label     'label' ;
     dct:title      'title' .

我想做这样的事情

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

如果存在类似luc:predicate 的内容,这可以为我提供实际匹配的谓词以及匹配值。但是,我什至不确定 Lucene 索引谓词,这是启用此类功能所必需的。

【问题讨论】:

    标签: lucene graphdb


    【解决方案1】:

    您无法使用旧版 FTS Lucene 插件有效地执行此操作。但是,Lucene Connectors 可以轻松支持您的用例。这是一个带有一些模拟数据的示例:

    样本数据

    <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" .
    

    注意:连接器索引单个 rdf:type 的数据。在你的例子中,我相信你应该有skos:Concept

    创建 Lucene 连接器

    连接器会将所选类型的每个属性或属性链索引到单独的 Lucene 字段中。

    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"
          ]
        }
      ]
    }
    ''' .
    }
    

    返回匹配字段和sn-p

    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 .
    }
    

    投影位置:

    • ?entities 是属性或属性链匹配的 RDF 资源,即
    • ?sn-pField是匹配全文查询的字段名
    • ?sn-pText 是匹配的sn-p值

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-21
      • 1970-01-01
      • 1970-01-01
      • 2014-01-01
      • 1970-01-01
      相关资源
      最近更新 更多