Thank you, Andrea, for answering so quickly.

However I got further errors. I also had to change 
"<uniqueKey>firma_ebi_nr</uniqueKey>" to "<uniqueKey>id</uniqueKey>". But it 
still does not work properly. It seems that an id is auto generated for the 
company documents but not for the nested ones (the business branches). Any 
ideas how to fix this? 

2015-10-16 12:49:29.650 WARN  (Thread-17) [   x:jcg] o.a.s.h.d.SolrWriter Error 
creating document : 
SolrInputDocument(
    fields: [firma_ebi_nr=317709682, firma_namenszeile_1=Example Company, 
id=3c7f7421-9d51-4056-a2a0-eebab87a546a, _version_=1515192078460518400, 
_root_=3c7f7421-9d51-4056-a2a0-eebab87a546a], 
    children: [
           SolrInputDocument(fields: [branche_ebc_code=7, 
_root_=3c7f7421-9d51-4056-a2a0-eebab87a546a]), 
           SolrInputDocument(fields: [branche_ebc_code=47000, 
_root_=3c7f7421-9d51-4056-a2a0-eebab87a546a]), 
           SolrInputDocument(fields: [branche_ebc_code=47700, 
_root_=3c7f7421-9d51-4056-a2a0-eebab87a546a]), 
           SolrInputDocument(fields: [branche_ebc_code=47790, 
_root_=3c7f7421-9d51-4056-a2a0-eebab87a546a]), 
           SolrInputDocument(fields: [branche_ebc_code=47791, 
_root_=3c7f7421-9d51-4056-a2a0-eebab87a546a])])
org.apache.solr.common.SolrException: [doc=null] missing required field: id
        at 
org.apache.solr.update.DocumentBuilder.toDocument(DocumentBuilder.java:198)
        at 
org.apache.solr.update.AddUpdateCommand$1.next(AddUpdateCommand.java:191)
        at 
org.apache.solr.update.AddUpdateCommand$1.next(AddUpdateCommand.java:166)
        at 
org.apache.lucene.index.DocumentsWriterPerThread.updateDocuments(DocumentsWriterPerThread.java:259)
        at 
org.apache.lucene.index.DocumentsWriter.updateDocuments(DocumentsWriter.java:413)
        at 
org.apache.lucene.index.IndexWriter.updateDocuments(IndexWriter.java:1316)
        at 
org.apache.solr.update.DirectUpdateHandler2.addDoc0(DirectUpdateHandler2.java:235)
        at 
org.apache.solr.update.DirectUpdateHandler2.addDoc(DirectUpdateHandler2.java:163)
        at 
org.apache.solr.update.processor.RunUpdateProcessor.processAdd(RunUpdateProcessorFactory.java:69)
        at 
org.apache.solr.update.processor.UpdateRequestProcessor.processAdd(UpdateRequestProcessor.java:51)
        at 
org.apache.solr.update.processor.DistributedUpdateProcessor.doLocalAdd(DistributedUpdateProcessor.java:955)
        at 
org.apache.solr.update.processor.DistributedUpdateProcessor.versionAdd(DistributedUpdateProcessor.java:1110)
        at 
org.apache.solr.update.processor.DistributedUpdateProcessor.processAdd(DistributedUpdateProcessor.java:706)
        at 
org.apache.solr.update.processor.LogUpdateProcessor.processAdd(LogUpdateProcessorFactory.java:104)
        at 
org.apache.solr.update.processor.UpdateRequestProcessor.processAdd(UpdateRequestProcessor.java:51)
        at 
org.apache.solr.update.processor.AbstractDefaultValueUpdateProcessorFactory$DefaultValueUpdateProcessor.processAdd(AbstractDefaultValueUpdateProcessorFactory.java:94)
        at 
org.apache.solr.handler.dataimport.SolrWriter.upload(SolrWriter.java:71)
        at 
org.apache.solr.handler.dataimport.DataImportHandler$1.upload(DataImportHandler.java:259)
        at 
org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:524)
        at 
org.apache.solr.handler.dataimport.DocBuilder.buildDocument(DocBuilder.java:414)
        at 
org.apache.solr.handler.dataimport.DocBuilder.doFullDump(DocBuilder.java:329)
        at 
org.apache.solr.handler.dataimport.DocBuilder.execute(DocBuilder.java:232)
        at 
org.apache.solr.handler.dataimport.DataImporter.doFullImport(DataImporter.java:416)
        at 
org.apache.solr.handler.dataimport.DataImporter.runCmd(DataImporter.java:480)
        at 
org.apache.solr.handler.dataimport.DataImporter$1.run(DataImporter.java:461)

Kind regards,
Matthias

-----Ursprüngliche Nachricht-----
Von: Andrea Gazzarini [mailto:a.gazzar...@gmail.com] 
Gesendet: Freitag, 16. Oktober 2015 13:59
An: solr-user@lucene.apache.org
Betreff: Re: Nested entities not imported / do not show up in search?

Hi Matthias,
you should use <entity-name>.<column-name> in your expressions. So for example, 
here

WHERE fb.EBI_NR='${firma.firma_ebi_nr}'

should be

WHERE fb.EBI_NR='${firma.EBI_NR}'

Best,
Andrea

2015-10-16 13:40 GMT+02:00 Matthias Fischer <matthias.fisc...@doubleslash.de
>:

> Hello everybody,
>
> I am trying to import from an Oracle DB 11g2 via DIH using SOLR 5.3.1.
> In my relational DB there are company addresses (table 
> tb_firmen_adressen) and branches (table tb_branchen). They have an n:m 
> relationship using the join table tb_firmen_branchen.
> Now I would like to find companies by their name and in each company 
> result I would like to see the associated branches.
> However I only get the companies without the nested entries. As a 
> newbie I'd highly appreciate some help as there are no errors or 
> warnings in the log file and I could not find any helpful hints in the 
> documentation or elsewhere in the internet concerning my problem.
>
> Here is my data config:
>
>     <dataConfig>
>         <dataSource name="jdbc" driver="oracle.jdbc.driver.OracleDriver"
> url="jdbc:oracle:thin:@//xxxxx.xxxxxxx:1521/pde11" user="myuser"
> password="mysecret"/>
>     <document>
>         <entity name="firma" pk="fa.EBI_NR" query="
>             SELECT fa.EBI_NR, fa.NAMENSZEILE_1, fa.NAMENSZEILE_2,
> fa.NAMENSZEILE_3
>             FROM tb_firmen_adressen fa
>             WHERE rownum &lt; 10000
>         ">
>
>             <field name="firma_ebi_nr"                  column="EBI_NR" />
>             <field name="firma_namenszeile_1"   column="NAMENSZEILE_1" />
>             <field name="firma_namenszeile_2"   column="NAMENSZEILE_2" />
>             <field name="firma_namenszeile_3"   column="NAMENSZEILE_3" />
>
>             <entity name="firma_branche" child="true" query="
>                 SELECT b.EBC_CODE AS EBC_CODE
>                 FROM
>                     tb_firmen_branchen fb
>                         JOIN tb_branchen b ON fb.EBC_CODE = b.EBC_CODE
>                 WHERE fb.EBI_NR='${firma.firma_ebi_nr}'
>             ">
>                 <field name="branche_ebc_code" column="EBC_CODE" />
>                 <!-- I would like to add more fields later here once I 
> get it to work -->
>             </entity>
>
>         </entity>
>     </document>
>     </dataConfig>
>
>
> And here are the relevant lines from my schema file:
>
>     <uniqueKey>firma_ebi_nr</uniqueKey>
>
>      <field name="firma_ebi_nr"                 type="long"
>  required="true"         indexed="true"  stored="true"/>
>      <field name="firma_namenszeile_1"  type="text_general"
>              indexed="true"  stored="true"/>
>      <field name="firma_namenszeile_2"  type="text_general"
>              indexed="true"  stored="true"/>
>      <field name="firma_namenszeile_3"  type="text_general"
>              indexed="true"  stored="true"/>
>      <field name="branche_ebc_code"             type="long"
>                      indexed="true"  stored="true"/>
>
>
>
> After restarting solr and calling
> http://localhost:8983/solr/jcg/dataimport?command=full-import I get 
> "Indexing completed. Added/Updated: 9999 documents. Deleted 0 documents."
> So basically it seams to work, but my search results look like this:
>
> {
>   "responseHeader":{
>     "status":0,
>     "QTime":71,
>     "params":{
>       "q":"Der Bunte",
>       "defType":"edismax",
>       "indent":"true",
>       "qf":"firma_namenszeile_1",
>       "wt":"json"}},
>   "response":{"numFound":85,"start":0,"docs":[
>       {
>         "firma_ebi_nr":123123123,
>         "firma_namenszeile_1":"Der Bunte Laden",
>         "_version_":1515185579421073408},
>       {
>      ...
> }
>
> Why are there no company branches inside the company records? What's 
> wrong with my configuration? Any help is appreciated!
>
> Kind regards
> Matthias Fischer
>
>

Reply via email to