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.
The WITH clause allows query parts to be chained together, piping the results from one to be used as starting points or criteria in the next. It is important to note that WITH affects variables in scope.
The MATCH clause allows you to specify the patterns Neo4j will search for in the database.
Neo4j will automatically pick up and start using the index once it has been created and brought online. There are multiple index types available: b-tree (deprecated), fulltext, lookup, and text index types.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With