问题
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