cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Multiple Properties in single Vertex

Could you please help me understand if we can have multiple array properties in 1 vertex.. For example,

"id": "CU10611973PH",
    "label": "Phone-Home",
    "type": "vertex",
    "properties": {
      "PhonePreference": [
        {
          "id": "c63cf5c9-329b-456e-b94e-0c500587780f",
          "value": "Primary"
        }
      ],
      "PhoneType": [
        {
          "id": "11f241d8-8e84-479b-b6a4-aeab7e039665",
          "value": "Home"
        }
      ],
      "PhoneNumber": [
        {
          "id": "5795e2ec-6d8c-424c-b42d-f01b587caeca",
          "value": "22222222222"
        }
      ],
      "pk": [
        {
          "id": "CU10611973PH|pk",
          "value": "pk"
        }
      ]
    }
  },
  {
    "id": "CU10611973PC",
    "label": "Phone-cell",
    "type": "vertex",
    "properties": {
      "PhonePreference": [
        {
          "id": "488c54b2-f256-4053-adc5-c07ec2e1a629",
          "value": "Primary"
        }
      ],
      "PhoneType": [
        {
          "id": "2f5263e7-f42b-487f-a185-338682a68fdd",
          "value": "Cell"
        }
      ],
      "PhoneNumber": [
        {
          "id": "a967516d-986c-4eac-929a-b86824677922",
          "value": "123456789"
        }
      ],
      "pk": [
        {
          "id": "CU10611973PC|pk",
          "value": "pk"

So here we are having 2 vertex, one for Phone-Home and one for Phone-Cell. Is there a way to make it come under 1 vertex with 2 set of properties, where both could be easily queried and outputs as 2 arrays in 1 vertex

4 REPLIES 4

Bennu
Graph Fellow

Hi @kidzofy !

Why not just 2 vertexes with a Phone Tag plus relation HAS_PHONE?

Otherwise you may need some to storage the array as a JSON but it will not so easy to query info related to.

H

@Bennu : Thanks for the info.. Actually we have around 6-7 phone number entries per person and 2-4 addresses along with 2-3 email addresses. So it will be really bulky for a single customer. I mean 10-12 vertices just for a single Customer personal details.. So in future this might go upto 100 vertices per Customer when other details come into picture. So were thinking to put all sub categories as 1 vertex.

Just to clarify a single customer might have 2 categories Primary and Alternative. And in each category he might be having "Home","Cell" and "Work" type of phone numbers.. So right now we are having 1 phone tag and has phone with all these sub categories.. But it is making the system more bulky. Could you please help put some insight on how to proceed.

Oh I get it.

You can try something like this.

CREATE(p:Person)-[:HAS_CONTACT_INFO]->(i:Info)
set p.NAME = 'Gary'
SET i:Phone
SET i.HOME_PRIMARY = ["2222222222", "+32238922932"]
SET i.HOME_ATERNATIVE = []
SET i.CELL_PRIMARY = ["33333333"]
SET i.CELL_ALTERNATIVE = ["23"]
return i

And then query persons like:

MATCH(d:Person)-[:HAS_CONTACT_INFO]->(i:Info)
where any(number in i.CELL_PRIMARY where number starts with "33")
return d 

I hope this example may give you more insights about.

EDIT: I'm wondering how does index work on array tho.

H

thank you sooo much. Let me try that out