org.apache.solr.common.params.SolrParams Java Examples

The following examples show how to use org.apache.solr.common.params.SolrParams. 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: SignatureUpdateProcessorFactory.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@Override
public void init(@SuppressWarnings({"rawtypes"})final NamedList args) {
  if (args != null) {
    SolrParams params = args.toSolrParams();
    boolean enabled = params.getBool("enabled", true);
    this.enabled = enabled;

    overwriteDupes = params.getBool("overwriteDupes", true);

    signatureField = params.get("signatureField", "signatureField");

    signatureClass = params.get("signatureClass",
        "org.apache.solr.update.processor.Lookup3Signature");
    this.params = params;

    Object fields = args.get("fields");
    sigFields = fields == null ? null: StrUtils.splitSmart((String)fields, ",", true); 
    if (sigFields != null) {
      Collections.sort(sigFields);
    }
  }
}
 
Example #2
Source File: ReplicationHandler.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
public DirectoryFileStream(SolrParams solrParams) {
  params = solrParams;
  delPolicy = core.getDeletionPolicy();

  fileName = validateFilenameOrError(params.get(FILE));
  cfileName = validateFilenameOrError(params.get(CONF_FILE_SHORT));
  tlogFileName = validateFilenameOrError(params.get(TLOG_FILE));
  
  sOffset = params.get(OFFSET);
  sLen = params.get(LEN);
  compress = params.get(COMPRESSION);
  useChecksum = params.getBool(CHECKSUM, false);
  indexGen = params.getLong(GENERATION);
  if (useChecksum) {
    checksum = new Adler32();
  }
  //No throttle if MAX_WRITE_PER_SECOND is not specified
  double maxWriteMBPerSec = params.getDouble(MAX_WRITE_PER_SECOND, Double.MAX_VALUE);
  rateLimiter = new RateLimiter.SimpleRateLimiter(maxWriteMBPerSec);
}
 
Example #3
Source File: SharedFSAutoReplicaFailoverTest.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
private void queryAndAssertResultSize(String collection, int expectedResultSize, int timeoutMS)
    throws SolrServerException, IOException, InterruptedException {
  long startTimestamp = System.nanoTime();

  long actualResultSize = 0;
  while(true) {
    if (System.nanoTime() - startTimestamp > TimeUnit.MILLISECONDS.toNanos(timeoutMS) || actualResultSize > expectedResultSize) {
      fail("expected: " + expectedResultSize + ", actual: " + actualResultSize);
    }
    SolrParams queryAll = new SolrQuery("*:*");
    cloudClient.setDefaultCollection(collection);
    try {
      QueryResponse queryResponse = cloudClient.query(queryAll);
      actualResultSize = queryResponse.getResults().getNumFound();
      if(expectedResultSize == actualResultSize) {
        return;
      }
    } catch (SolrServerException | IOException e) {
      log.warn("Querying solr threw an exception. This can be expected to happen during restarts.", e);
    }

    Thread.sleep(1000);
  }
}
 
Example #4
Source File: CollectionsHandler.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
/**
 * Places all prefixed properties in the sink map (or a new map) using the prefix as the key and a map of
 * all prefixed properties as the value. The sub-map keys have the prefix removed.
 *
 * @param params The solr params from which to extract prefixed properties.
 * @param sink   The map to add the properties too.
 * @param prefix The prefix to identify properties to be extracted
 * @return The sink map, or a new map if the sink map was null
 */
private static Map<String, Object> convertPrefixToMap(SolrParams params, Map<String, Object> sink, String prefix) {
  Map<String, Object> result = new LinkedHashMap<>();
  Iterator<String> iter = params.getParameterNamesIterator();
  while (iter.hasNext()) {
    String param = iter.next();
    if (param.startsWith(prefix)) {
      result.put(param.substring(prefix.length() + 1), params.get(param));
    }
  }
  if (sink == null) {
    sink = new LinkedHashMap<>();
  }
  sink.put(prefix, result);
  return sink;
}
 
Example #5
Source File: PrunerFactoryTest.java    From BioSolr with Apache License 2.0 6 votes vote down vote up
@Test(expected=org.apache.solr.search.SyntaxError.class)
public void constructPruner_datapointsPruner_noDatapoints() throws Exception {
	final String prunerParam = PrunerFactory.DATAPOINTS_PRUNER_VALUE;
	final FacetTreeParameters ftParams = mock(FacetTreeParameters.class);
	when(ftParams.getDefault(FacetTreeParameters.PRUNE_PARAM)).thenReturn(null);
	when(ftParams.getIntDefault(FacetTreeParameters.DATAPOINTS_PARAM)).thenReturn(0);
	final SolrParams params = mock(SolrParams.class);
	when(params.get(FacetTreeParameters.PRUNE_PARAM, null)).thenReturn(prunerParam);
	when(params.getInt(FacetTreeParameters.DATAPOINTS_PARAM, 0)).thenReturn(0);
	
	PrunerFactory factory = new PrunerFactory(ftParams);
	factory.constructPruner(params);
	
	verify(params).get(FacetTreeParameters.PRUNE_PARAM, null);
	verify(ftParams).getIntDefault(FacetTreeParameters.DATAPOINTS_PARAM);
}
 
Example #6
Source File: ResponseLogComponent.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@Override
public void process(ResponseBuilder rb) throws IOException {
  SolrParams params = rb.req.getParams();
  if (!params.getBool(COMPONENT_NAME, false)) return;
  
  SolrIndexSearcher searcher = rb.req.getSearcher();
  IndexSchema schema = searcher.getSchema();
  if (schema.getUniqueKeyField() == null) return;

  ResultContext rc = (ResultContext) rb.rsp.getResponse();

  DocList docs = rc.getDocList();
  if (docs.hasScores()) {
    processScores(rb, docs, schema, searcher);
  } else {
    processIds(rb, docs, schema, searcher);
  }
}
 
Example #7
Source File: StatusOp.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(CoreAdminHandler.CallInfo it) throws Exception {
  SolrParams params = it.req.getParams();

  String cname = params.get(CoreAdminParams.CORE);
  String indexInfo = params.get(CoreAdminParams.INDEX_INFO);
  boolean isIndexInfoNeeded = Boolean.parseBoolean(null == indexInfo ? "true" : indexInfo);
  NamedList<Object> status = new SimpleOrderedMap<>();
  Map<String, Exception> failures = new HashMap<>();
  for (Map.Entry<String, CoreContainer.CoreLoadFailure> failure : it.handler.coreContainer.getCoreInitFailures().entrySet()) {
    failures.put(failure.getKey(), failure.getValue().exception);
  }
  if (cname == null) {
    for (String name : it.handler.coreContainer.getAllCoreNames()) {
      status.add(name, CoreAdminOperation.getCoreStatus(it.handler.coreContainer, name, isIndexInfoNeeded));
    }
    it.rsp.add("initFailures", failures);
  } else {
    failures = failures.containsKey(cname)
        ? Collections.singletonMap(cname, failures.get(cname))
            : Collections.<String, Exception>emptyMap();
        it.rsp.add("initFailures", failures);
        status.add(cname, CoreAdminOperation.getCoreStatus(it.handler.coreContainer, cname, isIndexInfoNeeded));
  }
  it.rsp.add("status", status);
}
 
Example #8
Source File: MetricsHandler.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
private List<MetricType> parseMetricTypes(SolrParams params) {
  String[] typeStr = params.getParams(TYPE_PARAM);
  List<String> types = Collections.emptyList();
  if (typeStr != null && typeStr.length > 0)  {
    types = new ArrayList<>();
    for (String type : typeStr) {
      types.addAll(StrUtils.splitSmart(type, ','));
    }
  }

  List<MetricType> metricTypes = Collections.singletonList(MetricType.all); // include all metrics by default
  try {
    if (types.size() > 0) {
      metricTypes = types.stream().map(String::trim).map(MetricType::valueOf).collect(Collectors.toList());
    }
  } catch (IllegalArgumentException e) {
    throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Invalid metric type in: " + types +
        " specified. Must be one of " + MetricType.SUPPORTED_TYPES_MSG, e);
  }
  return metricTypes;
}
 
Example #9
Source File: TestCloudPseudoReturnFields.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
public void testGlobsRTG() throws Exception {
  // behavior shouldn't matter if we are committed or uncommitted
  for (String id : Arrays.asList("42","99")) {
    
    SolrDocument doc = getRandClient(random()).getById(id, params("fl","val_*"));
    String msg = id + ": fl=val_* => " + doc;
    assertEquals(msg, 1, doc.size());
    assertTrue(msg, doc.getFieldValue("val_i") instanceof Integer);
    assertEquals(msg, 1, doc.getFieldValue("val_i"));
    
    for (SolrParams p : Arrays.asList(params("fl","val_*,subj*,ss*"),
                                      params("fl","val_*","fl","subj*,ss*"))) {
      doc = getRandClient(random()).getById(id, p);
      msg = id + ": " + p + " => " + doc;
      
      assertEquals(msg, 3, doc.size());
      assertTrue(msg, doc.getFieldValue("val_i") instanceof Integer);
      assertEquals(msg, 1, doc.getFieldValue("val_i"));
      assertTrue(msg, doc.getFieldValue("subject") instanceof String); 
      // NOTE: 'subject' is diff between two docs
      assertTrue(msg, doc.getFieldValue("ssto") instanceof String); // TODO: val_ss: List<String>
      assertEquals(msg, "X", doc.getFieldValue("ssto"));
    }
  }
}
 
Example #10
Source File: TestCloudPseudoReturnFields.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
public void testAugmentersAndExplicit() throws Exception {
  for (SolrParams p : Arrays.asList(params("q", "*:*", "fl","id,[docid],[explain],x_alias:[value v=10 t=int]"),
                                    params("q", "*:*", "fl","id","fl","[docid],[explain],x_alias:[value v=10 t=int]"),
                                    params("q", "*:*", "fl","id","fl","[docid]","fl","[explain]","fl","x_alias:[value v=10 t=int]"))) {
    SolrDocumentList docs = assertSearch(p);
    assertEquals(p + " => " + docs, 5, docs.getNumFound());
    // shouldn't matter what doc we pick...
    for (SolrDocument doc : docs) {
      String msg = p + " => " + doc;
      assertEquals(msg, 4, doc.size());
      assertTrue(msg, doc.getFieldValue("id") instanceof String);
      assertTrue(msg, doc.getFieldValue("[docid]") instanceof Integer);
      assertTrue(msg, doc.getFieldValue("[explain]") instanceof String);
      assertTrue(msg, doc.getFieldValue("x_alias") instanceof Integer);
      assertEquals(msg, 10, doc.getFieldValue("x_alias"));
    }
  }
}
 
Example #11
Source File: AlfrescoSolrUtils.java    From SearchServices with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Asserts that the input {@link ShardState} and the CoreAdmin.SUMMARY response give the same information.
 *
 * @param state the {@link ShardState} instance.
 * @param core the target {@link SolrCore} instance.
 */
public static void assertShardAndCoreSummaryConsistency(ShardState state, SolrCore core) {
    SolrParams params =
            new ModifiableSolrParams()
                    .add(CoreAdminParams.CORE, core.getName())
                    .add(CoreAdminParams.ACTION, "SUMMARY");

    SolrQueryRequest request = new LocalSolrQueryRequest(core, params);
    SolrQueryResponse response = new SolrQueryResponse();
    coreAdminHandler(core).handleRequest(request, response);

    NamedList<?> summary =
            ofNullable(response.getValues())
                    .map(values -> values.get("Summary"))
                    .map(NamedList.class::cast)
                    .map(values -> values.get(core.getName()))
                    .map(NamedList.class::cast)
                    .orElseGet(NamedList::new);

    assertEquals(state.getLastIndexedChangeSetId(), summary.get("Id for last Change Set in index"));
    assertEquals(state.getLastIndexedChangeSetCommitTime(), summary.get("Last Index Change Set Commit Time"));
    assertEquals(state.getLastIndexedTxCommitTime(), summary.get("Last Index TX Commit Time"));
    assertEquals(state.getLastIndexedTxId(), summary.get("Id for last TX in index"));
}
 
Example #12
Source File: QueryDocAuthorizationComponentTest.java    From incubator-sentry with Apache License 2.0 6 votes vote down vote up
private ResponseBuilder runComponent(String user, NamedList args, SolrParams params)
throws Exception {
  ResponseBuilder builder = getResponseBuilder();
  prepareCollAndUser(core, builder.req, "collection1", user);

  if (params != null) {
    builder.req.setParams(params);
  } else {
    builder.req.setParams(new ModifiableSolrParams());
  }

  QueryDocAuthorizationComponent component =
    new QueryDocAuthorizationComponent(sentryInstance);
  component.init(args);
  component.prepare(builder);
  return builder;
}
 
Example #13
Source File: FacetTreeBuilderFactoryTest.java    From BioSolr with Apache License 2.0 6 votes vote down vote up
@Test
public void constructFTB_derivedChildnodeStrategy() throws Exception {
	final String strategy = null;
	final String childField = "child_nodes";
	final String nodeField = "node_id";
	final SolrParams params = mock(SolrParams.class);
	when(params.get(FacetTreeParameters.STRATEGY_PARAM)).thenReturn(strategy);
	when(params.get(FacetTreeParameters.CHILD_FIELD_PARAM)).thenReturn(childField);
	when(params.get(FacetTreeParameters.NODE_FIELD_PARAM)).thenReturn(nodeField);
	
	FacetTreeBuilderFactory factory = new FacetTreeBuilderFactory();
	FacetTreeBuilder ftb = factory.constructFacetTreeBuilder(params);
	
	assertNotNull(ftb);
	assertTrue(ftb instanceof ChildNodeFacetTreeBuilder);
	
	verify(params).get(FacetTreeParameters.STRATEGY_PARAM);
	verify(params, atLeastOnce()).get(FacetTreeParameters.CHILD_FIELD_PARAM);
	verify(params, atLeastOnce()).get(FacetTreeParameters.NODE_FIELD_PARAM);
}
 
Example #14
Source File: DaemonStreamApiTest.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
private List<Tuple> getTuples(final SolrParams params, String ofInterest) throws IOException {
  //log.info("Tuples from params: {}", params);
  TupleStream tupleStream = new SolrStream(url, params);

  tupleStream.open();
  List<Tuple> tuples = new ArrayList<>();
  for (; ; ) {
    Tuple t = tupleStream.read();
    //log.info(" ... {}", t.fields);
    if (t.EOF) {
      break;
    } else if (ofInterest == null || t.getString("id").equals(ofInterest) || t.getString(ofInterest).equals("null") == false) {
      // a failed return is a bit different, the onlyh key is DaemonOp
      tuples.add(t);
    }
  }
  tupleStream.close();
  Collections.sort(tuples, (o1, o2) -> (o1.getString("id").compareTo(o2.getString("id"))));
  return tuples;
}
 
Example #15
Source File: PrefixQParserPlugin.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public QParser createParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req) {
  return new QParser(qstr, localParams, params, req) {
    @Override
    public Query parse() {
      SchemaField sf = req.getSchema().getField(localParams.get(QueryParsing.F));
      return sf.getType().getPrefixQuery(this, sf, localParams.get(QueryParsing.V));
    }
  };
}
 
Example #16
Source File: UUIDUpdateProcessorFallbackTest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
SolrInputDocument processAdd(final String chain,
                             final SolrInputDocument docIn, SolrParams params)
    throws IOException {

  SolrCore core = h.getCore();
  UpdateRequestProcessorChain pc = chain == null ?
      core.getUpdateProcessorChain(params) :
      core.getUpdateProcessingChain(chain);
  assertNotNull("No Chain named: " + chain, pc);

  SolrQueryResponse rsp = new SolrQueryResponse();

  SolrQueryRequest req = new LocalSolrQueryRequest
      (core, params);
  try {
    SolrRequestInfo.setRequestInfo(new SolrRequestInfo(req,rsp));
    AddUpdateCommand cmd = new AddUpdateCommand(req);
    cmd.solrDoc = docIn;

    UpdateRequestProcessor processor = pc.createProcessor(req, rsp);
    processor.processAdd(cmd);

    return cmd.solrDoc;
  } finally {
    SolrRequestInfo.clearRequestInfo();
    req.close();
  }
}
 
Example #17
Source File: SimpleXJoinResultsFactory.java    From BioSolr with Apache License 2.0 5 votes vote down vote up
@Override
public XJoinResults<String> getResults(SolrParams params) throws IOException {
  try (Connection cnx = new Connection(rootUrl, type.getMimeType(), params)) {
    cnx.open();
    return new Results(type.read(cnx.getInputStream()));
  }
}
 
Example #18
Source File: NodePreferenceRulesComparator.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public NodePreferenceRulesComparator(final List<PreferenceRule> preferenceRules, final SolrParams requestParams,
    final String nodeName, final String localHostAddress, final NodesSysPropsCacher sysPropsCache,
    final ReplicaListTransformerFactory defaultRltFactory, final ReplicaListTransformerFactory stableRltFactory) {
  this.sysPropsCache = sysPropsCache;
  this.preferenceRules = preferenceRules;
  this.nodeName = nodeName;
  this.localHostAddress = localHostAddress;
  final int maxIdx = preferenceRules.size() - 1;
  final PreferenceRule lastRule = preferenceRules.get(maxIdx);
  if (!ShardParams.SHARDS_PREFERENCE_REPLICA_BASE.equals(lastRule.name)) {
    this.sortRules = preferenceRules;
    this.baseReplicaListTransformer = defaultRltFactory.getInstance(null, requestParams, RequestReplicaListTransformerGenerator.RANDOM_RLTF);
  } else {
    if (maxIdx == 0) {
      this.sortRules = null;
    } else {
      this.sortRules = preferenceRules.subList(0, maxIdx);
    }
    String[] parts = lastRule.value.split(":", 2);
    switch (parts[0]) {
      case ShardParams.REPLICA_RANDOM:
        this.baseReplicaListTransformer = RequestReplicaListTransformerGenerator.RANDOM_RLTF.getInstance(parts.length == 1 ? null : parts[1], requestParams, null);
        break;
      case ShardParams.REPLICA_STABLE:
        this.baseReplicaListTransformer = stableRltFactory.getInstance(parts.length == 1 ? null : parts[1], requestParams, RequestReplicaListTransformerGenerator.RANDOM_RLTF);
        break;
      default:
        throw new IllegalArgumentException("Invalid base replica order spec");
    }
  }
}
 
Example #19
Source File: MoreLikeThisComponent.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public void modifyRequest(ResponseBuilder rb, SearchComponent who, ShardRequest sreq) {
  SolrParams params = rb.req.getParams();
  if (!params.getBool(COMPONENT_NAME, false)) return;
  if ((sreq.purpose & ShardRequest.PURPOSE_GET_MLT_RESULTS) == 0
      && (sreq.purpose & ShardRequest.PURPOSE_GET_TOP_IDS) == 0) {
    sreq.params.set(COMPONENT_NAME, "false");
  }
}
 
Example #20
Source File: BackupCoreOp.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(CoreAdminHandler.CallInfo it) throws Exception {
  final SolrParams params = it.req.getParams();

  String cname = params.required().get(CoreAdminParams.CORE);
  String name = params.required().get(NAME);

  String repoName = params.get(CoreAdminParams.BACKUP_REPOSITORY);
  BackupRepository repository = it.handler.coreContainer.newBackupRepository(Optional.ofNullable(repoName));

  String location = repository.getBackupLocation(params.get(CoreAdminParams.BACKUP_LOCATION));
  if (location == null) {
    throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "'location' is not specified as a query"
        + " parameter or as a default repository property");
  }

  // An optional parameter to describe the snapshot to be backed-up. If this
  // parameter is not supplied, the latest index commit is backed-up.
  String commitName = params.get(CoreAdminParams.COMMIT_NAME);

  URI locationUri = repository.createURI(location);
  try (SolrCore core = it.handler.coreContainer.getCore(cname)) {
    SnapShooter snapShooter = new SnapShooter(repository, core, locationUri, name, commitName);
    // validateCreateSnapshot will create parent dirs instead of throw; that choice is dubious.
    //  But we want to throw. One reason is that
    //  this dir really should, in fact must, already exist here if triggered via a collection backup on a shared
    //  file system. Otherwise, perhaps the FS location isn't shared -- we want an error.
    if (!snapShooter.getBackupRepository().exists(snapShooter.getLocation())) {
      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
          "Directory to contain snapshots doesn't exist: " + snapShooter.getLocation() + ". " +
          "Note that Backup/Restore of a SolrCloud collection " +
          "requires a shared file system mounted at the same path on all nodes!");
    }
    snapShooter.validateCreateSnapshot();
    snapShooter.createSnapshot();
  } catch (Exception e) {
    throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
        "Failed to backup core=" + cname + " because " + e, e);
  }
}
 
Example #21
Source File: RewriteFacetParametersComponent.java    From SearchServices with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Prevents users from requesting a large number of rows by
 * replacing an enormous row value with a maximum value that will
 * not cause a run time exception.
 * @param fixed
 * @param params
 * @param rb
 */
private void fixRows(ModifiableSolrParams fixed, SolrParams params, ResponseBuilder rb)
{
    String rows = params.get("rows");
    if(rows != null && !rows.isEmpty())
    {
        Integer row = Integer.valueOf(rows);
        // Avoid +1 in SOLR code which produces null:java.lang.NegativeArraySizeException at at org.apache.lucene.util.PriorityQueue.<init>(PriorityQueue.java:56)
        if(row >  1000000)
        {
            fixed.remove("rows");
            fixed.add("rows", "1000000");
        }
    }
}
 
Example #22
Source File: DymReSearcher.java    From solr-researcher with Apache License 2.0 5 votes vote down vote up
@Override
public boolean checkComponentShouldProcess(ResponseBuilder rb) {
  SolrParams params = rb.req.getParams();
  if (!params.getBool(COMPONENT_NAME, false)) {
    return false;
  }
  if (!params.getBool(SpellCheckComponent.COMPONENT_NAME, false)) {
    return false;
  }

  return true;
}
 
Example #23
Source File: OfferXJoinResultsFactory.java    From BioSolr with Apache License 2.0 5 votes vote down vote up
/**
 * Use 'offers' REST API to fetch current offer data. 
 */
@Override
public XJoinResults<String> getResults(SolrParams params)
throws IOException {
  try (HttpConnection http = new HttpConnection(url)) {
    JsonArray offers = (JsonArray)http.getJson();
    return new OfferResults(offers);
  }
}
 
Example #24
Source File: CdcrReplicatorScheduler.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
CdcrReplicatorScheduler(final CdcrReplicatorManager replicatorStatesManager, final SolrParams replicatorConfiguration) {
  this.replicatorManager = replicatorStatesManager;
  this.statesQueue = new ConcurrentLinkedQueue<>(replicatorManager.getReplicatorStates());
  if (replicatorConfiguration != null) {
    poolSize = replicatorConfiguration.getInt(CdcrParams.THREAD_POOL_SIZE_PARAM, DEFAULT_POOL_SIZE);
    timeSchedule = replicatorConfiguration.getInt(CdcrParams.SCHEDULE_PARAM, DEFAULT_TIME_SCHEDULE);
    batchSize = replicatorConfiguration.getInt(CdcrParams.BATCH_SIZE_PARAM, DEFAULT_BATCH_SIZE);
  }
}
 
Example #25
Source File: SpellingOptions.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
public SpellingOptions(Collection<Token> tokens, IndexReader reader,
    int count, int alternativeTermCount, SuggestMode suggestMode,
    boolean extendedResults, float accuracy, SolrParams customParams) {
  this.tokens = tokens;
  this.reader = reader;
  this.count = count;
  this.alternativeTermCount = alternativeTermCount;
  this.suggestMode = suggestMode;
  this.extendedResults = extendedResults;
  this.accuracy = accuracy;
  this.customParams = customParams;
}
 
Example #26
Source File: AlfrescoSolrHighlighter.java    From SearchServices with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void rewriteHighlightFieldOptions(ModifiableSolrParams fixed, SolrParams params, String paramName, String oldField, String newField)
{
	for(Iterator<String> it = params.getParameterNamesIterator(); it.hasNext();)
	{
		String name = it.next();
		if(name.startsWith("f."))
		{
			if(name.endsWith("." + paramName))
			{

				String source = name.substring(2, name.length() - paramName.length() - 1);
				if(source.equals(oldField))
				{
					fixed.set("f." + newField + "." + paramName, params.getParams(name));
				}
				else
				{
					fixed.set(name, params.getParams(name));
				}
			}
			else
			{
				fixed.set(name, params.getParams(name));
			}
		}       
	}
}
 
Example #27
Source File: ShardAugmenterFactory.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public DocTransformer create(String field, SolrParams params, SolrQueryRequest req) {
  String v = req.getParams().get(ShardParams.SHARD_URL);
  if( v == null ) {
    if( req.getParams().getBool(ShardParams.IS_SHARD, false) ) {
      v = "[unknown]";
    }
    else {
      v = "[not a shard request]";
    }
  }
  return new ValueAugmenterFactory.ValueAugmenter( field, v );
}
 
Example #28
Source File: CollectionAdminRequest.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public SolrParams getParams() {
  ModifiableSolrParams params = new ModifiableSolrParams(super.getParams());
  params.set(CoreAdminParams.REPLICA, replica);
  params.set("property", propertyName);
  return params;
}
 
Example #29
Source File: BaseDistributedSearchTestCase.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
protected UpdateResponse del(SolrClient client, SolrParams params, Object... ids) throws IOException, SolrServerException {
  UpdateRequest ureq = new UpdateRequest();
  ureq.setParams(new ModifiableSolrParams(params));
  for (Object id: ids) {
    ureq.deleteById(id.toString());
  }
  return ureq.process(client);
}
 
Example #30
Source File: BaseTestCase.java    From BioSolr with Apache License 2.0 5 votes vote down vote up
public static SolrQueryResponse query(SolrCore core, String handlerName, SolrParams params) {
  SolrQueryResponse rsp = new SolrQueryResponse();
  SolrQueryRequest req = new SolrQueryRequestBase(core, params) { };
  try {
    SolrRequestHandler handler = core.getRequestHandler(handlerName);
    core.execute(handler, req, rsp);
    return rsp;
  } finally {
    req.close();
  }
}