querying with an “IN” clause using the index in neo4j with Cypher

帅比萌擦擦* 提交于 2019-12-09 18:24:02

问题


I'd like to use my auto_index in neo4j and pass in an array of strings to match against. I know that you can add an IN clause to the end of your cypher query but that doesn't use the indexes and I'm assuming will do a database scan of all the records. What's the best way to do this with an index query?

e.g. Get me users whose facebookId is in ["123", "456", "789"] assuming there is an auto_index on facebookId and there are 1 million user nodes.


回答1:


I suppose this is worth posting as an answer:

START n=node:node_auto_index('facebookId:("123", "456", "789")')
...

Example: http://console.neo4j.org/r/3mcvr5




回答2:


You would do this query by having an explicit index lookup, like

start user = node:node_auto_index('facebookId:123 OR facebookId:456') match  ...

http://console.neo4j.org/r/nj98lt for an example.



来源:https://stackoverflow.com/questions/13634179/querying-with-an-in-clause-using-the-index-in-neo4j-with-cypher

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!