ElasticSearch NEST - FieldValueFactorFunction score function outputting invalid json query

155 views Asked by At

Let me preface this to say I'm newer to ElasticSearch and NEST, and may be doing something wrong. This is using NEST 7.6.2.
I'm following the documentation to create a field_value_factor score function containing a filter and weight using object initializer syntax, i.e.:

new FieldValueFactorFunction
{
    Field = "foo",
    Modifier = FieldValueFactorModifier.Log1P,
    Missing = 1,
    Filter = new MatchQuery
    {
        Field = "bar",
        Query = "1"
    },
    Weight = .2
}

However, at runtime it appears to output an invalid json format in the query itself:

{
    "filter": {
        "match": {
            "bar": {
                "query": "1"
            }
        }
    },
    "field_value_factor": {
        "field": "foo",
        "missing": 1.0,
        "modifier": "log1p",
        "filter": {
            "match": {
                "bar": {
                    "query": "1"
                }
            }
        },
        "weight": 0.2
    },
    "weight": 0.2
}

Which fails with the error field_value_factor query does not support [value]. I do know the valid function syntax I'm trying to emulate is the following:

{
    "filter": {
        "match": {
            "bar": {
                "query": "1"
            }
        }
    },
    "field_value_factor": {
        "field": "foo",
        "missing": 1.0,
        "modifier": "log1p"
    },
    "weight": 0.2
}

Is this a bug in NEST/Elasticsearch.net? Is my syntax incorrect? Is there an alternate way to do what I'm trying to do?

1

There are 1 answers

0
Rob On BEST ANSWER

This was apparently an issue in the version of NEST I was using. Updating the nuget package resolved it.