1

我打算将我的 Neo4j 应用程序与 Elasticsearch 集成。我将尝试来自 GraphAware https://github.com/graphaware/neo4j-to-elasticsearch的以下 Neo4j 插件

请问是否支持 Neo4j 3.1.3 版本?另外,应该在那里使用什么版本的 ES?例如,它是否支持 ES 5.3.0?

现在我已经在本地安装了 Elasticsearch 5.3.0。我还添加了 2 个罐子:

graphaware-neo4j-to-elasticsearch-3.1.3.45.7.jar 
graphaware-server-community-all-3.1.3.46.jar 

到我的Neo4j CE 3.1.3\plugins\文件夹。

另外,我在我的数据库配置( )中添加了以下配置(如此处所述https://github.com/neo4j-contrib/neo4j-elasticsearch#exampleNeo4j Community Edition\neo4j.conf )行:

elasticsearch.host_name=http://localhost:9200
elasticsearch.index_spec=decisions:Decision(name,description)

但是当我通过 Spring Data Neo4j 项目插入数据时,什么也没有发生。Elasticsearch 索引仍然是空的。

我做错了什么以及如何使它工作?

更新

我在这方面取得了一些进展:

这是我的 Neo4j.conf:

dbms.unmanaged_extension_classes=com.graphaware.server=/graphaware

com.graphaware.runtime.enabled=true

com.graphaware.module.ES.2=com.graphaware.module.es.ElasticSearchModuleBootstrapper

com.graphaware.module.UIDM.uuidProperty=ID()
com.graphaware.module.ES.node=hasLabel('Decision')
com.graphaware.module.ES.relationship=(false)

com.graphaware.module.ES.uri=localhost
com.graphaware.module.ES.port=9200

com.graphaware.module.ES.index=neo4j-index

在我的应用程序中,我有一个实体:Decision. Decision是具有大父层次结构的复杂类型:

Decision extends Commentable extends Votable extends Flaggable ... and so on.

现在我正在向我的 Neo4j 数据库中添加约 60 个决策节点,但我无法在 ES 上看到所有这些节点。我只能看到第一个在层次结构中每个父类都有重复的。

这就是我现在所拥有的:

$ curl -XGET 'http://127.0.0.1:9200/neo4j-index-node/_search?pretty=true&q=*:*'
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 8,
    "max_score" : 1.0,
    "hits" : [ {
      "_index" : "neo4j-index-node",
      "_type" : "Decision",
      "_id" : "null",
      "_score" : 1.0,
      "_source" : {
        "avgVotesWeight" : 0.0,
        "updateDate" : "2017-04-19T09:17:36.883Z",
        "nameSlug" : "antivirus-software-for-windows",
        "lowerName" : "antivirus software for windows",
        "description" : "This is a non-exhaustive list of notable antivirus and Internet Security software, in the form of comparison tables, according to their platform (e.g. desktop and server, mobile, etc.)",
        "totalDislikes" : 0,
        "totalChildDecisions" : 59,
        "totalCriteria" : 19,
        "multiVotesAllowed" : false,
        "totalCharacteristics" : 8,
        "totalComments" : 0,
        "totalFlags" : 0,
        "likeSum" : 0.0,
        "totalVotes" : 665,
        "name" : "Antivirus software for Windows",
        "totalLikes" : 0,
        "createDate" : "2017-04-19T09:17:20.347Z"
      }
    }, {
      "_index" : "neo4j-index-node",
      "_type" : "Authorable",
      "_id" : "null",
      "_score" : 1.0,
      "_source" : {
        "avgVotesWeight" : 0.0,
        "updateDate" : "2017-04-19T09:17:36.883Z",
        "nameSlug" : "antivirus-software-for-windows",
        "lowerName" : "antivirus software for windows",
        "description" : "This is a non-exhaustive list of notable antivirus and Internet Security software, in the form of comparison tables, according to their platform (e.g. desktop and server, mobile, etc.)",
        "totalDislikes" : 0,
        "totalChildDecisions" : 59,
        "totalCriteria" : 19,
        "multiVotesAllowed" : false,
        "totalCharacteristics" : 8,
        "totalComments" : 0,
        "totalFlags" : 0,
        "likeSum" : 0.0,
        "totalVotes" : 665,
        "name" : "Antivirus software for Windows",
        "totalLikes" : 0,
        "createDate" : "2017-04-19T09:17:20.347Z"
      }
    }, {
      "_index" : "neo4j-index-node",
      "_type" : "Subscribable",
      "_id" : "null",
      "_score" : 1.0,
      "_source" : {
        "avgVotesWeight" : 0.0,
        "updateDate" : "2017-04-19T09:17:36.883Z",
        "nameSlug" : "antivirus-software-for-windows",
        "lowerName" : "antivirus software for windows",
        "description" : "This is a non-exhaustive list of notable antivirus and Internet Security software, in the form of comparison tables, according to their platform (e.g. desktop and server, mobile, etc.)",
        "totalDislikes" : 0,
        "totalChildDecisions" : 59,
        "totalCriteria" : 19,
        "multiVotesAllowed" : false,
        "totalCharacteristics" : 8,
        "totalComments" : 0,
        "totalFlags" : 0,
        "likeSum" : 0.0,
        "totalVotes" : 665,
        "name" : "Antivirus software for Windows",
        "totalLikes" : 0,
        "createDate" : "2017-04-19T09:17:20.347Z"
      }
    }, {
      "_index" : "neo4j-index-node",
      "_type" : "BaseEntity",
      "_id" : "null",
      "_score" : 1.0,
      "_source" : {
        "avgVotesWeight" : 0.0,
        "updateDate" : "2017-04-19T09:17:36.883Z",
        "nameSlug" : "antivirus-software-for-windows",
        "lowerName" : "antivirus software for windows",
        "description" : "This is a non-exhaustive list of notable antivirus and Internet Security software, in the form of comparison tables, according to their platform (e.g. desktop and server, mobile, etc.)",
        "totalDislikes" : 0,
        "totalChildDecisions" : 59,
        "totalCriteria" : 19,
        "multiVotesAllowed" : false,
        "totalCharacteristics" : 8,
        "totalComments" : 0,
        "totalFlags" : 0,
        "likeSum" : 0.0,
        "totalVotes" : 665,
        "name" : "Antivirus software for Windows",
        "totalLikes" : 0,
        "createDate" : "2017-04-19T09:17:20.347Z"
      }
    }, {
      "_index" : "neo4j-index-node",
      "_type" : "Votable",
100  7842  100  7842    0     0   7842      0  0:00:01 --:--:--  0:00:01 7658kl",
      "_score" : 1.0,
      "_source" : {
        "avgVotesWeight" : 0.0,
        "updateDate" : "2017-04-19T09:17:36.883Z",
        "nameSlug" : "antivirus-software-for-windows",
        "lowerName" : "antivirus software for windows",
        "description" : "This is a non-exhaustive list of notable antivirus and Internet Security software, in the form of comparison tables, according to their platform (e.g. desktop and server, mobile, etc.)",
        "totalDislikes" : 0,
        "totalChildDecisions" : 59,
        "totalCriteria" : 19,
        "multiVotesAllowed" : false,
        "totalCharacteristics" : 8,
        "totalComments" : 0,
        "totalFlags" : 0,
        "likeSum" : 0.0,
        "totalVotes" : 665,
        "name" : "Antivirus software for Windows",
        "totalLikes" : 0,
        "createDate" : "2017-04-19T09:17:20.347Z"
      }
    }, {
      "_index" : "neo4j-index-node",
      "_type" : "Flaggable",
      "_id" : "null",
      "_score" : 1.0,
      "_source" : {
        "avgVotesWeight" : 0.0,
        "updateDate" : "2017-04-19T09:17:36.883Z",
        "nameSlug" : "antivirus-software-for-windows",
        "lowerName" : "antivirus software for windows",
        "description" : "This is a non-exhaustive list of notable antivirus and Internet Security software, in the form of comparison tables, according to their platform (e.g. desktop and server, mobile, etc.)",
        "totalDislikes" : 0,
        "totalChildDecisions" : 59,
        "totalCriteria" : 19,
        "multiVotesAllowed" : false,
        "totalCharacteristics" : 8,
        "totalComments" : 0,
        "totalFlags" : 0,
        "likeSum" : 0.0,
        "totalVotes" : 665,
        "name" : "Antivirus software for Windows",
        "totalLikes" : 0,
        "createDate" : "2017-04-19T09:17:20.347Z"
      }
    }, {
      "_index" : "neo4j-index-node",
      "_type" : "Likeable",
      "_id" : "null",
      "_score" : 1.0,
      "_source" : {
        "avgVotesWeight" : 0.0,
        "updateDate" : "2017-04-19T09:17:36.883Z",
        "nameSlug" : "antivirus-software-for-windows",
        "lowerName" : "antivirus software for windows",
        "description" : "This is a non-exhaustive list of notable antivirus and Internet Security software, in the form of comparison tables, according to their platform (e.g. desktop and server, mobile, etc.)",
        "totalDislikes" : 0,
        "totalChildDecisions" : 59,
        "totalCriteria" : 19,
        "multiVotesAllowed" : false,
        "totalCharacteristics" : 8,
        "totalComments" : 0,
        "totalFlags" : 0,
        "likeSum" : 0.0,
        "totalVotes" : 665,
        "name" : "Antivirus software for Windows",
        "totalLikes" : 0,
        "createDate" : "2017-04-19T09:17:20.347Z"
      }
    }, {
      "_index" : "neo4j-index-node",
      "_type" : "Commentable",
      "_id" : "null",
      "_score" : 1.0,
      "_source" : {
        "avgVotesWeight" : 0.0,
        "updateDate" : "2017-04-19T09:17:36.883Z",
        "nameSlug" : "antivirus-software-for-windows",
        "lowerName" : "antivirus software for windows",
        "description" : "This is a non-exhaustive list of notable antivirus and Internet Security software, in the form of comparison tables, according to their platform (e.g. desktop and server, mobile, etc.)",
        "totalDislikes" : 0,
        "totalChildDecisions" : 59,
        "totalCriteria" : 19,
        "multiVotesAllowed" : false,
        "totalCharacteristics" : 8,
        "totalComments" : 0,
        "totalFlags" : 0,
        "likeSum" : 0.0,
        "totalVotes" : 665,
        "name" : "Antivirus software for Windows",
        "totalLikes" : 0,
        "createDate" : "2017-04-19T09:17:20.347Z"
      }
    } ]
  }
}

为什么 Decision 的所有子类(如Votable, Likeable)也在那里重复?正如您从我的配置中看到的那样,我试图排除所有内容,除了:

com.graphaware.module.ES.node=hasLabel('Decision')

我的目标是仅索引DecisionES 中的节点。

另外,为什么从~60 中唯一的一个决定被索引在那里?我认为 Elasticsearch JSON 输出中的 "_id" : "null" 与此问题有关。我究竟做错了什么 ?

4

1 回答 1

1

似乎我们的文档对于将内部 id 用作文档 id 的用法很奇怪:

替换这一行: com.graphaware.module.UIDM.uuidProperty=ID()

这样

com.graphaware.module.ES.keyProperty=ID()

但是,如果您也使用 uuid 模块,最好使用“uuid”而不是内部 ID

我用提到的版本在社区 3.1.3 上进行了测试,它正在工作。

{ "took" : 1, "timed_out" : false, "_shards" : { "total" : 5, "successful" : 5, "failed" : 0 }, "hits" :{ "_index" : "neo4j-index-node", "_type" : "Decision", "_id" : "2", "_score" : 1.0, "_source":{"id":123,"title":"Ibiza"} }, { "_index" : "neo4j-index-node", "_type" : "Decision", "_id" : "3", "_score" : 1.0, "_source":{"id":123,"title":"Weird Decision"} } ] } }

如果您的节点同时具有标签 Decision 和 Votable,那么您必须在配置中排除它们,如下所示:

com.graphaware.module.ES.node=hasLabel('Decision') && !hasLabel('Votable') && !hasLabel('BaseEntity')

于 2017-04-20T19:11:45.763 回答