我正在使用 GraphDB 的Lucene 连接器。我在我的三元组商店中为实体代码构建索引my_index
,我想使用这样的索引进行子字符串匹配。
例.
实体代码:
FooBar
FooBaz
BazFoo
Lucene 连接器:
PREFIX :<http://www.ontotext.com/connectors/lucene#>
PREFIX inst:<http://www.ontotext.com/connectors/lucene/instance#>
INSERT DATA {
inst:my_index :createConnector '''
{
"fields": [
{
"fieldName": "code",
"propertyChain": [
"http://foo#identifier"
],
"indexed": true,
"stored": true,
"analyzed": true,
"multivalued": true,
"facet": true
}
],
"types": [
http://foo#MyType"
],
"stripMarkup": false
}
''' .
}
SPARQL
查询利用 Lucene 连接器:
PREFIX : <http://www.ontotext.com/connectors/lucene#>
PREFIX inst: <http://www.ontotext.com/connectors/lucene/instance#>
SELECT ?entity {
?search a inst:my_index ;
:query "code:Foo*" ;
:entities ?entity .
}
我想让所有实体的代码都以Foo
(i.e.,FooBar
,FooBaz
)开头,但我得到一个空的结果集。
我怎么能得到它们?
编辑:
在 Vassil 的回答中尝试了这个例子后,我发现问题可能与区分大小有关。
行为:
-
:query "label:Foo*"
什么都不返回 -
:query "label:foo*"
返回FooBar
和FooBaz
1 回答
默认情况下,前缀搜索应该可以使用。我怀疑您的查询还有其他问题。如果使用
:query "*:*"
搜索所有可能的值,会发生什么?以下是检查并使用您的数据集重复它的测试用例。
生成样本虚拟数据
您还需要为每个 RDF 资源定义
rdf:type
语句。创建 Lucene 连接器
连接器将索引所有
urn:type
类的所有rdfs:label
值。测试前缀搜索
数据库返回
urn:1
和urn:2