[英]How to create nested document in Solr indexing?
I want to create nested document in solr, I am using java/GWT/SolrJ. 我想在solr中创建嵌套文档,我使用的是java / GWT / SolrJ。
Currently I am indexing following fields: 目前我正在索引以下字段:
Items: 项目:
id title desc. id title desc。
1 xyz xyzxyzxyz 1 xyz xyzxyzxyz
2 pqr pqrpqrpqr 2 pqr pqrpqrpqr
3 abc abcabcabc. 3 abc abcabcabc。
But now i want to create one more document linked with each document from above ie for id 1 there is one subdocument which contains follwing fields: 但是现在我想创建一个与上面的每个文档链接的文档,即对于id 1,有一个子文档包含以下字段:
Item_User_Details: Item_User_Details:
for item 1 : 对于第1项:
user details 用户详情
1 qweqweqwe 1 qweqweqwe
2 xyzxyzxyz 2 xyzxyzxyz
3 asdasdasd 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. 通过这种方式,我想为上表中的每个项目id创建一个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. 为此,我们创建了一个自定义导入器(使用SolrJ),它从索引中加载每个文档,添加相关字段并将该文档写回。
[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, "");
this.solr = new HttpSolrServer("http://[your-url]/solr");
this.solr.add(ClientUtils.toSolrInputDocument(doc));
将它添加到索引this.solr.add(ClientUtils.toSolrInputDocument(doc));
this.solr.commit();
提交this.solr.commit();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.