org.apache.solr.common.util.StrUtils Java Examples
The following examples show how to use
org.apache.solr.common.util.StrUtils.
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: TermsComponent.java From lucene-solr with Apache License 2.0 | 6 votes |
protected void checkShardsWhitelist(final ResponseBuilder rb, final List<String> lst) { final List<String> urls = new LinkedList<String>(); for (final String ele : lst) { urls.addAll(StrUtils.splitSmart(ele, '|')); } if (whitelistHostChecker.isWhitelistHostCheckingEnabled() && rb.req.getCore().getCoreContainer().getZkController() == null && !whitelistHostChecker.hasExplicitWhitelist()) { throw new SolrException(ErrorCode.FORBIDDEN, "TermsComponent "+HttpShardHandlerFactory.INIT_SHARDS_WHITELIST +" not configured but required when using the '"+ShardParams.SHARDS+"' parameter with the TermsComponent." +HttpShardHandlerFactory.SET_SOLR_DISABLE_SHARDS_WHITELIST_CLUE); } else { ClusterState cs = null; if (rb.req.getCore().getCoreContainer().getZkController() != null) { cs = rb.req.getCore().getCoreContainer().getZkController().getClusterState(); } whitelistHostChecker.checkWhitelist(cs, urls.toString(), urls); } }
Example #2
Source File: Assign.java From lucene-solr with Apache License 2.0 | 6 votes |
public static List<String> getLiveOrLiveAndCreateNodeSetList(final Set<String> liveNodes, final ZkNodeProps message, final Random random) { List<String> nodeList; final String createNodeSetStr = message.getStr(CREATE_NODE_SET); final List<String> createNodeList = (createNodeSetStr == null) ? null : StrUtils.splitSmart((OverseerCollectionMessageHandler.CREATE_NODE_SET_EMPTY.equals(createNodeSetStr) ? "" : createNodeSetStr), ",", true); if (createNodeList != null) { nodeList = new ArrayList<>(createNodeList); nodeList.retainAll(liveNodes); if (message.getBool(OverseerCollectionMessageHandler.CREATE_NODE_SET_SHUFFLE, OverseerCollectionMessageHandler.CREATE_NODE_SET_SHUFFLE_DEFAULT)) { Collections.shuffle(nodeList, random); } } else { nodeList = new ArrayList<>(liveNodes); Collections.shuffle(nodeList, random); } return nodeList; }
Example #3
Source File: AutoScalingHandler.java From lucene-solr with Apache License 2.0 | 6 votes |
private AutoScalingConfig handleRemovePolicy(SolrQueryRequest req, SolrQueryResponse rsp, CommandOperation op, AutoScalingConfig currentConfig) throws KeeperException, InterruptedException, IOException { String policyName = (String) op.getVal(""); if (op.hasError()) return currentConfig; Map<String, List<Clause>> policies = currentConfig.getPolicy().getPolicies(); if (policies == null || !policies.containsKey(policyName)) { op.addError("No policy exists with name: " + policyName); return currentConfig; } cloudManager.getClusterStateProvider().getClusterState().forEachCollection(coll -> { if (policyName.equals(coll.getPolicyName())) op.addError(StrUtils.formatString("policy : {0} is being used by collection {1}", policyName, coll.getName())); }); if (op.hasError()) return currentConfig; policies = new HashMap<>(policies); policies.remove(policyName); Policy p = currentConfig.getPolicy().withPolicies(policies); currentConfig = currentConfig.withPolicy(p); return currentConfig; }
Example #4
Source File: CdcrVersionReplicationTest.java From lucene-solr with Apache License 2.0 | 6 votes |
void doRealTimeGet(String ids, String versions) throws Exception { Map<String, Object> expectedIds = new HashMap<>(); List<String> strs = StrUtils.splitSmart(ids, ",", true); List<String> verS = StrUtils.splitSmart(versions, ",", true); for (int i = 0; i < strs.size(); i++) { if (!verS.isEmpty()) { expectedIds.put(strs.get(i), Long.valueOf(verS.get(i))); } } QueryResponse rsp = solrServer.query(params("qt", "/get", "ids", ids)); Map<String, Object> obtainedIds = new HashMap<>(); for (SolrDocument doc : rsp.getResults()) { obtainedIds.put((String) doc.get("id"), doc.get(vfield)); } assertEquals(expectedIds, obtainedIds); }
Example #5
Source File: SolrParams.java From lucene-solr with Apache License 2.0 | 6 votes |
/** Like {@link #toQueryString()}, but only replacing enough chars so that * the URL may be unambiguously pasted back into a browser. * This method can be used to properly log query parameters without * making them unreadable. * <p> * Characters with a numeric value less than 32 are encoded. * &,=,%,+,space are encoded. */ @Override public String toString() { final StringBuilder sb = new StringBuilder(128); try { boolean first=true; for (final Iterator<String> it = getParameterNamesIterator(); it.hasNext();) { final String name = it.next(); for (String val : getParams(name)) { if (!first) sb.append('&'); first=false; StrUtils.partialURLEncodeVal(sb, name); sb.append('='); StrUtils.partialURLEncodeVal(sb, val); } } return sb.toString(); } catch (IOException e) { // impossible! throw new AssertionError(e); } }
Example #6
Source File: Preference.java From lucene-solr with Apache License 2.0 | 6 votes |
public Preference(Map<String, Object> m, int idx) { this.idx = idx; this.original = Utils.getDeepCopy(m, 3); sort = Policy.Sort.get(m); name = Policy.SortParam.get(m.get(sort.name()).toString()); Object p = m.getOrDefault("precision", 0); precision = p instanceof Number ? ((Number) p).intValue() : Integer.parseInt(p.toString()); if (precision < 0) { throw new RuntimeException("precision must be a positive value "); } if (precision < name.min || precision > name.max) { throw new RuntimeException(StrUtils.formatString("invalid precision value {0} , must lie between {1} and {2}", precision, name.min, name.max)); } }
Example #7
Source File: CreateAliasCmd.java From lucene-solr with Apache License 2.0 | 6 votes |
private void validateAllCollectionsExistAndNoDuplicates(List<String> collectionList, ZkStateReader zkStateReader) { final String collectionStr = StrUtils.join(collectionList, ','); if (new HashSet<>(collectionList).size() != collectionList.size()) { throw new SolrException(BAD_REQUEST, String.format(Locale.ROOT, "Can't create collection alias for collections='%s', since it contains duplicates", collectionStr)); } ClusterState clusterState = zkStateReader.getClusterState(); Set<String> aliasNames = zkStateReader.getAliases().getCollectionAliasListMap().keySet(); for (String collection : collectionList) { if (clusterState.getCollectionOrNull(collection) == null && !aliasNames.contains(collection)) { throw new SolrException(BAD_REQUEST, String.format(Locale.ROOT, "Can't create collection alias for collections='%s', '%s' is not an existing collection or alias", collectionStr, collection)); } } }
Example #8
Source File: PluginBag.java From lucene-solr with Apache License 2.0 | 6 votes |
@Override public void init(PluginInfo info) { name = info.attributes.get(NAME); url = info.attributes.get("url"); sig = info.attributes.get("sig"); if(url == null) { Object v = info.attributes.get("version"); if (name == null || v == null) { throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "runtimeLib must have name and version"); } version = String.valueOf(v); } else { sha512 = info.attributes.get("sha512"); if(sha512 == null){ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "runtimeLib with url must have a 'sha512' attribute"); } ByteBuffer buf = null; buf = coreContainer.getBlobRepository().fetchFromUrl(name, url); String digest = BlobRepository.sha512Digest(buf); if(!sha512.equals(digest)) { throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, StrUtils.formatString(BlobRepository.INVALID_JAR_MSG, url, sha512, digest) ); } log.info("dynamic library verified {}, sha512: {}", url, sha512); } }
Example #9
Source File: ConfigOverlay.java From lucene-solr with Apache License 2.0 | 6 votes |
@SuppressWarnings({"rawtypes"}) public static Class checkEditable(String path, boolean isXpath, List<String> hierarchy) { List<String> parts = StrUtils.splitSmart(path, isXpath ? '/' : '.'); Object obj = editable_prop_map; for (int i = 0; i < parts.size(); i++) { String part = parts.get(i); boolean isAttr = isXpath && part.startsWith("@"); if (isAttr) { part = part.substring(1); } if (hierarchy != null) hierarchy.add(part); if (obj == null) return null; if (i == parts.size() - 1) { if (obj instanceof Map) { Map map = (Map) obj; Object o = map.get(part); return checkType(o, isXpath, isAttr); } return null; } obj = ((Map) obj).get(part); } return null; }
Example #10
Source File: DataImportHandler.java From lucene-solr with Apache License 2.0 | 6 votes |
@Override @SuppressWarnings("unchecked") public void inform(SolrCore core) { try { String name = getPluginInfo().name; if (name.startsWith("/")) { myName = name.substring(1); } // some users may have '/' in the handler name. replace with '_' myName = myName.replaceAll("/", "_"); debugEnabled = StrUtils.parseBool((String)initArgs.get(ENABLE_DEBUG), true); importer = new DataImporter(core, myName); } catch (Exception e) { log.error( DataImporter.MSG.LOAD_EXP, e); throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, DataImporter.MSG.LOAD_EXP, e); } }
Example #11
Source File: RealTimeGetComponent.java From lucene-solr with Apache License 2.0 | 6 votes |
/** * Helper method for creating a new ShardRequest for the specified ids, based on the params * specified for the current request. The new ShardRequest does not yet know anything about * which shard/slice it will be sent to. */ private ShardRequest createShardRequest(final ResponseBuilder rb, final List<String> ids) { final ShardRequest sreq = new ShardRequest(); sreq.purpose = 1; sreq.params = new ModifiableSolrParams(rb.req.getParams()); // TODO: how to avoid hardcoding this and hit the same handler? sreq.params.set(ShardParams.SHARDS_QT,"/get"); sreq.params.set(DISTRIB,false); sreq.params.remove(ShardParams.SHARDS); sreq.params.remove(ID); sreq.params.remove("ids"); sreq.params.set("ids", StrUtils.join(ids, ',')); return sreq; }
Example #12
Source File: StatsField.java From lucene-solr with Apache License 2.0 | 6 votes |
/** special for percentiles **/ boolean parseParams(StatsField sf) { String percentileParas = sf.localParams.get(this.name()); if (percentileParas != null) { List<Double> percentiles = new ArrayList<Double>(); try { for (String percentile : StrUtils.splitSmart(percentileParas, ',')) { percentiles.add(Double.parseDouble(percentile)); } if (!percentiles.isEmpty()) { sf.percentilesList.addAll(percentiles); sf.tdigestCompression = sf.localParams.getDouble("tdigestCompression", sf.tdigestCompression); return true; } } catch (NumberFormatException e) { throw new SolrException(ErrorCode.BAD_REQUEST, "Unable to parse " + StatsParams.STATS_FIELD + " local params: " + sf.localParams + " due to: " + e.getMessage(), e); } } return false; }
Example #13
Source File: QueryElevationComponent.java From lucene-solr with Apache License 2.0 | 6 votes |
protected Elevation getElevation(ResponseBuilder rb) { SolrParams localParams = rb.getQparser().getLocalParams(); String queryString = localParams == null ? rb.getQueryString() : localParams.get(QueryParsing.V); if (queryString == null || rb.getQuery() == null) { return null; } SolrParams params = rb.req.getParams(); String paramElevatedIds = params.get(QueryElevationParams.IDS); String paramExcludedIds = params.get(QueryElevationParams.EXCLUDE); try { if (paramElevatedIds != null || paramExcludedIds != null) { List<String> elevatedIds = paramElevatedIds != null ? StrUtils.splitSmart(paramElevatedIds,",", true) : Collections.emptyList(); List<String> excludedIds = paramExcludedIds != null ? StrUtils.splitSmart(paramExcludedIds, ",", true) : Collections.emptyList(); return new ElevationBuilder().addElevatedIds(elevatedIds).addExcludedIds(excludedIds).build(); } else { IndexReader reader = rb.req.getSearcher().getIndexReader(); return getElevationProvider(reader, rb.req.getCore()).getElevationForQuery(queryString); } } catch (Exception e) { throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Error loading elevation", e); } }
Example #14
Source File: RequestHandlers.java From lucene-solr with Apache License 2.0 | 6 votes |
private PluginInfo applyInitParams(SolrConfig config, PluginInfo info) { List<InitParams> ags = new ArrayList<>(); String p = info.attributes.get(InitParams.TYPE); if(p!=null) { for (String arg : StrUtils.splitSmart(p, ',')) { if(config.getInitParams().containsKey(arg)) ags.add(config.getInitParams().get(arg)); else log.warn("INVALID paramSet {} in requestHandler {}", arg, info); } } for (InitParams args : config.getInitParams().values()) if(args.matchPath(info.name)) ags.add(args); if(!ags.isEmpty()){ info = info.copy(); for (InitParams initParam : ags) { initParam.apply(info); } } return info; }
Example #15
Source File: CloudReplicaSource.java From lucene-solr with Apache License 2.0 | 6 votes |
@SuppressWarnings({"unchecked", "rawtypes"}) private void withShardsParam(Builder builder, String shardsParam) { List<String> sliceOrUrls = StrUtils.splitSmart(shardsParam, ",", true); this.slices = new String[sliceOrUrls.size()]; this.replicas = new List[sliceOrUrls.size()]; ClusterState clusterState = builder.zkStateReader.getClusterState(); for (int i = 0; i < sliceOrUrls.size(); i++) { String sliceOrUrl = sliceOrUrls.get(i); if (sliceOrUrl.indexOf('/') < 0) { // this is a logical shard this.slices[i] = sliceOrUrl; replicas[i] = findReplicas(builder, shardsParam, clusterState, clusterState.getCollection(builder.collection).getSlice(sliceOrUrl)); } else { // this has urls this.replicas[i] = StrUtils.splitSmart(sliceOrUrl, "|", true); builder.replicaListTransformer.transform(replicas[i]); builder.hostChecker.checkWhitelist(clusterState, shardsParam, replicas[i]); } } }
Example #16
Source File: HttpSolrCall.java From lucene-solr with Apache License 2.0 | 6 votes |
/** * Resolves the parameter as a potential comma delimited list of collections, and resolves aliases too. * One level of aliases pointing to another alias is supported. * De-duplicates and retains the order. * {@link #getCollectionsList()} */ protected List<String> resolveCollectionListOrAlias(String collectionStr) { if (collectionStr == null || collectionStr.trim().isEmpty()) { return Collections.emptyList(); } List<String> result = null; LinkedHashSet<String> uniqueList = null; Aliases aliases = getAliases(); List<String> inputCollections = StrUtils.splitSmart(collectionStr, ",", true); if (inputCollections.size() > 1) { uniqueList = new LinkedHashSet<>(); } for (String inputCollection : inputCollections) { List<String> resolvedCollections = aliases.resolveAliases(inputCollection); if (uniqueList != null) { uniqueList.addAll(resolvedCollections); } else { result = resolvedCollections; } } if (uniqueList != null) { return new ArrayList<>(uniqueList); } else { return result; } }
Example #17
Source File: PackageStoreAPI.java From lucene-solr with Apache License 2.0 | 6 votes |
public static void validateName(String path, boolean failForTrusted) { if (path == null) { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "empty path"); } List<String> parts = StrUtils.splitSmart(path, '/', true); for (String part : parts) { if (part.charAt(0) == '.') { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "cannot start with period"); } for (int i = 0; i < part.length(); i++) { for (int j = 0; j < INVALIDCHARS.length(); j++) { if (part.charAt(i) == INVALIDCHARS.charAt(j)) throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unsupported char in file name: " + part); } } } if (failForTrusted && TRUSTED_DIR.equals(parts.get(0))) { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "trying to write into /_trusted_/ directory"); } }
Example #18
Source File: Rule.java From lucene-solr with Apache License 2.0 | 6 votes |
@SuppressWarnings({"rawtypes"}) public static Map parseRule(String s) { Map<String, String> result = new LinkedHashMap<>(); s = s.trim(); List<String> keyVals = StrUtils.splitSmart(s, ','); for (String kv : keyVals) { List<String> keyVal = StrUtils.splitSmart(kv, ':'); if (keyVal.size() != 2) { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Invalid rule. should have only key and val in : " + kv); } if (keyVal.get(0).trim().length() == 0 || keyVal.get(1).trim().length() == 0) { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Invalid rule. should have key and val in : " + kv); } result.put(keyVal.get(0).trim(), keyVal.get(1).trim()); } return result; }
Example #19
Source File: PivotFacetProcessor.java From lucene-solr with Apache License 2.0 | 6 votes |
/** * returns the {@link StatsField} instances that should be computed for a pivot * based on the 'stats' local params used. * * @return A list of StatsFields to compute for this pivot, or the empty list if none */ private static List<StatsField> getTaggedStatsFields(StatsInfo statsInfo, String statsLocalParam) { if (null == statsLocalParam || null == statsInfo) { return Collections.emptyList(); } List<StatsField> fields = new ArrayList<>(7); List<String> statsAr = StrUtils.splitSmart(statsLocalParam, ','); // TODO: for now, we only support a single tag name - we reserve using // ',' as a possible delimiter for logic related to only computing stats // at certain levels -- see SOLR-6663 if (1 < statsAr.size()) { String msg = StatsParams.STATS + " local param of " + FacetParams.FACET_PIVOT + "may not include tags separated by a comma - please use a common tag on all " + StatsParams.STATS_FIELD + " params you wish to compute under this pivot"; throw new SolrException(ErrorCode.BAD_REQUEST, msg); } for(String stat : statsAr) { fields.addAll(statsInfo.getStatsFieldsByTag(stat)); } return fields; }
Example #20
Source File: UpdateRequestProcessorChain.java From lucene-solr with Apache License 2.0 | 6 votes |
public static UpdateRequestProcessorChain constructChain(UpdateRequestProcessorChain defaultUrp, ProcessorInfo processorInfo, SolrCore core) { LinkedList<UpdateRequestProcessorFactory> urps = new LinkedList<>(defaultUrp.chain); List<UpdateRequestProcessorFactory> p = getReqProcessors(processorInfo.processor, core); List<UpdateRequestProcessorFactory> post = getReqProcessors(processorInfo.postProcessor, core); //processor are tried to be inserted before LogUpdateprocessor+DistributedUpdateProcessor insertBefore(urps, p, DistributedUpdateProcessorFactory.class, 0); //port-processor is tried to be inserted before RunUpdateProcessor insertBefore(urps, post, RunUpdateProcessorFactory.class, urps.size() - 1); UpdateRequestProcessorChain result = new UpdateRequestProcessorChain(urps, core); if (log.isDebugEnabled()) { ArrayList<String> names = new ArrayList<>(urps.size()); for (UpdateRequestProcessorFactory urp : urps) names.add(urp.getClass().getSimpleName()); if (log.isDebugEnabled()) { log.debug("New dynamic chain constructed : {}", StrUtils.join(names, '>')); } } return result; }
Example #21
Source File: MetricsHandler.java From lucene-solr with Apache License 2.0 | 6 votes |
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 #22
Source File: FacetParser.java From lucene-solr with Apache License 2.0 | 6 votes |
@SuppressWarnings({"unchecked"}) public List<String> getStringList(Map<String, Object> args, String paramName, boolean decode) { Object o = args.get(paramName); if (o == null) { return null; } if (o instanceof List) { return (List<String>)o; } if (o instanceof String) { // TODO: SOLR-12539 handle spaces in b/w comma & value ie, should the values be trimmed before returning?? return StrUtils.splitSmart((String)o, ",", decode); } throw err("Expected list of string or comma separated string values for '" + paramName + "', received " + o.getClass().getSimpleName() + "=" + o); }
Example #23
Source File: FiltersQParser.java From lucene-solr with Apache License 2.0 | 6 votes |
protected void exclude(Collection<QParser> clauses) { Set<String> tagsToExclude = new HashSet<>(); String excludeTags = localParams.get("excludeTags"); if (excludeTags != null) { tagsToExclude.addAll(StrUtils.splitSmart(excludeTags, ',')); } @SuppressWarnings("rawtypes") Map tagMap = (Map) req.getContext().get("tags"); final Collection<QParser> excludeSet; if (tagMap != null && !tagMap.isEmpty() && !tagsToExclude.isEmpty()) { excludeSet = excludeSet(tagMap, tagsToExclude); } else { excludeSet = Collections.emptySet(); } clauses.removeAll(excludeSet); }
Example #24
Source File: RuntimeUrp.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override protected void process(AddUpdateCommand cmd, SolrQueryRequest req, SolrQueryResponse rsp) { UpdateRequestProcessorChain processorChain = req.getCore().getUpdateProcessorChain(req.getParams()); List<String> names = new ArrayList<>(); for (UpdateRequestProcessorFactory p : processorChain.getProcessors()) { if (p instanceof UpdateRequestProcessorChain.LazyUpdateProcessorFactoryHolder.LazyUpdateRequestProcessorFactory) { p = ((UpdateRequestProcessorChain.LazyUpdateProcessorFactoryHolder.LazyUpdateRequestProcessorFactory) p).getDelegate(); } names.add(p.getClass().getSimpleName()); } cmd.solrDoc.addField("processors_s", StrUtils.join(names,'>')); }
Example #25
Source File: ComputePlanAction.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public void configure(SolrResourceLoader loader, SolrCloudManager cloudManager, Map<String, Object> properties) throws TriggerValidationException { super.configure(loader, cloudManager, properties); Object value = properties.get("collections"); if (value instanceof String) { String colString = (String) value; if (!colString.isEmpty()) { List<String> whiteListedCollections = StrUtils.splitSmart(colString, ','); collectionsPredicate = whiteListedCollections::contains; } } else if (value instanceof Map) { @SuppressWarnings({"unchecked"}) Map<String, String> matchConditions = (Map<String, String>) value; collectionsPredicate = collectionName -> { try { DocCollection collection = cloudManager.getClusterStateProvider().getCollection(collectionName); if (collection == null) { log.debug("Collection: {} was not found while evaluating conditions", collectionName); return false; } for (Map.Entry<String, String> entry : matchConditions.entrySet()) { if (!entry.getValue().equals(collection.get(entry.getKey()))) { if (log.isDebugEnabled()) { log.debug("Collection: {} does not match condition: {}:{}", collectionName, entry.getKey(), entry.getValue()); } return false; } } return true; } catch (IOException e) { log.error("Exception fetching collection information for: {}", collectionName, e); return false; } }; } }
Example #26
Source File: MetricsHandler.java From lucene-solr with Apache License 2.0 | 5 votes |
private MetricFilter parseMustMatchFilter(SolrParams params) { String[] prefixes = params.getParams(PREFIX_PARAM); MetricFilter prefixFilter = null; if (prefixes != null && prefixes.length > 0) { Set<String> prefixSet = new HashSet<>(); for (String prefix : prefixes) { prefixSet.addAll(StrUtils.splitSmart(prefix, ',')); } prefixFilter = new SolrMetricManager.PrefixFilter(prefixSet); } String[] regexes = params.getParams(REGEX_PARAM); MetricFilter regexFilter = null; if (regexes != null && regexes.length > 0) { regexFilter = new SolrMetricManager.RegexFilter(regexes); } MetricFilter mustMatchFilter; if (prefixFilter == null && regexFilter == null) { mustMatchFilter = MetricFilter.ALL; } else { if (prefixFilter == null) { mustMatchFilter = regexFilter; } else if (regexFilter == null) { mustMatchFilter = prefixFilter; } else { mustMatchFilter = new SolrMetricManager.OrFilter(prefixFilter, regexFilter); } } return mustMatchFilter; }
Example #27
Source File: StandaloneReplicaSource.java From lucene-solr with Apache License 2.0 | 5 votes |
@SuppressWarnings({"unchecked", "rawtypes"}) public StandaloneReplicaSource(Builder builder) { List<String> list = StrUtils.splitSmart(builder.shardsParam, ",", true); replicas = new List[list.size()]; for (int i = 0; i < list.size(); i++) { replicas[i] = StrUtils.splitSmart(list.get(i), "|", true); // todo do we really not need to transform in non-cloud mode?! // builder.replicaListTransformer.transform(replicas[i]); builder.hostChecker.checkWhitelist(builder.shardsParam, replicas[i]); } }
Example #28
Source File: MaintainRoutedAliasCmd.java From lucene-solr with Apache License 2.0 | 5 votes |
private void removeCollectionFromAlias(String aliasName, ZkStateReader.AliasesManager aliasesManager, String createCollName) { aliasesManager.applyModificationAndExportToZk(curAliases -> { final List<String> curTargetCollections = curAliases.getCollectionAliasListMap().get(aliasName); if (curTargetCollections.contains(createCollName)) { List<String> newTargetCollections = new ArrayList<>(curTargetCollections.size()); newTargetCollections.addAll(curTargetCollections); newTargetCollections.remove(createCollName); return curAliases.cloneWithCollectionAlias(aliasName, StrUtils.join(newTargetCollections, ',')); } else { return curAliases; } }); }
Example #29
Source File: FacetComponent.java From lucene-solr with Apache License 2.0 | 5 votes |
private void modifyRequestForPivotFacets(ResponseBuilder rb, ShardRequest sreq, SimpleOrderedMap<PivotFacet> pivotFacets) { for (Entry<String,PivotFacet> pfwEntry : pivotFacets) { PivotFacet pivot = pfwEntry.getValue(); for (String pivotField : StrUtils.splitSmart(pivot.getKey(), ',')) { modifyRequestForIndividualPivotFacets(rb, sreq, pivotField); } } }
Example #30
Source File: ReplicationHandler.java From lucene-solr with Apache License 2.0 | 5 votes |
private boolean isEnabled( @SuppressWarnings({"rawtypes"})NamedList params ){ if( params == null ) return false; Object enable = params.get( "enable" ); if( enable == null ) return true; if( enable instanceof String ) return StrUtils.parseBool( (String)enable ); return Boolean.TRUE.equals( enable ); }