简体   繁体   English

Cypher REST查询中的索引参数化

[英]Index parameterization in Cypher REST query

I have this query which works well but without parametrization in index. 我有这个查询,但在索引中没有参数化。 emp is an index, and NUM_OFC_CA is an emp number (key in emp index), to simplify i want to return NME_CA. emp是一个索引,NUM_OFC_CA是一个emp号(emp索引中的键),以简化我想返回NME_CA。

curl -X POST http://xyzhost:7474/db/data/ext/CypherPlugin/graphdb/execute_query -H "Content-Type: application/json" --data-binary '{
    "query": "START ca=node:emp(\"NUM_OFC_CA: 997015\") RETURN distinct ca.NME_CA as `CA Name`",
    "params": {
     }
}'

How can i parametrize above REST query, i have tried something like this: 我如何参数化上面的REST查询,我尝试过这样的事情:

curl -X POST http://xyzhost:7474/db/data/ext/CypherPlugin/graphdb/execute_query -H "Content-Type: application/json" --data-binary '{
    "query": "START ca=node:emp(\"NUM_OFC_CA: {num_ofc_ca}\") RETURN distinct ca.NME_CA as `CAName`",
    "params": {
        "num_ofc_ca": "997015"
    }
}'

I am getting this error: 我收到此错误:

{
  "message" : "org.apache.lucene.queryParser.ParseException: Cannot parse 'NUM_OFC_CA: {num_ofc_ca}': Encountered \" \"}\" \"} \"\" at line 1, column 23.\nWas expecting one of:\n    \"TO\" ...\n    <RANGEEX_QUOTED> ...\n    <RANGEEX_GOOP> ...\n    ",
  "exception" : "BadInputException",
  "stacktrace" : [ "org.neo4j.server.plugin.cypher.CypherPlugin.executeScript(CypherPlugin.java:61)", "java.lang.reflect.Method.invoke(Method.java:597)", "org.neo4j.server.plugins.PluginMethod.invoke(PluginMethod.java:57)", "org.neo4j.server.plugins.PluginManager.invoke(PluginManager.java:168)", "org.neo4j.server.rest.web.ExtensionService.invokeGraphDatabaseExtension(ExtensionService.java:300)", "org.neo4j.server.rest.web.ExtensionService.invokeGraphDatabaseExtension(ExtensionService.java:122)", "java.lang.reflect.Method.invoke(Method.java:597)" ]
}

Need help to resolve this issue. 需要帮助来解决此问题。 Thanks! 谢谢!

If you need a plain index query, the syntax is as follows: 如果需要普通索引查询,则语法如下:

curl -X POST http://<host>:7474/db/data/ext/CypherPlugin/graphdb/execute_query -H "Content-Type: application/json" --databinary '{
    "query": ca=node:emp(NUM_OFC_CA = {num_ofc_ca}) RETURN distinct ca.NME_CA as `CAName`",
    "params": {
        "num_ofc_ca": "997015"
    }
}'

For a general lucene index query , you need to parametrize the full query: 对于一般的lucene索引查询 ,您需要参数化完整查询:

curl -X POST http://<host>:7474/db/data/ext/CypherPlugin/graphdb/execute_query -H "Content-Type: application/json" --databinary '{
    "query": ca=node:emp({num_ofc_ca_query}) RETURN distinct ca.NME_CA as `CAName`",
    "params": {
        "num_ofc_ca_query": "NUM_OFC_CA:997015"
    }
}'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM