我正在使用meetup dataset我希望获得成员数据,特别是我对lat和lon字段感兴趣。与此同时,我想获得团体名称和场地位置(纬度和纬度)。 我创建了这样的Neo4j查询,然而,它并没有返回任何内容:
MATCH (m)-[mtg_r:MT_TO_MEMBER_CSV]->(mt)-[mtt_r:MT_TO_TOPIC_CSV]->(t)-[tt_r:GT_TO_TOPIC_CSV]->(gt)-[tg_r:GT_TO_GROUP_CSV]->(g)-[h_r:HAS_CSV]->(e)-[a_r:AT_CSV]->(v)
RETURN mt.member_id,t.topic_name, gt.topic_id , v.lat, v.lon, e.event_name
虽然如果我将删除成员实体遍历并以这种方式更改它,我可以获取数据:
MATCH (mt)-[mtt_r:MT_TO_TOPIC_CSV]->(t)-[tt_r:GT_TO_TOPIC_CSV]->(gt)-[tg_r:GT_TO_GROUP_CSV]->(g)-[h_r:HAS_CSV]->(e)-[a_r:AT_CSV]->(v)
RETURN mt.member_id,t.topic_name, gt.topic_id , v.lat, v.lon, e.event_name
在我的查询中,我需要按照他们感兴趣的主题按成员和地点查找成员的活动。 那么我应该如何更改查询以遍历所有必需的节点并获取我需要的信息呢?
更新: 这就是我创建关系的方式:
MATCH (e:EventCSV),(v:VenueCSV) WHERE e.venue_id=v.venue_id CREATE (e)-[a_r:AT_CSV]->(v);
MATCH (e:EventCSV),(g:GroupCSV) WHERE g.group_id=e.group_id CREATE (g)-[h_r:HAS_CSV]->(e);
MATCH (m:MemberCSV),(g:GroupCSV) WHERE m.group_id=g.group_id CREATE (m)-[pi_r:PARTICIPATE_IN_CSV]->(g);
MATCH (g:GroupCSV),(gt:GroupTopicsCSV) WHERE gt.group_id=g.group_id CREATE (gt)-[tg_r:GT_TO_GROUP_CSV]->(g);
MATCH (t:TopicCSV),(gt:GroupTopicsCSV) WHERE t.topic_id=gt.topic_id CREATE (t)-[tt_r:GT_TO_TOPIC_CSV]->(gt);
MATCH (m:MemberCSV),(mt:MemberTopicsCSV) WHERE m.member_id=mt.member_id CREATE (m)-[mtg_r:MT_TO_MEMBER_CSV]->(mt);
MATCH (t:TopicCSV),(mt:MemberTopicsCSV) WHERE t.topic_id=mt.topic_id CREATE (mt)-[mtt_r:MT_TO_TOPIC_CSV]->(t);
MATCH p=()-[r:AT_CSV]->() RETURN count(p);
表格导入:
CREATE (e:EventCSV { event_id: toInteger(line.event_id), created: line.created, description: line.description, duration: toInteger(line.duration),event_url: line.event_url, group_created: line.`group.created`, group_lat: toFloat(line.`group.group_lat`), group_lon: toFloat(line.`group.group_lon`), group_id: toInteger(line.`group_id`), group_join_mode: line.`group.join_mode`, group_name: line.`group.name`, event_name: line.event_name, photo_url: line.photo_url, event_time: line.event_time, venue_address_2: line.`venue.address_2`, venue_city: line.`venue.city`, venue_country: line.`venue.country`, venue_id: toInteger(line.venue_id), venue_lat: toFloat(line.`venue.lat`), venue_lon: toFloat(line.`venue.lon`), venue_name: line.`venue.name`, yes_rsvp_count: toInteger(line.yes_rsvp_count)});
CREATE (v:VenueCSV { venue_id: toInteger(line.venue_id), address_1: line.address_1, city: line.city, country: line.country, lat: toFloat(line.lat), lon: toFloat(line.lon), venue_name: line.venue_name, rating: toFloat(line.rating)});
CREATE (g:GroupCSV { group_id: toInteger(line.group_id), category_name: line.`category.name`, city: line.city, country: line.country, created: line.created, description: line.description, join_mode: line.join_mode, lat: toFloat(line.lat), link: line.link, lon: toFloat(line.lon), members: toInteger(line.members), group_name: line.group_name, organizer_name: line.`organizer.name`, rating: toFloat(line.rating)});
CREATE (m: MemberCSV { member_id: toInteger(line.member_id), bio: line.bio, city: line.city, country: line.country, joined: line.joined, lat: toFloat(line.lat), link: line.link, lon: toFloat(line.lon), member_name: line.member_name, member_status: line.member_status, group_id: toInteger(line.group_id)});
CREATE (t:TopicCSV { topic_id: toInteger(line.topic_id), description: line.description, link: line.link, members: toInteger(line.members), topic_name: line.`topic_name`, main_topic_id: toInteger(line.main_topic_id)});
CREATE (gt:GroupTopicsCSV { topic_id: toInteger(line.topic_id), topic_name: line.`topic_name`, group_id: toInteger(line.group_id)});
CREATE (mt:MemberTopicsCSV { topic_id: toInteger(line.topic_id), topic_name: line.`topic_name`,member_id: toInteger(line.member_id)});