Solr: Set field boost at index-time with DataImportHandler

最后都变了- 提交于 2019-12-11 06:16:43

问题


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>

Please, Do you have any suggest?


回答1:


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.



来源:https://stackoverflow.com/questions/21680563/solr-set-field-boost-at-index-time-with-dataimporthandler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!