Value Boost on number fields not working

Hello Elastic Community,

when creating a value boost on a number field via the appsearch ui in kibana, the value is interpreted as string and won´t boost any document.

as you can see in the search settings the created value boost contains 1 as a string

    "boosts": {
        "type": [
            {
                "type": "value",
                "factor": 10,
                "value": [
                    "1"
                ]
            }
        ]
    },

following script will be generated, which obviously wont work for a float field, when comparing "1" as a string to a float.

{
    "script_score": {
        "script": {
            "source": "Math.max(_score + (((doc.containsKey(\"type.float\") && !doc[\"type.float\"].empty && ((doc[\"type.float\"].length > 1) ? new HashSet(doc[\"type.float\"]).removeAll([\"1\"]) : [\"1\"].contains(doc[\"type.float\"].value))) ? 10.0 : 0)) - _score, 0)"
        }
    }
}

When creating the boost via the api the value is interpreted as float and the boosting works then. Is there a way to escape the value boost for numbers, so it is interpreted as float in the UI or is this a bug?

Hi CodeDan, you're absolutely right, that is a bug! Thank you for pointing it out to us, we will look into this. For now, seeing as the API allows for correct number field boosts, can you continue using the API as a workaround?

Hi nfeekery, we just changed the data type to text of the field as a workaround, as we don´t use other boost methods currently for the field.

Glad to hear that you have found a workaround! Sorry for the hassle involved there.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.