0

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

我在http://ontotext.com/products/graphdb/editions/#feature-comparison-table检查了特征矩阵,似乎这个特征“连接器 Lucene”可用于 GraphDB 的免费版。

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

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

谢谢 !

4

1 回答 1

1

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

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

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

然后从 Import > Text 区域手动添加一些示例测试数据:

<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/路径中。

于 2017-04-24T07:41:16.853 回答