List of usage examples for org.apache.solr.common.util NamedList NamedList
NamedList(List<Object> nameValuePairs)
From source file:au.org.ala.biocache.web.ChartController.java
License:Open Source License
private void insertZeros(List<Map> seriesFqs) { if (seriesFqs.size() > 1) { //build list List all = new ArrayList(); for (Map s : seriesFqs) { List data = (List) s.get("data"); for (Object o : data) { if (o instanceof FieldStatsItem) { all.add(((FieldStatsItem) o).getLabel()); } else if (o instanceof FieldResultDTO) { all.add(((FieldResultDTO) o).getLabel()); }/* w w w .j av a 2 s .c om*/ } } //insert zeros Map m = new HashMap(); m.put("count", 0L); for (Map s : seriesFqs) { Set<String> current = new HashSet(all); List data = (List) s.get("data"); boolean fieldStatsItem = false; for (Object o : data) { if (o instanceof FieldStatsItem) { fieldStatsItem = true; current.remove(((FieldStatsItem) o).getLabel()); } else if (o instanceof FieldResultDTO) { current.remove(((FieldResultDTO) o).getLabel()); } } for (String c : current) { if (fieldStatsItem) { data.add(new FieldStatsItem(new FieldStatsInfo(new NamedList<>(m), c))); } else { data.add(new FieldResultDTO(c, 0)); } } //sort Collections.sort(data, new Comparator() { @Override public int compare(Object o1, Object o2) { String label1 = "", label2 = ""; if (o1 instanceof FieldStatsItem) { label1 = ((FieldStatsItem) o1).getLabel(); label2 = ((FieldStatsItem) o2).getLabel(); } else if (o1 instanceof FieldResultDTO) { label1 = ((FieldResultDTO) o1).getLabel(); label2 = ((FieldResultDTO) o2).getLabel(); } if (label1 == null) label1 = ""; if (label2 == null) label2 = ""; return label1.compareTo(label2); } }); s.put("data", data); } } }
From source file:com.lucid.solr.sidecar.SidecarIndexReaderFactoryTest.java
License:Apache License
private LocalSolrQueryRequest makeReq(SolrCore core, String... q) { if (q.length == 1) { return new LocalSolrQueryRequest(core, q[0], null, 0, 20, new HashMap<String, String>()); }//from ww w .j a v a 2 s.c o m if (q.length % 2 != 0) { throw new RuntimeException("The length of the string array (query arguments) needs to be even"); } NamedList.NamedListEntry[] entries = new NamedList.NamedListEntry[q.length / 2]; for (int i = 0; i < q.length; i += 2) { entries[i / 2] = new NamedList.NamedListEntry<String>(q[i], q[i + 1]); } return new LocalSolrQueryRequest(core, new NamedList<Object>(entries)); }
From source file:org.apache.lucene.analysis.ko.managed.ManagedKoreanDictionary.java
License:Apache License
@SuppressWarnings("unchecked") @Override// ww w . ja va 2 s . c o m public synchronized void doPut(BaseSolrResource endpoint, Representation entity, Object json) { log.info("Processing update to {}", getResourceId()); boolean updatedInitArgs = false; Object managedData = null; boolean valid = false; if (json instanceof Map) { Map<String, Object> jsonMap = (Map<String, Object>) json; if (jsonMap.containsKey(INIT_ARGS_JSON_FIELD)) { Map<String, Object> initArgsMap = (Map<String, Object>) jsonMap.get(INIT_ARGS_JSON_FIELD); updatedInitArgs = updateInitArgs(new NamedList<>(initArgsMap)); valid = true; } if (jsonMap.containsKey(WORDSET) // || jsonMap.containsKey(COMPOUNDS) // || jsonMap.containsKey(UNCOMPOUNDS)) { managedData = jsonMap; valid = true; } } if (!valid) { throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "Unsupported update format " + json.getClass().getName()); } Object updated = null; if (managedData != null) { updated = applyUpdatesToManagedData(managedData); } if (updatedInitArgs || updated != null) { storeManagedData(buildManagedMap()); } }
From source file:org.vootoo.schema.CrossCoreFieldTest.java
License:Apache License
public LocalSolrQueryRequest makeRequest(String handler, SolrCore core, int start, int limit, String... q) { if (q.length == 1) { return new LocalSolrQueryRequest(core, q[0], handler, start, limit, LocalSolrQueryRequest.emptyArgs); }//from www . j a v a2s. c om if (q.length % 2 != 0) { throw new RuntimeException("The length of the string array (query arguments) needs to be even"); } Map.Entry<String, String>[] entries = new NamedList.NamedListEntry[q.length / 2]; for (int i = 0; i < q.length; i += 2) { entries[i / 2] = new NamedList.NamedListEntry<>(q[i], q[i + 1]); } NamedList nl = new NamedList(entries); if (nl.get("wt") == null) nl.add("wt", "xml"); return new LocalSolrQueryRequest(core, nl); }