I'm facing a very weird problem. Here is my case. My documents is composed of 2 entities, each one from different databases. Below is part of my bd-data-config.xml (some code has been modified/stripped for security purpose)
<document>
<entity name="process_oracle" datasource="oracle" query="
select 'oracle-' || p.process_id as id, p.process_id from tb_process p">
<field column="process_id" name="process_id"/>
<entity name="subject" datasource="oracle" query="
select distinct sub.subject
from tb_subject sub, tb_process_subject prc_sub
where sub.id_subject = prc_sub.id_subject
and prc_sub.id_process = ${process_oracle.process_id}">
<field column="subject" name="subject"/>
</entity>
</entity>
<entity name="process_postgresql" datasource="postgresql" query="
select 'postgresql-' || p.process_id as id, p.process_id from tb_process p">
<field column="process_id" name="process_id"/>
<entity name="subject" datasource="postgresql" query="
select distinct sub.subject
from tb_subject sub, tb_process_subject prc_sub
where sub.id_subject = prc_sub.id_subject
and prc_sub.id_process = ${process_postgresql.process_id}">
<field column="subject" name="subject"/>
</entity>
</entity>
</document>
When I execute the import, it runs normally. No error is reported at Web Admin interface nor at log, althought, here is the weird thing. Whilst the subjects of process_postgresql are indexed, the subjects of process_oracle are not. Here a small piece of the output query.
{
"responseHeader":{
"status":0,
"QTime":0,
"params":{
"q":"*:*",
"_":"1583958908786"}},
"response":{"numFound":7,"start":0,"docs":[
{
"process_id":"oracle-1"
},
...
{
"process_id":"postgresql-12",
"subject":["subject1", "subject2"]
}
}
}
As you can see, the subjects from postgresql are indexed, meanwhile those from oracle are not. When I checked the log (run in debug mode) I noticed this:
2020-03-13 11:52:47.085 DEBUG (Thread-33) [ ] o.a.s.h.d.JdbcDataSource Executing SQL: select distinct sub.subject from tb_subject sub, tb_process_subject prc_sub where sub.id_subject = prc_sub.id_subject and prc_sub.id_process = ... 2020-03-13 11:52:47.953 DEBUG (Thread-33) [ ] o.a.s.h.d.JdbcDataSource Executing SQL: select distinct sub.subject from tb_subject sub, tb_process_subject prc_sub where sub.id_subject = prc_sub.id_subject and prc_sub.id_process = 12
As you can see, the problem is that the variable ${process_oracle.process_id} is not been set, meanwhile the variable ${process_postgresql.process_id} runs just fine.
Does anyone have a clue of why is it happening?
Best Regards
After few days, I could solve the problem. The variable must be in upper case. So It must look like that:
<document>
<entity name="process_oracle" datasource="oracle" query="
select 'oracle-' || p.process_id as id, p.process_id from tb_process p">
<field column="process_id" name="process_id"/>
<entity name="subject" datasource="oracle" query="
select distinct sub.subject
from tb_subject sub, tb_process_subject prc_sub
where sub.id_subject = prc_sub.id_subject
and prc_sub.id_process = ${process_oracle.PROCESS_ID}">
<field column="subject" name="subject"/>
</entity>
</entity>
<entity name="process_postgresql" datasource="postgresql" query="
select 'postgresql-' || p.process_id as id, p.process_id from tb_process p">
<field column="process_id" name="process_id"/>
<entity name="subject" datasource="postgresql" query="
select distinct sub.subject
from tb_subject sub, tb_process_subject prc_sub
where sub.id_subject = prc_sub.id_subject
and prc_sub.id_process = ${process_postgresql.PROCESS_ID}">
<field column="subject" name="subject"/>
</entity>
</entity>
</document>
That's it. As simple as that.