Neo4j 3.1.3 与 Elasticsearch 集成

Neo4j 3.1.3 with Elasticsearch integration

我打算将我的 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#example)行(Neo4j 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

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

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

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

这是我现在拥有的:

$ 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 的所有子 classes(如 VotableLikeable)也在那里重复?正如您从我的配置中看到的那样,我已尝试排除所有内容,除了:

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

我的目标是在 ES 处仅索引 Decision 个节点。

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

我们的文档似乎对使用内部 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')