2 個答案
- 最新
- 最多得票
- 最多評論
0
In the query:
g.V().hasLabel('Company').as('company')
.V().hasLabel('SocialMedia').as('socialMedia')
.select('company')
.addE('hasSocialMedia').to('socialMedia')
.next();
If there is more than one vertex returned by g.V().hasLabel('Company')
, then what gets saved in the 'company'
label would be a set of vertices. You can't pass a set of vertices into the addE()
step.
A better way to express this query would be:
g.V().hasLabel('Company').as('company')
.V().hasLabel('SocialMedia').as('socialMedia')
.addE('hasSocialMedia').from('company')
.next();
已回答 4 個月前
0
Hey Taylor-AWS, From line 1 to 148, the code is running however at line 150 it is giving error, also I have check that the error is occuring where there is more then one addE If you can fix my complete edges.js and make it error free, it would be great help
const gremlin = require('gremlin');
const createNodes = require('./nodes');
async function createEdges(g) {
// Import nodes creation function
await createNodes(g);
// Define edge relationships
await g.V().hasLabel('Person').as('person')
.V().hasLabel('Email').as('email')
.select('person')
.addE('hasEmail').to('email')
.next();
await g.V().hasLabel('Person').as('person')
.V().hasLabel('PhoneNumber').as('phoneNumber')
.select('person')
.addE('hasPhoneNumber').to('phoneNumber')
.next();
await g.V().hasLabel('Person').as('person')
.V().hasLabel('Address').as('address')
.select('person')
.addE('hasAddress').to('address')
.next();
await g.V().hasLabel('Person').as('person')
.V().hasLabel('Company').as('company')
.select('person')
.addE('hasEmployment').to('company')
.next();
await g.V().hasLabel('Person').as('person')
.V().hasLabel('School').as('school')
.select('person')
.addE('hasEducation').to('school')
.next();
await g.V().hasLabel('Person').as('person')
.V().hasLabel('Person').as('friend')
.select('person')
.addE('hasFriend').to('friend')
.next();
await g.V().hasLabel('Person').as('person')
.V().hasLabel('SocialMediaAccount').as('socialMediaAccount')
.select('person')
.addE('hasSocialMediaAccount').to('socialMediaAccount')
.next();
await g.V().hasLabel('Person').as('person')
.V().hasLabel('Website').as('website')
.select('person')
.addE('hasWebsite').to('website')
.next();
await g.V().hasLabel('Person').as('person')
.V().hasLabel('Risk').as('risk')
.select('person')
.addE('hasRisk').to('risk')
.next();
await g.V().hasLabel('Person').as('person')
.V().hasLabel('Skill').as('skill')
.select('person')
.addE('hasSkill').to('skill')
.next();
// Define edge relationships for Company
await g.V().hasLabel('Company').as('company')
.V().hasLabel('Address').as('address')
.select('company')
.addE('hasAddress').to('address')
.next();
await g.V().hasLabel('Company').as('company')
.V().hasLabel('TradingAddress').as('tradingAddress')
.select('company')
.addE('hasTradingAddress').to('tradingAddress')
.next();
await g.V().hasLabel('Company').as('company')
.V().hasLabel('PreviousAddress').as('previousAddress')
.select('company')
.addE('hasPreviousAddress').to('previousAddress')
.next();
await g.V().hasLabel('Company').as('company')
.V().hasLabel('CurrentAddress').as('currentAddress')
.select('company')
.addE('hasCurrentAddress').to('currentAddress')
.next();
await g.V().hasLabel('Company').as('company')
.V().hasLabel('Country').as('country')
.select('company')
.addE('hasJurisdiction').to('country')
.next();
await g.V().hasLabel('Company').as('company')
.V().hasLabel('Person').as('beneficialOwner')
.select('company')
.addE('hasBeneficialOwner').to('beneficialOwner')
.next();
await g.V().hasLabel('Company').as('company')
.V().hasLabel('Person').as('attorney')
.select('company')
.addE('hasAttorney').to('attorney')
.next();
await g.V().hasLabel('Company').as('company')
.V().hasLabel('Person').as('officer')
.select('company')
.addE('hasOfficer').to('officer')
.next();
await g.V().hasLabel('Company').as('company')
.V().hasLabel('Filing').as('filing')
.select('company')
.addE('hasFiling').to('filing')
.next();
await g.V().hasLabel('Company').as('company')
.V().hasLabel('Email').as('email')
.select('company')
.addE('hasEmail').to('email')
.next();
await g.V().hasLabel('Company').as('company')
.V().hasLabel('PhoneNumber').as('phoneNumber')
.select('company')
.addE('hasPhoneNumber').to('phoneNumber')
.next();
await g.V().hasLabel('Company').as('company')
.V().hasLabel('URL').as('website')
.select('company')
.addE('hasWebsite').to('website')
.next();
await g.V().hasLabel('Company').as('company')
.V().hasLabel('SocialMedia').as('socialMedia')
.select('company')
.addE('hasSocialMedia').to('socialMedia')
.next();
line 150 to rest
// Define relationships for Court
await g.V().hasLabel('Court').as('court')
.V().hasLabel('Address').as('courtAddress')
.V().hasLabel('Country').as('jurisdiction')
.select('court')
.addE('HasAddress').to('courtAddress')
.addE('LocatedIn').to('jurisdiction')
.next();
// Define Person relationships for Court Record
await g.V().hasLabel('CourtRecord').as('courtRecord')
.V().hasLabel('Person').as('person')
.V().hasLabel('Company').as('company')
.V().hasLabel('Country').as('jurisdiction')
.V().hasLabel('Court').as('court')
.select('courtRecord')
.addE('Plaintiff').to('person')
.addE('Defendant').to('person')
.addE('Judge').to('person')
.addE('Attorney').to('person')
.property('startDate', 'date')
.addE('Petitioner').to('person')
.property('endDate', 'date')
.property('allocatedBy', 'string')
.addE('Respondent').to('person').property('type', 'string')
.addE('Appellant').to('person').property('type', 'string')
.next();
// Define Company relationships for Court Record
await g.V().hasLabel('CourtRecord').as('courtRecord')
.V().hasLabel('Company').as('company')
.select('courtRecord')
.addE('Plaintiff').to('company')
.addE('Defendant').to('company')
.next();
// Define Jurisdiction relationships for Court Record
await g.V().hasLabel('CourtRecord').as('courtRecord')
.V().hasLabel('Country').as('jurisdiction')
.select('courtRecord')
.addE('LocatedIn').to('jurisdiction')
.next();
// Define Court relationships for Court Record
await g.V().hasLabel('CourtRecord').as('courtRecord')
.V().hasLabel('Court').as('court')
.select('courtRecord')
.addE('FiledIn').to('court')
.next();
// Define relationships for Warning
await g.V().hasLabel('Warning').as('warning')
.V().hasLabel('AdverseMedia').as('adverseMedia')
.select('warning')
.addE('hasAdverseMedia').to('adverseMedia')
.next();
// Define relationships for Special Interest Persons
await g.V().hasLabel('SpecialInterestPersons').as('specialInterestPersons')
.V().hasLabel('Person').as('person')
.select('specialInterestPersons')
.addE('hasSpecialInterestPerson').to('person')
.next();
// Define relationships for Special Interest Entity
await g.V().hasLabel('SpecialInterestEntity').as('specialInterestEntity')
.V().hasLabel('Company').as('company')
.select('specialInterestEntity')
.addE('hasSpecialInterestEntity').to('company')
.next();
// Define relationships for Trafficking
await g.V().hasLabel('Trafficking').as('trafficking')
.V().hasLabel('Person').as('person')
.select('trafficking')
.addE('involvedInTrafficking').to('person')
.next();
// Define relationships for Domain
await g.V().hasLabel('Domain').as('domain')
.V().hasLabel('URL').as('url')
.select('domain')
.addE('hasDomain').to('url')
.next();
// Define relationships for IPAddress
await g.V().hasLabel('IPAddress').as('ipAddress')
.V().hasLabel('URL').as('url')
.select('ipAddress')
.addE('hasIPAddress').to('url')
.next();
// Define relationships for SocialMediaPosts
await g.V().hasLabel('SocialMediaPosts').as('socialMediaPosts')
.V().hasLabel('Person').as('person')
.select('socialMediaPosts')
.addE('hasSocialMediaPosts').to('person')
.next();
// Define relationships for PEP
await g.V().hasLabel('PEP').as('pep')
.V().hasLabel('PoliticalParty').as('politicalParty')
.select('pep')
.addE('isMemberOfParty').to('politicalParty')
.next();
// Define relationships for PEP and Address
await g.V().hasLabel('PEP').as('pep')
.V().hasLabel('Address').as('placeOfBirth')
.select('pep')
.addE('wasBornIn').to('placeOfBirth')
.next();
// Define relationships for PlaceOfBirth
await g.V().hasLabel('PlaceOfBirth').as('placeOfBirth')
.V().hasLabel('Country').as('country')
.select('placeOfBirth')
.addE('isLocatedIn').to('country')
.next();
// Define relationships for Sanctions
await g.V().hasLabel('Sanctions').as('sanctions')
.V().hasLabel('Country').as('jurisdiction')
.select('sanctions')
.addE('isSanctionedIn').to('jurisdiction')
.next();
// Define relationships for Sanctions and Warnings
await g.V().hasLabel('Sanctions').as('sanctions')
.V().hasLabel('Warnings').as('warnings')
.select('sanctions')
.addE('hasWarnings').to('warnings')
.next();
// Define relationships for FitnessProbity
await g.V().hasLabel('FitnessProbity').as('fitnessProbity')
.V().hasLabel('Country').as('country')
.select('fitnessProbity')
.addE('enforcesIn').to('country')
.next();
// Define relationships for FitnessProbity and Address
await g.V().hasLabel('FitnessProbity').as('fitnessProbity')
.V().hasLabel('Address').as('address')
.select('fitnessProbity')
.addE('locatedAt').to('address')
.next();
// Define relationships for SocialMedia, Person, Company, Email, SocialPost, Location, Education, Employment, Risk, Lawsuit, and Case
await g.V().hasLabel('SocialMedia').as('socialMedia')
.V().hasLabel('Person').as('person')
.V().hasLabel('Company').as('company')
.V().hasLabel('Email').as('email')
.V().hasLabel('SocialPost').as('socialPost')
.V().hasLabel('Location').as('location')
.V().hasLabel('Education').as('education')
.V().hasLabel('Employment').as('employment')
.V().hasLabel('Risk').as('risk')
.V().hasLabel('Lawsuit').as('lawsuit')
.V().hasLabel('Case').as('case')
.select('socialMedia')
.addE('BelongsTo').to('person')
.addE('BelongsTo').to('company')
.select('email')
.addE('BelongsTo').to('person')
.select('socialPost')
.addE('Posted').to('person')
.addE('Posted').to('company')
.select('email')
.addE('EmailCorrespondence').to('person')
.addE('EmailCorrespondence').to('company')
.select('risk')
.addE('RiskRelation').to('person')
.addE('RiskRelation').to('company')
.addE('RiskRelation').to('socialPost')
.select('person')
.addE('ResidesIn').to('location')
.addE('StudiedAt').to('education')
.addE('WorkedAt').to('employment')
.select('person')
.addE('RelatedTo').to('person')
.select('company')
.addE('RelatedTo').to('company')
.select('person')
.addE('RelatedTo').to('risk')
.addE('RelatedTo').to('lawsuit')
.addE('RelatedTo').to('case')
.next();
console.log('Edges creation complete.');
}
module.exports = createEdges;
已回答 4 個月前
相關內容
- 已提問 1 年前
- AWS 官方已更新 1 年前
Thankyou so much Taylor for your responses.
Hey Taylor, But using from directly is giving the below error Neptune schema creation failed: TypeError: g.V(...).hasLabel(...).as(...).V(...).hasLabel(...).as(...).addE(...).from is not a function at createEdges (/home/rajat.mahajan_ext/Downloads/neptune-Service/src/data/models/edges.js:150:29) at async createNeptuneSchema (/home/rajat.mahajan_ext/Downloads/neptune-Service/src/data/models/model.js:20:3)
What is at line 150 of
edges.js
? I tried looking at the edges.js file that you posted in the other thread but I only see 77 lines of code there.