List of usage examples for org.apache.solr.common SolrInputDocument hasChildDocuments
public boolean hasChildDocuments()
From source file:org.apache.blur.slur.RowMutationHelper.java
License:Apache License
public static RowMutation from(SolrInputDocument doc, String table) { validateAsRow(doc);/*from www . j av a 2s .c o m*/ RowMutation mutate = new RowMutation(); String rowid = extractRowId(doc); mutate.setRowId(rowid); mutate.setTable(table); List<RecordMutation> recordMutations = Lists.newArrayList(); if (doc.hasChildDocuments()) { for (SolrInputDocument child : doc.getChildDocuments()) { validateAsRecord(child); recordMutations.add(createRecordMutation(child, extractRecordId(child))); } } mutate.setRecordMutations(recordMutations); return mutate; }
From source file:org.craftercms.search.service.impl.DenormalizingPostProcessor.java
License:Open Source License
@Override public void postProcess(SolrInputDocument solrDoc) { if (solrDoc.hasChildDocuments()) { Collection<SolrInputDocument> childDocs = solrDoc.getChildDocuments(); Collection<SolrInputField> parentFields = getParentFields(solrDoc); Collection<SolrInputField> childrenFields = getChildrenFields(childDocs); if (copyChildrenFieldsToParent) { copyChildrenFieldsToParent(childrenFields, solrDoc); }/*from www . j av a 2 s . com*/ if (copyParentFieldsToChildren) { copyParentFieldsToChildren(parentFields, childDocs); } } }
From source file:org.craftercms.search.service.impl.RenameFieldsIfMultiValuePostProcessor.java
License:Open Source License
@Override public void postProcess(SolrInputDocument solrDoc) { String id = solrDoc.getFieldValue(idFieldName).toString(); List<SolrInputField> renamedFields = new ArrayList<>(); // Remap single value fields to multi value fields if they have more than one value for (Iterator<SolrInputField> iter = solrDoc.iterator(); iter.hasNext();) { SolrInputField field = iter.next(); SolrInputField renamedField = renameFieldIfMultiValue(id, field); if (renamedField != null) { renamedFields.add(renamedField); iter.remove();/*from ww w . ja v a2 s . com*/ } } for (SolrInputField renamedField : renamedFields) { solrDoc.put(renamedField.getName(), renamedField); } // Do the same for child docs if (solrDoc.hasChildDocuments()) { for (SolrInputDocument childDoc : solrDoc.getChildDocuments()) { postProcess(childDoc); } } }