Fix NPE when Lucene is building TermQuery and BooleanQuery