The Lucene project hacks generated scanners to do this - see https://issues.apache.org/jira/browse/LUCENE-5897 and https://issues.apache.org/jira/browse/LUCENE-5400 for background.