Update,

I checked with the following example as well and this also flattens the
results.

I took the example from here -
https://issues.apache.org/jira/browse/SOLR-1945


package com.airplus.poc.edl.spark.auditeventindexer;
import java.io.IOException;

import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.beans.Field;
import org.apache.solr.client.solrj.impl.CloudSolrClient;

/**
 * @author Biplob Biswas on 19.05.2017.
 */

public class SolrNestedTest {

  public static void main(String[] args) throws IOException,
          SolrServerException {
    new SolrNestedTest().test();
  }

  public void test() throws IOException, SolrServerException {

    String zkHostString = "host:2181/solr";
    CloudSolrClient client = new CloudSolrClient(zkHostString);

    Test test = new Test();
    test.setId("2");
    Child c = new Child();
    c.child = true;
    c.id = "1";
    test.setChild(c);
    client.addBean("event_store", test, 10);

    client.close();

  }

  public class Child {
    @Field
    public String id;
    @Field
    public boolean child;
  }

  public class Test {

    @Field
    private String id;

    @Field(child = true)
    private Child child;

    public String getId() {
      return id;
    }

    public void setId(String id) {
      this.id = id;
    }

    public Child getChild() {
      return child;
    }

    public void setChild(Child child) {
      this.child = child;
    }

  }
}



The response back  - 

{
  "responseHeader": {
    "status": 0,
    "QTime": 8,
    "params": {
      "q": "*:*",
      "indent": "true",
      "wt": "json",
      "_": "1495194572357"
    }
  },
  "response": {
    "numFound": 2,
    "start": 0,
    "maxScore": 1,
    "docs": [
      {
        "id": "1",
        "child": [
          true
        ]
      },
      {
        "id": "2",
        "_version_": 1567825059298410500
      }
    ]
  }
}



--
View this message in context: 
http://lucene.472066.n3.nabble.com/Nested-Document-is-flattened-even-with-Field-child-true-annotation-tp4335877p4335878.html
Sent from the Solr - User mailing list archive at Nabble.com.

Reply via email to