首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在AnalyzerFactory全文搜索中创建自定义GraphDB?

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

Stack Overflow用户
提问于 2017-04-20 10:33:32
回答 1查看 241关注 0票数 0

(使用GraphDB 8.1免费)。http://graphdb.ontotext.com/documentation/free/full-text-search.html说,通过嵌入接口com.ontotext.trree.plugin.lucene.AnalyzerFactory,我可以使用luc:analyzer param为GraphDB全文搜索启用自定义的com.ontotext.trree.plugin.lucene.AnalyzerFactory。然而,我在任何地方都找不到这个界面。它不在jar图形数据库-空闲运行时-8.1.0.jar中。

我在http://ontotext.com/products/graphdb/editions/#feature-comparison-table上查看了功能矩阵,似乎这个特性‘Connectors’是免费版的GraphDB。

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

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

谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-04-24 07:41:16

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

  • Lucene插件索引RDF分子和正确的文档链接是:http://graphdb.ontotext.com/documentation/free/full-text-search.html
  • Lucene使用配置序列执行RDF和Lucene文档模型之间的在线同步,比如从propertyPath对象到id\fild值。正确的文档链接是:http://graphdb.ontotext.com/documentation/free/lucene-graphdb-connector.html

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

代码语言:javascript
运行
复制
  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区域手动添加一些示例测试数据:

代码语言:javascript
运行
复制
<urn:instance:test>  <http://www.w3.org/2000/01/rdf-schema#label> "C'est une example".
<urn:instance:test> a <urn:MyClass>.

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

代码语言:javascript
运行
复制
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/路径中。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43517064

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档