Java Code Examples for org.apache.solr.common.SolrDocument#forEach()
The following examples show how to use
org.apache.solr.common.SolrDocument#forEach() .
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: ExportTool.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings({"unchecked", "rawtypes"}) public synchronized void accept(SolrDocument doc) throws IOException { charArr.reset(); Map m = new LinkedHashMap(doc.size()); doc.forEach((s, field) -> { if (s.equals("_version_") || s.equals("_roor_")) return; if (field instanceof List) { if (((List) field).size() == 1) { field = ((List) field).get(0); } } field = constructDateStr(field); if (field instanceof List) { List list = (List) field; if (hasdate(list)) { ArrayList<Object> listCopy = new ArrayList<>(list.size()); for (Object o : list) listCopy.add(constructDateStr(o)); field = listCopy; } } m.put(s, field); }); jsonWriter.write(m); writer.write(charArr.getArray(), charArr.getStart(), charArr.getEnd()); writer.append('\n'); super.accept(doc); }
Example 2
Source File: ExportTool.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public synchronized void accept(SolrDocument doc) throws IOException { int sz = doc.size(); if(doc.containsKey("_version_")) sz--; if(doc.containsKey("_root_")) sz--; codec.writeTag(SOLRINPUTDOC, sz); codec.writeFloat(1f); // document boost doc.forEach(bic); super.accept(doc); }
Example 3
Source File: ConverterService.java From chronix.server with Apache License 2.0 | 3 votes |
/** * Converts a solr document to a time series. * <p> * The resulting time series does not contain user defined attributes present in the solr document * (see {@link de.qaware.chronix.Schema#isUserDefined(String)} ). * * @param solrDoc the solr document * @return time series representing the given solr document */ public MetricTimeSeries toTimeSeries(SolrDocument solrDoc) { BinaryTimeSeries.Builder btsBuilder = new BinaryTimeSeries.Builder(); solrDoc.forEach(field -> btsBuilder.field(field.getKey(), field.getValue())); BinaryTimeSeries bts = btsBuilder.build(); long start = (long) solrDoc.get(START); long end = (long) solrDoc.get(END); return converter.from(bts, start, end); }