i've build a solr-index like here: https://wiki.apache.org/solr/DataImportHandler
I used something like this in my data-config.xml:
<entity name="article" pk="id" query="Select * from msp_article">
<field column="id" name="id"/>
<field column="title" name="docTitle"/>
<field column="orgRef" name="ref" />
<entity name="text" query="select content from msp_articleText where fk_articleId='${article.id}'">
<field column="content" name="textContent"/>
</entity>
</entity>
When look in my db and test the keys, i get in the msp_articleText 3 rows, but in the solr-index its only the first row.
What's wrong here? Please help
Try to have a single query using the join like below
Select * from msp_article ma, msp_articleText mat where mat.fk_articleId = ma.msp_article.id
and then have the fields like
<field column="id" name="id"/>
<field column="title" name="docTitle"/>
<field column="orgRef" name="ref" />
<field column="content" name="textContent"/>
It should be like :
<entity name="article" pk="id" query="Select * from msp_article , msp_articleText where fk_articleId = msp_article.id">
<field column="id" name="id"/>
<field column="title" name="docTitle"/>
<field column="orgRef" name="ref" />
<field column="content" name="textContent"/>
</entity>
You can build your own query as you want, I just wanted to convey that instead of 2 entities go for one where you will have a join query.
Thanks, but can this work? When i try it i get 3 rows with same id. The id is the pk for solr.
For the moment i use SELECT GROUP_CONCAT(content) because the content is to big, i put it in a procedure
CREATE PROCEDURE `msp_bla`(IN con CHAR(20))
BEGIN
SET SESSION group_concat_max_len = 1000000;
SELECT GROUP_CONCAT(content) as content from msp_articleText WHERE fk_articleId = con group by fk_articleId;
END
And in my data-config.xml i use
<entity name="text" query="call msp_bla('${article.id}')">
It works, but im not happy with that.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.