@Override public Query clone() { ChildrenConstantScoreQuery q = (ChildrenConstantScoreQuery) super.clone(); q.originalChildQuery = originalChildQuery.clone(); if (q.rewrittenChildQuery != null) { q.rewrittenChildQuery = rewrittenChildQuery.clone(); } return q; }
/*(non-Javadoc) @see org.apache.lucene.search.Query#clone() */ @Override public Object clone() { CustomScoreQuery clone = (CustomScoreQuery) super.clone(); clone.subQuery = (Query) subQuery.clone(); clone.valSrcQueries = new ValueSourceQuery[valSrcQueries.length]; for (int i = 0; i < valSrcQueries.length; i++) { clone.valSrcQueries[i] = (ValueSourceQuery) valSrcQueries[i].clone(); } return clone; }
/** * Optimize our representation and our subqueries representations * * @param reader the IndexReader we query * @return an optimized copy of us (which may not be a copy if there is nothing to optimize) */ @Override public Query rewrite(IndexReader reader) throws IOException { int numDisjunctions = disjuncts.size(); if (numDisjunctions == 1) { Query singleton = disjuncts.get(0); Query result = singleton.rewrite(reader); if (getBoost() != 1.0f) { if (result == singleton) result = result.clone(); result.setBoost(getBoost() * result.getBoost()); } return result; } DisjunctionMaxQuery clone = null; for (int i = 0; i < numDisjunctions; i++) { Query clause = disjuncts.get(i); Query rewrite = clause.rewrite(reader); if (rewrite != clause) { if (clone == null) clone = this.clone(); clone.disjuncts.set(i, rewrite); } } if (clone != null) return clone; else return this; }