class SimSwitcherQuery extends Query {

    @Override
    public Weight createWeight(IndexSearcher searcher, boolean needsScores, float boost) throws IOException {
        if (!needsScores) {
            return searcher.createWeight(subQuery, false, boost);
        }
        final Similarity oldSim = searcher.getSimilarity(true);
        try {
            // XXX: hackish, this only works because a searcher
            // is created per SearchContext (multiple queries does not share the
            // same ContextIndexSearcher)
            // and that setSimilarity is delegated to super not the real IndexSearcher
            searcher.setSimilarity(similarity);
            return searcher.createWeight(subQuery, true, boost);
        } finally {
            searcher.setSimilarity(oldSim);
        }
    }

    public  SimSwitcherQuery(Similarity similarity, Query subQuery);

}