mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
@appinteractive thanks for pointing out `split`. You just saved me some days of work to refactor the import statements to use CSV instead of JSON files. @Tirokk when I enter `:schema` in Neo4J web UI, I see the following: ``` :schema Indexes ON :Badge(id) ONLINE ON :Category(id) ONLINE ON :Comment(id) ONLINE ON :Post(id) ONLINE ON :Tag(id) ONLINE ON :User(id) ONLINE No constraints ``` So I temporarily removed the unique constraints on `slug` and added plain indices on `id` for all relevant node types. We cannot omit the `:Label` unfortunately, neo4j does not allow this. So I had to add all indices for all known node labels instead. With indices the import finishes in: ``` Time elapsed: 351 seconds ``` 🎉 @appinteractive when I keep the unique indices on slug, I get an error during import that a node with label `:User` and slug `tobias` already exists. Ie. we have unqiue constraint violations in our production data. @mattwr18 @ulfgebhardt @ogerly I started the application on my machine on the production data and it turns out that the index page http://localhost:3000/ takes way to long. Visiting my profile page at http://localhost:3000/profile/5b1693daf850c11207fa6109/robert-schafer is fine, though. Even pagination works. When I visit a post page with not too many comments, the application is fast enough, too: http://localhost:3000/post/5bbf49ebc428ea001c7ca89c/neues-video-format-human-connection-tech-news
26 lines
852 B
SQL
26 lines
852 B
SQL
CALL apoc.load.json('file:/tmp/mongo-export/splits/current-chunk.json') YIELD value as post
|
|
MERGE (p:Post {id: post._id["$oid"]})
|
|
ON CREATE SET
|
|
p.title = post.title,
|
|
p.slug = post.slug,
|
|
p.image = post.teaserImg,
|
|
p.content = post.content,
|
|
p.contentExcerpt = post.contentExcerpt,
|
|
p.visibility = toLower(post.visibility),
|
|
p.createdAt = post.createdAt.`$date`,
|
|
p.updatedAt = post.updatedAt.`$date`,
|
|
p.deleted = post.deleted,
|
|
p.disabled = NOT post.isEnabled
|
|
WITH p, post
|
|
MATCH (u:User {id: post.userId})
|
|
MERGE (u)-[:WROTE]->(p)
|
|
WITH p, post, post.categoryIds as categoryIds
|
|
UNWIND categoryIds AS categoryId
|
|
MATCH (c:Category {id: categoryId})
|
|
MERGE (p)-[:CATEGORIZED]->(c)
|
|
WITH p, post.tags AS tags
|
|
UNWIND tags AS tag
|
|
MERGE (t:Tag {id: apoc.create.uuid(), name: tag})
|
|
MERGE (p)-[:TAGGED]->(t)
|
|
;
|