Improve Lucene query generation