图形辅助搜索结果过滤示例

时间:2017-06-07 14:49:18

标签: elasticsearch neo4j cypher graphaware

我在Neo4j上复制了Elasticsearch的电影数据库,并使用索引nodes编制索引。它有两种类型MoviePerson。我正在尝试使用此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中得到了Personnodes这两种类型的171个节点的结果。但是,正如我的查询所说,我想仅通过其标题返回类型Movie。所以基本上它看起来不是gas-filter部分。

此外,当我将false作为shouldExclude的值时,我得到相同的结果。

[UPDATE]

我尝试了@Tezra的建议,我现在只返回了身份uuid,我将shouldExclude代替exclude,但仍然得到相同的结果。

我正在使用:

  • Elasticsearch 2.3.2
  • 图表辅助搜索-2.3.2.0
  • Neo4j-community 2.3.2.10
  • graphaware-UUID-2.3.2.37.7
  • graphaware - 服务器 - 社区全2.3.2.37
  • graphaware-的Neo4j到elasticsearch-2.3.2.37.1

应返回的结果

标题为uuid的电影的You've Got Mail

我尝试按照此tutorial进行配置,我发现index.gas.enable的值为false所以我更改了它并完成了配置,就像在教程中一样:< / p>

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}

完成配置后,我再次尝试Postmangas-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"
        }
      }
    }
  }
}

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

我发现我得到的Connection refused例外是因为Wifi。所以我不得不断开互联网的连接才能让它发挥作用。我知道这不是完美的解决方案。因此,如果有人找到了更好的方法,请在此处分享。