public float getValue() { return getBoost(); }
public float getValue() { return getBoost(); }
public float getValue() { return getBoost(); }
public float sumOfSquaredWeights() throws IOException { float sum = 0.0f; for (int i = 0 ; i < weights.size(); i++) { BooleanClause c = (BooleanClause)clauses.elementAt(i); Weight w = (Weight)weights.elementAt(i); if (!c.prohibited) sum += w.sumOfSquaredWeights(); // sum sub weights } sum *= getBoost() * getBoost(); // boost each sub-weight return sum ; }
public void normalize(float norm) { norm *= getBoost(); // incorporate boost for (int i = 0 ; i < weights.size(); i++) { Weight w = (Weight)weights.get(i); // normalize all clauses, (even if prohibited in case of side affects) w.normalize(norm); } }
/** Returns a hash code value for this object.*/ public int hashCode() { return Float.floatToIntBits(getBoost()) ^ clauses.hashCode() + getMinimumNumberShouldMatch(); }
/** Returns a hash code value for this object.*/ public int hashCode() { return Float.floatToIntBits(getBoost()) ^ clauses.hashCode() + getMinimumNumberShouldMatch(); }
public void normalize(float norm) { norm *= getBoost(); // incorporate boost for (int i = 0 ; i < weights.size(); i++) { BooleanClause c = (BooleanClause)clauses.elementAt(i); Weight w = (Weight)weights.elementAt(i); if (!c.prohibited) w.normalize(norm); } }
/** Returns a hash code value for this object.*/ public int hashCode() { return Float.floatToIntBits(getBoost()) ^ clauses.hashCode(); }
public float sumOfSquaredWeights() throws IOException { float sum = 0.0f; for (int i = 0 ; i < weights.size(); i++) { BooleanClause c = (BooleanClause)clauses.get(i); Weight w = (Weight)weights.get(i); // call sumOfSquaredWeights for all clauses in case of side effects float s = w.sumOfSquaredWeights(); // sum sub weights if (!c.isProhibited()) // only add to sum for non-prohibited clauses sum += s; } sum *= getBoost() * getBoost(); // boost each sub-weight return sum ; }
public void normalize(float norm) { norm *= getBoost(); // incorporate boost for (int i = 0 ; i < weights.size(); i++) { Weight w = (Weight)weights.get(i); // normalize all clauses, (even if prohibited in case of side affects) w.normalize(norm); } }
/** Returns true iff <code>o</code> is equal to this. */ public boolean equals(Object o) { if (!(o instanceof BooleanQuery)) return false; BooleanQuery other = (BooleanQuery)o; return (this.getBoost() == other.getBoost()) && this.clauses.equals(other.clauses) && this.getMinimumNumberShouldMatch() == other.getMinimumNumberShouldMatch(); }
/** Returns true iff <code>o</code> is equal to this. */ public boolean equals(Object o) { if (!(o instanceof BooleanQuery)) return false; BooleanQuery other = (BooleanQuery)o; return (this.getBoost() == other.getBoost()) && this.clauses.equals(other.clauses) && this.getMinimumNumberShouldMatch() == other.getMinimumNumberShouldMatch(); }
public float sumOfSquaredWeights() throws IOException { float sum = 0.0f; for (int i = 0 ; i < weights.size(); i++) { BooleanClause c = (BooleanClause)clauses.get(i); Weight w = (Weight)weights.get(i); // call sumOfSquaredWeights for all clauses in case of side effects float s = w.sumOfSquaredWeights(); // sum sub weights if (!c.isProhibited()) // only add to sum for non-prohibited clauses sum += s; } sum *= getBoost() * getBoost(); // boost each sub-weight return sum ; }
@Override public void writeObject(final ObjectOutput output, final BooleanQuery query) throws IOException { output.writeBoolean(query.isCoordDisabled()); output.writeFloat(query.getBoost()); UnsignedNumeric.writeUnsignedInt(output, query.getMinimumNumberShouldMatch()); final List<BooleanClause> booleanClauses = query.clauses(); final int numberOfClauses = booleanClauses.size(); UnsignedNumeric.writeUnsignedInt(output, numberOfClauses); for (BooleanClause booleanClause : booleanClauses) { writeClause(output, booleanClause); } }
@Override public void writeObject(final ObjectOutput output, final BooleanQuery query) throws IOException { output.writeBoolean(query.isCoordDisabled()); output.writeFloat(query.getBoost()); UnsignedNumeric.writeUnsignedInt(output, query.getMinimumNumberShouldMatch()); final List<BooleanClause> booleanClauses = query.clauses(); final int numberOfClauses = booleanClauses.size(); UnsignedNumeric.writeUnsignedInt(output, numberOfClauses); for (BooleanClause booleanClause : booleanClauses) { writeClause(output, booleanClause); } }
/** * Recursively walks the "from" query pulling out sub-queries and * adding them to the "to" query. * * <p> * Boosts are multiplied as needed. Sub-BooleanQueryies which are not * optional will not be flattened. From will be mangled durring the walk, * so do not attempt to reuse it. * </p> */ public static void flattenBooleanQuery(BooleanQuery to, BooleanQuery from) { for (BooleanClause clause : (List<BooleanClause>)from.clauses()) { Query cq = clause.getQuery(); cq.setBoost(cq.getBoost() * from.getBoost()); if (cq instanceof BooleanQuery && !clause.isRequired() && !clause.isProhibited()) { /* we can recurse */ flattenBooleanQuery(to, (BooleanQuery)cq); } else { to.add(clause); } } }
/** * Substitutes one term in the term query for another. * * <p>This method only creates new query object if required; it does not modify the given query. * * @param query the query where the substitution should occur. * @param original the original term to replace. * @param replacement the term it should be replaced with. * * @return A new term query where the term has been substituted; * or the same query if no substitution was needed. */ @Beta public static Query substitute(BooleanQuery query, Term original, Term replacement) { BooleanQuery q = new BooleanQuery(); for (BooleanClause clause : query.getClauses()) { Query qx = substitute(clause.getQuery(), original, replacement); q.add(qx, clause.getOccur()); } q.setBoost(query.getBoost()); return q; }