mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2026-01-20 20:01:22 +00:00
Update broken cypher statement
- I think this does what you want @Tirokk, but let me know if I missed something - this removes all white spaces in the hashtag, then removes any hashtags that have special characters, or that start with a number, but do not have any letters after - it does not check that the size is greater or equal to 1 because the regex already removes anything that does not have at least one character
This commit is contained in:
parent
25bac9a84c
commit
20c625a827
@ -147,8 +147,11 @@ UNWIND categoryIds AS categoryId
|
||||
MATCH (c:Category {id: categoryId})
|
||||
MERGE (p)-[:CATEGORIZED]->(c)
|
||||
WITH p, post.tags AS tags
|
||||
UNWIND apoc.text.replace(tags, '/[^a-z^A-Z^0-9]{1}/g', '') AS tag
|
||||
WHERE size(apoc.text.regexGroups(tag, '/^(([a-zA-Z]+[a-zA-Z0-9]*)|([0-9]+[a-zA-Z]+[a-zA-Z0-9]*))$/g')) >= 1
|
||||
MERGE (t:Tag { id: tag, disabled: false, deleted: false })
|
||||
UNWIND tags AS tag
|
||||
WITH apoc.text.replace(tag, '[^a-z^A-Z^0-9]', '') as tagNoSpacesAllowed
|
||||
CALL apoc.when(tagNoSpacesAllowed =~ '^(([a-zA-Z]+[a-zA-Z0-9]*)|([0-9]+[a-zA-Z]+[a-zA-Z0-9]*))$', 'RETURN tagNoSpacesAllowed', '', {tagNoSpacesAllowed: tagNoSpacesAllowed})
|
||||
YIELD value as validated
|
||||
WHERE validated.tagNoSpacesAllowed IS NOT NULL
|
||||
MERGE (t:Tag { id: validated.tagNoSpacesAllowed, disabled: false, deleted: false })
|
||||
MERGE (p)-[:TAGGED]->(t)
|
||||
;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user