Github user dsmiley commented on a diff in the pull request:

    https://github.com/apache/lucene-solr/pull/416#discussion_r204764287
  
    --- Diff: 
solr/core/src/java/org/apache/solr/response/transform/ChildDocTransformerFactory.java
 ---
    @@ -91,15 +100,37 @@ public DocTransformer create(String field, SolrParams 
params, SolrQueryRequest r
     
         Query childFilterQuery = null;
         if(childFilter != null) {
    -      try {
    -        childFilterQuery = QParser.getParser( childFilter, req).getQuery();
    -      } catch (SyntaxError syntaxError) {
    -        throw new SolrException( ErrorCode.BAD_REQUEST, "Failed to create 
correct child filter query" );
    +      if(buildHierarchy) {
    +        childFilter = buildHierarchyChildFilterString(childFilter);
    +        return new DeeplyNestedChildDocTransformer(field, parentsFilter, 
req,
    +            getChildQuery(childFilter, req), limit);
           }
    +      childFilterQuery = getChildQuery(childFilter, req);
    +    } else if(buildHierarchy) {
    +      return new DeeplyNestedChildDocTransformer(field, parentsFilter, 
req, null, limit);
         }
     
         return new ChildDocTransformer( field, parentsFilter, uniqueKeyField, 
req.getSchema(), childFilterQuery, limit);
       }
    +
    +  private static Query getChildQuery(String childFilter, SolrQueryRequest 
req) {
    +    try {
    +      return QParser.getParser( childFilter, req).getQuery();
    +    } catch (SyntaxError syntaxError) {
    +      throw new SolrException( ErrorCode.BAD_REQUEST, "Failed to create 
correct child filter query" );
    +    }
    +  }
    +
    +  protected static String buildHierarchyChildFilterString(String 
queryString) {
    --- End diff --
    
    When writing parsing code like this, it helps tremendously to add a comment 
showing the example input.  Here you could also comment on what the resulting 
query would be.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to