Package org.apache.lucene.facet

Examples of org.apache.lucene.facet.FacetResult


      dv.lookupOrd(ordAndValue.ord, scratch);
      String[] parts = FacetsConfig.stringToPath(scratch.utf8ToString());
      labelValues[i] = new LabelAndValue(parts[1], ordAndValue.value);
    }

    return new FacetResult(dim, new String[0], dimCount, labelValues, childCount);
  }
View Full Code Here


  @Override
  public List<FacetResult> getAllDims(int topN) throws IOException {

    List<FacetResult> results = new ArrayList<>();
    for(Map.Entry<String,OrdRange> ent : state.getPrefixToOrdRange().entrySet()) {
      FacetResult fr = getDim(ent.getKey(), ent.getValue(), topN);
      if (fr != null) {
        results.add(fr);
      }
    }
View Full Code Here

    List<FacetResult> results = new ArrayList<>();
    while (ord != TaxonomyReader.INVALID_ORDINAL) {
      String dim = taxoReader.getPath(ord).components[0];
      FacetsConfig.DimConfig dimConfig = config.getDimConfig(dim);
      if (dimConfig.indexFieldName.equals(indexFieldName)) {
        FacetResult result = getTopChildren(topN, dim);
        if (result != null) {
          results.add(result);
        }
      }
      ord = siblings[ord];
View Full Code Here

          labelValues.add(new LabelAndValue(ent.getKey(), ent.getValue()));
          totCount += ent.getValue();
        }
        sortLabelValues(labelValues);
        if (totCount > 0) {
          expected.add(new FacetResult("dim" + i, new String[0], totCount, labelValues.toArray(new LabelAndValue[labelValues.size()]), labelValues.size()));
        }
      }

      // Sort by highest value, tie break by value:
      sortFacetResults(expected);
View Full Code Here

          labelValues.add(new LabelAndValue(ent.getKey(), ent.getValue()));
          totValue += ent.getValue();
        }
        sortLabelValues(labelValues);
        if (totValue > 0) {
          expected.add(new FacetResult("dim" + i, new String[0], totValue, labelValues.toArray(new LabelAndValue[labelValues.size()]), labelValues.size()));
        }
      }

      // Sort by highest value, tie break by value:
      sortFacetResults(expected);
View Full Code Here

        try {
          //System.out.println("search maxOrd=" + pair.taxonomyReader.getSize());
          FacetsCollector sfc = new FacetsCollector();
          pair.searcher.search(new MatchAllDocsQuery(), sfc);
          Facets facets = getTaxonomyFacetCounts(pair.taxonomyReader, config, sfc);
          FacetResult result = facets.getTopChildren(10, "field");
          if (pair.searcher.getIndexReader().numDocs() > 0) {
            //System.out.println(pair.taxonomyReader.getSize());
            assertTrue(result.childCount > 0);
            assertTrue(result.labelValues.length > 0);
          }
View Full Code Here

        try {
          //System.out.println("search maxOrd=" + pair.taxonomyReader.getSize());
          FacetsCollector sfc = new FacetsCollector();
          pair.searcher.search(new MatchAllDocsQuery(), sfc);
          Facets facets = getTaxonomyFacetCounts(pair.taxonomyReader, config, sfc);
          FacetResult result = facets.getTopChildren(10, "field");
          if (pair.searcher.getIndexReader().numDocs() > 0) {
            //System.out.println(pair.taxonomyReader.getSize());
            assertTrue(result.childCount > 0);
            assertTrue(result.labelValues.length > 0);
          }
View Full Code Here

      fail("didn't hit expected exception");
    } catch (IllegalArgumentException iae) {
      // expected
    }

    FacetResult result = facets.getTopChildren(10, "a");
    assertEquals(1, result.labelValues.length);
    assertEquals(1, result.labelValues[0].value.intValue());

    IOUtils.close(writer, taxoWriter, searcher.getIndexReader(), taxoReader, dir, taxoDir);
  }
View Full Code Here

   
    Facets facets = getTaxonomyFacetCounts(taxoReader, config, c);
    assertEquals(1, facets.getSpecificValue("dim", "test\u001Fone"));
    assertEquals(1, facets.getSpecificValue("dim", "test\u001Etwo"));

    FacetResult result = facets.getTopChildren(10, "dim");
    assertEquals("dim=dim path=[] value=-1 childCount=2\n  test\u001Fone (1)\n  test\u001Etwo (1)\n", result.toString());
    IOUtils.close(writer, taxoWriter, searcher.getIndexReader(), taxoReader, dir, taxoDir);
  }
View Full Code Here

    // you'd use a "normal" query, and use MultiCollector to
    // wrap collecting the "normal" hits and also facets:
    searcher.search(new MatchAllDocsQuery(), c);
    Facets facets = getTaxonomyFacetCounts(taxoReader, config, c);

    FacetResult result = facets.getTopChildren(Integer.MAX_VALUE, "dim");
    assertEquals(numLabels, result.labelValues.length);
    Set<String> allLabels = new HashSet<>();
    for (LabelAndValue labelValue : result.labelValues) {
      allLabels.add(labelValue.label);
      assertEquals(1, labelValue.value.intValue());
View Full Code Here

TOP

Related Classes of org.apache.lucene.facet.FacetResult

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.