gpt4 book ai didi

java - 如何在GraphDB全文搜索中创建自定义AnalyzerFactory?

转载 作者:行者123 更新时间:2023-12-02 13:22:47 25 4
gpt4 key购买 nike

(免费使用 GraphDB 8.1)。 http://graphdb.ontotext.com/documentation/free/full-text-search.html说我可以使用 luc:analyzer 参数,通过实现接口(interface) com.ontotext.trree.plugin.lucene.AnalyzerFactory 为 GraphDB 全文搜索启用自定义AnalyzerFactory >。但是我在任何地方都找不到这个界面。它不在 jar graphdb-free-runtime-8.1.0.jar 中。

我检查了http://ontotext.com/products/graphdb/editions/#feature-comparison-table处的特征矩阵看来这个功能“Connectors Lucene”可用于 GraphDB 的免费版本。

com.ontotext.trree.plugin.lucene.AnalyzerFactory 接口(interface)位于哪个 jar 中?我需要在我的项目中导入什么来实现这个接口(interface)?

GraphDB 中是否包含预先存在的 AnalyzerFactories 来使用 Lucene 其他分析器? (我对使用 FrenchAnalyzer 感兴趣)。

谢谢!

最佳答案

GraphDB 提供了两种不同的基于 Lucene 的插件。

我鼓励您使用 Lucene Connector,除非您没有 RDF 分子的特殊情况。下面是一个简单的示例,说明如何使用 French 分析器配置连接器,并为 urn:MyClass 类型的资源的 rdfs:label 谓词的所有值建立索引。选择一个存储库并从 SPARQL 查询 View 执行:

  PREFIX :<http://www.ontotext.com/connectors/lucene#>
PREFIX inst:<http://www.ontotext.com/connectors/lucene/instance#>
INSERT DATA {
inst:labelFR-copy :createConnector '''
{
"fields": [
{
"indexed": true,
"stored": true,
"analyzed": true,
"multivalued": true,
"fieldName": "label",
"propertyChain": [
"http://www.w3.org/2000/01/rdf-schema#label"
],
"facet": true
}
],
"types": [
"urn:MyClass"
],
"stripMarkup": false,
"analyzer": "org.apache.lucene.analysis.fr.FrenchAnalyzer"
}
''' .
}

然后从“导入”>“文本”区域手动添加一些示例测试数据:

<urn:instance:test>  <http://www.w3.org/2000/01/rdf-schema#label> "C'est une example".
<urn:instance:test> a <urn:MyClass>.

提交事务后,连接器将更新 Lucene 索引。现在您可以运行搜索查询,例如:

PREFIX : <http://www.ontotext.com/connectors/lucene#>
PREFIX inst: <http://www.ontotext.com/connectors/lucene/instance#>
SELECT ?entity ?snippetField ?snippetText {
?search a inst:labelFR ;
:query "label:*" ;
:entities ?entity .
?entity :snippets _:s .
_:s :snippetField ?snippetField ;
:snippetText ?snippetText .
}

要创建自定义分析器,请按照文档中的说明进行操作并扩展 org.apache.lucene.analysis.Analyzer 类。将自定义分析器 JAR 放入 lib/plugins/lucene-connector/ 路径中。

关于java - 如何在GraphDB全文搜索中创建自定义AnalyzerFactory?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43517064/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com