本文介绍了如何在GraphDB全文搜索中创建自定义的AnalyzerFactory?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

(Using GraphDB 8.1 free).http://graphdb.ontotext.com/documentation/free/full-text-search.html says that I can enable a custom AnalyzerFactory for GraphDB full-text search, using the luc:analyzer param, by implemeting the interface com.ontotext.trree.plugin.lucene.AnalyzerFactory. However I can't find this interface anywhere. It is not in the jar graphdb-free-runtime-8.1.0.jar.

我在 http://ontotext.com/上检查了功能矩阵.产品/graphdb/editions/#feature-comparison-table ,似乎此功能"Connectors Lucene"可用于GraphDB的免费版.

I checked the feature matrix at http://ontotext.com/products/graphdb/editions/#feature-comparison-table and it seems this feature '"Connectors Lucene" is available for the free edition of GraphDB.

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

In which jar is the com.ontotext.trree.plugin.lucene.AnalyzerFactory interface located ? what do I need to import in my project to implement this interface ?

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

Is there pre-existing AnalyzerFactories included with GraphDB to use Lucene other analyzers ? (I am interested in using a FrenchAnalyzer).

谢谢!

推荐答案

GraphDB提供了两个不同的基于Lucene的插件.

GraphDB offers two different Lucene-based plugins.

  • Lucene FTS plugin indexes RDF molecules and the correct documentation link is: http://graphdb.ontotext.com/documentation/free/full-text-search.html
  • Lucene Connector performs online synchronization between the RDF and Lucene document models using sequences of configurations like ?subject propertyPath ?object to id|fild value. The correct documentation link is: http://graphdb.ontotext.com/documentation/free/lucene-graphdb-connector.html

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

I encourage you to use the Lucene Connector, unless you don't have a special case for RDF molecules. Here is a simple example how to configure the connector with French analyzer and index all values for rdfs:label predicate for resources of type urn:MyClass. Select a repository and from the SPARQL query view execute:

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

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

Then manually add some sample test data from Import > Text area:

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

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

Once you commit the transaction, the Connector will update the Lucene index. Now you can run search queries like:

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

To create a custom analyzer follow the instructions in the documentation and extend org.apache.lucene.analysis.Analyzer class. Put the custom analyzer JAR in lib/plugins/lucene-connector/ path.

这篇关于如何在GraphDB全文搜索中创建自定义的AnalyzerFactory?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 05:40