### Question:
ForceNoBulkScoringQuery extends Query { @Override public Query rewrite(IndexReader reader) throws IOException { Query rewritten = inner.rewrite(reader); if (rewritten != inner) return new ForceNoBulkScoringQuery(rewritten); return super.rewrite(reader); } ForceNoBulkScoringQuery(Query inner); @Override Query rewrite(IndexReader reader); @Override boolean equals(Object o); @Override int hashCode(); Query getWrappedQuery(); @Override Weight createWeight(IndexSearcher searcher, boolean needsScores, float boost); @Override String toString(String s);  }### Answer:
@Test public void testRewrite() throws IOException { try (Directory dir = new RAMDirectory(); IndexWriter iw = new IndexWriter(dir, new IndexWriterConfig(new StandardAnalyzer()))) { Document doc = new Document(); doc.add(new TextField("field", "term1 term2 term3 term4", Field.Store.NO)); iw.addDocument(doc); iw.commit(); IndexReader reader = DirectoryReader.open(dir); PrefixQuery pq = new PrefixQuery(new Term("field", "term")); ForceNoBulkScoringQuery q = new ForceNoBulkScoringQuery(pq); assertThat(q.getWrappedQuery()).isEqualTo(pq); Query rewritten = q.rewrite(reader); assertThat(rewritten).isInstanceOf(ForceNoBulkScoringQuery.class); Query inner = ((ForceNoBulkScoringQuery) rewritten).getWrappedQuery(); assertThat(inner).isNotEqualTo(pq); } }