I want to create nested document in solr, I am using java/GWT/SolrJ.
Currently I am indexing following fields:
Items:
id title desc.
1 xyz xyzxyzxyz
2 pqr pqrpqrpqr
3 abc abcabcabc.
But now i want to create one more document linked with each document from above i.e. for id 1 there is one subdocument which contains follwing fields:
Item_User_Details:
for item 1 :
user details
1 qweqweqwe
2 xyzxyzxyz
3 asdasdasd
in this way I want to create for each item id from above table, there is one linked document of item_user_details.
How can I do this…?
Thanks in advance…
In our schema we’ve a lot of related tables.
We decided to flatten all relations into one document. To achieve this we created a custom importer (using SolrJ), which loads each document from the index, adds the related fields and write that document back.
[edit]
We do this in the following way:
System.setProperty("solr.solr.home", config.getSolrIndexPath());CoreContainer.Initializer initializer = new CoreContainer.Initializer();this.coreContainer = initializer.initialize();this.solr = new EmbeddedSolrServer(this.coreContainer, "");Alternatively you can access a remote solr instance:
this.solr = new HttpSolrServer("http://[your-url]/solr");this.solr.add(ClientUtils.toSolrInputDocument(doc));this.solr.commit();