Apache Solr multicast mapping

I use Solr to index my report database. Reports may contain text, information about submitters, etc. This currently works and looks like this:

"docs": [ { "Text": "Some Report Text" "ReportId": "1", "Date": "2013-08-09T14:59:28.147Z", "SubmitterId": "11111", "FirstName": "John", "LastName": "Doe", "_version_": 1444554112206110700 } ] 

Otherwise, what a report can have is viewers (this is a one-to-many relationship between one report and viewers.) I want to be able to capture these viewers like this in my JSON release:

 "docs": [ { "Text": "Some Report Text" "ReportId": "1", "Date": "2013-08-09T14:59:28.147Z", "SubmitterId": "11111", "FirstName": "John", "LastName": "Doe", "Viewers": [ { ViewerId: "22222" }, { ViewerId: "33333" } ] "_version_": 1444554112206110700 } ] 

I can not seem that this will happen. Here is my data-config.xml (removed parts that are not needed for the question):

 <entity name="Report" query="select * from Reports"> <field column="Text" /> <field column="ReportId" /> <!-- Get Submitter Information as another entity. --> <entity name="Viewers" query="select * from ReportViewers where Id='${Report.ReportId}'"> <field column="Id" name="ViewerId" /> </entity> </entity> 

And schema.xml :

 <field name="Text" type="text_en" indexed="true" stored="true" /> <field name="ReportId" type="string" indexed="true" stored="true" /> <field name="Viewers" type="string" indexed="true" stored="true" multiValued="true" /> <field name="ViewerId" type="string" indexed="true" stored="true" /> 

When I import data, I don’t see anything. There are no errors, nothing is clearly wrong, but I'm sure my config-data and / or my schema is wrong. What am I doing wrong?

+4
source share
1 answer

Unfortunately, Solr does not allow nesting (see http://lucene.472066.n3.nabble.com/Possible-to-have-Solr-documents-with-deeply-nested-data-structures-ie-hashes-within- hashes-td4004285.html ). You need to smooth your data!

So

 "Viewers": [ { ViewerId: "22222" }, { ViewerId: "33333" } ] 

impossible. Instead, flatten it and get an array of ViewerIds :

 "ViewerIds": ["22222", "33333" ] 

In your circuit you will have:

 <field name="ViewerIds" type="string" indexed="true" stored="true" multiValued="true" /> 

and modify your data configuration accordingly.

+8
source

Source: https://habr.com/ru/post/1499239/


All Articles