@Override public void prepare(ResponseBuilder rb) throws IOException { if( SolandraComponent.prepare(rb) ) { ModifiableSolrParams params = new ModifiableSolrParams(rb.req.getParams()); if(params.get(ShardParams.SHARDS_QT) == null) { params.add(ShardParams.SHARDS_QT, "/terms"); } rb.req.setParams(params); } super.prepare(rb); } }
private void index(boolean isSolrCloud, String collection, Long commitWithin, String contentStreamPath, MultiMapSolrParams requestParams, List<SolrInputDocument> inputDocumentList) throws IOException, SolrServerException,SolrException { UpdateRequest request = new UpdateRequest(contentStreamPath); request.setParams(new ModifiableSolrParams()); // add the extra params, don't use 'set' in case of repeating params Iterator<String> paramNames = requestParams.getParameterNamesIterator(); while (paramNames.hasNext()) { String paramName = paramNames.next(); for (String paramValue : requestParams.getParams(paramName)) { request.getParams().add(paramName, paramValue); } } // specify the collection for SolrCloud if (isSolrCloud) { request.setParam(COLLECTION_PARAM_NAME, collection); } if (commitWithin != null && commitWithin > 0) { request.setParam(COMMIT_WITHIN_PARAM_NAME, commitWithin.toString()); } // if a username and password were provided then pass them for basic auth if (isBasicAuthEnabled()) { request.setBasicAuthCredentials(getUsername(), getPassword()); } request.add(inputDocumentList); UpdateResponse response = request.process(getSolrClient()); getLogger().debug("Got {} response from Solr", new Object[]{response.getStatus()}); inputDocumentList.clear(); }
public static Map<String, String[]> getRequestParams(ProcessContext context, FlowFile flowFile) { final Map<String,String[]> paramsMap = new HashMap<>(); final SortedMap<String,String> repeatingParams = new TreeMap<>(); for (final Map.Entry<PropertyDescriptor, String> entry : context.getProperties().entrySet()) { final PropertyDescriptor descriptor = entry.getKey(); if (descriptor.isDynamic()) { final String paramName = descriptor.getName(); final String paramValue = context.getProperty(descriptor).evaluateAttributeExpressions(flowFile).getValue(); if (!paramValue.trim().isEmpty()) { if (paramName.matches(REPEATING_PARAM_PATTERN)) { repeatingParams.put(paramName, paramValue); } else { MultiMapSolrParams.addParam(paramName, paramValue, paramsMap); } } } } for (final Map.Entry<String,String> entry : repeatingParams.entrySet()) { final String paramName = entry.getKey(); final String paramValue = entry.getValue(); final int idx = paramName.lastIndexOf("."); MultiMapSolrParams.addParam(paramName.substring(0, idx), paramValue, paramsMap); } return paramsMap; }
final KerberosCredentialsService kerberosCredentialsService = context.getProperty(KERBEROS_CREDENTIALS_SERVICE).asControllerService(KerberosCredentialsService.class); final ModifiableSolrParams params = new ModifiableSolrParams(); params.set(HttpClientUtil.PROP_SO_TIMEOUT, socketTimeout); params.set(HttpClientUtil.PROP_CONNECTION_TIMEOUT, connectionTimeout); params.set(HttpClientUtil.PROP_MAX_CONNECTIONS, maxConnections); params.set(HttpClientUtil.PROP_MAX_CONNECTIONS_PER_HOST, maxConnectionsPerHost);
public QueryRequest getCreateCollectionsRequest(String name, int numShards, int replicationFactor) { ModifiableSolrParams params = new ModifiableSolrParams(); params.set(SolrConstants.REQUEST_ACTION, CollectionParams.CollectionAction.CREATE.name()); params.set(SolrConstants.REQUEST_NAME, name); params.set(SolrConstants.REQUEST_NUM_SHARDS, numShards); params.set(SolrConstants.REQUEST_REPLICATION_FACTOR, replicationFactor); params.set(SolrConstants.REQUEST_COLLECTION_CONFIG_NAME, name); QueryRequest request = new QueryRequest(params); request.setPath(SolrConstants.REQUEST_COLLECTIONS_PATH); return request; }
@Override public SolrParams getParams() { ModifiableSolrParams params = new ModifiableSolrParams(); params.set(CoreAdminParams.ACTION, action.toString()); return params; }
/** * Create a new SolrPing object. */ public SolrPing() { super(METHOD.GET, CommonParams.PING_HANDLER); params = new ModifiableSolrParams(); }
/** * Set the action parameter on this request to ping. This is the same as not * including the action at all. For Solr server version 4.0 and later. * * @return this */ public SolrPing setActionPing() { params.set(CommonParams.ACTION, CommonParams.PING); return this; } }
if (rb.req.getParams().getBool(ShardParams.IS_SHARD, false))
final Long commitWithin = context.getProperty(COMMIT_WITHIN).evaluateAttributeExpressions(flowFile).asLong(); final String contentStreamPath = context.getProperty(CONTENT_STREAM_PATH).evaluateAttributeExpressions(flowFile).getValue(); final MultiMapSolrParams requestParams = new MultiMapSolrParams(SolrUtils.getRequestParams(context, flowFile));
/** Create SolrParams from NamedList. */ public static SolrParams toSolrParams(NamedList params) { // always use MultiMap for easier processing further down the chain return new MultiMapSolrParams(toMultiMap(params)); }
Map<String, String> params = new HashMap<>(); params.put("fl", fieldList + ",[child parentFilter=" + metaalertTypeClause + " limit=999]"); SolrParams solrParams = new MapSolrParams(params); try { SolrDocumentList solrDocumentList = solrClient
/** * Returns the float value of the field param or * the value for param or * the default value for float - zero (<code>0.0f</code>) */ public float getPrimitiveFieldFloat(String field, String param) { return getFieldFloat(field, param, 0.0f); }
public static SolrParams toSolrProps(Map<String, Object> config) { if(config == null || config.isEmpty()) { return null; } ModifiableSolrParams ret = new ModifiableSolrParams(); for(Map.Entry<String, Object> kv : config.entrySet()) { Object v = kv.getValue(); if(v instanceof Boolean) { ret.set(kv.getKey(), (Boolean)v); } else if(v instanceof Integer) { ret.set(kv.getKey(), (Integer)v); } else if(v instanceof Iterable) { Iterable vals = (Iterable)v; String[] strVals = new String[Iterables.size(vals)]; int i = 0; for(Object o : (Iterable)v) { strVals[i++] = o.toString(); } } } return ret; }
public QueryRequest getListCollectionsRequest() { ModifiableSolrParams params = new ModifiableSolrParams(); params.set(SolrConstants.REQUEST_ACTION, CollectionParams.CollectionAction.LIST.name()); QueryRequest request = new QueryRequest(params); request.setPath(SolrConstants.REQUEST_COLLECTIONS_PATH); return request; } }
@Override public void process(final InputStream in) throws IOException { ContentStreamUpdateRequest request = new ContentStreamUpdateRequest(contentStreamPath); request.setParams(new ModifiableSolrParams()); Iterator<String> paramNames = requestParams.getParameterNamesIterator(); while (paramNames.hasNext()) { String paramName = paramNames.next(); for (String paramValue : requestParams.getParams(paramName)) { request.getParams().add(paramName, paramValue);
final Long commitWithin = context.getProperty(COMMIT_WITHIN).evaluateAttributeExpressions(flowFile).asLong(); final String contentStreamPath = context.getProperty(UPDATE_PATH).evaluateAttributeExpressions(flowFile).getValue(); final MultiMapSolrParams requestParams = new MultiMapSolrParams(SolrUtils.getRequestParams(context, flowFile)); final RecordReaderFactory readerFactory = context.getProperty(RECORD_READER).asControllerService(RecordReaderFactory.class); final String fieldsToIndex = context.getProperty(FIELDS_TO_INDEX).evaluateAttributeExpressions(flowFile).getValue();
public void setParam(String param, String value) { if (params == null) params = new ModifiableSolrParams(); params.set(param, value); }
solrQuery.add(new MultiMapSolrParams(additionalSolrParams));