Skip to content

ElasticType attribute issue #806

@chrisdrobison

Description

@chrisdrobison

I'm using the RC1 nuget package. I'm using the ElasticType attribute to specify the IdProperty of a poco.

[ElasticType(Name = "pricelistitem", IdProperty = "Code")]
public class PriceListItem
{
    [ElasticProperty(Name = "code")]
    public string Code { get; set; }

    [ElasticProperty(Name = "category")]
    public string Category { get; set; }

    [ElasticProperty(Name = "selector")]
    public string Selector { get; set; }

    [ElasticProperty(Name = "description")]
    public string Description { get; set; }

    [ElasticProperty(Name = "definition")]
    public string Definition { get; set; }

    [ElasticProperty(Name = "popularity")]
    public double Popuarity { get; set; }

    [ElasticProperty(Name = "grade_popularity")]
    public double GradePopularity { get; set; }

    [ElasticProperty(Name = "refsearchrefinedtopics")]
    public HashSet<string> RefSearchRefinedTopics
    {
        get { return _refSearchRefinedTopics; }
        set { _refSearchRefinedTopics = value; }
    }

    [ElasticProperty(Name = "sharedpricelists")]
    public HashSet<string> SharedPriceLists
    {
        get { return _sharedPriceLists; }
        set { _sharedPriceLists = value; }
    }

    [ElasticProperty(Name = "filters")]
    public HashSet<string> Filters
    {
        get { return _filters; }
        set { _filters = value; }
    }
}

I have a method I call (the _client being the ElasticClient):

    public void Update(PriceListItem priceListItem)
    {
        _client.Update<PriceListItem>(descriptor => descriptor.DocAsUpsert().Document(priceListItem));
    }

I get the following exception:

System.ArgumentNullException: Value cannot be null.
Parameter name: id
   at Nest.Extensions.ThrowIfNullOrEmpty(String object, String parameterName) in c:\code\elasticsearch-net\src\Nest\Extensions\Extensions.cs:line 71
   at Nest.DocumentPathDescriptor`3.SetRouteParameters(IConnectionSettingsValues settings, ElasticsearchPathInfo`1 pathInfo) in c:\code\elasticsearch-net\src\Nest\DSL\Paths\DocumentPathDescriptor.cs:line 51
   at Nest.BaseRequest`1.ToPathInfo(IConnectionSettingsValues settings, TParameters queryString) in c:\code\elasticsearch-net\src\Nest\DSL\Common\BaseRequest.cs:line 44
   at Nest.BaseRequest`1.Nest.IPathInfo<TParameters>.ToPathInfo(IConnectionSettingsValues settings) in c:\code\elasticsearch-net\src\Nest\DSL\Common\BaseRequest.cs:line 61
   at Nest.ElasticClient.Dispatch[D,Q,R](D descriptor, Func`3 dispatch) in c:\code\elasticsearch-net\src\Nest\ElasticClient.cs:line 83
   at Nest.ElasticClient.Dispatch[D,Q,R](Func`2 selector, Func`3 dispatch) in c:\code\elasticsearch-net\src\Nest\ElasticClient.cs:line 72
   at Nest.ElasticClient.Update[T,K](Func`2 updateSelector) in c:\code\elasticsearch-net\src\Nest\ElasticClient-Update.cs:line 27
   at Nest.ElasticClient.Update[T](Func`2 updateSelector) in c:\code\elasticsearch-net\src\Nest\ElasticClient-Update.cs:line 13
   at XactPrm.Search.ElasticSearch.EsPriceListSearcher.Update(PriceListItem priceListItem) in c:\development\prm-online\XactPrm.Search\ElasticSearch\EsPriceListSearcher.cs:line 27

This used to work with the beta version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions