Package org.apache.lucene.search

Examples of org.apache.lucene.search.Explanation


    HashMap<String, Float> map = new HashMap<String, Float>();
    map.put("0,120:1", 3.0f);
    FacetTermQuery geoQ = new FacetTermQuery(sel2,map);
   
    BoboBrowser b = newBrowser();
    Explanation expl = b.explain(geoQ, 0);
   
    br2.setQuery(geoQ);
    doTest(br2,2,null,new String[]{"1","5"});
    expl = b.explain(geoQ, 1);
     
      // facet query for color "red" and getting facet counts for the distance facet.
    BrowseRequest br3 = new BrowseRequest();
    br3.setCount(10);
    br3.setOffset(0)

    BrowseSelection sel3 = new BrowseSelection("color");
    sel3.addValue("red");
    HashMap<String, Float> map3 = new HashMap<String, Float>();
    map3.put("red", 3.0f);
    FacetTermQuery colorQ = new FacetTermQuery(sel3,map3);

    BoboBrowser b2 = newBrowser();
    Explanation expl2 = b.explain(colorQ, 0);
   
    br3.setFacetSpec("distance", geoSpec);
    geoSpec.setMinHitCount(0);
    br3.setQuery(colorQ);             // query is color=red
    br3.addSelection(sel);        // count facets <30,70,5> and <60,120,1>
View Full Code Here


    HashMap<String, Float> map = new HashMap<String, Float>();
    map.put("60,120:1", 3.0f);
    FacetTermQuery geoQ = new FacetTermQuery(sel2,map);
   
    BoboBrowser b = newBrowser();
    Explanation expl = b.explain(geoQ, 0);
   
    br2.setQuery(geoQ);
    doTest(br2,2,null,new String[]{"1","5"});

    expl = b.explain(geoQ, 1);
     
      // facet query for color "red" and getting facet counts for the distance facet.
    BrowseRequest br3 = new BrowseRequest();
    br3.setCount(10);
    br3.setOffset(0)

    BrowseSelection sel3 = new BrowseSelection("color");
    sel3.addValue("red");
    HashMap<String, Float> map3 = new HashMap<String, Float>();
    map3.put("red", 3.0f);
    FacetTermQuery colorQ = new FacetTermQuery(sel3,map3);

    BoboBrowser b2 = newBrowser();
    Explanation expl2 = b.explain(colorQ, 0);

    br3.setFacetSpec("correctDistance", geoSpec);
    geoSpec.setMinHitCount(1);
    br3.setQuery(colorQ);             // query is color=red
    br3.addSelection(sel);        // count facets <30,70,5> and <60,120,1>
View Full Code Here

        if (idx>=0){
          scoreList.add(_function.score(_dataCache.freqs[idx], _boostList[idx]));
          explList.add(_function.explain(_dataCache.freqs[idx], _boostList[idx]));
        }
      }
      Explanation topLevel = _function.explain(scoreList.toFloatArray());
      for (Explanation sub : explList){
        topLevel.addDetail(sub);
      }
      return topLevel;
    }
View Full Code Here

          explList.add(_function.explain(_dataCache.freqs[idx], _boostList[idx]));
        }
        count++;
        encoded >>>= 1;
      }
      Explanation topLevel = _function.explain(scoreList.toFloatArray());
      for (Explanation sub : explList){
        topLevel.addDetail(sub);
      }
      return topLevel;
    }
View Full Code Here

      q = new MatchAllDocsQuery();
    }
    if (req.isShowExplanation()){
      for (BrowseHit hit : hits){
        try {
        Explanation expl = explain(q, hit.getDocid());
        hit.setExplanation(expl);
      } catch (IOException e) {
        logger.error(e.getMessage(),e);
      }
      }
View Full Code Here

      q = new MatchAllDocsQuery();
    }
    if (req.isShowExplanation()){
      for (BrowseHit hit : hits){
        try {
        Explanation expl = explain(q, hit.getDocid());
        hit.setExplanation(expl);
      } catch (IOException e) {
        logger.error(e.getMessage(),e);
      }
      }
View Full Code Here

  
   //*-- build the list of answers
   DbTools dbt = Constants.getDbt();
   dbt.openDB(Constants.EXT_FILES_DB, true, false); //*-- read only access
  
   Explanation explanation;
   LOOP: for (int i = 0; i < hits.length(); i++)
   {
     //*-- limit explanations for the top 100 hits
     if (i > 100) break LOOP; boolean foundHit = false;
   
     //*-- check if the hit rank matches the passed rank
     for (int j = 0; j < ranks.length; j++) if (ranks[j] == i) foundHit = true;
     if (!foundHit) continue LOOP;
    
     retv.append("Document: " + i + Constants.NEWLINE);
     explanation = is.explain(query, hits.id(i))
     Document doc = hits.doc(i);
     String key = doc.get("key");
     DatabaseEntry data = new DatabaseEntry();
     if (!dbt.fetch(key, data)) continue LOOP;

     //*-- extract the text
     IndexableDoc idoc = new IndexableDoc();
     idoc = (IndexableDoc) idoc.getBdbBinding().entryToObject(data);
     String line= idoc.getContents().toString();
     if (line.length() > 1000) line = line.substring(0, 999);
 
     retv.append(" Score: " + hits.score(i) + " TEXT: " + line + Constants.NEWLINE);
     retv.append(explanation.toString());
     retv.append("------------------------------------------------------------------");
     retv.append(Constants.NEWLINE); retv.append(Constants.NEWLINE);
   }
  } //*-- end of try

View Full Code Here

    results[j++] = "  Author: " + idoc.getAuthor();
    results[j++] = "  Language: " + idoc.getLanguage();
    j = dumpResults(contents, j);
    results[j++] = "";
    if (explain
    { Explanation exp = is.explain(query, hits.id(i));
      results[j++] = "  Explanation: " + exp; }
   
    if (i >= 9) break LOOP;

   } //*-- end of for
View Full Code Here

   * not a direct test of NearSpans, but a demonstration of how/when
   * this causes problems
   */
  public void testSpanNearScorerExplain() throws Exception {
    SpanNearQuery q = makeQuery();
    Explanation e = q.weight(searcher).explain(searcher.getIndexReader(), 1);
    assertTrue("Scorer explanation value for doc#1 isn't positive: "
               + e.toString(),
               0.0f < e.getValue());
  }
View Full Code Here

          * function.docScore(doc, fieldName, payloadsSeen, payloadScore);
    }

    @Override
    protected Explanation explain(int doc) throws IOException {
      Explanation result = new Explanation();
      Explanation nonPayloadExpl = super.explain(doc);
      result.addDetail(nonPayloadExpl);
      Explanation payloadBoost = new Explanation();
      result.addDetail(payloadBoost);
      float avgPayloadScore = (payloadsSeen > 0 ? (payloadScore / payloadsSeen)
          : 1);
      payloadBoost.setValue(avgPayloadScore);
      payloadBoost.setDescription("scorePayload(...)");
      result.setValue(nonPayloadExpl.getValue() * avgPayloadScore);
      result.setDescription("bnq, product of:");
      return result;
    }
View Full Code Here

TOP

Related Classes of org.apache.lucene.search.Explanation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.