我已经在Neo4j
上复制了Elasticsearch
的Movie数据库,并且使用索引nodes
对其进行了索引。它有两种类型Movie
和Person
。我正在尝试使用此curl命令行使用Result Filtering
创建一个简单的Graph-Aided Search
:
curl -X GET localhost:9200/nodes/_search?pretty -d '{
"query": {
"match_all" : {}
},
"gas-filter": {
"name": "SearchResultCypherfilter",
"query": "MATCH (p:Person)-[ACTED_IN]->(m:Movie) WHERE p.name= 'Parker Posey' RETURN m.uuid as id",
"ShouldExclude": true,
"protocol": "bolt"
}
}'
但是我得到的结果是我的索引
Movie
中的所有171t类型为Person
和nodes
的节点。但是,正如我的查询所说,我只想按其标题返回Movie
类型。因此,基本上,它不希望看到gas-filter
部分。另外,当我将
false
用作shouldExclude
的值时,我得到的结果也相同。[更新]
我尝试了@Tezra的建议,我现在只返回id
uuid
,我放了shouldExclude
而不是exclude
,但仍然得到相同的结果。我正在与:
应该返回的结果:
电影的
uuid
名为You've Got Mail
。我尝试按照此tutorial进行配置,结果发现
index.gas.enable
的值是false
,因此我像在本教程中一样更改了它并完成了配置:mac$ curl -XPUT http://localhost:9200/nodes/_settings?index.gas.neo4j.hostname=http://localhost:7474
{"acknowledged":true}
mac$ curl -XPUT http://localhost:9200/nodes/_settings?index.gas.enable=true
{"acknowledged":true}
mac$ curl -XPUT http://localhost:9200/indexname/_settings?index.gas.neo4j.user=neo4j
{"acknowledged":true}
mac$ curl -XPUT http://localhost:9200/indexname/_settings?index.gas.neo4j.password=mypassword
{"acknowledged":true}
之后,我尝试添加
boltHostname
和bolt.secure
的设置,但是它不起作用,并且出现此错误:{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Can't update non dynamic settings[[index.gas.neo4j.boltHostname]] for open indices [[nodes]]"}],"type":"illegal_argument_exception","reason":"Can't update non dynamic settings[[index.gas.neo4j.boltHostname]] for open indices [[nodes]]"},"status":400}
因此,我关闭了索引以对其进行配置,然后再次将其打开:
mac$ curl -XPOST http://localhost:9200/nodes/_close
{"acknowledged":true}
mac$ curl -XPUT http://localhost:9200/nodes/_settings?index.gas.neo4j.boltHostname=bolt://localhost:7687
{"acknowledged":true}
mac$ curl -XPUT http://localhost:9200/nodes/_settings?index.gas.neo4j.bolt.secure=false
{"acknowledged":true}
mac$ curl -XPOST http://localhost:9200/nodes/_open
{"acknowledged":true}
完成配置后,我再次对
Postman
尝试执行与gas-filter
相同的curl
查询,现在出现此错误:{
"error": {
"root_cause": [
{
"type": "runtime_exception",
"reason": "Failed to parse a search response."
}
],
"type": "runtime_exception",
"reason": "Failed to parse a search response.",
"caused_by": {
"type": "client_handler_exception",
"reason": "java.net.ConnectException: Connection refused (Connection refused)",
"caused_by": {
"type": "connect_exception",
"reason": "Connection refused (Connection refused)"
}
}
},
"status": 500
}
我不知道错误在说哪个连接。我确定我在配置中输入了正确的
Neo4j
密码。我什至停止并重新启动了Elasticsearch
和Neo4j
服务器,但仍然存在相同的错误。我的索引
nodes
的设置如下所示:{
"nodes" : {
"settings" : {
"index" : {
"gas" : {
"enable" : "true",
"neo4j" : {
"hostname" : "http://localhost:7474",
"password" : "neo4j.",
"bolt" : {
"secure" : "false"
},
"boltHostname" : "bolt://localhost:7687",
"user" : "neo4j"
}
},
"creation_date" : "1495531307760",
"number_of_shards" : "5",
"number_of_replicas" : "1",
"uuid" : "SdrmQKhXQmyGKHmOh_xhhA",
"version" : {
"created" : "2030299"
}
}
}
}
}
有任何想法吗?
最佳答案
我发现我得到的Connection refused
异常是由于Wifi
引起的。因此,我必须断开与互联网的连接才能使其正常运行。我知道这不是完美的解决方案。因此,如果有人发现更好的方法,请在此处分享。
关于elasticsearch - 图辅助搜索结果过滤示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44415990/