本文整理汇总了Java中org.apache.solr.request.SimpleFacets类的典型用法代码示例。如果您正苦于以下问题:Java SimpleFacets类的具体用法?Java SimpleFacets怎么用?Java SimpleFacets使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SimpleFacets类属于org.apache.solr.request包,在下文中一共展示了SimpleFacets类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addFacet
import org.apache.solr.request.SimpleFacets; //导入依赖的package包/类
private void addFacet(SolrQueryRequest req, SolrQueryResponse rsp, SolrParams params, DocListAndSet rfDocs) {
if( rfDocs.docSet == null ) {
rsp.add( "facet_counts", null );
}
else {
FacetComponent fct = new FacetComponent();
rsp.add( "facet_counts", fct.getFacetCounts(new SimpleFacets(req, rfDocs.docSet, params )) );
}
}
示例2: process
import org.apache.solr.request.SimpleFacets; //导入依赖的package包/类
/**
* Actually run the query
*/
@Override
public void process(ResponseBuilder rb) throws IOException {
//SolrParams params = rb.req.getParams();
if (rb.doFacets) {
ModifiableSolrParams params = new ModifiableSolrParams();
SolrParams origParams = rb.req.getParams();
Iterator<String> iter = origParams.getParameterNamesIterator();
while (iter.hasNext()) {
String paramName = iter.next();
// Deduplicate the list with LinkedHashSet, but _only_ for facet params.
if (paramName.startsWith(FacetParams.FACET) == false) {
params.add(paramName, origParams.getParams(paramName));
continue;
}
HashSet<String> deDupe = new LinkedHashSet<>(Arrays.asList(origParams.getParams(paramName)));
params.add(paramName, deDupe.toArray(new String[deDupe.size()]));
}
SimpleFacets f = new SimpleFacets(rb.req, rb.getResults().docSet, params, rb);
NamedList<Object> counts = f.getFacetCounts();
String[] pivots = params.getParams(FacetParams.FACET_PIVOT);
if (pivots != null && pivots.length > 0) {
PivotFacetProcessor pivotProcessor
= new PivotFacetProcessor(rb.req, rb.getResults().docSet, params, rb);
SimpleOrderedMap<List<NamedList<Object>>> v
= pivotProcessor.process(pivots);
if (v != null) {
counts.add(PIVOT_KEY, v);
}
}
rb.rsp.add("facet_counts", counts);
}
}
示例3: addFacet
import org.apache.solr.request.SimpleFacets; //导入依赖的package包/类
private void addFacet(SolrQueryRequest req, SolrQueryResponse rsp, SolrParams params, DocListAndSet mltDocs) {
if( mltDocs.docSet == null ) {
rsp.add( "facet_counts", null );
}
else {
FacetComponent fct = new FacetComponent();
rsp.add( "facet_counts", fct.getFacetCounts(new SimpleFacets(req, mltDocs.docSet, params )) );
}
}
示例4: listGraphNodes
import org.apache.solr.request.SimpleFacets; //导入依赖的package包/类
@Override
public Iterator<Node> listGraphNodes() {
final SolrIndexSearcher.QueryResult result = new SolrIndexSearcher.QueryResult();
try {
request.getSearcher().search(result, GET_GRAPH_NODES_QUERY);
final SimpleFacets facets = new SimpleFacets(
request,
result.getDocSet(),
GET_GRAPH_NODES_QUERY_PARAMS);
final NamedList<Integer> list = facets.getFacetTermEnumCounts(
request.getSearcher(),
result.getDocSet(),
Field.C,
0,
-1,
1,
false,
"count"
,null,
null,
false,
null);
final List<Node> graphs = new ArrayList<Node>();
for (final Entry<String, Integer> entry : list) {
if (!SolRDFGraph.UNNAMED_GRAPH_PLACEHOLDER.equals(entry.getKey())) {
graphs.add(NTriples.asURI(entry.getKey()));
}
}
LOGGER.debug(MessageCatalog._00112_GRAPHS_TOTAL_COUNT, graphs.size());
return graphs.iterator();
} catch (final Exception exception) {
LOGGER.error(MessageCatalog._00113_NWS_FAILURE, exception);
throw new SolrException(ErrorCode.SERVER_ERROR, exception);
}
}
示例5: process
import org.apache.solr.request.SimpleFacets; //导入依赖的package包/类
/**
* Actually run the query
*/
@Override
public void process(ResponseBuilder rb) throws IOException
{
if (rb.doFacets) {
SolrParams params = rb.req.getParams();
SimpleFacets f = new SimpleFacets(rb.req,
rb.getResults().docSet,
params,
rb );
NamedList<Object> counts = f.getFacetCounts();
String[] pivots = params.getParams( FacetParams.FACET_PIVOT );
if( pivots != null && pivots.length > 0 ) {
PivotFacetHelper pivotHelper = new PivotFacetHelper(rb.req,
rb.getResults().docSet,
params,
rb );
NamedList v = pivotHelper.process(pivots);
if( v != null ) {
counts.add( PIVOT_KEY, v );
}
}
// TODO ???? add this directly to the response, or to the builder?
rb.rsp.add( "facet_counts", counts );
}
}
示例6: newSimpleFacets
import org.apache.solr.request.SimpleFacets; //导入依赖的package包/类
protected SimpleFacets newSimpleFacets(SolrQueryRequest req, DocSet docSet, SolrParams params, ResponseBuilder rb) {
return new SimpleFacets(req, docSet, params, rb);
}
示例7: getFacetCounts
import org.apache.solr.request.SimpleFacets; //导入依赖的package包/类
public static NamedList<Object> getFacetCounts(SimpleFacets simpleFacets) {
return getFacetCounts(simpleFacets, null);
}
示例8: doFacetSearch
import org.apache.solr.request.SimpleFacets; //导入依赖的package包/类
protected static NamedList doFacetSearch(DocSet docSet, SolrParams params,
SolrQueryRequest req) throws IOException, SyntaxError {
SimpleFacets f = new SimpleFacets(req, docSet, params, null);
NamedList counts = f.getFacetFieldCounts();
return counts;
}
示例9: doFacets
import org.apache.solr.request.SimpleFacets; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "deprecation" })
private NamedList<Integer> doFacets(String fieldName, DocSet docs, SolrQueryRequest req, SolrParams params) throws IOException {
// check of we are doing range facet
String start_range = req.getParams().get(Params.RANGE + "." + fieldName + ".start");
String end_range = req.getParams().get(Params.RANGE + "." + fieldName + ".end");
String gap = req.getParams().get(Params.RANGE + "." + fieldName + ".gap");
if (start_range != null && end_range != null && gap != null) {
ModifiableSolrParams x = new ModifiableSolrParams(params);
x.set("facet", true);
x.set("facet.date", fieldName);
x.set("facet.date.start", DateMathParserFixed.toIsoFormat(DateMathParserFixed.extract(null, start_range)));
x.set("facet.date.end", DateMathParserFixed.toIsoFormat(DateMathParserFixed.extract(null, end_range)));
x.set("facet.date.gap", gap);
try {
// TODO move to range query filter
SimpleOrderedMap<Object> ranges = new SimpleOrderedMap<Object>();
new SimpleFacets(req, docs, x).getFacetDateCounts(fieldName, ranges);
NamedList<Object> dates = (NamedList<Object>)ranges.get(fieldName);
// remove metadata from result set
dates.remove("end");
dates.remove("start");
dates.remove("gap");
NamedList<Integer> results = new NamedList<Integer>();
DateTime start_period = DateMathParserFixed.extract(null, start_range);
DateTime end_period = DateMathParserFixed.extract(null, end_range);
// build up all dates available
DateTime current_start_period = start_period;
while (current_start_period.isBefore(end_period)) {
DateMathParserFixed p = new DateMathParserFixed();
p.setNow(current_start_period);
DateTime start_date = current_start_period;
DateTime stop_date = p.parseMath(gap);
Object match = null;
for (Entry<String, Object> entry : dates) {
DateTime dt = DateMathParserFixed.fromIsoFormat(entry.getKey());
if (start_date.toDate().getTime() <= dt.toDate().getTime() && dt.toDate().getTime() < stop_date.toDate().getTime()) {
match = entry.getValue();
}
}
if (match != null) {
results.add(fieldName + ":[" + DateMathParserFixed.toIsoFormat(start_date) + " TO " + DateMathParserFixed.toIsoFormat(stop_date) + "]", Integer.parseInt(match.toString()));
} else {
results.add(fieldName + ":[" + DateMathParserFixed.toIsoFormat(start_date) + " TO " + DateMathParserFixed.toIsoFormat(stop_date) + "]", 0);
}
current_start_period = stop_date;
}
return results;
} catch (Exception ex) {
throw new RuntimeException(ex);
}
} else {
return new SimpleFacets(req, docs, params).getTermCounts(fieldName);
}
}
示例10: DistribFacetExistsField
import org.apache.solr.request.SimpleFacets; //导入依赖的package包/类
private DistribFacetExistsField(ResponseBuilder rb, String facetStr) {
super(rb, facetStr);
SimpleFacets.checkMincountOnExists(field, minCount);
}