private static Query newSaturationQuery(String fieldName, String featureName, float weight, Float pivot) { if (weight <= 0 || weight > MAX_WEIGHT) { throw new IllegalArgumentException("weight must be in (0, " + MAX_WEIGHT + "], got: " + weight); } if (pivot != null && (pivot <= 0 || Float.isFinite(pivot) == false)) { throw new IllegalArgumentException("pivot must be > 0, got: " + pivot); } Query q = new FeatureQuery(fieldName, featureName, new SaturationFunction(fieldName, featureName, pivot)); if (weight != 1f) { q = new BoostQuery(q, weight); } return q; }
private static Query newSaturationQuery(String fieldName, String featureName, float weight, Float pivot) { if (weight <= 0 || weight > MAX_WEIGHT) { throw new IllegalArgumentException("weight must be in (0, " + MAX_WEIGHT + "], got: " + weight); } if (pivot != null && (pivot <= 0 || Float.isFinite(pivot) == false)) { throw new IllegalArgumentException("pivot must be > 0, got: " + pivot); } Query q = new FeatureQuery(fieldName, featureName, new SaturationFunction(fieldName, featureName, pivot)); if (weight != 1f) { q = new BoostQuery(q, weight); } return q; }
@Override public FeatureFunction rewrite(IndexReader reader) throws IOException { if (pivot != null) { return super.rewrite(reader); } float newPivot = computePivotFeatureValue(reader, field, feature); return new SaturationFunction(field, feature, newPivot); }
@Override public FeatureFunction rewrite(IndexReader reader) throws IOException { if (pivot != null) { return super.rewrite(reader); } float newPivot = computePivotFeatureValue(reader, field, feature); return new SaturationFunction(field, feature, newPivot); }