Package org.apache.lucene.search

Examples of org.apache.lucene.search.Weight.explain()


    final Query query = npq("renaud", "delbru").getLuceneProxyQuery();

    final Weight w = query.createWeight(searcher);

    // Explain entity 0 : 1 match
    Explanation explanation = w.explain((AtomicReaderContext) reader.getContext(), 0);
    assertNotNull("explanation is null and it shouldn't be", explanation);

//    final Similarity sim = searcher.getSimilarity();
    // TODO: The similarity is randomly set
//     System.out.println("Explanation: " + explanation.toString());
View Full Code Here


//    //All this Explain does is return the term frequency
//    assertEquals("term frq is not 1",
//      sim.tf(1), explanation.getDetails()[1].getDetails()[0].getValue(), 0.01);

    // Explain entity 1 : 2 match
    explanation = w.explain((AtomicReaderContext) reader.getContext(), 1);
    assertNotNull("explanation is null and it shouldn't be", explanation);
    // TODO: The similarity is randomly set
//     System.out.println("Explanation: " + explanation.toString());
//    //All this Explain does is return the term frequency
//    assertEquals("term frq is not 2",
View Full Code Here

//    //All this Explain does is return the term frequency
//    assertEquals("term frq is not 2",
//      sim.tf(2), explanation.getDetails()[1].getDetails()[0].getValue(), 0f);

    // Explain non existing entity
    explanation = w.explain((AtomicReaderContext) reader.getContext(), 2);
    assertNotNull("explanation is null and it shouldn't be", explanation);
//    System.out.println("Explanation: " + explanation.toString());
    //All this Explain does is return the term frequency
    assertEquals("term frq is not 0", 0f, explanation.getValue(), 0f);
  }
View Full Code Here

    final Weight w = searcher.createNormalizedWeight(query);
    assertTrue(searcher.getTopReaderContext() instanceof AtomicReaderContext);
    final AtomicReaderContext context = (AtomicReaderContext) searcher.getTopReaderContext();

    // Explain entity 0
    Explanation explanation = w.explain(context, 0);
    assertNotNull("explanation is null and it shouldn't be", explanation);

    // TODO: the similarity is random
    // All this Explain does is return the term frequency
//    final float termFreq = explanation.getDetails()[0].getDetails()[0].getValue();
View Full Code Here

    // All this Explain does is return the term frequency
//    final float termFreq = explanation.getDetails()[0].getDetails()[0].getValue();
//    assertEquals("term frq is not 2", 2f, termFreq, 0f);

    // Explain non existing entity
    explanation = w.explain(context, 1);
    assertNotNull("explanation is null and it shouldn't be", explanation);
    //All this Explain does is return the term frequency
    assertEquals("term frq is not 0", 0f, explanation.getValue(), 0f);
  }
View Full Code Here

    final Weight baseWeight = baseQuery.createWeight(searcher);

    return new Weight() {
      @Override
      public Explanation explain(AtomicReaderContext context, int doc) throws IOException {
        return baseWeight.explain(context, doc);
      }

      @Override
      public Query getQuery() {
        return baseQuery;
View Full Code Here

    }

    return new Weight() {
      @Override
      public Explanation explain(AtomicReaderContext context, int doc) throws IOException {
        return baseWeight.explain(context, doc);
      }

      @Override
      public Query getQuery() {
        return baseQuery;
View Full Code Here

    final Weight baseWeight = baseQuery.createWeight(searcher);

    return new Weight() {
      @Override
      public Explanation explain(AtomicReaderContext context, int doc) throws IOException {
        return baseWeight.explain(context, doc);
      }

      @Override
      public Query getQuery() {
        return baseQuery;
View Full Code Here

    final Weight baseWeight = baseQuery.createWeight(searcher);

    return new Weight() {
      @Override
      public Explanation explain(AtomicReaderContext context, int doc) throws IOException {
        return baseWeight.explain(context, doc);
      }

      @Override
      public Query getQuery() {
        return baseQuery;
View Full Code Here

    final Weight baseWeight = baseQuery.createWeight(searcher);

    return new Weight() {
      @Override
      public Explanation explain(AtomicReaderContext context, int doc) throws IOException {
        return baseWeight.explain(context, doc);
      }

      @Override
      public Query getQuery() {
        return baseQuery;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.