Solr nested documents : Query for child documents filtered by a parent field

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Solr nested documents : Query for child documents filtered by a parent field

Ashika Umanga Umagiliya
I have following parent-child models

parent:
--------
    public class DataSet {
    @Field
    private String id;
    @Field
    private String type="type_dataset";
    @Field
    private String name;

    @Field
    private String dataSourceId;

    @Field
    private String serviceId;

    @Field(child=true)
    private List<DataSetColumn> columns;
    }

child:
--------
     public class DataSetColumn {
        @Field
        private String id;
        @Field
        private String name;
        @Field
        private String type="type_column";
        }


I can query for parent documents filtered by fields belongs to the parent
as :

>
http://solrserver:8886/solr/BeanTest10/select?q=*:*&fq=(type:type_dataset)&fl=*,[child
> parentFilter=type:type_dataset]&wt=json&indent=true


Now I want to :

1) Query for "DataSetColumns"(child documents) filtered by serviceId
(parent field)

2) also return "dataSourceId" which is a field in parent in the response
(DataSet)

How can I achieve this ?