使用传统的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"
]
}
]
}
''' .
}
返回匹配的字段和代码段
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 .
}
在投影图中:
-
?实体是属性或属性链匹配的RDF资源,即
-
?snippetfield是与全文查询匹配的字段名
-
?snippettext是匹配的snippet值