我有两个实体Person&PersonMarks,在此PersonMarks中会定期更新,因此我只需要更新Persons标记,而不是Person实体,所以我选择使用DIH的增量导入来实现。
请查看我的db-data-config.xml,其中包含Person和PersonMarks作为实体,并且还使用了ScriptTransformer。
<dataConfig>
<script><![CDATA[
function f1(row){
var subject = row.get('Subject');
var marks = row.get('Marks');
row.put(subject, marks);
return row;
}
]]></script>
<dataSource type="JdbcDataSource" driver="com.microsoft.sqlserver.jdbc.SQLServerDriver" url="jdbc:sqlserver://XIT027\MSSQLSERVER2017;databaseName=School_Management" user="admin" password="admin" />
<document>
<entity name="Person" transformer="RegexTransformer" query="Select * from Person" deltaQuery="Select * from Person" parentDeltaQuery="Select * from Person">
</entity>
<entity name="Personmarks" transformer="script:f1"
query="Select PersonId,Subject,Marks from PersonMarks where PersonId=1"
deltaQuery="Select PersonId,Subject,Marks from PersonMarks where PersonId=1"
deltaImportQuery="Select PersonId,Subject,Marks from PersonMarks where PersonId=1" >
</entity>
</document>
</dataConfig>
对“人”进行完全导入实体后,我的文档如下:
完全导入后,我的文档如下所示:
"response":{"numFound":1,"start":0,"docs":[
{
"PersonId":1,
"ClassId":[1],
"JoinDate":"2019-07-11T08:39:38.606Z",
"Name":"Rakesh Girase"
}]
完全导入后,我需要为实体PersonMarks做增量导入,不应更改文档中已经可用的Person实体
增量导入请求格式: http://localhost:8984/solr/SampleDemo/dataimport?command=delta-import&entity=PersonMarks&commit=true
此查询的查询结果(从PersonMarks中选择PersonId,Subject,Marks,其中PersonId = 1)看起来像:
PersonId Subject Marks
1 English 25
1 Marathi 28
1 Gujarati 30
完成Delta导入后,脚本转换器f1将像下面那样转换我的行:
"response":{"numFound":1,"start":0,"docs":[
{
"PersonId":1,
"English":25,
"Marathi":28,
"Gujarati":30,
"_version_":1641278401011515392
}]
但是我期望在完成增量导入后的结果是,所以它只会更新productMarks
"response":{"numFound":1,"start":0,"docs":[
{
"PersonId":1,
"ClassId":[1],
"JoinDate":"2019-07-11T08:39:38.606Z",
"Name":"Rakesh Girase"
"English":25,
"Marathi":28,
"Gujrati":30,
"_version_":1641278401011515392
}]
我不知道出了什么问题,任何帮助都将是可贵的。