Had to write a JQL function using the GroovyRunner plugin in JIRA. Am having some performance issues which I will put in another StackOverflow question
EDIT: Performance issue post available here: https://stackoverflow.com/questions/18606967/jira-jql-performance-issue-with-custom-function-in-groovyrunner