eq:in hyd ofc location how many employees have java skill, in vizag ofc location how many employees have java skill
like wise it should check the skillname, employee and diff locations and get count of emp from ea ch location
eq:in hyd ofc location how many employees have java skill, in vizag ofc location how many employees have java skill
like wise it should check the skillname, employee and diff locations and get count of emp from ea ch location
Using the sample graph here of people, offices, and skills
g.addV('Employee').property('name','Bob').as('b').
addV('Employee').property('name','Tom').as('t').
addV('Employee').property('name','Sally').as('s').
addV('Employee').property('name','Alice').as('a').
addV('Employee').property('name','Curt').as('c').
addV('Employee').property('name','Daisy').as('d').
addV('Office').property('location','Los Angeles').as('la').
addV('Office').property('location','New York').as('ny').
addV('Skill').property('skill','Java').as('java').
addV('Skill').property('skill','Python').as('python').
addV('Skill').property('skill','React').as('react').
addE('worksAt').from('b').to('la').
addE('worksAt').from('t').to('la').
addE('worksAt').from('s').to('la').
addE('worksAt').from('a').to('ny').
addE('worksAt').from('c').to('ny').
addE('worksAt').from('d').to('ny').
addE('hasSkill').from('b').to('java').
addE('hasSkill').from('t').to('java').
addE('hasSkill').from('s').to('python').
addE('hasSkill').from('a').to('python').
addE('hasSkill').from('c').to('react').
addE('hasSkill').from('d').to('react').
addE('hasSkill').from('b').to('react').
addE('hasSkill').from('s').to('java')
You'll need to derive a project that contains all possible combinations of location, employee, and skill. I'm assuming you want this by office location, so we should start with an office vertex:
g.V().hasLabel('Office').as('ofc').
in('worksAt').as('emp').
out('hasSkill').as('skl').
select('emp','ofc','skl').
by('name').
by('location').
by('skill')
This would provide us with all combinations:
[{'emp': 'Bob', 'ofc': 'Los Angeles', 'skl': 'React'},
{'emp': 'Bob', 'ofc': 'Los Angeles', 'skl': 'Java'},
{'emp': 'Tom', 'ofc': 'Los Angeles', 'skl': 'Java'},
{'emp': 'Sally', 'ofc': 'Los Angeles', 'skl': 'Java'},
{'emp': 'Sally', 'ofc': 'Los Angeles', 'skl': 'Python'},
{'emp': 'Alice', 'ofc': 'New York', 'skl': 'Python'},
{'emp': 'Curt', 'ofc': 'New York', 'skl': 'React'},
{'emp': 'Daisy', 'ofc': 'New York', 'skl': 'React'}]
Then we need to do a GROUP-BY operation to fetch the count of employees with a certain skill by office. So we'll add the following on to the query from above:
g.V().hasLabel('Office').as('ofc').
in('worksAt').as('emp').
out('hasSkill').as('skl').
select('emp','ofc','skl').
by('name').
by('location').
by('skill')
group().
by('ofc').
by(
groupCount().
by('skl')
)
That will provide a response as the following:
[{'New York': {'React': 2, 'Python': 1},
'Los Angeles': {'Java': 3, 'React': 1, 'Python': 1}}]