Solr:使用DataImportHandler在索引时设置字段增强 [英] Solr: Set field boost at index-time with DataImportHandler

查看:162
本文介绍了Solr:使用DataImportHandler在索引时设置字段增强的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用DataImportHandler在索引时设置字段增强. 我试图做这样的事情:

I need to set a field boost at index-time with DataImportHandler. I tried to do somethings like this:

<entity name="places"  
    query="Select id, boost, text from table">
<field name="id"    column="id" />
<field name="boost"     column="boost"  />
<field name="1_text"  column="text"  boost="${boost}" />
</entity>

但是它不起作用.那是错误:

but it doesn't works. That is the error:

Caused by: java.lang.NumberFormatException: For input string: "${boost}"

我做过的另一种尝试是也尝试使用脚本(一个转换器,但是我不知道在现场设置助推器的语法):

An other approch that i did is to try also to use a script (an transformer, but i don't know the syntax to set the boost at field):

<script><![CDATA[
                function addfield(row){
                    var fieldName = row.get('id') + "_text"
                    row.put(fieldName, row.get('text'));
                    return row;
                }
            ]]></script>

请,您有什么建议吗?

推荐答案

不幸的是,除非您在实体中指定了静态增强值,否则不支持变压器中每个字段的动态增强.有一种方法可以设置文档增强功能,但是它将影响文档中的所有字段,例如:

Unfortunately there is no support for dynamic boosting per field in the transformer, unless you specify a static boost value in the entity. There is a way to set a document boost, but it will affect all the fields in the doc like:

 row.put('$docBoost', row.get('boost'));

如果这不是您所需要的,我建议您查看提高查询时间,因为您已经存储了提升"字段.

If this is not what you need I would recommend to look at the query time boosting since you already store the "boost" field.

这篇关于Solr:使用DataImportHandler在索引时设置字段增强的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆