@Override public void transform(SolrDocument doc, int docid) { FieldType idFt = idField.getType(); Object parentIdField = doc.getFirstValue(idField.getName()); String parentIdExt = parentIdField instanceof IndexableField ? idFt.toExternal((IndexableField)parentIdField) : parentIdField.toString(); try { Query parentQuery = idFt.getFieldQuery(null, idField, parentIdExt); Query query = new ToChildBlockJoinQuery(parentQuery, parentsFilter, false); DocList children = context.searcher.getDocList(query, childFilterQuery, new Sort(), 0, limit); if(children.matches() > 0) { DocIterator i = children.iterator(); while(i.hasNext()) { Integer childDocNum = i.next(); Document childDoc = context.searcher.doc(childDocNum); SolrDocument solrChildDoc = ResponseWriterUtil.toSolrDocument(childDoc, schema); // TODO: future enhancement... // support an fl local param in the transformer, which is used to build // a private ReturnFields instance that we use to prune unwanted field // names from solrChildDoc doc.addChildDocument(solrChildDoc); } } } catch (IOException e) { doc.put(name, "Could not fetch child Documents"); } }
protected Query createQuery(Query parentListQuery, Query query) { return new ToChildBlockJoinQuery(query, getFilter(parentListQuery), false); }