On Sun, Dec 13, 2015 at 6:40 PM, santosh sidnal <sidnal.sant...@gmail.com> wrote: > Hi All, > > I want to define nested fileds in SOLR using schema.xml. we are using Apache > Solr 4.7.0. > > i see some links which says how to do, but not sure how can i do it in > schema.xml > https://cwiki.apache.org/confluence/display/solr/Other+Parsers#OtherParsers-BlockJoinQueryParsers > > > any help over here is appreciable. >
With nested documents, it is better to not think of them as "children", but as related documents. All the documents in your index will follow exactly the same schema, whether they are "children" or "parents", and the nested aspect of a a document simply allows you to restrict your queries based upon that relationship. Solr is extremely efficient dealing with sparse documents (docs with only a few fields defined), so one way is to define all your fields for "parent" and "child" in the schema, and only use the appropriate ones in the right document. Another way is to use a schema-less structure, although I'm not a fan of that for error checking reasons. You can also define a suffix or prefix for fields that you use as part of your methodology, so that you know what domain it belongs in, but that would just be for your benefit, Solr would not complain if you put a "child" field in a parent or vice-versa. Cheers Tom PS: I would not use Solr 4.7 for this. Nested docs are a new-ish feature, you may encounter bugs that have been fixed in later versions, and performance has certainly been improved in later versions. Faceting on a specific domain (eg, on children or parents) is only supported by the JSON facet API, which was added in 5.2, and the current stable version of Solr is 5.4.