Query works when executed in console but not in javascript - Apache TinkerPop