elasticsearch - 图辅助搜索结果过滤示例

标签 elasticsearch neo4j cypher graphaware

我已经在Neo4j上复制了Elasticsearch的Movie数据库,并且使用索引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中的所有171t类型为Personnodes的节点。但是,正如我的查询所说,我只想按其标题返回Movie类型。因此,基本上,它不希望看到gas-filter部分。

另外,当我将false用作shouldExclude的值时,我得到的结果也相同。

[更新]

我尝试了@Tezra的建议,我现在只返回id uuid,我放了shouldExclude而不是exclude,但仍然得到相同的结果。

我正在与:
  • Elasticsearch 2.3.2
  • graph-aided-search-2.3.2.0
  • Neo4j社区2.3.2.10
  • graphaware-uuid-2.3.2.37.7
  • graphaware-server-community-all-2.3.2.37
  • graphaware-neo4j-to-elasticsearch-2.3.2.37.1

  • 应该返回的结果:

    电影的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}
    

    之后,我尝试添加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"
            }
          }
        }
      }
    }
    

    有任何想法吗?

    最佳答案

    我发现我得到的Connection refused异常是由于Wifi引起的。因此,我必须断开与互联网的连接才能使其正常运行。我知道这不是完美的解决方案。因此,如果有人发现更好的方法,请在此处分享。

    关于elasticsearch - 图辅助搜索结果过滤示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44415990/

    相关文章:

    python - 大型数据集的自定义直方图输入

    elasticsearch - 停止Couchbase Elasticsearch XDCR OutOfMemory错误

    javascript - JS 功能对象构造函数 - Neo4j 数据库没有方法 'query'

    neo4j - 仅在一列上不同

    python - 如何使用elasticsearch生成词云?

    elasticsearch - 搜索结果不包含该页面的所有匹配

    ubuntu - 第一步 Neo4j Desktop 安装错误

    neo4j - Neo4j 的 Reco4j 替代方案

    regex - Neo4j Cypher 查询 - 使用正则表达式查询属性数组

    neo4j - 获取每个关系深度的节点数