Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
926 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 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...