The `USING INDEX` sub-clause is only for giving Neo4j a hint as to the index to use. Normally it will work that out for itself, and you shouldn't need to use it.
In your case, you have two indexes: one on :Person(name) and the other :Person(job). To use either of those indexes in a query, the Cypher statement must use both the label :Person AND one of the properties. ie. MATCH (n:Person) WHERE n.name = "Philip" RETURN n.name, n.job; This will use the :Person(name) index to find all entires with "Philip" and match the associated nodes MATCH (n:Person) WHERE n.job = "Developer" RETURN n.name, n.job; This will use the :Person(job) index to find all entires with "Developer" and match the associated nodes MATCH (n:Person) WHERE n.job IS NULL RETURN n.name, n.job; This will not use an index, but will instead use a scan over all nodes labeled :Person (to find those without a job property). I hope that helps understanding! Cheers, Chris On Tuesday, January 21, 2014 8:46:50 AM UTC-8, Javad Karabi wrote: > > Wes, could you elaborate on the following? > "You can specify more than one, but you have to have a WHERE clause with > an equality comparison on a property in the label index." > > On Monday, January 20, 2014 3:41:47 PM UTC-6, Wes Freeman wrote: >> >> The USING INDEX is for specifying which index(es) you want to use, when >> there is more than one choice. You can specify more than one, but you have >> to have a WHERE clause with an equality comparison on a property in the >> label index. >> >> There is also a USING SCAN :Person syntax, which specifies to scan that >> label only. It is not required for your query, however, since it will >> already scan just the :Person label. But, if you have more than one choice >> of labels to scan, you can specify which one is the best to start from >> (often this is the lowest cardinality label, in my experience). >> >> Wes >> >> On Mon, Jan 20, 2014 at 5:15 AM, Sylvain Roussy <[email protected]>wrote: >> >>> Hi Michael, thank you for the answer, >>>> >>> >>> But what is the USING INDEX clause use case then ? >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Neo4j" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >> >> -- You received this message because you are subscribed to the Google Groups "Neo4j" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
