本文整理汇总了Java中org.apache.lucene.search.ComplexExplanation类的典型用法代码示例。如果您正苦于以下问题:Java ComplexExplanation类的具体用法?Java ComplexExplanation怎么用?Java ComplexExplanation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ComplexExplanation类属于org.apache.lucene.search包,在下文中一共展示了ComplexExplanation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: explain
import org.apache.lucene.search.ComplexExplanation; //导入依赖的package包/类
@Override
public Explanation explain(final AtomicReaderContext context,
final int doc) throws IOException {
final Scorer scorer = scorer(context, context.reader()
.getLiveDocs());
if (scorer != null) {
final int newDoc = scorer.advance(doc);
if (newDoc == doc) {
final float freq = scorer.freq();
final SimScorer docScorer = similarity.simScorer(stats,
context);
final ComplexExplanation result = new ComplexExplanation();
result.setDescription("weight(" + getQuery() + " in " + doc
+ ") [" + similarity.getClass().getSimpleName()
+ "], result of:");
final Explanation scoreExplanation = docScorer.explain(doc,
new Explanation(freq, "termFreq=" + freq));
result.addDetail(scoreExplanation);
result.setValue(scoreExplanation.getValue());
result.setMatch(true);
return result;
}
}
return new ComplexExplanation(false, 0.0f, "no matching term");
}
示例2: explain
import org.apache.lucene.search.ComplexExplanation; //导入依赖的package包/类
@Override
public Explanation explain(final AtomicReaderContext context,
final int doc) throws IOException {
final Scorer scorer = scorer(context, context.reader()
.getLiveDocs());
if (scorer != null) {
final int newDoc = scorer.advance(doc);
if (newDoc == doc) {
final float freq = scorer.freq();
final SimScorer docScorer = sim.simScorer(stats, context);
final ComplexExplanation result = new ComplexExplanation();
result.setDescription("weight(" + getQuery() + " in " + doc
+ ") [" + sim.getClass().getSimpleName()
+ "], result of:");
final Explanation scoreExplanation = docScorer.explain(doc,
new Explanation(freq, "termFreq=" + freq));
result.addDetail(scoreExplanation);
result.setValue(scoreExplanation.getValue());
result.setMatch(true);
return result;
}
}
return new ComplexExplanation(false, 0.0f, "no matching term");
}
示例3: doExplain
import org.apache.lucene.search.ComplexExplanation; //导入依赖的package包/类
private Explanation doExplain(AtomicReaderContext info, int doc) throws IOException {
Explanation subQueryExpl = subQueryWeight.explain(info, doc);
if (!subQueryExpl.isMatch()) {
return subQueryExpl;
}
// match
Explanation[] valSrcExpls = new Explanation[valSrcWeights.length];
for(int i = 0; i < valSrcWeights.length; i++) {
valSrcExpls[i] = valSrcWeights[i].explain(info, doc);
}
Explanation customExp = CustomScoreQuery.this.getCustomScoreProvider(info).customExplain(doc,subQueryExpl,valSrcExpls);
float sc = queryWeight * customExp.getValue();
Explanation res = new ComplexExplanation(
true, sc, CustomScoreQuery.this.toString() + ", product of:");
res.addDetail(customExp);
res.addDetail(new Explanation(queryWeight, "queryWeight"));
return res;
}
示例4: explain
import org.apache.lucene.search.ComplexExplanation; //导入依赖的package包/类
private Explanation explain(int target) throws IOException {
int docId;
do {
docId = nextDocOutOfOrder();
if (docId < target) {
int tempDocId = docsEnum.advance(target);
if (tempDocId == target) {
docId = tempDocId;
break;
}
} else if (docId == target) {
break;
}
docsEnum = null; // goto the next ord.
} while (docId != DocIdSetIterator.NO_MORE_DOCS);
return new ComplexExplanation(true, scores[ords[scoreUpto]], "Score based on join value " + termsEnum.term().utf8ToString());
}
示例5: explain
import org.apache.lucene.search.ComplexExplanation; //导入依赖的package包/类
@Override
public Explanation explain(AtomicReaderContext context, int doc) throws IOException {
Scorer scorer = scorer(context, context.reader().getLiveDocs());
boolean exists = scorer.advance(doc) == doc;
ComplexExplanation result = new ComplexExplanation();
if (exists) {
result.setDescription(this.toString()
+ " , product of:");
result.setValue(queryWeight);
result.setMatch(Boolean.TRUE);
result.addDetail(new Explanation(getBoost(), "boost"));
result.addDetail(new Explanation(queryNorm,"queryNorm"));
} else {
result.setDescription(this.toString()
+ " doesn't match id " + doc);
result.setValue(0);
result.setMatch(Boolean.FALSE);
}
return result;
}
示例6: explain
import org.apache.lucene.search.ComplexExplanation; //导入依赖的package包/类
public Explanation explain(int doc) throws IOException {
advance(doc);
boolean matched = this.doc == doc;
this.doc = doc;
float sc = matched ? score() : 0;
double dist = dist(latVals.doubleVal(doc), lonVals.doubleVal(doc));
String description = SpatialDistanceQuery.this.toString();
Explanation result = new ComplexExplanation
(this.doc == doc, sc, description + " product of:");
// result.addDetail(new Explanation((float)dist, "hsin("+latVals.explain(doc)+","+lonVals.explain(doc)));
result.addDetail(new Explanation((float)dist, "hsin("+latVals.doubleVal(doc)+","+lonVals.doubleVal(doc)));
result.addDetail(new Explanation(getBoost(), "boost"));
result.addDetail(new Explanation(weight.queryNorm,"queryNorm"));
return result;
}
示例7: explain
import org.apache.lucene.search.ComplexExplanation; //导入依赖的package包/类
@Override
public Explanation explain(AtomicReaderContext context, int doc) throws IOException {
// TODO: figure out what this actually is!
final Scorer cs = scorer(context, context.reader().getLiveDocs());
final boolean exists = (cs != null && cs.advance(doc) == doc);
final ComplexExplanation result = new ComplexExplanation();
if (exists) {
result.setDescription(GraphQuery.this.toString() + ", product of:");
result.setValue(queryWeight);
result.setMatch(Boolean.TRUE);
result.addDetail(new Explanation(getBoost(), "boost"));
result.addDetail(new Explanation(queryNorm, "queryNorm"));
} else {
result.setDescription(GraphQuery.this.toString() + " doesn't match id " + doc);
result.setValue(0);
result.setMatch(Boolean.FALSE);
}
return result;
}
示例8: explain
import org.apache.lucene.search.ComplexExplanation; //导入依赖的package包/类
@Override
public Explanation explain(AtomicReaderContext context, int doc)
throws IOException {
Scorer scorer = scorer(context, true, false, context.reader()
.getLiveDocs());
if (scorer != null) {
int newDoc = scorer.advance(doc);
if (newDoc == doc) {
float freq = scorer.freq();
ExactSimScorer docScorer = sim.exactSimScorer(stats,
context);
ComplexExplanation result = new ComplexExplanation();
result.setDescription("weight(" + getQuery() + " in " + doc
+ ") [" + sim.getClass().getSimpleName()
+ "], result of:");
Explanation scoreExplanation = docScorer.explain(doc,
new Explanation(freq, "termFreq=" + freq));
result.addDetail(scoreExplanation);
result.setValue(scoreExplanation.getValue());
result.setMatch(true);
return result;
}
}
return new ComplexExplanation(false, 0.0f, "no matching term");
}
示例9: doExplain
import org.apache.lucene.search.ComplexExplanation; //导入依赖的package包/类
private Explanation doExplain(AtomicReaderContext info, int doc) throws IOException {
Explanation subQueryExpl = subQueryWeight.explain(info, doc);
if (!subQueryExpl.isMatch()) {
return subQueryExpl;
}
// match
Explanation[] valSrcExpls = new Explanation[valSrcWeights.length];
for(int i = 0; i < valSrcWeights.length; i++) {
valSrcExpls[i] = valSrcWeights[i].explain(info, doc);
}
Explanation customExp = CustomScoreQuery.this.getCustomScoreProvider(info).customExplain(doc,subQueryExpl,valSrcExpls);
float sc = getBoost() * customExp.getValue();
Explanation res = new ComplexExplanation(
true, sc, CustomScoreQuery.this.toString() + ", product of:");
res.addDetail(customExp);
res.addDetail(new Explanation(getBoost(), "queryBoost")); // actually using the q boost as q weight (== weight value)
return res;
}
示例10: explain
import org.apache.lucene.search.ComplexExplanation; //导入依赖的package包/类
@Override
public Explanation explain(AtomicReaderContext context, int doc) throws IOException {
Scorer scorer = scorer(context, true, false, context.reader().getLiveDocs());
boolean exists = scorer.advance(doc) == doc;
ComplexExplanation result = new ComplexExplanation();
if (exists) {
result.setDescription(this.toString()
+ " , product of:");
result.setValue(queryWeight);
result.setMatch(Boolean.TRUE);
result.addDetail(new Explanation(getBoost(), "boost"));
result.addDetail(new Explanation(queryNorm,"queryNorm"));
} else {
result.setDescription(this.toString()
+ " doesn't match id " + doc);
result.setValue(0);
result.setMatch(Boolean.FALSE);
}
return result;
}
示例11: getMatchingFieldNames
import org.apache.lucene.search.ComplexExplanation; //导入依赖的package包/类
public synchronized List<String> getMatchingFieldNames(int docId) {
Set<String> matchingFieldNames = new HashSet<String>();
try {
Explanation explanation = getIndexSearcher().explain(luceneQuery, docId);
if (explanation instanceof ComplexExplanation) {
Explanation[] details = explanation.getDetails();
if (details != null) {
for (int i = 0; i < details.length; i++) {
Explanation detail = details[i];
matchingFieldNames.addAll(getMatchingFieldNames(docId, detail));
}
}
} else {
matchingFieldNames.addAll(getMatchingFieldNames(docId, explanation));
}
} catch (IOException e) {
throw new RuntimeException(e);
}
return new ArrayList<String>(matchingFieldNames);
}
示例12: explain
import org.apache.lucene.search.ComplexExplanation; //导入依赖的package包/类
@Override
public Explanation explain(AtomicReaderContext context, int doc) throws IOException {
PayloadNearSpanScorer scorer = (PayloadNearSpanScorer) scorer(context, context.reader().getLiveDocs());
if (scorer != null) {
int newDoc = scorer.advance(doc);
if (newDoc == doc) {
float freq = scorer.freq();
SimScorer docScorer = similarity.simScorer(stats, context);
Explanation expl = new Explanation();
expl.setDescription("weight("+getQuery()+" in "+doc+") [" + similarity.getClass().getSimpleName() + "], result of:");
Explanation scoreExplanation = docScorer.explain(doc, new Explanation(freq, "phraseFreq=" + freq));
expl.addDetail(scoreExplanation);
expl.setValue(scoreExplanation.getValue());
String field = ((SpanQuery)getQuery()).getField();
// now the payloads part
Explanation payloadExpl = function.explain(doc, field, scorer.payloadsSeen, scorer.payloadScore);
// combined
ComplexExplanation result = new ComplexExplanation();
result.addDetail(expl);
result.addDetail(payloadExpl);
result.setValue(expl.getValue() * payloadExpl.getValue());
result.setDescription("PayloadNearQuery, product of:");
return result;
}
}
return new ComplexExplanation(false, 0.0f, "no matching term");
}
示例13: explain
import org.apache.lucene.search.ComplexExplanation; //导入依赖的package包/类
@Override
public Explanation explain(AtomicReaderContext context, int doc) throws IOException {
PayloadTermSpanScorer scorer = (PayloadTermSpanScorer) scorer(context, context.reader().getLiveDocs());
if (scorer != null) {
int newDoc = scorer.advance(doc);
if (newDoc == doc) {
float freq = scorer.sloppyFreq();
SimScorer docScorer = similarity.simScorer(stats, context);
Explanation expl = new Explanation();
expl.setDescription("weight("+getQuery()+" in "+doc+") [" + similarity.getClass().getSimpleName() + "], result of:");
Explanation scoreExplanation = docScorer.explain(doc, new Explanation(freq, "phraseFreq=" + freq));
expl.addDetail(scoreExplanation);
expl.setValue(scoreExplanation.getValue());
// now the payloads part
// QUESTION: Is there a way to avoid this skipTo call? We need to know
// whether to load the payload or not
// GSI: I suppose we could toString the payload, but I don't think that
// would be a good idea
String field = ((SpanQuery)getQuery()).getField();
Explanation payloadExpl = function.explain(doc, field, scorer.payloadsSeen, scorer.payloadScore);
payloadExpl.setValue(scorer.getPayloadScore());
// combined
ComplexExplanation result = new ComplexExplanation();
if (includeSpanScore) {
result.addDetail(expl);
result.addDetail(payloadExpl);
result.setValue(expl.getValue() * payloadExpl.getValue());
result.setDescription("btq, product of:");
} else {
result.addDetail(payloadExpl);
result.setValue(payloadExpl.getValue());
result.setDescription("btq(includeSpanScore=false), result of:");
}
result.setMatch(true); // LUCENE-1303
return result;
}
}
return new ComplexExplanation(false, 0.0f, "no matching term");
}
示例14: explain
import org.apache.lucene.search.ComplexExplanation; //导入依赖的package包/类
public Explanation explain(Similarity similarity, Query query) {
if (!isMatched())
return null;
ComplexExplanation result = new ComplexExplanation();
result.setDescription("weight("+query+" in "+ doc +") [" + similarity.getClass().getSimpleName() + "], result of:");
Explanation scoreExplanation = docScorer.explain(doc, new Explanation(freq, "termFreq=" + freq));
result.addDetail(scoreExplanation);
result.setValue(scoreExplanation.getValue());
result.setMatch(true);
return result;
}
示例15: explain
import org.apache.lucene.search.ComplexExplanation; //导入依赖的package包/类
@Override
public Explanation explain(AtomicReaderContext context, int doc) throws IOException {
FlexibleScorer scorer = (FlexibleScorer) scorer(context, context.reader().getLiveDocs());
if (scorer != null) {
int newDoc = scorer.advance(doc);
if (newDoc == doc) {
FlexibleScoreModelStrategy strategy = scorer.getStrategy();
strategy.prepare(0, 0, true);
return strategy.explain(similarity, query, doc);
}
}
return new ComplexExplanation(false, 0.0f, "no matching term");
}