2017-06-07 73 views
1

我複製了Neo4j的電影數據庫Elasticsearch,並且它的索引爲nodes。它有兩種類型MoviePerson。我試圖做一個簡單的Result Filtering使用此curl命令行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" 
    } 
}' 

,但我得到的結果,所有這兩種類型MoviePerson的171個節點在我的索引nodes。但是,正如我的查詢所說,我想僅返回其標題爲Movie的類型。所以基本上它不看gas-filter部分。

另外,當我把false作爲值shouldExclude我得到了同樣的結果。

[更新]

我試過@Tezra的建議,我現在只返回ID uuid,我把shouldExclude而不是exclude,但仍然得到了相同的結果。

我一起工作:

  • Elasticsearch 2.3.2
  • 圖形輔助搜索-2.3.2.0
  • 的Neo4j社區2.3.2.10
  • graphaware的UUID-2.3.2.37 0.7
  • graphaware服務器 - 社區全2.3.2.37
  • graphaware-的Neo4j到elasticsearch-2.3.2.37.1

結果應該返回

標題爲You've Got Mail影片的uuid


我試圖按照此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} 

之後我嘗試添加的boltHostnamebolt.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。我甚至停止並重新啓動了服務器ElasticsearchNeo4j,但仍然出現相同的錯誤。

我的索引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" 
     } 
     } 
    } 
    } 
} 

任何想法?

+0

不應該是「shouldExclude」而不是「exclude」嗎?另外,我認爲你只需要返回m.id. – Tezra

+0

@Tezra甚至用'shouldExclude'而不是'exclude'我得到的結果相同。爲什麼我應該只返回m.id? – Benz

回答

0

我發現我得到的Connection refused例外是因爲Wifi。所以我必須斷開與互聯網的連接才能使其工作。我知道這不是完美的解決方案。所以如果有人找到了更好的方法,請在此分享。