documento anidado índice solr
Frecuentes
Visto 3,135 veces
1
Does solr support nested documents? And is there a better way to achieve this sort of document?
<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>
What I have is a person that has been part of multiple cases. Is this form of schema legal with solr? A different person can also be part of the same case. So it does look like a task for a relational database, but I'm using solr for this project.
2 Respuestas
4
Newer versions of Solr provides support for Nested Documents
Index this 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"
}
]
}
]
Into schema.xml, u have to add all the fields which are getting used here that is "title","content_type","comments". The parameter "childDocuments" is the parameter which solr takes care and with which it understands this is a child document and "content_type": "parentDocument" is the identifier for solr to understand that this is parent document. After indexing this Json if we query
"*":"*"
We should see 4 documents in all. Now we can get parent or child documents with the help of Bloquear y unir analizadores de consultas. Try this queries
http://localhost:8983/solr/collection_test/select?q={!child%20of=%22content_type:parentDocument%22}title:lucene
y éste
http://localhost:8983/solr/collection_test/select?q={!parent%20which=%22content_type:parentDocument%22}comments:SolrCloud
Respondido 27 Oct 15, 04:10
3
No, Solr doesn't support that nested structure. Have a look at esta otra pregunta
contestado el 23 de mayo de 17 a las 13:05
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas xml solr indexing or haz tu propia pregunta.
There is some error in your json format. There should be a "[" after "childDocuments": - lijo abraham
@Lijo: thnks..I changed it. - Gunjan
:- If I want to index like below in solr,How can I do it? [{ "id": "1", "company_id": "1", "company_name" : "company_1", "meta_categories": [ { "cat_id": "1", "cat_name": "fashion" }, { "cat_id": "2", "cat_name": "sports" } ], "main_categories": [ { "cat_name": "1", "cat_name": "fashion" }, { "cat_name": "2", "cat_name": "sports" } ] - lijo abraham