Solr:在数据导入处理程序中使用自定义函数
我已经成功编写了一个自定义函数并将其连接到我的 Solr 引擎中。但是,我在从 data-import.xml 导入定义文件中将参数传递到该函数时遇到问题。
我尝试过方法,一种方法从当前实体查询中传递一个字段,另一种方法尝试使用最后一个查询中的变量......似乎不起作用。
尝试 1:从当前查询中传递列:
<entity name="doc" query="SELECT id, date, ${dataimporter.functions.myfunc(id,date)} AS custom_value FROM Documents" />
这不起作用,因为 id 和日期似乎是作为文字而不是列值传递的。
尝试 2:
<entity name="doc" query="SELECT id, date FROM Documents">
<entity name="special" query="SELECT ${dataimporter.functions.myfunc(${doc.id}, ${doc.date})} AS custom_value" >
<field name="custom_value" column="custom_value" />
</entity>
</entity>
这不起作用,因为它与变量内的变量混淆了。
关于如何开展这项工作有什么建议吗?
I have successfully written a custom function and hooked it into my Solr engine. However, I am having problems passing parameters into that function from within the data-import.xml import definition file.
I have tried to methods, one which passes in a field from the current entity query, and the other approach which tries to use a variable from the last query...no seem to work.
Attempt 1: Pass in columns from current query:
<entity name="doc" query="SELECT id, date, ${dataimporter.functions.myfunc(id,date)} AS custom_value FROM Documents" />
This doesn't work as id and date seem to be passed in as literals, not the column values.
Attempt 2:
<entity name="doc" query="SELECT id, date FROM Documents">
<entity name="special" query="SELECT ${dataimporter.functions.myfunc(${doc.id}, ${doc.date})} AS custom_value" >
<field name="custom_value" column="custom_value" />
</entity>
</entity>
This doesn't work because it gets confused from the variable within the variable.
Any suggestions on how to make this work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试
Try
<entity name="doc" query="SELECT id, date, ${dataimporter.functions.myfunc(doc.id,doc.date)} AS custom_value FROM Documents" />
生成 custom_value 的另一种方法是使用转换器标签
在 Transformer_row 中,您可以向行添加更多列,或者根据需要编写自定义函数进行转换。
An other way to generate custom_value is using transformer tag
in transformer_row you can add more column to the row or write custom function to transform if you want.