简体   繁体   中英

Parameterize collection: IN Operator WHERE clause Cypher REST

How to specify parameters in something like this - WHERE a.name IN ["Peter", "Tobias"] . I am trying to pass the collection after IN operator as a parameter in Cypher. I am using Cypher through REST API.

This is my example:

curl -X POST http://localhost:7474/db/data/ext/CypherPlugin/graphdb/execute_query -H "Content-Type: applicatio/json" --data-binary '{
    "query": "start ca=node:ca({search_ca_query}) MATCH ca_club-[:has]-ca WHERE (ca_club.CA_CLUB IN {CA_CLUB}) RETURN distinct ca.NUM_OFC_CA, ca.NME_CA, ca_club.CA_CLUB",
    "params": {
        "search_ca_query": "NUM_OFC_CA:(\"000333\", \"111033\", \"222197\")",
        "CA_CLUB": "[\"Driad\", \"No-Club\"]"
    }
}' 

I have also tried swapping square brackets in query, but even that didn't worked. (ie i am not getting any error but getting an empty list - "data" : [ ] .

Any suggestions on how to do this?

Your in parameter needs to be a list:

curl -X POST http://localhost:7474/db/data/ext/CypherPlugin/graphdb/execute_query -H "Content-Type: applicatio/json" --data-binary '{
    "query": "start ca=node:ca({search_ca_query}) MATCH ca_club-[:has]-ca WHERE (ca_club.CA_CLUB IN {CA_CLUB}) RETURN distinct ca.NUM_OFC_CA, ca.NME_CA, ca_club.CA_CLUB",
    "params": {
        "search_ca_query": "NUM_OFC_CA:(\"000333\", \"111033\", \"222197\")",
        "CA_CLUB": ["Driad", "No-Club"]
    }
}' 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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