Elasticsearch NEST FunctionScoreQuery

Hi,
I am using Elasticsearch NEST (7.17.4) with ElasticSearch 8.2.3 to build search request.
After added FunctionScoreQuery with Functions param i received exception "Can not write function score json for FunctionScoreFunction".

var funcScoreQry = new FunctionScoreQuery
                {
                    Query = boolQry,
                    Functions = GetFunctionScoreFunctions()
                };
                searchRequest.Query = funcScoreQry;
private IEnumerable<IScoreFunction> GetFunctionScoreFunctions()
        {
            var result = new List<IScoreFunction>();

            result.Add(new FunctionScoreFunction {
                Filter = new MatchQuery
                {
                    Field = "func",
                    Query = "1"
                },
                Weight = 2
            });

            return result;
        }

The Query (boolQry) is fine. If i remove Functions and just add other params (boost etc.) it's working.

The exception is thrown when i pass value to Functions property.

I coundn't find much on the problem so hope somebody could share experience using Score Functions.

Thanks

I changed FunctionScoreFunction to WeightFunction and it's working.

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