Github user moshebla commented on a diff in the pull request: https://github.com/apache/lucene-solr/pull/416#discussion_r205965045 --- Diff: solr/core/src/java/org/apache/solr/response/transform/DeeplyNestedChildDocTransformer.java --- @@ -0,0 +1,224 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.solr.response.transform; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.Multimap; +import org.apache.lucene.index.DocValues; +import org.apache.lucene.index.IndexableField; +import org.apache.lucene.index.LeafReaderContext; +import org.apache.lucene.index.SortedDocValues; +import org.apache.lucene.search.Query; +import org.apache.lucene.search.Sort; +import org.apache.lucene.search.SortField; +import org.apache.lucene.search.join.BitSetProducer; +import org.apache.lucene.search.join.ToChildBlockJoinQuery; +import org.apache.lucene.util.BytesRef; +import org.apache.solr.common.SolrDocument; +import org.apache.solr.request.SolrQueryRequest; +import org.apache.solr.response.DocsStreamer; +import org.apache.solr.schema.FieldType; +import org.apache.solr.schema.IndexSchema; +import org.apache.solr.schema.SchemaField; +import org.apache.solr.search.DocIterator; +import org.apache.solr.search.DocList; +import org.apache.solr.search.SolrDocumentFetcher; +import org.apache.solr.search.SolrIndexSearcher; +import org.apache.solr.search.SolrReturnFields; + +import static org.apache.solr.response.transform.ChildDocTransformerFactory.NUM_SEP_CHAR; +import static org.apache.solr.response.transform.ChildDocTransformerFactory.PATH_SEP_CHAR; +import static org.apache.solr.schema.IndexSchema.NEST_PATH_FIELD_NAME; + +class DeeplyNestedChildDocTransformer extends DocTransformer { + + private final String name; + protected final SchemaField idField; + protected final SolrQueryRequest req; + protected final IndexSchema schema; + private BitSetProducer parentsFilter; + protected int limit; + private final static Sort docKeySort = new Sort(new SortField(null, SortField.Type.DOC, false)); + private Query childFilterQuery; + + public DeeplyNestedChildDocTransformer(String name, final BitSetProducer parentsFilter, + final SolrQueryRequest req, final Query childFilterQuery, int limit) { + this.name = name; + this.schema = req.getSchema(); + this.idField = this.schema.getUniqueKeyField(); + this.req = req; + this.parentsFilter = parentsFilter; + this.limit = limit; + this.childFilterQuery = childFilterQuery; + } + + @Override + public String getName() { + return name; + } + + @Override + public String[] getExtraRequestFields() { + // we always need the idField (of the parent) in order to fill out it's children + return new String[] { idField.getName() }; --- End diff -- Perhaps since _root_ is added to every document, we could use that field instead of the ID field? This is just a thought that popped into my head.
--- --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org