Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
915 views
in Technique[技术] by (71.8m points)

graph - How can I create in Cypher an index that involves 2 primary keys?

I am creating a graph in Neo4j and I am starting by creating indexes. One index is linked to one csv file Product whose primary key is productID, another Client with clientID as PK and there's another file called ShoppingCart which contains ProductId and ClientId as PK.

Then how can I create an index for ShoppingCart? Or is it not needed?

CREATE INDEX ON :Product(productID);
CREATE INDEX ON :Client(clientID);
CREATE INDEX ON :ShoppingCart?????

Thanks!

question from:https://stackoverflow.com/questions/65864232/how-can-i-create-in-cypher-an-index-that-involves-2-primary-keys

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

With Neo4j 3.x, the syntax is:

CREATE INDEX ON :ShoppingCart(productID, clientID)

With Neo4j 4.x, the syntax is:

CREATE INDEX shopping_cart_index FOR (n:ShoppingCart) ON (n.productID, n.clientID)

Note: at the time of writing, only Neo4j 3.5.x is supported in the 3.x series.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...