Want to confirm that the way I am constructing my schema queries aligns with Neptune's expectations or not?

0

As when I am executing the below code it throws an error however when I am executing the bottom code with same query it doesn't give error:

Below code gives the error:- Neptune schema creation failed: ResponseError: Server error: {"requestId":"f708615b-4152-4af0-812a-24e7c134f778","code":"InvalidParameterException","detailedMessage":"The provided traverser does not map to a value: v[00c6766e-d42a-feac-7dd8-7c12adc38ab5]->[SelectOneStep(last,28c657a6-3f9d-aa33-505b-e07b81eb7171)]"} (499) at Connection._handleMessage (/home/rajat.mahajan_ext/Downloads/neptune-Service/node_modules/gremlin/lib/driver/connection.js:345:9) at WebSocket.<anonymous> (/home/rajat.mahajan_ext/Downloads/neptune-Service/node_modules/gremlin/lib/driver/connection.js:141:43) at WebSocket.emit (events.js:376:20) at Receiver.receiverOnMessage (/home/rajat.mahajan_ext/Downloads/neptune-Service/node_modules/ws/lib/websocket.js:1209:20) at Receiver.emit (events.js:376:20) at Receiver.dataMessage (/home/rajat.mahajan_ext/Downloads/neptune-Service/node_modules/ws/lib/receiver.js:576:14) at /home/rajat.mahajan_ext/Downloads/neptune-Service/node_modules/ws/lib/receiver.js:534:12 at /home/rajat.mahajan_ext/Downloads/neptune-Service/node_modules/ws/lib/permessage-deflate.js:309:9 at /home/rajat.mahajan_ext/Downloads/neptune-Service/node_modules/ws/lib/permessage-deflate.js:392:7 at afterWrite (internal/streams/writable.js:466:5) { statusCode: 499, statusMessage: '{"requestId":"f708615b-4152-4af0-812a-24e7c134f778","code":"InvalidParameterException","detailedMessage":"The provided traverser does not map to a value: v[00c6766e-d42a-feac-7dd8-7c12adc38ab5]->[SelectOneStep(last,28c657a6-3f9d-aa33-505b-e07b81eb7171)]"}', statusAttributes: Map(0) {} }

await g.V().hasLabel('Company').as('company')
    .V().hasLabel('SocialMedia').as('socialMedia')
    .select('company')
    .addE('hasSocialMedia').to('socialMedia')
    .next();

Below is getting executed successfully

// Define relationships for Court
const court = await g.V().hasLabel('Court').next();
const courtAddress = await g.V().hasLabel('Address').next();
const jurisdiction = await g.V().hasLabel('Country').next();

// Add 'HasAddress' edge
await g.V(court.value.id).addE('HasAddress').to(courtAddress.value.id);

// Add 'LocatedIn' edge
await g.V(court.value.id).addE('LocatedIn').to(jurisdiction.value.id);

Dev
已提問 4 個月前檢視次數 367 次
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();
profile pictureAWS
已回答 4 個月前
profile picture
專家
已審閱 2 天前
  • 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.

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;
Dev
已回答 4 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南