Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-19-2021 06:18 AM
I have data in object with this structure
[{
name:'here is name, which can have punctuation marks ',
value: 'here will be text '
},
{
name:'here is name, which can have punctuation marks ',
value: 'here will be text '
}]
I am trying to find the best way to keep it in neo4j node. Since later I am going to search, filter ... on this data I don't want to keep hole object as string. Creating property by name object.name is not possible because I have punctuation marks. The ideal way would be to keep it as property, because I am going to use this data as property of node, but removing punctuation marks from name is not an option too.
Probably I could keep them in array
['here is the name', ' and the second element of array is the text']
In this case the problem will be to give correct name to the property, which will have this array.
Another option could be to keep all data in list like this
tabs: ['first name - first value', ' second name - second value']
but to search later I will need to use regex inside the list. this doesn't seem flexible.
So what would be the best way ?
Thank you in advance!
Solved! Go to Solution.
11-19-2021 07:00 AM
Maybe this is not good for your use-case,
but what about use the apoc.create.nodes ,
to create a Node with a label ("MyLabel" in this case), so that you can have every data you need in a specific label (possibly to be indexed and/or connect with other entities)?
CALL apoc.create.nodes(["MyLabel"], [{
`name.with.dots`:'here is name, which can have punctuation marks .',
value: 'here will be text '
},
{
name:'here is name, which can have punctuation marks ',
value: 'here will be text '
}]) yield node
return node
11-19-2021 07:00 AM
Maybe this is not good for your use-case,
but what about use the apoc.create.nodes ,
to create a Node with a label ("MyLabel" in this case), so that you can have every data you need in a specific label (possibly to be indexed and/or connect with other entities)?
CALL apoc.create.nodes(["MyLabel"], [{
`name.with.dots`:'here is name, which can have punctuation marks .',
value: 'here will be text '
},
{
name:'here is name, which can have punctuation marks ',
value: 'here will be text '
}]) yield node
return node
11-19-2021 07:04 AM
For your scenario, would backticks be ok? For example...
CREATE ({`here is "name", which has punctuation marks!`:"here will be text"})
nvm, misread your description. @giuseppe.villani has a great suggestion!
-ABK
11-22-2021 02:44 AM
Thank you for your answer. So since now I can create property name with any symbol except backticks, I am curious if there is a way to have backticks in property name or label?
Seems like approach with backticks works only with property name and not value.
11-23-2021 12:46 AM
True, backticks are only for property names. For values, character escapes must be used inside regular quotes.
To use a backtick within a backtick, you can do. use double backticks, as in:
RETURN { `property name with ``backticks```:"property value with `backticks`"}
-ABK
All the sessions of the conference are now available online