public SolrInputDocument toSolrInputDocument(SolrDocument d) { final SolrInputDocument doc = new SolrInputDocument(); for (String name : d.getFieldNames()) { doc.addField(name, d.getFieldValue(name)); } return doc; } }
for (String field : hit.getFieldNames()) { entry.put(field, new StringByteIterator(String.valueOf(hit.getFirstValue(field))));
for (String field : hit.getFieldNames()) { entry.put(field, new StringByteIterator(String.valueOf(hit.getFirstValue(field))));
SolrDocumentList results = response.getResults(); if ((results != null) && (results.getNumFound() > 0)) { for (String field : results.get(0).getFieldNames()) { result.put(field, new StringByteIterator(String.valueOf(results.get(0).getFirstValue(field))));
SolrDocumentList results = response.getResults(); if ((results != null) && (results.getNumFound() > 0)) { for (String field : results.get(0).getFieldNames()) { result.put(field, new StringByteIterator(String.valueOf(results.get(0).getFirstValue(field))));
protected static void insertChildAlerts(SolrDocument solrDocument, Map<String, Object> document) { // Make sure to put child alerts in if (solrDocument.hasChildDocuments() && solrDocument .getFieldValue(Constants.SENSOR_TYPE) .equals(MetaAlertConstants.METAALERT_TYPE)) { List<Map<String, Object>> childDocuments = new ArrayList<>(); for (SolrDocument childDoc : solrDocument.getChildDocuments()) { Map<String, Object> childDocMap = new HashMap<>(); childDoc.getFieldNames().stream() .filter(name -> !name.equals(SolrDao.VERSION_FIELD)) .forEach(name -> childDocMap.put(name, childDoc.getFieldValue(name))); childDocuments.add(childDocMap); } document.put(MetaAlertConstants.ALERT_FIELD, childDocuments); } }
public static Document toDocument(SolrDocument solrDocument) { Map<String, Object> document = new HashMap<>(); solrDocument.getFieldNames().stream() .filter(name -> !name.equals(SolrDao.VERSION_FIELD)) .forEach(name -> document.put(name, solrDocument.getFieldValue(name))); reformatComments(solrDocument, document); insertChildAlerts(solrDocument, document); return new Document(document, (String) solrDocument.getFieldValue(Constants.GUID), (String) solrDocument.getFieldValue(Constants.SENSOR_TYPE), 0L); }
protected String getAllFieldsValues ( SolrDocument solrDocument ) { StringBuilder result = new StringBuilder ( ) ; for ( String field : solrDocument.getFieldNames ( ) ) { result.append(field).append(":").append(getFieldValues(solrDocument,field)).append("\n"); } return result.toString(); }
@Override public Map<String,Object> next() { SolrDocument solrDocument = solrDocumentIterator.next(); HashMap<String,Object> map = new HashMap<>(); Collection<String> fields = solrDocument.getFieldNames(); for (String field : fields) { Object fieldValue = solrDocument.getFieldValue(field); map.put(field, fieldValue); } return map; }
void prettyPrint(PrintStream out, SolrDocument doc) { List<String> sortedFieldNames = new ArrayList<String>(doc.getFieldNames()); Collections.sort(sortedFieldNames); out.println(); for (String field : sortedFieldNames) { out.println(String.format("\t%s: %s", field, doc.getFieldValue(field))); } out.println(); } }
private void copy(SolrDocument from, SolrInputDocument to) { for (String name : from.getFieldNames()) { to.addField(name, from.getFieldValue(name)); } }
@Override public String getColumnName(int columnIndex) { if(response == null || response.getResults().size() == 0) { return ""; } List<String> list = new LinkedList<String>(response.getResults().get(0).getFieldNames()); return list.get(columnIndex); }
public SolrInputDocument toSolrInputDocument(SolrDocument document) { SolrInputDocument inputDocument = createNewSolrInputDocument(); for (String name : document.getFieldNames()) { inputDocument.addField(name, document.getFieldValue(name)); } return inputDocument; } }
public SolrInputDocument toSolrInputDocument(SolrDocument d) { final SolrInputDocument doc = new SolrInputDocument(); for (String name : d.getFieldNames()) { doc.addField(name, d.getFieldValue(name)); } return doc; } }
@Override public int getColumnCount() { if(response == null || response.getResults().size() == 0) { return 0; } return response.getResults().get(0).getFieldNames().size(); }
private static SolrInputDocument solrDocumentToSolrInputDocument(SolrDocument d) { SolrInputDocument doc = new SolrInputDocument(); for (String name : d.getFieldNames()) { doc.addField(name, d.getFieldValue(name)); } return doc; }
/** * @param d SolrDocument to convert * @return a SolrInputDocument with the same fields and values as the * SolrDocument. All boosts are 1.0f */ public static SolrInputDocument toSolrInputDocument( SolrDocument d ) { SolrInputDocument doc = new SolrInputDocument(); for( String name : d.getFieldNames() ) { doc.addField( name, d.getFieldValue(name), 1.0f ); } return doc; }
/** * @param d SolrDocument to convert * @return a SolrInputDocument with the same fields and values as the * SolrDocument. All boosts are 1.0f */ public static SolrInputDocument toSolrInputDocument( SolrDocument d ) { SolrInputDocument doc = new SolrInputDocument(); for( String name : d.getFieldNames() ) { doc.addField( name, d.getFieldValue(name), 1.0f ); } return doc; }
CloudSolrServer server = new CloudSolrServer(solrZKServerUrl); SolrQuery query = new SolrQuery(); query.setQuery("*:*"); query.setRows(Integer.MAX_VALUE); QueryResponse rsp; rsp = server.query(query, METHOD.POST); SolrDocumentList docs = rsp.getResults(); for (SolrDocument doc : docs) { Collection<String> fieldNames = doc.getFieldNames(); for (String s: fieldNames) { System.out.println(doc.getFieldValue(s)); } }
public static SolrInputDocument toSolrInputDocument(SolrDocument solrDocument) { SolrInputDocument solrInputDocument = new SolrInputDocument(); for (String name : solrDocument.getFieldNames()) { solrInputDocument.addField(name, solrDocument.getFieldValue(name)); } //Don't forget children documents if(solrDocument.getChildDocuments() != null) { for(SolrDocument childDocument : solrDocument.getChildDocuments()) { //You can add paranoic check against infinite loop childDocument == solrDocument solrInputDocument.addChildDocument(toSolrInputDocument(childDocument)); } } return solrInputDocument; } }