Skip to content

GeoSuggestContextDescriptor's Precision-method accepts array instead of singular value #4089

@billbogaiv

Description

@billbogaiv

NEST/Elasticsearch.Net version: 6

Elasticsearch version: 6

Description of the problem including expected versus actual behavior:

When applying Mapping within client.CreateIndex, the GeoLocation Completion-descriptor takes a collection of Precision-values. However, ES only accepts a singular value. Even passing one-value to .Precision("25mi") results in the construction of an array. This eventually leads to an ES syntax-error when creating the index.

Steps to reproduce:

public class PlaceSearchDocument
{
    [GeoPoint]
    public Location Location { get; set; }
}

client.CreateIndex("places", (CreateIndexDescriptor createDescriptor) =>
    createDescriptor.Mappings(mappingDescriptor =>
        mappingDescriptor.Map<PlaceSearchDocument>(map => map
            .AllField(af => af.Enabled(false))
            .AutoMap()
            .Properties(property => property
                .Completion(completion => completion.Name("LocationSuggest").Contexts(context => context
                    .GeoLocation(geolocation => geolocation
                        .Name("Location")
                        .Path("Location")
                        .Precision("25mi"))
                ))))));

Provide DebugInformation (if relevant):

PUT places
{
  "mappings": {
    "place": {
      "_all": {
        "enabled": false
      },
      "properties": {
        "Location": {
          "type": "geo_point"
        },
        "LocationSuggest": {
          "type": "completion",
          "contexts": [
            {
              "type": "geo",
              "name": "Location",
              "path": "Location",
              "precision": ["25mi"]
            }
          ]
        }
      }
    }
  }
}

Expected value

PUT places
{
  "mappings": {
    "place": {
      "_all": {
        "enabled": false
      },
      "properties": {
        "Location": {
          "type": "geo_point"
        },
        "LocationSuggest": {
          "type": "completion",
          "contexts": [
            {
              "type": "geo",
              "name": "Location",
              "path": "Location",
              "precision": "25mi"
            }
          ]
        }
      }
    }
  }
}

Ref.

public GeoSuggestContextDescriptor<T> Precision(params string[] precisions) => Assign(precisions, (a, v) => a.Precision = v);

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