Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ElasticType attribute issue #806

Closed
chrisdrobison opened this issue Jul 17, 2014 · 1 comment
Closed

ElasticType attribute issue #806

chrisdrobison opened this issue Jul 17, 2014 · 1 comment
Milestone

Comments

@chrisdrobison
Copy link

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.

@gmarz gmarz added this to the NEST 1.0.1 milestone Jul 22, 2014
@gmarz gmarz added the Bug label Jul 22, 2014
@gmarz gmarz closed this as completed in 1a27fbf Jul 28, 2014
@gmarz
Copy link
Contributor

gmarz commented Jul 28, 2014

@chrisdrobison this was indeed a bug. Good catch and thank you for reporting. I've pushed the above commit which addresses the issue.

gmarz added a commit that referenced this issue Aug 1, 2014
Update was only inferring the doc id from Upsert and not Doc as well.
Additionally, a NullArgumentException was being thrown when specifying the
id property via the ElasticType attribute due to the order in which route
parameters were being validated (checking id before UpdatePathInfo() was
being called).

Closes #806
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants