When using Solr you are probably used to having a flat structure of documents without any relationships. However, there are situations where decomposing relationships is a cost we can't take. Because of that Solr 4.0 comes with a join functionality that allows us to use some basic relationships. For example, imagine that our index consists of books and workbooks and we would like to use that relationship. This recipe will show you how to do it.
First of all, let's assume that we have the following index structure (just place the following in the
fields
section of yourschema.xml
file):<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" /> <field name="name" type="text" indexed="true" stored="true" multiValued="false"/> <field name="type" type="string" indexed="true" stored="true"/> <field name="book" type="string" indexed="true" stored="true"/>
Now let's look at our test data...