Skip to content

RankQueryQueryFormatter generates incorrect JSON #4392

Closed
@gkinsman

Description

@gkinsman

NEST/Elasticsearch.Net version:
NEST 7.5.1

Elasticsearch version:
7.6.0

Description of the problem including expected versus actual behavior:
If no function is selected, then the JSON formatter will still add a comma after the field name:

writer.WritePropertyName("field");
var fieldFormatter = formatterResolver.GetFormatter<Field>();
fieldFormatter.Serialize(ref writer, value.Field, formatterResolver);
writer.WriteValueSeparator();
switch (value.Function)
{
case IRankFeatureSigmoidFunction sigmoid:
SerializeScoreFunction(ref writer, "sigmoid", sigmoid, formatterResolver);
break;
case IRankFeatureSaturationFunction saturation:
SerializeScoreFunction(ref writer, "saturation", saturation, formatterResolver);
break;
case IRankFeatureLogarithmFunction log:
SerializeScoreFunction(ref writer, "log", log, formatterResolver);
break;
}
writer.WriteEndObject();

Steps to reproduce:

  1. Create an index with a rank_feature field
  2. Add some docs to the index with field values
  3. Query for a single field without a Function parameter.
  4. Query generated will look like: {"query":{"rank_feature":{"field":"field.prop",}}} - note the extra comma.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions