Skip to content

SetDefaultFields across properties of different data types will generate an invalid multi-match query. #169

@niemyjski

Description

@niemyjski

Let's say you call this

protected override void ConfigureQueryParser(ElasticQueryParserConfiguration config)
{
    base.ConfigureQueryParser(config);
    config.SetDefaultFields([
        "id",
        "number"
    ])
}

and your index mapping is

public override TypeMappingDescriptor<MyRecord> ConfigureIndexMapping(TypeMappingDescriptor<MyRecord> map)
{
    return map
        .Dynamic(false)
        .Properties(p => p
            .SetupDefaults()
            .Keyword(f => f.Name(o => o.Id))
            .Number(f => f.Name(o => o.Number))
        );
    }

with filter test and will error as it's searching across multiple field types.

POST /my-record/_search?pretty=true&error_trace=true&typed_keys=true&ignore_unavailable=true
{
  "query": {
    "multi_match": {
      "query": "test",
      "fields": [
          "id",
          "number"
      ]
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions