当前位置: 首页>>代码示例>>Java>>正文


Java SolrPluginUtils类代码示例

本文整理汇总了Java中org.apache.solr.util.SolrPluginUtils的典型用法代码示例。如果您正苦于以下问题:Java SolrPluginUtils类的具体用法?Java SolrPluginUtils怎么用?Java SolrPluginUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SolrPluginUtils类属于org.apache.solr.util包,在下文中一共展示了SolrPluginUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: transform

import org.apache.solr.util.SolrPluginUtils; //导入依赖的package包/类
@Override
public void transform(SolrDocument doc, int docid) {
  if( context != null && context.query != null ) {
    try {
      Explanation exp = context.searcher.explain(context.query, docid);
      if( style == Style.nl ) {
        doc.setField( name, SolrPluginUtils.explanationToNamedList(exp) );
      }
      else if( style == Style.html ) {
        doc.setField( name, exp.toHtml() );
      }
      else {
        doc.setField( name, exp.toString() );
      }
    }
    catch (IOException e) {
      e.printStackTrace();
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:21,代码来源:ExplainAugmenterFactory.java

示例2: buildMergeScheduler

import org.apache.solr.util.SolrPluginUtils; //导入依赖的package包/类
private MergeScheduler buildMergeScheduler(IndexSchema schema) {
  String msClassName = mergeSchedulerInfo == null ? SolrIndexConfig.DEFAULT_MERGE_SCHEDULER_CLASSNAME : mergeSchedulerInfo.className;
  MergeScheduler scheduler = schema.getResourceLoader().newInstance(msClassName, MergeScheduler.class);

  if (mergeSchedulerInfo != null) {
    // LUCENE-5080: these two setters are removed, so we have to invoke setMaxMergesAndThreads
    // if someone has them configured.
    if (scheduler instanceof ConcurrentMergeScheduler) {
      NamedList args = mergeSchedulerInfo.initArgs.clone();
      Integer maxMergeCount = (Integer) args.remove("maxMergeCount");
      if (maxMergeCount == null) {
        maxMergeCount = ((ConcurrentMergeScheduler) scheduler).getMaxMergeCount();
      }
      Integer maxThreadCount = (Integer) args.remove("maxThreadCount");
      if (maxThreadCount == null) {
        maxThreadCount = ((ConcurrentMergeScheduler) scheduler).getMaxThreadCount();
      }
      ((ConcurrentMergeScheduler)scheduler).setMaxMergesAndThreads(maxMergeCount, maxThreadCount);
      SolrPluginUtils.invokeSetters(scheduler, args);
    } else {
      SolrPluginUtils.invokeSetters(scheduler, mergeSchedulerInfo.initArgs);
    }
  }

  return scheduler;
}
 
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:SolrIndexConfig.java

示例3: getBoostFunctions

import org.apache.solr.util.SolrPluginUtils; //导入依赖的package包/类
/**
 * Parses all function queries
 */
protected List<Query> getBoostFunctions() throws SyntaxError {
  List<Query> boostFunctions = new LinkedList<>();
  if (config.hasBoostFunctions()) {
    for (String boostFunc : config.boostFuncs) {
      if(null == boostFunc || "".equals(boostFunc)) continue;
      Map<String,Float> ff = SolrPluginUtils.parseFieldBoosts(boostFunc);
      for (String f : ff.keySet()) {
        Query fq = subQuery(f, FunctionQParserPlugin.NAME).getQuery();
        Float b = ff.get(f);
        if (null != b) {
          fq.setBoost(b);
        }
        boostFunctions.add(fq);
      }
    }
  }
  return boostFunctions;
}
 
开发者ID:europeana,项目名称:search,代码行数:22,代码来源:ExtendedDismaxQParser.java

示例4: addAliasesFromRequest

import org.apache.solr.util.SolrPluginUtils; //导入依赖的package包/类
/**
 * Extracts all the aliased fields from the requests and adds them to up
 */
private void addAliasesFromRequest(ExtendedSolrQueryParser up, float tiebreaker) {
  Iterator<String> it = config.solrParams.getParameterNamesIterator();
  while(it.hasNext()) {
    String param = it.next();
    if(param.startsWith("f.") && param.endsWith(".qf")) {
      // Add the alias
      String fname = param.substring(2,param.length()-3);
      String qfReplacement = config.solrParams.get(param);
      Map<String,Float> parsedQf = SolrPluginUtils.parseFieldBoosts(qfReplacement);
      if(parsedQf.size() == 0)
        return;
      up.addAlias(fname, tiebreaker, parsedQf);
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:ExtendedDismaxQParser.java

示例5: addBoostFunctions

import org.apache.solr.util.SolrPluginUtils; //导入依赖的package包/类
protected void addBoostFunctions(BooleanQuery query, SolrParams solrParams) throws SyntaxError {
  String[] boostFuncs = solrParams.getParams(DisMaxParams.BF);
  if (null != boostFuncs && 0 != boostFuncs.length) {
    for (String boostFunc : boostFuncs) {
      if (null == boostFunc || "".equals(boostFunc)) continue;
      Map<String, Float> ff = SolrPluginUtils.parseFieldBoosts(boostFunc);
      for (String f : ff.keySet()) {
        Query fq = subQuery(f, FunctionQParserPlugin.NAME).getQuery();
        Float b = ff.get(f);
        if (null != b) {
          fq.setBoost(b);
        }
        query.add(fq, BooleanClause.Occur.SHOULD);
      }
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:DisMaxQParser.java

示例6: getUserQuery

import org.apache.solr.util.SolrPluginUtils; //导入依赖的package包/类
protected Query getUserQuery(String userQuery, SolrPluginUtils.DisjunctionMaxQueryParser up, SolrParams solrParams)
        throws SyntaxError {


  String minShouldMatch = parseMinShouldMatch(req.getSchema(), solrParams);
  Query dis = up.parse(userQuery);
  Query query = dis;

  if (dis instanceof BooleanQuery) {
    BooleanQuery t = new BooleanQuery();
    SolrPluginUtils.flattenBooleanQuery(t, (BooleanQuery) dis);
    SolrPluginUtils.setMinShouldMatch(t, minShouldMatch);
    query = t;
  }
  return query;
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:DisMaxQParser.java

示例7: applyMinShouldMatch

import org.apache.solr.util.SolrPluginUtils; //导入依赖的package包/类
/**
 * @param query
 */
public Query applyMinShouldMatch(final Query query) {

    if (!(query instanceof BooleanQuery)) {
        return query;
    }

    final BooleanQuery bq = (BooleanQuery) query;
    List<BooleanClause> clauses = bq.clauses();
    if (clauses.size() < 2) {
        return bq;
    }

    for (BooleanClause clause : clauses) {
        if ((clause.getQuery() instanceof BooleanQuery) && (clause.getOccur() != Occur.MUST)) {
            return bq; // seems to be a complex query with sub queries - do not
            // apply mm
        }
    }

    return SolrPluginUtils.setMinShouldMatch(bq, config.getMinShouldMatch());

}
 
开发者ID:renekrie,项目名称:querqy,代码行数:26,代码来源:QuerqyDismaxQParser.java

示例8: finishStage

import org.apache.solr.util.SolrPluginUtils; //导入依赖的package包/类
@Override
public void finishStage(ResponseBuilder rb) {
  if (rb.doHighlights && rb.stage == ResponseBuilder.STAGE_GET_FIELDS) {

    Map.Entry<String, Object>[] arr = new NamedList.NamedListEntry[rb.resultIds.size()];

    // TODO: make a generic routine to do automatic merging of id keyed data
    for (ShardRequest sreq : rb.finished) {
      if ((sreq.purpose & ShardRequest.PURPOSE_GET_HIGHLIGHTS) == 0) continue;
      for (ShardResponse srsp : sreq.responses) {
        NamedList hl = (NamedList)srsp.getSolrResponse().getResponse().get("highlighting");
        for (int i=0; i<hl.size(); i++) {
          String id = hl.getName(i);
          ShardDoc sdoc = rb.resultIds.get(id);
          int idx = sdoc.positionInResponse;
          arr[idx] = new NamedList.NamedListEntry<Object>(id, hl.getVal(i));
        }
      }
    }

    // remove nulls in case not all docs were able to be retrieved
    rb.rsp.add("highlighting", SolrPluginUtils.removeNulls(new SimpleOrderedMap(arr)));      
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:25,代码来源:HighlightComponent.java

示例9: testParseFieldBoosts

import org.apache.solr.util.SolrPluginUtils; //导入依赖的package包/类
@Test
public void testParseFieldBoosts() throws Exception {

  Map<String,Float> e1 = new HashMap<String,Float>();
  e1.put("fieldOne",2.3f);
  e1.put("fieldTwo",null);
  e1.put("fieldThree",-0.4f);

  assertEquals("basic e1", e1, SolrPluginUtils.parseFieldBoosts
               ("fieldOne^2.3 fieldTwo fieldThree^-0.4"));
  assertEquals("spacey e1", e1, SolrPluginUtils.parseFieldBoosts
               ("  fieldOne^2.3   fieldTwo fieldThree^-0.4   "));
  assertEquals("really spacey e1", e1, SolrPluginUtils.parseFieldBoosts
               (" \t fieldOne^2.3 \n  fieldTwo fieldThree^-0.4   "));
  assertEquals("really spacey e1", e1, SolrPluginUtils.parseFieldBoosts
               (new String[]{" \t fieldOne^2.3 \n",
                             "  fieldTwo fieldThree^-0.4   ",
                             " "}));

  Map<String,Float> e2 = new HashMap<String,Float>();
  assertEquals("empty e2", e2, SolrPluginUtils.parseFieldBoosts
               (""));
  assertEquals("spacey e2", e2, SolrPluginUtils.parseFieldBoosts
               ("   \t   "));
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:26,代码来源:SolrPluginUtilsTest.java

示例10: computeFactorizedQueryFields

import org.apache.solr.util.SolrPluginUtils; //导入依赖的package包/类
/**
 * Computes
 */
protected String computeFactorizedQueryFields(SolrQueryRequest request, float factor) {

   checkNotNull(request, "Pre-condition violated: request must not be null.");

   StringBuilder qf = new StringBuilder();

   // parse fields and boosts
   Map<String, Float> fieldBoosts = SolrPluginUtils.parseFieldBoosts(request.getParams().getParams(DisMaxParams.QF));

   // iterate, add factor and add to result qf
   for (Entry<String, Float> f : fieldBoosts.entrySet()) {
      qf.append(f.getKey());
      qf.append('^');

      if (f.getValue() != null) {
         qf.append(f.getValue() * factor);
      } else {
         qf.append(factor);
      }

      qf.append(' ');
   }

   return qf.toString();
}
 
开发者ID:shopping24,项目名称:solr-bmax-queryparser,代码行数:29,代码来源:BmaxBoostTermComponent.java

示例11: getBoostFunctions

import org.apache.solr.util.SolrPluginUtils; //导入依赖的package包/类
/**
 * Parses all function queries
 */
protected List<Query> getBoostFunctions() throws SyntaxError {
  List<Query> boostFunctions = new LinkedList<Query>();
  if (config.hasBoostFunctions()) {
    for (String boostFunc : config.boostFuncs) {
      if(null == boostFunc || "".equals(boostFunc)) continue;
      Map<String,Float> ff = SolrPluginUtils.parseFieldBoosts(boostFunc);
      for (String f : ff.keySet()) {
        Query fq = subQuery(f, FunctionQParserPlugin.NAME).getQuery();
        Float b = ff.get(f);
        if (null != b) {
          fq.setBoost(b);
        }
        boostFunctions.add(fq);
      }
    }
  }
  return boostFunctions;
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:22,代码来源:ExtendedDismaxQParser.java

示例12: getOrQuery

import org.apache.solr.util.SolrPluginUtils; //导入依赖的package包/类
public Query getOrQuery(){
    BooleanQuery.Builder qryBuilder = new BooleanQuery.Builder();
    for(RFTerm RFTerm : this.RFTerms){
        qryBuilder.add(toBoostedQuery(RFTerm), BooleanClause.Occur.SHOULD);
    }
    SolrPluginUtils.setMinShouldMatch(qryBuilder, mm);
    return qryBuilder.build();
}
 
开发者ID:DiceTechJobs,项目名称:RelevancyFeedback,代码行数:9,代码来源:RFQuery.java

示例13: checkEngine

import org.apache.solr.util.SolrPluginUtils; //导入依赖的package包/类
private List<NamedList<Object>> checkEngine(CarrotClusteringEngine engine, int expectedNumDocs,
                         int expectedNumClusters, Query query, SolrParams clusteringParams) throws IOException {
  // Get all documents to cluster
  RefCounted<SolrIndexSearcher> ref = h.getCore().getSearcher();

  DocList docList;
  try {
    SolrIndexSearcher searcher = ref.get();
    docList = searcher.getDocList(query, (Query) null, new Sort(), 0,
            numberOfDocs);
    assertEquals("docList size", expectedNumDocs, docList.matches());

    ModifiableSolrParams solrParams = new ModifiableSolrParams();
    solrParams.add(clusteringParams);

    // Perform clustering
    LocalSolrQueryRequest req = new LocalSolrQueryRequest(h.getCore(), solrParams);
    Map<SolrDocument,Integer> docIds = new HashMap<>(docList.size());
    SolrDocumentList solrDocList = SolrPluginUtils.docListToSolrDocumentList( docList, searcher, engine.getFieldsToLoad(req), docIds );

    @SuppressWarnings("unchecked")
    List<NamedList<Object>> results = (List<NamedList<Object>>) engine.cluster(query, solrDocList, docIds, req);
    req.close();
    assertEquals("number of clusters: " + results, expectedNumClusters, results.size());
    checkClusters(results, false);
    return results;
  } finally {
    ref.decref();
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:31,代码来源:CarrotClusteringEngineTest.java

示例14: getInstance

import org.apache.solr.util.SolrPluginUtils; //导入依赖的package包/类
@Override
public UpdateRequestProcessor getInstance(SolrQueryRequest req,
                                          SolrQueryResponse rsp, UpdateRequestProcessor next) {
  // Process defaults, appends and invariants if we got a request
  if(req != null) {
    SolrPluginUtils.setDefaults(req, defaults, appends, invariants);
  }
  return new TikaLanguageIdentifierUpdateProcessor(req, rsp, next);
}
 
开发者ID:europeana,项目名称:search,代码行数:10,代码来源:TikaLanguageIdentifierUpdateProcessorFactory.java

示例15: getInstance

import org.apache.solr.util.SolrPluginUtils; //导入依赖的package包/类
@Override
public UpdateRequestProcessor getInstance(SolrQueryRequest req,
                                          SolrQueryResponse rsp, UpdateRequestProcessor next) {
  // Process defaults, appends and invariants if we got a request
  if(req != null) {
    SolrPluginUtils.setDefaults(req, defaults, appends, invariants);
  }
  return new LangDetectLanguageIdentifierUpdateProcessor(req, rsp, next);
}
 
开发者ID:europeana,项目名称:search,代码行数:10,代码来源:LangDetectLanguageIdentifierUpdateProcessorFactory.java


注:本文中的org.apache.solr.util.SolrPluginUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。