Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
10-18-2019 04:04 AM
Hello Team,
I am using neo4j cypher query where i am trying to return 4 different property names and their values. In this 1 property is having duplicate value but its other 3 properties are having unique values. Please help me in telling the way to get only unique property name and value in return for any specific column name.
Let say we have Point A and Point B , Point A is connected to Point B and vice-versa.
In this case , Path name between A and B is duplicated but with unique properties of A & B except path name is it is common between 2 points.
Regards
AK
10-18-2019 05:33 AM
Hello Akshat,
You should not model your data to have 2 paths with the same label between two nodes, unless you are using full-text schema indexes where you can include a relationship property in the index.
Elaine
10-18-2019 06:11 AM
Hello Elaine,
Thanks a lot for the quick response.
Apologies as I did not understand your suggestion. Please elaborate in detail if possible.
Let say we have Point A and Point B , Point A is connected to Point B and vice-versa.
In this case , Path name between A and B is X which will be duplicated where we navigate from A to B via X and B to A via X only but with unique properties of A & B except path name is it is common between 2 points.
Regards
AK
10-18-2019 08:05 AM
Is the relationship direction significant? If so, then A-->B means something different than B-->A and you would need to make sure direction is specified in the query. (similar to the Facebook analagy :IS_FRIENDS_WITH where direction matters.
If the direction is not significant, then (A)-[r:IS_RELATED_TO]-(B) with properties r.x,r.y vs. (A)-[r2:IS_RELATED_TO]-(B) with properties r2.z are definitely different paths/queries, but an index can never be used, unless the index is a full-text schema index where you can use property values of relationships. All other indexes can only be created for node property values.
Elaine
10-18-2019 06:35 AM
Adding More information by sharing query and result.
Please note : Path name is unique in source but while generating the result using neo4j csv query , I am getting the path_name twice but with other attributes are unique.
SOURCE DATA QUERY
with "jdbc:oracle:thin:scott/tiger@1.2.3.4:1521/XCOMPRD_STB" as url
CALL apoc.load.jdbc(url,"select PATH_ASIDE_EQUIPMENT , PATH_ZSIDE_EQUIPMENT , PATH_ZSIDE_PORT , PATH_ASIDE_PORT , PATH_NAME from RJILCUSTOMISATIONS.RIL_UTM_PATH_V where path_type = 'UBR ACCESS LINK' and PATH_NAME = 'INMUMUMBSIKWNB6002_INMUMUMBSIKWNB0002_IB5_3' AND rownum<10") YIELD row return row.PATH_ASIDE_EQUIPMENT , row.PATH_ZSIDE_EQUIPMENT , row.PATH_ZSIDE_PORT , row.PATH_ASIDE_PORT , row.PATH_NAME
Result is attached
Below is my NEO4J Query which is giving duplicate path_name in result.
MATCH p = (sa:SITE)-[rsa]-(ea:CONTAINER) –[ra*]-(n:PATH)-[rb*]-(eb:CONTAINER)-[rsb]-(sb:SITE) RETURN
ea.EQUIP_VENDOR as VENDOR,
sa.SITE_CIRCLE as A_End_CircleName,
sb.SITE_CIRCLE as B_End_CircleName,
sa.SITE_R4G_STATE as A_SITE_R4G_STATE,
sb.SITE_R4G_STATE as B_SITE_R4G_STATE,
sa.SITE_AREACODE as A_SITE_AREA_NAME,
sb.SITE_AREACODE as B_SITE_AREA_NAME,
sa.SITE_CITY as A_End_City_Name,
sb.SITE_CITY as B_End_City_Name,
sa.JIO_CENTER as A_JIO_CENTER,
sb.JIO_CENTER as B_JIO_CENTER,
ea.EQUIP_EMS_INSTANCENAME as AEnd_EMS_Name,
eb.EQUIP_EMS_INSTANCENAME as BEnd_EMS_Name,
ea.SAPID as AEND_SAP_ID,
eb.SAPID as BEND_SAP_ID,
ea.EQUIP_IPV6_DEFAULT_GATEWAY as GWIP,
ea.EQUIP_IPV6 as A_END_IPV6,
eb.EQUIP_IPV6 as B_END_IPV6,
n.PATH_ASIDE_EQUIPMENT as NEID_A,
n.PATH_ZSIDE_EQUIPMENT as NEID_B,
sa.SITE_FRIENDLY_NAME as A_SITE_FRIENDLYNAME,
sb.SITE_FRIENDLY_NAME as B_SITE_FRIENDLYNAME,
ea.EQUIP_POLARIZATION as A_POLARIZATION_HV,
eb.EQUIP_POLARIZATION as B_POLARIZATION_HV,
sa.SITE_NAME as A_SITE_NAME,
sa.SITE_LATITUDE as A_SITE_LATITUDE,
sa.SITE_LONGITUDE as A_SITE_LONGITUDE,
sb.SITE_NAME as B_SITE_NAME,
sb.SITE_LATITUDE as B_SITE_LATITUDE,
sb.SITE_LONGITUDE as B_SITE_LONGITUDE,
ea.EQUIP_DATA_PORT_NO as A_Data_Port_No,
eb.EQUIP_DATA_PORT_NO as B_Data_Port_No,
ea.EQUIP_RX_LEVEL as A_RX_Level,
eb.EQUIP_RX_LEVEL as B_Rx_Level,
n.PATH_ASIDE_EQUIPMENT+"-"+n.PATH_ZSIDE_EQUIPMENT as HOP_NAME,
n.PATH_NAME as PATH_NAME
limit 25
10-18-2019 08:23 AM
Relationship direction is significant as we need data from 1 direction only but for both Point A and Point B like MATCH p = (sa:SITE)-[rsa]->(ea:CONTAINER) –[ra*]->(n:PATH)-[rb*]-(eb:CONTAINER)-[rsb]-(sb:SITE).
RETURN
ea.EQUIP_VENDOR as VENDOR,
sa.SITE_CIRCLE as A_End_CircleName,
sb.SITE_CIRCLE as B_End_CircleName,
sa.SITE_R4G_STATE as A_SITE_R4G_STATE,
sb.SITE_R4G_STATE as B_SITE_R4G_STATE,
sa.SITE_AREACODE as A_SITE_AREA_NAME,
sb.SITE_AREACODE as B_SITE_AREA_NAME,
sa.SITE_CITY as A_End_City_Name,
sb.SITE_CITY as B_End_City_Name,
sa.JIO_CENTER as A_JIO_CENTER,
sb.JIO_CENTER as B_JIO_CENTER,
ea.EQUIP_EMS_INSTANCENAME as AEnd_EMS_Name,
eb.EQUIP_EMS_INSTANCENAME as BEnd_EMS_Name,
ea.SAPID as AEND_SAP_ID,
eb.SAPID as BEND_SAP_ID,
ea.EQUIP_IPV6_DEFAULT_GATEWAY as GWIP,
ea.EQUIP_IPV6 as A_END_IPV6,
eb.EQUIP_IPV6 as B_END_IPV6,
n.PATH_ASIDE_EQUIPMENT as NEID_A,
n.PATH_ZSIDE_EQUIPMENT as NEID_B,
sa.SITE_FRIENDLY_NAME as A_SITE_FRIENDLYNAME,
sb.SITE_FRIENDLY_NAME as B_SITE_FRIENDLYNAME,
ea.EQUIP_POLARIZATION as A_POLARIZATION_HV,
eb.EQUIP_POLARIZATION as B_POLARIZATION_HV,
sa.SITE_NAME as A_SITE_NAME,
sa.SITE_LATITUDE as A_SITE_LATITUDE,
sa.SITE_LONGITUDE as A_SITE_LONGITUDE,
sb.SITE_NAME as B_SITE_NAME,
sb.SITE_LATITUDE as B_SITE_LATITUDE,
sb.SITE_LONGITUDE as B_SITE_LONGITUDE,
ea.EQUIP_DATA_PORT_NO as A_Data_Port_No,
eb.EQUIP_DATA_PORT_NO as B_Data_Port_No,
ea.EQUIP_RX_LEVEL as A_RX_Level,
eb.EQUIP_RX_LEVEL as B_Rx_Level,
n.PATH_ASIDE_EQUIPMENT+"-"+n.PATH_ZSIDE_EQUIPMENT as HOP_NAME,
n.PATH_NAME as PATH_NAME
Please help me with query modification.
10-21-2019 01:36 PM
I don't think what you want is possible. If the properties themselves vary, such that the combination of all values is distinct per row, and if you're set on returning all of these properties and you don't want to use aggregation, then you're out of luck. DISTINCT only works across the entire row, and there is no way to represent in the returned record/row format what you want.
Now if you want to aggregate, that's a different issue. The variables that you want to be distinct should be the grouping key (not aggregated), and everything else needs to be aggregated in some way, but in a way that the results still make sense and are useful to you. This is because when you do an aggregation, the non-aggregation variables (which are referred to as the grouping key) become distinct as a consequence as everything else gets grouped.
Now all this said, perhaps we're misunderstanding what you want here. I think it would best help if you provided an example graph, and desired example output showing exactly what you want. Keep in mind this must be in a record/row format, that is each row is a record, and each row will have a value for the given variable / column name. It is not possible to have a column that has a different number of rows than others, which seems to be what you're asking, because results are row/record oriented, not column oriented.
10-22-2019 09:54 PM
Hello Andrew,
Thanks for explaining in detail. I did not get the last line of your explanation of 3rd paragraph.
Please help in it again.
What I am getting using Neo4j query is attached and what I exactly need is also attached in form of excel sheet. Also attaching the Neo4j browser screen shot to see the labels and relationship i am using in cypher query.
Please note HOP_NAME column and PATH_NAME column is having same values except - and _. Hence consider only HOP_NAME.
Below is the Neo4J output file ( current file )
Expected file from Neo4j
Below is the Neo4j Query i am using
MATCH p = (sa:SITE)-[rsa]-(ea:CONTAINER) –[ra*]-(n:PATH)-[rb*]-(eb:CONTAINER)-[rsb]-(sb:SITE) RETURN
ea.EQUIP_VENDOR as VENDOR,
sa.SITE_CIRCLE as A_End_CircleName,
sb.SITE_CIRCLE as B_End_CircleName,
sa.SITE_R4G_STATE as A_SITE_R4G_STATE,
sb.SITE_R4G_STATE as B_SITE_R4G_STATE,
sa.SITE_AREACODE as A_SITE_AREA_NAME,
sb.SITE_AREACODE as B_SITE_AREA_NAME,
sa.SITE_CITY as A_End_City_Name,
sb.SITE_CITY as B_End_City_Name,
sa.JIO_CENTER as A_JIO_CENTER,
sb.JIO_CENTER as B_JIO_CENTER,
ea.EQUIP_EMS_INSTANCENAME as AEnd_EMS_Name,
eb.EQUIP_EMS_INSTANCENAME as BEnd_EMS_Name,
ea.SAPID as AEND_SAP_ID,
eb.SAPID as BEND_SAP_ID,
ea.EQUIP_IPV6_DEFAULT_GATEWAY as GWIP,
ea.EQUIP_IPV6 as A_END_IPV6,
eb.EQUIP_IPV6 as B_END_IPV6,
n.PATH_ASIDE_EQUIPMENT as NEID_A,
n.PATH_ZSIDE_EQUIPMENT as NEID_B,
sa.SITE_FRIENDLY_NAME as A_SITE_FRIENDLYNAME,
sb.SITE_FRIENDLY_NAME as B_SITE_FRIENDLYNAME,
ea.EQUIP_POLARIZATION as A_POLARIZATION_HV,
eb.EQUIP_POLARIZATION as B_POLARIZATION_HV,
sa.SITE_NAME as A_SITE_NAME,
sa.SITE_LATITUDE as A_SITE_LATITUDE,
sa.SITE_LONGITUDE as A_SITE_LONGITUDE,
sb.SITE_NAME as B_SITE_NAME,
sb.SITE_LATITUDE as B_SITE_LATITUDE,
sb.SITE_LONGITUDE as B_SITE_LONGITUDE,
ea.EQUIP_DATA_PORT_NO as A_Data_Port_No,
eb.EQUIP_DATA_PORT_NO as B_Data_Port_No,
ea.EQUIP_RX_LEVEL as A_RX_Level,
eb.EQUIP_RX_LEVEL as B_Rx_Level,
n.PATH_ASIDE_EQUIPMENT+"-"+n.PATH_ZSIDE_EQUIPMENT as HOP_NAME LIMIT 10
screnshot of neo4 label and relationship in use
Regards
Akshat
All the sessions of the conference are now available online