Example usage for org.apache.solr.common SolrDocument getChildDocuments

List of usage examples for org.apache.solr.common SolrDocument getChildDocuments

Introduction

In this page you can find the example usage for org.apache.solr.common SolrDocument getChildDocuments.

Prototype

@Override
    public List<SolrDocument> getChildDocuments() 

Source Link

Usage

From source file:net.hasor.search.server.rsf.service.AbstractSearchService.java

License:Apache License

protected SearchDocument convetTo(SolrDocument solrDocument) {
    Set<Map.Entry<String, Object>> docDataEntrySet = solrDocument.entrySet();
    SearchDocument document = new SearchDocument();
    for (Map.Entry<String, Object> entry : docDataEntrySet) {
        document.setField(entry.getKey(), entry.getValue());
    }/*from  w  w w.j a va 2s  .  c o m*/
    List<SolrDocument> solrList = solrDocument.getChildDocuments();
    if (solrList != null) {
        for (SolrDocument solrDoc : solrList) {
            document.addChildDocument(convetTo(solrDoc));
        }
    }
    return document;
}

From source file:org.apache.metron.solr.dao.SolrUtilities.java

License:Apache License

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);
        }// www .  j a va  2 s  . c  o m

        document.put(MetaAlertConstants.ALERT_FIELD, childDocuments);
    }
}