Facets.getTopChildren
Code IndexAdd Codota to your IDE (free)

Best code snippets using org.apache.lucene.facet.Facets.getTopChildren(Showing top 15 results out of 315)

origin: org.apache.lucene/lucene-facet

@Override
public FacetResult getTopChildren(int topN, String dim, String... path) throws IOException {
 Facets facets = dimToFacets.get(dim);
 if (facets == null) {
  if (defaultFacets == null) {
   throw new IllegalArgumentException("invalid dim \"" + dim + "\"");
  }
  facets = defaultFacets;
 }
 return facets.getTopChildren(topN, dim, path);
}
origin: org.apache.lucene/lucene-facet

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

  List<FacetResult> results = new ArrayList<FacetResult>();

  // First add the specific dim's facets:
  for(Map.Entry<String,Facets> ent : dimToFacets.entrySet()) {
   results.add(ent.getValue().getTopChildren(topN, ent.getKey()));
  }

  if (defaultFacets != null) {

   // Then add all default facets as long as we didn't
   // already add that dim:
   for(FacetResult result : defaultFacets.getAllDims(topN)) {
    if (dimToFacets.containsKey(result.dim) == false) {
     results.add(result);
    }
   }
  }

  return results;
 }
}
origin: boyter/searchcode-server

/**
 * Returns the matching source facets for a given query
 */
private List<CodeFacetSource> getSourceFacetResults(IndexSearcher searcher, IndexReader reader, Query query) {
  List<CodeFacetSource> codeFacetSource = new ArrayList<>();
  try {
    SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(reader, Values.SOURCE);
    FacetsCollector fc = new FacetsCollector();
    FacetsCollector.search(searcher, query, 10, fc);
    Facets facets = new SortedSetDocValuesFacetCounts(state, fc);
    FacetResult result = facets.getTopChildren(this.CHILD_FACET_LIMIT, Values.SOURCE);
    if (result != null) {
      int stepThrough = result.childCount > this.CHILD_FACET_LIMIT ? this.CHILD_FACET_LIMIT : result.childCount;
      for (int i = 0; i < stepThrough; i++) {
        LabelAndValue lv = result.labelValues[i];
        if (lv != null && lv.value != null) {
          codeFacetSource.add(new CodeFacetSource(lv.label, lv.value.intValue()));
        }
      }
    }
  } catch (Exception ignore) {}
  return codeFacetSource;
}
origin: boyter/searchcode-server

/**
 * Returns the matching revision facets for a given query
 */
private List<CodeFacetDeleted> getDeletedFacetResults(IndexSearcher searcher, IndexReader reader, Query query) {
  List<CodeFacetDeleted> deletedFacets = new ArrayList<>();
  try {
    SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(reader, Values.DELETED);
    FacetsCollector fc = new FacetsCollector();
    FacetsCollector.search(searcher, query, 10, fc);
    Facets facets = new SortedSetDocValuesFacetCounts(state, fc);
    FacetResult result = facets.getTopChildren(200, Values.DELETED);
    if (result != null) {
      int stepThru = result.childCount > 200 ? 200 : result.childCount;
      for (int i = 0; i < stepThru; i++) {
        LabelAndValue lv = result.labelValues[i];
        if (lv != null && lv.value != null) {
          deletedFacets.add(new CodeFacetDeleted(lv.label, lv.value.intValue()));
        }
      }
    }
  }
  catch(IOException ex) {
    LOGGER.warning(" caught a " + ex.getClass() + "\n with message: " + ex.getMessage());
  }
  catch(Exception ex) {
    LOGGER.warning(" caught a " + ex.getClass() + "\n with message: " + ex.getMessage());
  }
  return deletedFacets;
}
origin: boyter/searchcode-server

/**
 * Returns the matching owner facets for a given query
 */
private List<CodeFacetOwner> getOwnerFacetResults(IndexSearcher searcher, IndexReader reader, Query query) {
  List<CodeFacetOwner> codeFacetRepo = new ArrayList<>();
  try {
    SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(reader, Values.CODEOWNER);
    FacetsCollector fc = new FacetsCollector();
    FacetsCollector.search(searcher, query, 10, fc);
    Facets facets = new SortedSetDocValuesFacetCounts(state, fc);
    FacetResult result = facets.getTopChildren(this.CHILD_FACET_LIMIT, Values.CODEOWNER);
    if (result != null) {
      int stepThrough = result.childCount > this.CHILD_FACET_LIMIT ? this.CHILD_FACET_LIMIT : result.childCount;
      for (int i = 0; i < stepThrough; i++) {
        LabelAndValue lv = result.labelValues[i];
        if (lv != null && lv.value != null) {
          codeFacetRepo.add(new CodeFacetOwner(lv.label, lv.value.intValue()));
        }
      }
    }
  } catch (Exception ignore) {}
  return codeFacetRepo;
}
origin: boyter/searchcode-server

FacetsCollector.search(searcher, query, 10, fc);
Facets facets = new SortedSetDocValuesFacetCounts(state, fc);
FacetResult result = facets.getTopChildren(200, Values.CODEOWNER);
origin: boyter/searchcode-server

/**
 * Returns the matching language facets for a given query
 */
private List<CodeFacetLanguage> getLanguageFacetResults(IndexSearcher searcher, IndexReader reader, Query query) {
  List<CodeFacetLanguage> codeFacetLanguages = new ArrayList<>();
  try {
    SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(reader, Values.LANGUAGENAME);
    FacetsCollector fc = new FacetsCollector();
    FacetsCollector.search(searcher, query, 10, fc);
    Facets facets = new SortedSetDocValuesFacetCounts(state, fc);
    FacetResult result = facets.getTopChildren(this.CHILD_FACET_LIMIT, Values.LANGUAGENAME);
    if (result != null) {
      int stepThru = result.childCount > this.CHILD_FACET_LIMIT ? this.CHILD_FACET_LIMIT : result.childCount;
      for (int i = 0; i < stepThru; i++) {
        LabelAndValue lv = result.labelValues[i];
        if (lv != null && lv.value != null) {
          codeFacetLanguages.add(new CodeFacetLanguage(lv.label, lv.value.intValue()));
        }
      }
    }
  } catch (Exception ignore) {}
  return codeFacetLanguages;
}
origin: boyter/searchcode-server

/**
 * Returns the matching yearmonthday facets for a given query
 */
private List<CodeFacetYearMonthDay> getYearMonthDayFacetResults(IndexSearcher searcher, IndexReader reader, Query query) {
  List<CodeFacetYearMonthDay> codeFacetYearMonthDay = new ArrayList<>();
  try {
    SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(reader, Values.DATEYEARMONTHDAY);
    FacetsCollector fc = new FacetsCollector();
    FacetsCollector.search(searcher, query, 10, fc);
    Facets facets = new SortedSetDocValuesFacetCounts(state, fc);
    FacetResult result = facets.getTopChildren(200, Values.DATEYEARMONTHDAY);
    if (result != null) {
      int stepThru = result.childCount > 200 ? 200 : result.childCount;
      for (int i = 0; i < stepThru; i++) {
        LabelAndValue lv = result.labelValues[i];
        if (lv != null && lv.value != null) {
          codeFacetYearMonthDay.add(new CodeFacetYearMonthDay(lv.label, lv.value.intValue()));
        }
      }
    }
  }
  catch(IOException ex) {
    LOGGER.warning(" caught a " + ex.getClass() + "\n with message: " + ex.getMessage());
  }
  catch(Exception ex) {
    LOGGER.warning(" caught a " + ex.getClass() + "\n with message: " + ex.getMessage());
  }
  return codeFacetYearMonthDay;
}
origin: boyter/searchcode-server

/**
 * Returns the matching repository facets for a given query
 */
private List<CodeFacetRepo> getRepoFacetResults(IndexSearcher searcher, IndexReader reader, Query query) {
  List<CodeFacetRepo> codeFacetRepo = new ArrayList<>();
  try {
    SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(reader, Values.REPONAME);
    FacetsCollector fc = new FacetsCollector();
    FacetsCollector.search(searcher, query, 10, fc);
    Facets facets = new SortedSetDocValuesFacetCounts(state, fc);
    FacetResult result = facets.getTopChildren(this.CHILD_FACET_LIMIT, Values.REPONAME);
    if (result != null) {
      int stepThru = result.childCount > this.CHILD_FACET_LIMIT ? this.CHILD_FACET_LIMIT : result.childCount;
      for (int i = 0; i < stepThru; i++) {
        LabelAndValue lv = result.labelValues[i];
        if (lv != null && lv.value != null) {
          codeFacetRepo.add(new CodeFacetRepo(lv.label, lv.value.intValue()));
        }
      }
    }
  } catch (Exception ignore) {}
  return codeFacetRepo;
}
origin: boyter/searchcode-server

/**
 * Returns the matching yearmonth facets for a given query
 */
private List<CodeFacetYear> getYearFacetResults(IndexSearcher searcher, IndexReader reader, Query query) {
  List<CodeFacetYear> codeFacetYear = new ArrayList<>();
  try {
    SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(reader, Values.DATEYEAR);
    FacetsCollector fc = new FacetsCollector();
    FacetsCollector.search(searcher, query, 10, fc);
    Facets facets = new SortedSetDocValuesFacetCounts(state, fc);
    FacetResult result = facets.getTopChildren(200, Values.DATEYEAR);
    if (result != null) {
      int stepThru = result.childCount > 200 ? 200 : result.childCount;
      for (int i = 0; i < stepThru; i++) {
        LabelAndValue lv = result.labelValues[i];
        if (lv != null && lv.value != null) {
          codeFacetYear.add(new CodeFacetYear(lv.label, lv.value.intValue()));
        }
      }
    }
  }
  catch(IOException ex) {
    LOGGER.warning(" caught a " + ex.getClass() + "\n with message: " + ex.getMessage());
  }
  catch(Exception ex) {
    LOGGER.warning(" caught a " + ex.getClass() + "\n with message: " + ex.getMessage());
  }
  return codeFacetYear;
}
origin: boyter/searchcode-server

/**
 * Returns the matching repository facets for a given query
 */
private List<CodeFacetRepo> getRepoFacetResults(IndexSearcher searcher, IndexReader reader, Query query) {
  List<CodeFacetRepo> codeFacetRepo = new ArrayList<>();
  try {
    SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(reader, Values.REPONAME);
    FacetsCollector fc = new FacetsCollector();
    FacetsCollector.search(searcher, query, 10, fc);
    Facets facets = new SortedSetDocValuesFacetCounts(state, fc);
    FacetResult result = facets.getTopChildren(200, Values.REPONAME);
    if (result != null) {
      int stepThru = result.childCount > 200 ? 200 : result.childCount;
      for (int i = 0; i < stepThru; i++) {
        LabelAndValue lv = result.labelValues[i];
        if (lv != null && lv.value != null) {
          codeFacetRepo.add(new CodeFacetRepo(lv.label, lv.value.intValue()));
        }
      }
    }
  }
  catch(IOException ex) {
    LOGGER.warning(" caught a " + ex.getClass() + "\n with message: " + ex.getMessage());
  }
  catch(Exception ex) {
    LOGGER.warning(" caught a " + ex.getClass() + "\n with message: " + ex.getMessage());
  }
  return codeFacetRepo;
}
origin: boyter/searchcode-server

/**
 * Returns the matching yearmonth facets for a given query
 */
private List<CodeFacetYearMonth> getYearMonthFacetResults(IndexSearcher searcher, IndexReader reader, Query query) {
  List<CodeFacetYearMonth> codeFacetYearMonth = new ArrayList<>();
  try {
    SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(reader, Values.DATEYEARMONTH);
    FacetsCollector fc = new FacetsCollector();
    FacetsCollector.search(searcher, query, 10, fc);
    Facets facets = new SortedSetDocValuesFacetCounts(state, fc);
    FacetResult result = facets.getTopChildren(200, Values.DATEYEARMONTH);
    if (result != null) {
      int stepThru = result.childCount > 200 ? 200 : result.childCount;
      for (int i = 0; i < stepThru; i++) {
        LabelAndValue lv = result.labelValues[i];
        if (lv != null && lv.value != null) {
          codeFacetYearMonth.add(new CodeFacetYearMonth(lv.label, lv.value.intValue()));
        }
      }
    }
  }
  catch(IOException ex) {
    LOGGER.warning(" caught a " + ex.getClass() + "\n with message: " + ex.getMessage());
  }
  catch(Exception ex) {
    LOGGER.warning(" caught a " + ex.getClass() + "\n with message: " + ex.getMessage());
  }
  return codeFacetYearMonth;
}
origin: boyter/searchcode-server

/**
 * Returns the matching language facets for a given query
 */
private List<CodeFacetLanguage> getLanguageFacetResults(IndexSearcher searcher, IndexReader reader, Query query) {
  List<CodeFacetLanguage> codeFacetLanguages = new ArrayList<>();
  try {
    SortedSetDocValuesReaderState state = new DefaultSortedSetDocValuesReaderState(reader, Values.LANGUAGENAME);
    FacetsCollector fc = new FacetsCollector();
    FacetsCollector.search(searcher, query, 10, fc);
    Facets facets = new SortedSetDocValuesFacetCounts(state, fc);
    FacetResult result = facets.getTopChildren(200, Values.LANGUAGENAME);
    if (result != null) {
      int stepThru = result.childCount > 200 ? 200 : result.childCount;
      for (int i = 0; i < stepThru; i++) {
        LabelAndValue lv = result.labelValues[i];
        if (lv != null && lv.value != null) {
          codeFacetLanguages.add(new CodeFacetLanguage(lv.label, lv.value.intValue()));
        }
      }
    }
  }
  catch(IOException ex) {
    LOGGER.warning(" caught a " + ex.getClass() + "\n with message: " + ex.getMessage());
  }
  catch(Exception ex) {
    LOGGER.warning(" caught a " + ex.getClass() + "\n with message: " + ex.getMessage());
  }
  return codeFacetLanguages;
}
origin: org.apache.lucene/lucene-facet

@Override
public FacetResult getTopChildren(int topN, String dim, String... path) throws IOException {
 Facets facets = dimToFacets.get(dim);
 if (facets == null) {
  if (defaultFacets == null) {
   throw new IllegalArgumentException("invalid dim \"" + dim + "\"");
  }
  facets = defaultFacets;
 }
 return facets.getTopChildren(topN, dim, path);
}
origin: org.apache.lucene/lucene-facet

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

  List<FacetResult> results = new ArrayList<FacetResult>();

  // First add the specific dim's facets:
  for(Map.Entry<String,Facets> ent : dimToFacets.entrySet()) {
   results.add(ent.getValue().getTopChildren(topN, ent.getKey()));
  }

  if (defaultFacets != null) {

   // Then add all default facets as long as we didn't
   // already add that dim:
   for(FacetResult result : defaultFacets.getAllDims(topN)) {
    if (dimToFacets.containsKey(result.dim) == false) {
     results.add(result);
    }
   }
  }

  return results;
 }
}
org.apache.lucene.facetFacetsgetTopChildren

Javadoc

Returns the topN child labels under the specified path. Returns null if the specified path doesn't exist or if this dimension was never seen.

Popular methods of Facets

  • getAllDims
    Returns topN labels for any dimension that had hits, sorted by the number of hits that dimension mat
  • getSpecificValue
    Return the count or value for a specific path. Returns -1 if this path doesn't exist, else the count

Popular classes and methods

  • getExternalFilesDir (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
    Creates and executes a periodic action that becomes enabled first after the given initial delay, and
  • getOriginalFilename (MultipartFile)
  • Component (java.awt)
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • ResultSet (java.sql)
    A table of data representing a database result set, which is usually generated by executing a statem
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • BoxLayout (javax.swing)
  • JFileChooser (javax.swing)

For IntelliJ IDEA,
Android Studio or Eclipse

  • Codota IntelliJ IDEA pluginCodota Android Studio pluginCode IndexSign in
  • EnterpriseFAQAboutContact Us
  • Terms of usePrivacy policyCodeboxFind Usages
Add Codota to your IDE (free)