Here are the examples of the java api org.apache.solr.common.util.NamedList taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
927 Examples
19
Source : CachedTermsQParserPlugin.java
with GNU Affero General Public License v3.0
from qlangtech
with GNU Affero General Public License v3.0
from qlangtech
@Override
public void init(NamedList args) {
super.init(args);
FORMAT_URL_GET_IDS = null;
// FORMAT_URL_GET_IDS = new MessageFormat(TSearcherConfigFetcher.get().getProp("abroadIntelligenceUrl",
// "http://192.168.3.35:9002/abroadIntelligence/queryCachedTerms?key={0}&v={1}"));
}
19
Source : SearchRequestUtil.java
with MIT License
from MighTguY
with MIT License
from MighTguY
/**
* Get value of Type T from named list
* @param namedList
* @param key
* @param def
* @param <T>
* @return
*/
public static <T> T getFromNamedList(NamedList namedList, String key, T def) {
T val = (T) namedList.get(key);
if (val == null) {
val = def;
}
return val;
}
19
Source : CustomSpellCheckListner.java
with MIT License
from MighTguY
with MIT License
from MighTguY
/**
* Init method
* @param args
*/
@Override
public void init(NamedList args) {
// Nothing to do at init
}
19
Source : MtasSolrTestDistributedSearchConsistency.java
with Apache License 2.0
from meertensinstituut
with Apache License 2.0
from meertensinstituut
/**
* Creates the stats replacedertions.
*
* @param response1
* the response 1
* @param response2
* the response 2
* @param type
* the type
* @param key
* the key
* @param names
* the names
*/
private static void createStatsreplacedertions(NamedList<Object> response1, NamedList<Object> response2, String type, String key, String[] names) {
NamedList<Object>[] responses2 = new NamedList[] { response2 };
createStatsreplacedertions(response1, responses2, type, key, names);
}
19
Source : MtasSolrTestDistributedSearchConsistency.java
with Apache License 2.0
from meertensinstituut
with Apache License 2.0
from meertensinstituut
/**
* Creates the stats replacedertions.
*
* @param response1
* the response 1
* @param responses2
* the responses 2
* @param type
* the type
* @param key
* the key
* @param names
* the names
*/
private static void createStatsreplacedertions(NamedList<Object> response1, NamedList<Object>[] responses2, String type, String key, String[] names) {
for (String name : names) {
replacedertFalse("no " + type + " - " + name, MtreplacedolrBase.getFromMtreplacedtats(response1, type, key, name).equals(0));
for (NamedList<Object> response2 : responses2) {
replacedertEquals(MtreplacedolrBase.getFromMtreplacedtats(response1, type, key, name), MtreplacedolrBase.getFromMtreplacedtats(response2, type, key, name));
}
}
}
19
Source : MtasSolrBase.java
with Apache License 2.0
from meertensinstituut
with Apache License 2.0
from meertensinstituut
/**
* Gets the from mtas collection list.
*
* @param response the response
* @param key the key
* @param id the id
* @return the from mtas collection list
*/
public static NamedList<Object> getFromMtasCollectionList(NamedList<Object> response, String key, String id) {
NamedList<Object> collectionResponse = getFromMtasCollection(response, key);
if (collectionResponse != null) {
Object collectionResponseListRaw = collectionResponse.get("list");
if (collectionResponseListRaw != null && collectionResponseListRaw instanceof List) {
List<NamedList<Object>> collectionResponseList = (List<NamedList<Object>>) collectionResponseListRaw;
for (NamedList<Object> item : collectionResponseList) {
if (item.get("id") != null && item.get("id") instanceof String) {
if (id.equals((String) item.get("id"))) {
return item;
}
}
}
} else {
log.error("unexpected " + collectionResponseListRaw + " (searching list)");
}
} else {
log.error("no collectionResponse (searching key " + key + ")");
}
return null;
}
19
Source : MtasSolrBase.java
with Apache License 2.0
from meertensinstituut
with Apache License 2.0
from meertensinstituut
/**
* Gets the from stats.
*
* @param response the response
* @param field the field
* @param name the name
* @param round the round
* @return the from stats
*/
public static Number getFromStats(NamedList<Object> response, String field, String name, boolean round) {
if (response == null) {
log.error("no (valid); response");
} else {
Object mtreplacedtatsRaw = response.get("stats");
if (mtreplacedtatsRaw != null && mtreplacedtatsRaw instanceof NamedList) {
NamedList<Object> mtreplacedtats = (NamedList) mtreplacedtatsRaw;
Object mtreplacedtatsFieldsRaw = mtreplacedtats.get("stats_fields");
if (mtreplacedtatsFieldsRaw != null && mtreplacedtatsFieldsRaw instanceof NamedList) {
NamedList<Object> mtreplacedtatsFields = (NamedList<Object>) mtreplacedtatsFieldsRaw;
Object mtreplacedtatsFieldsFieldRaw = mtreplacedtatsFields.get(field);
if (mtreplacedtatsFieldsFieldRaw != null && mtreplacedtatsFieldsFieldRaw instanceof NamedList) {
NamedList<Object> mtreplacedtatsFieldsField = (NamedList<Object>) mtreplacedtatsFieldsFieldRaw;
Object mtreplacedtatsFieldsFieldNameRaw = mtreplacedtatsFieldsField.get(name);
if (mtreplacedtatsFieldsFieldNameRaw != null && mtreplacedtatsFieldsFieldNameRaw instanceof Number) {
if (round) {
return ((Number) mtreplacedtatsFieldsFieldNameRaw).longValue();
} else {
return (Number) mtreplacedtatsFieldsFieldNameRaw;
}
} else {
log.error("unexpected " + mtreplacedtatsFieldsFieldNameRaw);
}
} else {
log.error("unexpected " + mtreplacedtatsFieldsFieldRaw);
}
} else {
log.error("unexpected " + mtreplacedtatsFieldsRaw);
}
} else {
log.error("unexpected " + mtreplacedtatsRaw);
}
}
return null;
}
19
Source : LireValueSourceParser.java
with GNU General Public License v2.0
from dermotte
with GNU General Public License v2.0
from dermotte
public void init(NamedList namedList) {
}
19
Source : KnowledgeGraphResponseWriter.java
with Apache License 2.0
from careerbuilder
with Apache License 2.0
from careerbuilder
public void init(NamedList args) {
}
19
Source : SolrResponseBase.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* @since solr 1.3
*/
public clreplaced SolrResponseBase extends SolrResponse implements MapWriter {
private long elapsedTime = -1;
private NamedList<Object> response = null;
private String requestUrl = null;
@Override
public void writeMap(EntryWriter ew) throws IOException {
if (response != null)
response.writeMap(ew);
}
@Override
public long getElapsedTime() {
return elapsedTime;
}
public void setElapsedTime(long elapsedTime) {
this.elapsedTime = elapsedTime;
}
@Override
public NamedList<Object> getResponse() {
return response;
}
@Override
public void setResponse(NamedList<Object> response) {
this.response = response;
}
@Override
public String toString() {
return response.toString();
}
@SuppressWarnings({ "rawtypes" })
public NamedList getResponseHeader() {
return (NamedList) response.get("responseHeader");
}
// these two methods are based on the logic in SolrCore.setResponseHeaderValues(...)
public int getStatus() {
@SuppressWarnings({ "rawtypes" })
NamedList header = getResponseHeader();
if (header != null) {
return (Integer) header.get("status");
} else {
return 0;
}
}
public int getQTime() {
@SuppressWarnings({ "rawtypes" })
NamedList header = getResponseHeader();
if (header != null) {
return (Integer) header.get("QTime");
} else {
return 0;
}
}
public String getRequestUrl() {
return requestUrl;
}
public void setRequestUrl(String requestUrl) {
this.requestUrl = requestUrl;
}
}
19
Source : SolrResponseBase.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
public int getQTime() {
@SuppressWarnings({ "rawtypes" })
NamedList header = getResponseHeader();
if (header != null) {
return (Integer) header.get("QTime");
} else {
return 0;
}
}
19
Source : SolrResponseBase.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
// these two methods are based on the logic in SolrCore.setResponseHeaderValues(...)
public int getStatus() {
@SuppressWarnings({ "rawtypes" })
NamedList header = getResponseHeader();
if (header != null) {
return (Integer) header.get("status");
} else {
return 0;
}
}
19
Source : SimpleSolrResponse.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
public clreplaced SimpleSolrResponse extends SolrResponse {
public long elapsedTime;
public NamedList<Object> nl;
@Override
public long getElapsedTime() {
return elapsedTime;
}
@Override
public NamedList<Object> getResponse() {
return nl;
}
@Override
public void setResponse(NamedList<Object> rsp) {
nl = rsp;
}
@Override
public void setElapsedTime(long elapsedTime) {
this.elapsedTime = elapsedTime;
}
}
19
Source : SchemaResponse.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
private static Map<String, Object> getSimilarity(@SuppressWarnings({ "rawtypes" }) Map schemaNamedList) {
@SuppressWarnings({ "unchecked" })
NamedList<Object> similarityNamedList = (NamedList<Object>) schemaNamedList.get("similarity");
Map<String, Object> similarity = null;
if (similarityNamedList != null)
similarity = extractAttributeMap(similarityNamedList);
return similarity;
}
19
Source : CoreAdminResponse.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
public Date getStartTime(String core) {
NamedList<Object> v = getCoreStatus(core);
if (v == null) {
return null;
}
return (Date) v.get("startTime");
}
19
Source : CoreAdminResponse.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
public Long getUptime(String core) {
NamedList<Object> v = getCoreStatus(core);
if (v == null) {
return null;
}
return (Long) v.get("uptime");
}
19
Source : CoreStatus.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
public clreplaced CoreStatus {
private final NamedList<Object> response;
public CoreStatus(NamedList<Object> response) {
this.response = response;
}
public String getDataDirectory() {
return (String) response.get("dataDir");
}
public String getInstanceDirectory() {
return (String) response.findRecursive("instanceDir");
}
@Override
public String toString() {
return response.toString();
}
public Date getCoreStartTime() {
return (Date) response.get("startTime");
}
}
19
Source : XMLResponseParser.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* parse the text into a named list...
*/
private NamedList<Object> processResponse(XMLStreamReader parser) {
try {
NamedList<Object> response = null;
for (int event = parser.next(); event != XMLStreamConstants.END_DOreplacedENT; event = parser.next()) {
switch(event) {
case XMLStreamConstants.START_ELEMENT:
if (response != null) {
throw new Exception("already read the response!");
}
// only top-level element is "response
String name = parser.getLocalName();
if (name.equals("response") || name.equals("result")) {
response = readNamedList(parser);
} else if (name.equals("solr")) {
return new SimpleOrderedMap<>();
} else {
throw new Exception("really needs to be response or result. " + "not:" + parser.getLocalName());
}
break;
}
}
return response;
} catch (Exception ex) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "parsing error", ex);
} finally {
try {
parser.close();
} catch (Exception ex) {
}
}
}
19
Source : CloudSolrClient.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* @deprecated since Solr 8.0
*/
@Deprecated
public RouteResponse condenseResponse(@SuppressWarnings({ "rawtypes" }) NamedList response, int timeMillis) {
return condenseResponse(response, timeMillis, RouteResponse::new);
}
19
Source : TestRTimerTree.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
public void test() {
RTimerTree rt = new MockRTimerTree(), subt, st;
MockTimerImpl.incrementSystemTime(100);
replacedertEquals(100, (int) rt.getTime());
subt = rt.sub("sub1");
MockTimerImpl.incrementSystemTime(50);
replacedertEquals(150, (int) rt.getTime());
replacedertEquals(50, (int) subt.getTime());
st = subt.sub("sub1.1");
st.resume();
MockTimerImpl.incrementSystemTime(10);
replacedertEquals(10, (int) st.getTime());
st.pause();
MockTimerImpl.incrementSystemTime(50);
replacedertEquals(10, (int) st.getTime());
st.resume();
MockTimerImpl.incrementSystemTime(10);
st.pause();
subt.stop();
rt.stop();
replacedertEquals(20, (int) st.getTime());
replacedertEquals(120, (int) subt.getTime());
replacedertEquals(220, (int) rt.getTime());
@SuppressWarnings({ "rawtypes" })
NamedList nl = rt.asNamedList();
replacedertEquals(220, ((Double) nl.get("time")).intValue());
@SuppressWarnings({ "rawtypes" })
NamedList sub1nl = (NamedList) nl.get("sub1");
replacedertNotNull(sub1nl);
replacedertEquals(120, ((Double) sub1nl.get("time")).intValue());
@SuppressWarnings({ "rawtypes" })
NamedList sub11nl = (NamedList) sub1nl.get("sub1.1");
replacedertNotNull(sub11nl);
replacedertEquals(20, ((Double) sub11nl.get("time")).intValue());
}
19
Source : SolrIndexSplitterTest.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
private void doSplit(SplitIndexCommand command) throws Exception {
NamedList<Object> results = new NamedList<>();
new SolrIndexSplitter(command).split(results);
command.rsp.addResponse(results);
}
19
Source : TestDocBasedVersionConstraints.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
public void testCanCreateTombstonesBasic() {
DocBasedVersionConstraintsProcessorFactory factory = new DocBasedVersionConstraintsProcessorFactory();
NamedList<Object> config = new NamedList<>();
config.add("versionField", "_version_");
factory.init(config);
IndexSchema schema = h.getCore().getLatestSchema();
replacedertThat(factory.canCreateTombstoneDoreplacedent(schema), is(true));
}
19
Source : StatsReloadRaceTest.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
private void requestMetrics(boolean softFail) throws Exception {
SolrQueryResponse rsp = new SolrQueryResponse();
String registry = "solr.core." + h.coreName;
String key = "SEARCHER.searcher.indexVersion";
boolean found = false;
int count = 10;
while (!found && count-- > 0) {
h.getCoreContainer().getRequestHandler("/admin/metrics").handleRequest(req("prefix", "SEARCHER", "registry", registry, "compact", "true"), rsp);
@SuppressWarnings({ "rawtypes" })
NamedList values = rsp.getValues();
// this is not guaranteed to exist right away after core reload - there's a
// small window between core load and before searcher metrics are registered
// so we may have to check a few times, and then fail softly if reload is not complete yet
@SuppressWarnings({ "rawtypes" })
NamedList metrics = (NamedList) values.get("metrics");
if (metrics == null) {
if (softFail) {
return;
} else {
fail("missing 'metrics' element in handler's output: " + values.asMap(5).toString());
}
}
metrics = (NamedList) metrics.get(registry);
if (metrics.get(key) != null) {
found = true;
replacedertTrue(metrics.get(key) instanceof Long);
break;
} else {
Thread.sleep(500);
}
}
if (softFail && !found) {
return;
}
replacedertTrue("Key " + key + " not found in registry " + registry, found);
}
19
Source : HdfsBackupRepositoryIntegrationTest.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
protected BackupRepository getRepository() {
HdfsBackupRepository repository = new HdfsBackupRepository();
NamedList config = new NamedList();
config.add(HdfsDirectoryFactory.HDFS_HOME, hdfsUri + "/solr");
repository.init(config);
return repository;
}
19
Source : ReplicationFactorTest.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
protected void doDelete(UpdateRequest req, String msg, int expectedRf, int retries) throws IOException, SolrServerException, InterruptedException {
int achievedRf = -1;
for (int idx = 0; idx < retries; ++idx) {
NamedList<Object> response = cloudClient.request(req);
achievedRf = cloudClient.getMinAchievedReplicationFactor(cloudClient.getDefaultCollection(), response);
if (achievedRf == expectedRf)
return;
Thread.sleep(1000);
}
replacedertEquals(msg, expectedRf, achievedRf);
}
19
Source : ReplicationFactorTest.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
private int runAndGetAchievedRf(UpdateRequest up) throws SolrServerException, IOException {
NamedList<Object> response = cloudClient.request(up);
return cloudClient.getMinAchievedReplicationFactor(cloudClient.getDefaultCollection(), response);
}
19
Source : CloneFieldUpdateProcessorFactory.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* macro
*/
private static SelectorParams parseSelectorParams(@SuppressWarnings({ "rawtypes" }) NamedList args) {
return FieldMutatingUpdateProcessorFactory.parseSelectorParams(args);
}
19
Source : ClassificationUpdateProcessorFactory.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
@Override
public void init(@SuppressWarnings({ "rawtypes" }) final NamedList args) {
if (args != null) {
params = args.toSolrParams();
clreplacedificationParams = new ClreplacedificationUpdateProcessorParams();
// must be a comma separated list of fields
String fieldNames = params.get(INPUT_FIELDS_PARAM);
checkNotNull(INPUT_FIELDS_PARAM, fieldNames);
clreplacedificationParams.setInputFieldNames(fieldNames.split("\\,"));
String trainingClreplacedField = (params.get(TRAINING_CLreplaced_FIELD_PARAM));
checkNotNull(TRAINING_CLreplaced_FIELD_PARAM, trainingClreplacedField);
clreplacedificationParams.setTrainingClreplacedField(trainingClreplacedField);
String predictedClreplacedField = (params.get(PREDICTED_CLreplaced_FIELD_PARAM));
if (predictedClreplacedField == null || predictedClreplacedField.isEmpty()) {
predictedClreplacedField = trainingClreplacedField;
}
clreplacedificationParams.setPredictedClreplacedField(predictedClreplacedField);
clreplacedificationParams.setMaxPredictedClreplacedes(getIntParam(params, MAX_CLreplacedES_TO_replacedIGN_PARAM, DEFAULT_MAX_CLreplacedES_TO_replacedIGN));
String algorithmString = params.get(ALGORITHM_PARAM);
Algorithm clreplacedificationAlgorithm;
try {
if (algorithmString == null || Algorithm.valueOf(algorithmString.toUpperCase(Locale.ROOT)) == null) {
clreplacedificationAlgorithm = DEFAULT_ALGORITHM;
} else {
clreplacedificationAlgorithm = Algorithm.valueOf(algorithmString.toUpperCase(Locale.ROOT));
}
} catch (IllegalArgumentException e) {
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Clreplacedification UpdateProcessor Algorithm: '" + algorithmString + "' not supported");
}
clreplacedificationParams.setAlgorithm(clreplacedificationAlgorithm);
clreplacedificationParams.setMinTf(getIntParam(params, KNN_MIN_TF_PARAM, DEFAULT_MIN_TF));
clreplacedificationParams.setMinDf(getIntParam(params, KNN_MIN_DF_PARAM, DEFAULT_MIN_DF));
clreplacedificationParams.setK(getIntParam(params, KNN_K_PARAM, DEFAULT_K));
}
}
19
Source : WordBreakSolrSpellChecker.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
private int intParam(@SuppressWarnings("rawtypes") NamedList config, String paramName) {
Object o = config.get(paramName);
if (o == null) {
return 0;
}
try {
return Integer.parseInt(o.toString());
} catch (NumberFormatException nfe) {
throw new IllegalArgumentException("Invalid integer for parameter " + paramName + " : " + o);
}
}
19
Source : WordBreakSolrSpellChecker.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
private String strParam(@SuppressWarnings("rawtypes") NamedList config, String paramName) {
Object o = config.get(paramName);
return o == null ? null : o.toString();
}
19
Source : WordBreakSolrSpellChecker.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
private boolean boolParam(@SuppressWarnings("rawtypes") NamedList config, String paramName) {
String s = strParam(config, paramName);
if ("true".equalsIgnoreCase(s) || "on".equalsIgnoreCase(s)) {
return true;
}
return false;
}
19
Source : DictionaryFactory.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Sets the parameters available to SolrSuggester for use in Dictionary creation
*/
public void setParams(@SuppressWarnings({ "rawtypes" }) NamedList params) {
this.params = params;
}
19
Source : SpellCheckCollation.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
public clreplaced SpellCheckCollation implements Comparable<SpellCheckCollation> {
private NamedList<String> misspellingsAndCorrections;
private long hits;
private int internalRank;
private String collationQuery;
@Override
public int compareTo(SpellCheckCollation scc) {
int c = Integer.compare(internalRank, scc.internalRank);
if (c == 0) {
return collationQuery.compareTo(scc.collationQuery);
}
return c;
}
public NamedList<String> getMisspellingsAndCorrections() {
return misspellingsAndCorrections;
}
public void setMisspellingsAndCorrections(NamedList<String> misspellingsAndCorrections) {
this.misspellingsAndCorrections = misspellingsAndCorrections;
}
public long getHits() {
return hits;
}
public void setHits(long hits) {
this.hits = hits;
}
public String getCollationQuery() {
return collationQuery;
}
public void setCollationQuery(String collationQuery) {
this.collationQuery = collationQuery;
}
public int getInternalRank() {
return internalRank;
}
public void setInternalRank(int internalRank) {
this.internalRank = internalRank;
}
}
19
Source : TabularResponseWriter.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
@Override
public void writeNamedList(String name, @SuppressWarnings({ "rawtypes" }) NamedList val) throws IOException {
}
19
Source : RawResponseWriter.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
@Override
public void init(@SuppressWarnings({ "rawtypes" }) NamedList n) {
if (n != null) {
Object base = n.get("base");
if (base != null) {
_baseWriter = base.toString();
}
}
}
19
Source : PHPSerializedResponseWriter.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
@Override
public void writeNamedList(String name, @SuppressWarnings({ "rawtypes" }) NamedList val) throws IOException {
writeNamedListAsMapMangled(name, val);
}
19
Source : GraphMLResponseWriter.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
public void init(@SuppressWarnings({ "rawtypes" }) NamedList args) {
/* NOOP */
}
19
Source : GeoJSONResponseWriter.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
@Override
public void writeResponse() throws IOException {
if (req.getParams().getBool(CommonParams.OMIT_HEADER, false)) {
if (wrapperFunction != null) {
writer.write(wrapperFunction + "(");
}
rsp.removeResponseHeader();
@SuppressWarnings({ "unchecked" })
NamedList<Object> vals = rsp.getValues();
Object response = vals.remove("response");
if (vals.size() == 0) {
writeVal(null, response);
} else {
throw new SolrException(ErrorCode.BAD_REQUEST, "GeoJSON with " + CommonParams.OMIT_HEADER + " can not return more than a result set");
}
if (wrapperFunction != null) {
writer.write(')');
}
// ending with a newline looks much better from the command line
writer.write('\n');
} else {
super.writeResponse();
}
}
19
Source : UnifiedSolrHighlighter.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Encodes the resulting snippets into a namedlist
*
* @param keys the doreplacedent unique keys
* @param fieldNames field names to highlight in the order
* @param snippets map from field name to snippet array for the docs
* @return encoded namedlist of summaries
*/
protected NamedList<Object> encodeSnippets(String[] keys, String[] fieldNames, Map<String, String[]> snippets) {
NamedList<Object> list = new SimpleOrderedMap<>();
for (int i = 0; i < keys.length; i++) {
NamedList<Object> summary = new SimpleOrderedMap<>();
for (String field : fieldNames) {
String snippet = snippets.get(field)[i];
if (snippet == null) {
// TODO reuse logic of DefaultSolrHighlighter.alternateField
summary.add(field, ZERO_LEN_STR_ARRAY);
} else {
// we used a special snippet separator char and we can now split on it.
summary.add(field, snippet.split(SNIPPET_SEPARATOR));
}
}
list.add(keys[i], summary);
}
return list;
}
19
Source : UpdateRequestHandler.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
@Override
public void init(@SuppressWarnings({ "rawtypes" }) NamedList args) {
super.init(args);
// Since backed by a non-thread safe Map, it should not be modifiable
loaders = Collections.unmodifiableMap(createDefaultLoaders(args));
}
19
Source : RequestHandlerBase.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
public static SolrParams getSolrParamsFromNamedList(@SuppressWarnings({ "rawtypes" }) NamedList args, String key) {
Object o = args.get(key);
if (o != null && o instanceof NamedList) {
return ((NamedList) o).toSolrParams();
}
return null;
}
19
Source : ContentStreamHandlerBase.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
@Override
public void init(@SuppressWarnings({ "rawtypes" }) NamedList args) {
super.init(args);
// Caching off by default
httpCaching = false;
if (args != null) {
Object caching = args.get("httpCaching");
if (caching != null) {
httpCaching = Boolean.parseBoolean(caching.toString());
}
}
}
19
Source : StatsComponent.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Given a map of {@link StatsValues} using the appropriate response key,
* builds up the necessary "stats" data structure for including in the response --
* including the esoteric "stats_fields" wrapper.
*/
public static NamedList<NamedList<NamedList<?>>> convertToResponse(Map<String, StatsValues> statsValues) {
NamedList<NamedList<NamedList<?>>> stats = new SimpleOrderedMap<>();
NamedList<NamedList<?>> stats_fields = new SimpleOrderedMap<>();
stats.add("stats_fields", stats_fields);
for (Map.Entry<String, StatsValues> entry : statsValues.entrySet()) {
String key = entry.getKey();
@SuppressWarnings({ "rawtypes" })
NamedList stv = entry.getValue().getStatsValues();
stats_fields.add(key, stv);
}
return stats;
}
19
Source : ResponseBuilder.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
public void addDebug(Object val, String... path) {
if (debugInfo == null) {
debugInfo = new SimpleOrderedMap<>();
}
NamedList<Object> target = debugInfo;
for (int i = 0; i < path.length - 1; i++) {
String elem = path[i];
@SuppressWarnings({ "unchecked" })
NamedList<Object> newTarget = (NamedList<Object>) debugInfo.get(elem);
if (newTarget == null) {
newTarget = new SimpleOrderedMap<>();
target.add(elem, newTarget);
}
target = newTarget;
}
target.add(path[path.length - 1], val);
}
19
Source : PivotFacetField.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Recursively merges the contributions from the specified shard for each
* {@link PivotFacetValue} represended in the <code>response</code>.
*
* @see PivotFacetValue#mergeContributionFromShard
* @param shardNumber the id of the shard that provided this data
* @param rb The response builder of the current request
* @param response the data from the specified shard for this pivot field, may be null
*/
public void contributeFromShard(int shardNumber, ResponseBuilder rb, List<NamedList<Object>> response) {
if (null == response)
return;
for (NamedList<Object> responseValue : response) {
contributeValueFromShard(shardNumber, rb, responseValue);
}
}
19
Source : HttpShardHandlerFactory.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
protected <T> T getParameter(@SuppressWarnings({ "rawtypes" }) NamedList initArgs, String configKey, T defaultValue, StringBuilder sb) {
T toReturn = defaultValue;
if (initArgs != null) {
@SuppressWarnings({ "unchecked" })
T temp = (T) initArgs.get(configKey);
toReturn = (temp != null) ? temp : defaultValue;
}
if (sb != null && toReturn != null)
sb.append(configKey).append(" : ").append(toReturn).append(",");
return toReturn;
}
19
Source : HighlightComponent.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
protected Object convertHighlights(@SuppressWarnings({ "rawtypes" }) NamedList hl) {
return hl;
}
19
Source : MetricsHistoryHandler.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
@SuppressWarnings({ "unchecked", "rawtypes" })
private void mergeRemoteRes(SolrQueryResponse rsp, NamedList<Object> remoteRes) {
if (remoteRes == null || remoteRes.get("metrics") == null) {
return;
}
NamedList<Object> remoteMetrics = (NamedList<Object>) remoteRes.get("metrics");
SimpleOrderedMap localMetrics = (SimpleOrderedMap) rsp.getValues().get("metrics");
remoteMetrics.forEach((k, v) -> localMetrics.add(k, v));
}
19
Source : InfoHandler.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
@Override
final public void init(@SuppressWarnings({ "rawtypes" }) NamedList args) {
}
19
Source : SolrDeletionPolicy.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
@Override
public void init(@SuppressWarnings("rawtypes") NamedList args) {
String keepOptimizedOnlyString = (String) args.get("keepOptimizedOnly");
String maxCommitsToKeepString = (String) args.get("maxCommitsToKeep");
String maxOptimizedCommitsToKeepString = (String) args.get("maxOptimizedCommitsToKeep");
String maxCommitAgeString = (String) args.get("maxCommitAge");
if (maxCommitsToKeepString != null && maxCommitsToKeepString.trim().length() > 0)
maxCommitsToKeep = Integer.parseInt(maxCommitsToKeepString);
if (maxCommitAgeString != null && maxCommitAgeString.trim().length() > 0)
maxCommitAge = "-" + maxCommitAgeString;
if (maxOptimizedCommitsToKeepString != null && maxOptimizedCommitsToKeepString.trim().length() > 0) {
maxOptimizedCommitsToKeep = Integer.parseInt(maxOptimizedCommitsToKeepString);
}
// legacy support
if (keepOptimizedOnlyString != null && keepOptimizedOnlyString.trim().length() > 0) {
boolean keepOptimizedOnly = Boolean.parseBoolean(keepOptimizedOnlyString);
if (keepOptimizedOnly) {
maxOptimizedCommitsToKeep = Math.max(maxOptimizedCommitsToKeep, maxCommitsToKeep);
maxCommitsToKeep = 0;
}
}
}
See More Examples