solr支持嵌套文档吗?有没有更好的方法来实现这种文档?
<doc>
<field name="name">Mr. Test</field>
<field name="case">
<field name="link">http://foo.com</field>
<field name="date">1-2-1234</filed>
<field name="title">My title</filed>
</field>
<field name="case">
<field name="link">http://foo.com/2/</field>
<field name="date">1-2-1234</filed>
<field name="title">My title 2</filed>
</field>
</doc>
我所拥有的是一个参与过多个案件的人。这种形式的模式对于 solr 来说合法吗?不同的人也可以参与同一案件。所以它看起来确实像是关系数据库的任务,但我在这个项目中使用 solr。
新版本的 Solr 提供了对嵌套文档的支持
索引这个 Json
[
{
"id": "1",
"title": "Solr adds block join support",
"content_type": "parentDocument",
"_childDocuments_": [
{
"id": "2",
"comments": "SolrCloud supports it too!"
}
]
},
{
"id": "3",
"title": "Lucene and Solr 4.5 is out",
"content_type": "parentDocument",
"_childDocuments_": [
{
"id": "4",
"comments": "Lots of new features"
}
]
}
]
在 schema.xml 中,您必须添加此处使用的所有字段,即“标题”、“内容类型”、“评论”。参数“子文件" 是 solr 所关心的参数,通过它它可以理解这是一个子文档,而 "content_type": "parentDocument" 是 solr 理解这是父文档的标识符。在索引此 Json 后,如果我们查询
"*":"*"
我们总共应该看到 4 个文档。现在我们可以在以下工具的帮助下获取父母或孩子的文件块和连接查询解析器 https://cwiki.apache.org/confluence/display/solr/Other+Parsers#OtherParsers-BlockJoinQueryParsers。尝试这个查询
http://localhost:8983/solr/collection_test/select?q={!child%20of=%22content_type:parentDocument%22}title:lucene
和这个
http://localhost:8983/solr/collection_test/select?q={!parent%20which=%22content_type:parentDocument%22}comments:SolrCloud
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)