我要将我的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
在我的应用程序中,我有一个实体: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')
我的目标是仅在ES上编制Decision
个节点。
另外,为什么来自~60的唯一单一决定被编入索引?我认为“_id”:Elasticsearch JSON输出中的“null”与此问题有关。我做错了什么?
答案 0 :(得分: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')