use of org.apache.lucene.facet.sortedset.DefaultSortedSetDocValuesReaderState in project searchcode-server by boyter.
the class IndexService method getSourceFacetResults.
/**
* 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;
}
use of org.apache.lucene.facet.sortedset.DefaultSortedSetDocValuesReaderState in project searchcode-server by boyter.
the class TimeCodeSearcher method getYearMonthFacetResults.
/**
* 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;
}
use of org.apache.lucene.facet.sortedset.DefaultSortedSetDocValuesReaderState in project searchcode-server by boyter.
the class TimeCodeSearcher method getOwnerFacetResults.
/**
* 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(200, Values.CODEOWNER);
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 CodeFacetOwner(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;
}
use of org.apache.lucene.facet.sortedset.DefaultSortedSetDocValuesReaderState in project searchcode-server by boyter.
the class TimeCodeSearcher method getLanguageFacetResults.
/**
* 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;
}
Aggregations