本文整理了Java中org.apache.lucene.search.Query.getSimilarity
方法的一些代码示例,展示了Query.getSimilarity
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.getSimilarity
方法的具体详情如下:
包路径:org.apache.lucene.search.Query
类名称:Query
方法名:getSimilarity
[英]Expert: Returns the Similarity implementation to be used for this query. Subclasses may override this method to specify their own Similarity implementation, perhaps one that delegates through that of the Searcher. By default the Searcher's Similarity implementation is returned.
[中]专家:返回用于此查询的相似性实现。子类可以重写这个方法来指定它们自己的相似性实现,可能是一个通过搜索者的相似性实现进行委托的实现。默认情况下,将返回搜索者的相似性实现。
代码示例来源:origin: org.apache.lucene/lucene-core-jfrog
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;
}
代码示例来源:origin: org.apache.lucene/com.springsource.org.apache.lucene
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;
}
代码示例来源:origin: Cue/greplin-lucene-utils
public Weight createWeight(final Searcher searcher) throws IOException {
final Weight weight = this.query.createWeight(searcher);
final Similarity similarity = this.query.getSimilarity(searcher);
代码示例来源:origin: org.apache.lucene/com.springsource.org.apache.lucene
final Similarity similarity = query.getSimilarity(searcher);
return new Weight() {
private float value;
代码示例来源:origin: org.apache.lucene/lucene-core-jfrog
final Similarity similarity = query.getSimilarity(searcher);
return new Weight() {
private float value;
代码示例来源:origin: lucene/lucene
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;
}
};
}
};
代码示例来源:origin: org.apache.lucene/lucene-core-jfrog
/** 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;
}
代码示例来源:origin: org.apache.lucene/com.springsource.org.apache.lucene
/** 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;
}
代码示例来源:origin: lucene/lucene
/** 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;
}
内容来源于网络,如有侵权,请联系作者删除!