Package org.apache.lucene.facet.search

Examples of org.apache.lucene.facet.search.FacetsCollector


        new FloatRange("less than or equal to 10", 0.0f, true, 10.0f, true),
        new FloatRange("over 90", 90.0f, false, 100.0f, false),
        new FloatRange("90 or above", 90.0f, true, 100.0f, false),
        new FloatRange("over 1000", 1000.0f, false, Float.POSITIVE_INFINITY, false)));
   
    FacetsCollector fc = FacetsCollector.create(a);

    IndexSearcher s = newSearcher(r);
    s.search(new MatchAllDocsQuery(), fc);
    List<FacetResult> result = fc.getFacetResults();
    assertEquals(1, result.size());
    assertEquals("field (0)\n  less than 10 (10)\n  less than or equal to 10 (11)\n  over 90 (9)\n  90 or above (10)\n  over 1000 (0)\n", FacetTestUtils.toSimpleString(result.get(0)));
   
    r.close();
    d.close();
View Full Code Here


            expectedCounts[rangeID]++;
          }
        }
      }

      FacetsCollector fc = FacetsCollector.create(new RangeAccumulator(new RangeFacetRequest<LongRange>("field", ranges)));
      s.search(new MatchAllDocsQuery(), fc);
      List<FacetResult> results = fc.getFacetResults();
      assertEquals(1, results.size());
      List<FacetResultNode> nodes = results.get(0).getFacetResultNode().subResults;
      assertEquals(numRange, nodes.size());
      for(int rangeID=0;rangeID<numRange;rangeID++) {
        if (VERBOSE) {
View Full Code Here

            expectedCounts[rangeID]++;
          }
        }
      }

      FacetsCollector fc = FacetsCollector.create(new RangeAccumulator(new RangeFacetRequest<FloatRange>("field", ranges)));
      s.search(new MatchAllDocsQuery(), fc);
      List<FacetResult> results = fc.getFacetResults();
      assertEquals(1, results.size());
      List<FacetResultNode> nodes = results.get(0).getFacetResultNode().subResults;
      assertEquals(numRange, nodes.size());
      for(int rangeID=0;rangeID<numRange;rangeID++) {
        if (VERBOSE) {
View Full Code Here

            expectedCounts[rangeID]++;
          }
        }
      }

      FacetsCollector fc = FacetsCollector.create(new RangeAccumulator(new RangeFacetRequest<DoubleRange>("field", ranges)));
      s.search(new MatchAllDocsQuery(), fc);
      List<FacetResult> results = fc.getFacetResults();
      assertEquals(1, results.size());
      List<FacetResultNode> nodes = results.get(0).getFacetResultNode().subResults;
      assertEquals(numRange, nodes.size());
      for(int rangeID=0;rangeID<numRange;rangeID++) {
        if (VERBOSE) {
View Full Code Here

        new LongRange("less than or equal to 10", 0L, true, 10L, true),
        new LongRange("over 90", 90L, false, 100L, false),
        new LongRange("90 or above", 90L, true, 100L, false),
        new LongRange("over 1000", 1000L, false, Long.MAX_VALUE, false)));
   
    FacetsCollector fc = FacetsCollector.create(a);

    IndexSearcher s = newSearcher(r);
    s.search(new MatchAllDocsQuery(), fc);
    List<FacetResult> result = fc.getFacetResults();
    assertEquals(1, result.size());
    assertEquals("field (0)\n  less than 10 (8)\n  less than or equal to 10 (8)\n  over 90 (8)\n  90 or above (8)\n  over 1000 (0)\n", FacetTestUtils.toSimpleString(result.get(0)));
   
    r.close();
    d.close();
View Full Code Here

      public void run() {
        try {
          FacetSearchParams fsp = new FacetSearchParams(iParams, new CountFacetRequest(new CategoryPath("a"), 10),
              new CountFacetRequest(new CategoryPath("b"), 10));
          IndexSearcher searcher = new IndexSearcher(indexReader);
          FacetsCollector fc = FacetsCollector.create(fsp, indexReader, taxoReader);
          searcher.search(new MatchAllDocsQuery(), fc);
          results = fc.getFacetResults();
        } catch (Exception e) {
          throw new RuntimeException(e);
        }
      }
    }
View Full Code Here

      public void run() {
        try {
          FacetSearchParams fsp = new FacetSearchParams(iParams, new CountFacetRequest(new CategoryPath("a"), 10),
              new CountFacetRequest(new CategoryPath("b"), 10));
          IndexSearcher searcher = new IndexSearcher(indexReader);
          FacetsCollector fc = FacetsCollector.create(fsp, indexReader, taxoReader);
          searcher.search(new MatchAllDocsQuery(), fc);
          results = fc.getFacetResults();
        } catch (Exception e) {
          throw new RuntimeException(e);
        }
      }
View Full Code Here

        new SumIntAssociationFacetRequest(aint, 10),
        new SumIntAssociationFacetRequest(bint, 10));
   
    Query q = new MatchAllDocsQuery();
   
    FacetsCollector fc = FacetsCollector.create(fsp, reader, taxo);
   
    IndexSearcher searcher = newSearcher(reader);
    searcher.search(q, fc);
    List<FacetResult> res = fc.getFacetResults();
   
    assertNotNull("No results!",res);
    assertEquals("Wrong number of results!",2, res.size());
    assertEquals("Wrong count for category 'a'!", 200, (int) res.get(0).getFacetResultNode().value);
    assertEquals("Wrong count for category 'b'!", 150, (int) res.get(1).getFacetResultNode().value);
View Full Code Here

        new SumFloatAssociationFacetRequest(afloat, 10),
        new SumFloatAssociationFacetRequest(bfloat, 10));
   
    Query q = new MatchAllDocsQuery();
   
    FacetsCollector fc = FacetsCollector.create(fsp, reader, taxo);
   
    IndexSearcher searcher = newSearcher(reader);
    searcher.search(q, fc);
    List<FacetResult> res = fc.getFacetResults();
   
    assertNotNull("No results!",res);
    assertEquals("Wrong number of results!", 2, res.size());
    assertEquals("Wrong count for category 'a'!",50f, (float) res.get(0).getFacetResultNode().value, 0.00001);
    assertEquals("Wrong count for category 'b'!",10f, (float) res.get(1).getFacetResultNode().value, 0.00001);
View Full Code Here

        new SumFloatAssociationFacetRequest(afloat, 10),
        new SumFloatAssociationFacetRequest(bfloat, 10));
   
    Query q = new MatchAllDocsQuery();
   
    FacetsCollector fc = FacetsCollector.create(fsp, reader, taxo);
   
    IndexSearcher searcher = newSearcher(reader);
    searcher.search(q, fc);
    List<FacetResult> res = fc.getFacetResults();
   
    assertEquals("Wrong number of results!", 4, res.size());
    assertEquals("Wrong count for category 'a'!", 200, (int) res.get(0).getFacetResultNode().value);
    assertEquals("Wrong count for category 'b'!", 150, (int) res.get(1).getFacetResultNode().value);
    assertEquals("Wrong count for category 'a'!",50f, (float) res.get(2).getFacetResultNode().value, 0.00001);
View Full Code Here

TOP

Related Classes of org.apache.lucene.facet.search.FacetsCollector

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.