本文整理汇总了Java中org.apache.solr.handler.component.ResponseBuilder类的典型用法代码示例。如果您正苦于以下问题:Java ResponseBuilder类的具体用法?Java ResponseBuilder怎么用?Java ResponseBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ResponseBuilder类属于org.apache.solr.handler.component包,在下文中一共展示了ResponseBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sort
import org.apache.solr.handler.component.ResponseBuilder; //导入依赖的package包/类
@Override
public void sort(ResponseBuilder rb, List<AcGroupResult> allGroupsResults) {
// Look if some words of the query is in a dictionary
String q = rb.req.getParams().get(CommonParams.Q);
List<TypedSegment> segments = segmenter.segment(q);
// No words from the query in any dictionary. Just keep the original ordering of groups.
if (segments.isEmpty()) {
return;
}
// TODO for now, we only elevate the first group that matches, but we might need to do the same for the others.
TypedSegment typedSegment = segments.get(0);
// The dictionary name is the group name
String groupNameToElevate = typedSegment.getDictionaryName();
// Check if a group with the same name is there. If it's the case, remove it from list (temporarily).
AcGroupResult groupToElavate = removeMatchingGroup(allGroupsResults, groupNameToElevate);
// Put back group at the top of the list
if (groupToElavate != null) {
allGroupsResults.add(0, groupToElavate);
}
}
示例2: doProcess
import org.apache.solr.handler.component.ResponseBuilder; //导入依赖的package包/类
public void doProcess(ResponseBuilder rb) {
ReSearcherRequestContext ctx = new ReSearcherRequestContext(rb);
ctx.setCore(getCore());
ctx.setQueryOnlyComponents(getQueryOnlyComponents());
ctx.setShardHandlerFactory(getShardHandlerFactory());
try {
doProcess(ctx, rb);
} catch (Exception e) {
String msg = "ReSearcher error";
LOG.error(msg, e);
throw new RuntimeException(msg, e);
}
ctx.restoreContext(rb);
}
示例3: process
import org.apache.solr.handler.component.ResponseBuilder; //导入依赖的package包/类
@Override
public void process(ResponseBuilder rb) throws IOException {
Boolean isFusionQuery = rb.req.getParams().getBool(IS_FUSION_QUERY_PARAM);
if (isFusionQuery != null) {
if (isFusionQuery) {
log.info("Skipping the logging to Fusion as this is a Fusion query");
return;
}
}
SolrParams params = rb.req.getParams();
boolean isShard = params.getBool(ShardParams.IS_SHARD, false);
if (isShard) {
return;
}
sendSearchLogsToFusion(rb, false);
}
示例4: finishStage
import org.apache.solr.handler.component.ResponseBuilder; //导入依赖的package包/类
@Override
public void finishStage(ResponseBuilder rb) {
SolrParams params = rb.req.getParams();
boolean isShard = params.getBool(ShardParams.IS_SHARD, false);
if (isShard) {
return;
}
Boolean isFusionQuery = params.getBool(IS_FUSION_QUERY_PARAM);
if (isFusionQuery != null) {
if (isFusionQuery) {
log.info("Skipping the logging to Fusion as this a Fusion query");
return;
}
}
if (rb.stage != ResponseBuilder.STAGE_GET_FIELDS) {
return;
}
sendSearchLogsToFusion(rb, true);
}
示例5: finishStage
import org.apache.solr.handler.component.ResponseBuilder; //导入依赖的package包/类
@Override
public void finishStage(ResponseBuilder rb) {
SolrParams params = rb.req.getParams();
if (!params.getBool(COMPONENT_NAME, false) || !params.getBool(ClusteringParams.USE_SEARCH_RESULTS, false)) {
return;
}
if (rb.stage == ResponseBuilder.STAGE_GET_FIELDS) {
SearchClusteringEngine engine = getSearchClusteringEngine(rb);
if (engine != null) {
SolrDocumentList solrDocList = (SolrDocumentList)rb.rsp.getValues().get("response");
// TODO: Currently, docIds is set to null in distributed environment.
// This causes CarrotParams.PRODUCE_SUMMARY doesn't work.
// To work CarrotParams.PRODUCE_SUMMARY under distributed mode, we can choose either one of:
// (a) In each shard, ClusteringComponent produces summary and finishStage()
// merges these summaries.
// (b) Adding doHighlighting(SolrDocumentList, ...) method to SolrHighlighter and
// making SolrHighlighter uses "external text" rather than stored values to produce snippets.
Map<SolrDocument,Integer> docIds = null;
Object clusters = engine.cluster(rb.getQuery(), solrDocList, docIds, rb.req);
rb.rsp.add("clusters", clusters);
} else {
String name = getClusteringEngineName(rb);
log.warn("No engine for: " + name);
}
}
}
示例6: transform
import org.apache.solr.handler.component.ResponseBuilder; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void transform(Map<String, ?> result, ResponseBuilder rb, SolrDocumentSource solrDocumentSource) {
Object value = result.get(rb.getGroupingSpec().getFields()[0]);
if (TopGroups.class.isInstance(value)) {
@SuppressWarnings("unchecked")
TopGroups<BytesRef> topGroups = (TopGroups<BytesRef>) value;
SolrDocumentList docList = new SolrDocumentList();
docList.setStart(rb.getGroupingSpec().getOffset());
docList.setNumFound(rb.totalHitCount);
Float maxScore = Float.NEGATIVE_INFINITY;
for (GroupDocs<BytesRef> group : topGroups.groups) {
for (ScoreDoc scoreDoc : group.scoreDocs) {
if (maxScore < scoreDoc.score) {
maxScore = scoreDoc.score;
}
docList.add(solrDocumentSource.retrieve(scoreDoc));
}
}
if (maxScore != Float.NEGATIVE_INFINITY) {
docList.setMaxScore(maxScore);
}
rb.rsp.add("response", docList);
}
}
示例7: process
import org.apache.solr.handler.component.ResponseBuilder; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void process(ResponseBuilder rb, ShardRequest shardRequest) {
boolean returnScores = (rb.getFieldFlags() & SolrIndexSearcher.GET_SCORES) != 0;
ShardResponse srsp = shardRequest.responses.get(0);
SolrDocumentList docs = (SolrDocumentList)srsp.getSolrResponse().getResponse().get("response");
String uniqueIdFieldName = rb.req.getSchema().getUniqueKeyField().getName();
for (SolrDocument doc : docs) {
Object id = doc.getFieldValue(uniqueIdFieldName).toString();
ShardDoc shardDoc = rb.resultIds.get(id);
FieldDoc fieldDoc = (FieldDoc) shardDoc;
if (shardDoc != null) {
if (returnScores && !Float.isNaN(fieldDoc.score)) {
doc.setField("score", fieldDoc.score);
}
rb.retrievedDocuments.put(id, doc);
}
}
}
示例8: getDebugInterests
import org.apache.solr.handler.component.ResponseBuilder; //导入依赖的package包/类
public static Set<String> getDebugInterests(String[] params, ResponseBuilder rb){
Set<String> debugInterests = new HashSet<>();
if (params != null) {
for (int i = 0; i < params.length; i++) {
if (params[i].equalsIgnoreCase("all") || params[i].equalsIgnoreCase("true")){
rb.setDebug(true);
break;
//still might add others
} else if (params[i].equals(CommonParams.TIMING)){
rb.setDebugTimings(true);
} else if (params[i].equals(CommonParams.QUERY)){
rb.setDebugQuery(true);
} else if (params[i].equals(CommonParams.RESULTS)){
rb.setDebugResults(true);
} else if (params[i].equals(CommonParams.TRACK)){
rb.setDebugTrack(true);
}
}
}
return debugInterests;
}
示例9: prepare
import org.apache.solr.handler.component.ResponseBuilder; //导入依赖的package包/类
@Override
public void prepare(ResponseBuilder rb) throws IOException {
if (isEnabled(rb)) {
long startTime = System.currentTimeMillis();
long timeSinceRefresh = startTime - lastRefresh;
SolrParams params = rb.req.getParams();
Integer minCount = getMinCountParameter(params);
Integer limit = getLimitParameter(params);
if (classField == null) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
String.format("Unable to determine class field due to missing parameter: %s", getPrefix() + "." + CLASS_FIELD));
}
boolean build = getBuildParameter(params);
String buildQuery = getBuildQuery(params);
float alpha = getAlpha(params);
refreshCache(rb, startTime, timeSinceRefresh, params, minCount, limit, build, buildQuery, alpha);
}
}
示例10: refreshCache
import org.apache.solr.handler.component.ResponseBuilder; //导入依赖的package包/类
private void refreshCache(ResponseBuilder rb, long startTime, long timeSinceRefresh, SolrParams params,
Integer minCount, Integer limit, boolean build, String buildQuery, float alpha) throws IOException {
if (shouldRefreshCache(build, timeSinceRefresh)) {
// need to update these on a build, as model must match these parameters
setFieldsParameter(params);
setClassField(params);
refreshModel(rb, buildQuery, minCount, limit, classField, fields, alpha);
long duration = this.lastRefresh - startTime;
if (build) {
rb.rsp.add("command", "build");
}
NamedList<Object> stats = new NamedList<Object>();
stats.add("BuildTime", duration);
stats.add("Joints", this.model.getNumJointCounts());
stats.add("Priors", this.model.getNumPriors());
rb.rsp.add(BUILD, stats);
}
}
示例11: prepare
import org.apache.solr.handler.component.ResponseBuilder; //导入依赖的package包/类
@Override
public void prepare(ResponseBuilder rb) throws IOException {
if (isEnabled(rb)) {
rb.setNeedDocSet(true);
// De-duplicate field list
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.equals(JointProbabilityParams.FIELDS)) {
params.add(paramName, origParams.getParams(paramName));
continue;
}
HashSet<String> deDupe = new LinkedHashSet<String>(Arrays.asList(origParams.getParams(paramName)));
params.add(paramName, deDupe.toArray(new String[deDupe.size()]));
}
rb.req.setParams(params);
}
}
示例12: process
import org.apache.solr.handler.component.ResponseBuilder; //导入依赖的package包/类
@Override
public void process(ResponseBuilder rb) throws IOException {
if(isEnabled(rb)){
long startTime = System.currentTimeMillis();
SolrParams params = rb.req.getParams();
Integer minCount = getMinCountParameter(params);
Integer limit = getLimitParameter(params);
String[] fields = getFieldsParameter(params);
JointCounts jointProb = new JointCounts(rb.req, rb.getResults().docSet, minCount, limit, fields);
NamedList<Object> counts = jointProb.process();
long duration = System.currentTimeMillis() - startTime;
NamedList<Object> results = new NamedList<Object>();
results.add("Time", duration);
results.add("counts", counts);
rb.rsp.add("joint_probabilities", results);
}
}
示例13: process
import org.apache.solr.handler.component.ResponseBuilder; //导入依赖的package包/类
@Override
public void process(ResponseBuilder rb)
{
// rewrite
rewrite(rb, "_field_mappings_", "facet_counts", "facet_fields");
rewrite(rb, "_date_mappings_", "facet_counts", "facet_dates");
rewrite(rb, "_range_mappings_", "facet_counts", "facet_ranges");
rewrite(rb, "_pivot_mappings_", "facet_counts", "facet_pivot");
rewritePivotFields(rb, "facet_counts", "facet_pivot");
// TODO: rewrite(rb, "_interval_mappings_", "facet_counts", "facet_fields");
rewrite(rb, "_stats_field_mappings_", "stats", "stats_fields");
copyAnalytics(rb, "facet_counts", "facet_fields");
HashMap<String, String> mappings = (HashMap<String, String>)rb.rsp.getValues().get("_stats_field_mappings_");
if(mappings != null)
{
for(String key : mappings.keySet())
{
rewrite(rb, "_stats_facet_mappings_", "stats", "stats_fields", key, "facets");
}
}
}
示例14: distributedProcess
import org.apache.solr.handler.component.ResponseBuilder; //导入依赖的package包/类
/** Dispatch shard request in <code>STAGE_EXECUTE_QUERY</code> stage */
@Override
public int distributedProcess(ResponseBuilder rb) {
SolrParams params = rb.req.getParams();
LOG.debug("SuggestComponent distributedProcess with : " + params);
if (rb.stage < ResponseBuilder.STAGE_EXECUTE_QUERY)
return ResponseBuilder.STAGE_EXECUTE_QUERY;
if (rb.stage == ResponseBuilder.STAGE_EXECUTE_QUERY) {
ShardRequest sreq = new ShardRequest();
sreq.purpose = ShardRequest.PURPOSE_GET_TOP_IDS;
sreq.params = new ModifiableSolrParams(rb.req.getParams());
sreq.params.remove(ShardParams.SHARDS);
rb.addRequest(this, sreq);
return ResponseBuilder.STAGE_GET_FIELDS;
}
return ResponseBuilder.STAGE_DONE;
}
示例15: prepare
import org.apache.solr.handler.component.ResponseBuilder; //导入依赖的package包/类
@Override
public void prepare(ResponseBuilder rb) throws IOException
{
SolrQueryRequest req = rb.req;
Properties props = new CoreDescriptorDecorator(req.getCore().getCoreDescriptor()).getCoreProperties();
if (Boolean.parseBoolean(props.getProperty("enable.alfresco.tracking", "false")))
{
AlfrescoCoreAdminHandler adminHandler = (AlfrescoCoreAdminHandler) req.getCore().getCoreDescriptor()
.getCoreContainer().getMultiCoreHandler();
TrackerRegistry trackerRegistry = adminHandler.getTrackerRegistry();
ModelTracker modelTracker;
// Prevents other threads from registering the ModelTracker at the same time
synchronized (trackerRegistry)
{
modelTracker = trackerRegistry.getModelTracker();
if (modelTracker == null)
{
modelTracker = registerModelTracker(req.getCore(), adminHandler);
}
}
log.info("Ensuring first model sync.");
modelTracker.ensureFirstModelSync();
log.info("Done ensuring first model sync.");
}
}