Java Code Examples for org.apache.solr.common.params.SolrParams#getDouble()

The following examples show how to use org.apache.solr.common.params.SolrParams#getDouble() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RelatednessAgg.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public void setOpts(QParser parser) {
  final boolean isShard = parser.getReq().getParams().getBool(ShardParams.IS_SHARD, false);
  SolrParams opts = parser.getLocalParams();
  if (null != opts) {
    if (!isShard) { // ignore min_pop if this is a shard request
      this.min_pop = opts.getDouble("min_popularity", 0.0D);
    }
  }
}
 
Example 2
Source File: NRTCachingDirectoryFactory.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings({"rawtypes"})
public void init(NamedList args) {
  super.init(args);
  SolrParams params = args.toSolrParams();
  maxMergeSizeMB = params.getDouble("maxMergeSizeMB", DEFAULT_MAX_MERGE_SIZE_MB);
  if (maxMergeSizeMB <= 0){
    throw new IllegalArgumentException("maxMergeSizeMB must be greater than 0");
  }
  maxCachedMB = params.getDouble("maxCachedMB", DEFAULT_MAX_CACHED_MB);
  if (maxCachedMB <= 0){
    throw new IllegalArgumentException("maxCachedMB must be greater than 0");
  }
}
 
Example 3
Source File: SweetSpotSimilarityFactory.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@Override
public void init(SolrParams params) {
  super.init(params);

  Integer ln_min = params.getInt("lengthNormMin");
  Integer ln_max = params.getInt("lengthNormMax");
  Float ln_steep = params.getFloat("lengthNormSteepness");
  if (! allOrNoneNull(ln_min, ln_max, ln_steep)) {
    throw new SolrException(SERVER_ERROR, "Overriding default lengthNorm settings requires all to be specified: lengthNormMin, lengthNormMax, lengthNormSteepness");
  }

  Float hyper_min = params.getFloat("hyperbolicTfMin");
  Float hyper_max = params.getFloat("hyperbolicTfMax");
  Double hyper_base = params.getDouble("hyperbolicTfBase");
  Float hyper_offset = params.getFloat("hyperbolicTfOffset");
  if (! allOrNoneNull(hyper_min, hyper_max, hyper_base, hyper_offset)) {
    throw new SolrException(SERVER_ERROR, "Overriding default hyperbolicTf settings requires all to be specified: hyperbolicTfMin, hyperbolicTfMax, hyperbolicTfBase, hyperbolicTfOffset");
  }

  Float baseline_base = params.getFloat("baselineTfBase");
  Float baseline_min = params.getFloat("baselineTfMin");
  if (! allOrNoneNull(baseline_min, baseline_base)) {
    throw new SolrException(SERVER_ERROR, "Overriding default baselineTf settings requires all to be specified: baselineTfBase, baselineTfMin");
  }

  // sanity check that they aren't trying to use two diff tf impls
  if ((null != hyper_min) && (null != baseline_min)) {
    throw new SolrException(SERVER_ERROR, "Can not mix hyperbolicTf settings with baselineTf settings");
  }

  // pick Similarity impl based on whether hyper tf settings are set
  sim = (null != hyper_min) ? new HyperbolicSweetSpotSimilarity() 
    : new SweetSpotSimilarity();
  
  if (null != ln_min) {
    // overlaps already handled by super factory
    sim.setLengthNormFactors(ln_min, ln_max, ln_steep, this.discountOverlaps);
  }

  if (null != hyper_min) {
    sim.setHyperbolicTfFactors(hyper_min, hyper_max, hyper_base, hyper_offset);
  }

  if (null != baseline_min) {
    sim.setBaselineTfFactors(baseline_base, baseline_min);
  }
}