简体   繁体   中英

create indexes on existing nodes - Neo4J

I've created 1 Million of nodes with Cypher but during the creation of these nodes I forgot to insert INDEX ON to create indexes.

Now, how do I create indexes for all the nodes? I tried with CREATE INDEX ON :user(userID) and I received this message: Added 1 index, statement executed in 32 ms.

But I expected to get a message saying "Added 1000000 indexes ... " since I have 1 million of nodes with user label and UserID property.

When you do a CREATE INDEX you only create one index. The million entries are going to be things within that one index.

Cypher indexes are built in the background; so when this command successfully executes, that means the index is there, but it probably isn't fully built until some time later.

See this blog post for more details, notably this part:

You create a schema index with CREATE INDEX ON :Label(property) eg CREATE INDEX ON :Person(name).

You list available schema indexes (and constraints) and their status (POPULATING,ONLINE,FAILED) with :schema in the browser or schema in the shell.

Always make sure that the indexes and constraints you want to use in your operations are ONLINE otherwise they won't be used and your queries will be slow.

My guess is that right after you execute CREATE INDEX , if you were to check the status of the index you'd find it in the POPULATING state.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM