public Similarity getSimilarity(Searcher searcher) { Similarity result = super.getSimilarity(searcher); if (disableCoord) { // disable coord as requested result = new SimilarityDelegator(result) { public float coord(int overlap, int maxOverlap) { return 1.0f; } }; } return result; }
public Similarity getSimilarity(Searcher searcher) { Similarity result = super.getSimilarity(searcher); if (disableCoord) { // disable coord as requested result = new SimilarityDelegator(result) { public float coord(int overlap, int maxOverlap) { return 1.0f; } }; } return result; }
public Weight createWeight(final Searcher searcher) throws IOException { final Weight weight = this.query.createWeight(searcher); final Similarity similarity = this.query.getSimilarity(searcher);
final Similarity similarity = query.getSimilarity(searcher); return new Weight() { private float value;
final Similarity similarity = query.getSimilarity(searcher); return new Weight() { private float value;
public Scorer scorer (IndexReader indexReader) throws IOException { final Scorer scorer = weight.scorer (indexReader); final BitSet bitset = filter.bits (indexReader); return new Scorer (query.getSimilarity (searcher)) { // pass these methods through to the enclosed scorer public boolean next() throws IOException { return scorer.next(); } public int doc() { return scorer.doc(); } public boolean skipTo (int i) throws IOException { return scorer.skipTo(i); } // if the document has been filtered out, set score to 0.0 public float score() throws IOException { return (bitset.get(scorer.doc())) ? scorer.score() : 0.0f; } // add an explanation about whether the document was filtered public Explanation explain (int i) throws IOException { Explanation exp = scorer.explain (i); if (bitset.get(i)) exp.setDescription ("allowed by filter: "+exp.getDescription()); else exp.setDescription ("removed by filter: "+exp.getDescription()); return exp; } }; } };
/** Expert: Constructs and initializes a Weight for a top-level query. */ public Weight weight(Searcher searcher) throws IOException { Query query = searcher.rewrite(this); Weight weight = query.createWeight(searcher); float sum = weight.sumOfSquaredWeights(); float norm = getSimilarity(searcher).queryNorm(sum); weight.normalize(norm); return weight; }
/** Expert: Constructs and initializes a Weight for a top-level query. */ public Weight weight(Searcher searcher) throws IOException { Query query = searcher.rewrite(this); Weight weight = query.createWeight(searcher); float sum = weight.sumOfSquaredWeights(); float norm = getSimilarity(searcher).queryNorm(sum); weight.normalize(norm); return weight; }
/** Expert: Constructs an initializes a Weight for a top-level query. */ public Weight weight(Searcher searcher) throws IOException { Query query = searcher.rewrite(this); Weight weight = query.createWeight(searcher); float sum = weight.sumOfSquaredWeights(); float norm = getSimilarity(searcher).queryNorm(sum); weight.normalize(norm); return weight; }