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

breaking change when applying FieldType.Object to a Dictionary<long, SomeOtherClass> and using MapFromAttributes() #926

Closed
goalie7960 opened this issue Sep 5, 2014 · 7 comments

Comments

@goalie7960
Copy link

This used to work in v0.12. Here is the class I want to index:

class SomeClass
{
    public SomeClass()
    {
        this.Data = new Dictionary<long, SomeOtherClass>();
    }

    public long ID { get; set; }

    [ElasticProperty(Type = FieldType.Object)]
    public Dictionary<long, SomeOtherClass> Data { get; set; }
}

Then I do the following mapping:

        var mapResult = client.Map<SomeClass>(m => m
            .MapFromAttributes());

I get the following exception:
"Type is not a class or interface Parameter name: type"

Call stack is as follows:
at Nest.Resolvers.ElasticAttributes._Type(Type type) in c:\Users\gmarz\code\elasticsearch-net\src\Nest\Resolvers\PropertyNameResolver.cs:line 52
at Nest.Resolvers.ElasticAttributes.Type(Type type) in c:\Users\gmarz\code\elasticsearch-net\src\Nest\Resolvers\PropertyNameResolver.cs:line 42
at Nest.Resolvers.TypeNameResolver.GetTypeNameFor(Type type) in c:\Users\gmarz\code\elasticsearch-net\src\Nest\Resolvers\TypeNameResolver.cs:line 32
at Nest.ElasticInferrer.TypeName(Type t) in c:\Users\gmarz\code\elasticsearch-net\src\Nest\ExposedInternals\ElasticInferrer.cs:line 127
at Nest.Resolvers.Writers.TypeMappingWriter.WriteProperties(JsonWriter jsonWriter) in c:\Users\gmarz\code\elasticsearch-net\src\Nest\Resolvers\Writers\TypeMappingWriter.cs:line 158
at Nest.Resolvers.Writers.TypeMappingWriter.MapFromAttributes() in c:\Users\gmarz\code\elasticsearch-net\src\Nest\Resolvers\Writers\TypeMappingWriter.cs:line 116
at Nest.Resolvers.Writers.TypeMappingWriter.RootObjectMappingFromAttributes() in c:\Users\gmarz\code\elasticsearch-net\src\Nest\Resolvers\Writers\TypeMappingWriter.cs:line 78
at Nest.PutMappingDescriptor1.MapFromAttributes(Int32 maxRecursion) in c:\Users\gmarz\code\elasticsearch-net\src\Nest\DSL\PutMappingDescriptor.cs:line 111 at ElasticSearchUpgrade.Program.<Main>b__0(PutMappingDescriptor1 m) in d:\test\ElasticSearchUpgrade\ElasticSearchUpgrade\Program.cs:line 22
at Nest.ElasticClient.Map[T](Func`2 mappingSelector) in c:\Users\gmarz\code\elasticsearch-net\src\Nest\ElasticClient-MappingType.cs:line 16
at ElasticSearchUpgrade.Program.Main(String[] args) in d:\test\ElasticSearchUpgrade\ElasticSearchUpgrade\Program.cs:line 22
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

@gmarz
Copy link
Contributor

gmarz commented Sep 5, 2014

Hey @goalie7960, I'm not able to reproduce this. What version of NEST are you running?

@goalie7960
Copy link
Author

Whatever the latest is from nuget, I think 1.0.2?

@gmarz
Copy link
Contributor

gmarz commented Sep 5, 2014

Yea, that would be 1.0.2.

Can you try writing a test (like one of these) to reproduce this? I've tried your example, but it works fine...maybe I'm missing something.

@goalie7960
Copy link
Author

gmarz added a commit that referenced this issue Sep 7, 2014
Since #731, this was causing an ArgumentException to be thrown when
mapping generic objects with value type parameters (List<int>,
Dictionary<long, string>, etc..).  The check doesn't seem necessary since
ElasticTypeAttribute is already constained to classes at compile time.

Also cleaned up PropertyNameResolver a bit.

Closes #926
@gmarz
Copy link
Contributor

gmarz commented Sep 7, 2014

@goalie7960 Good catch, I was able to reproduce this with your test. See the above PR for details.

Thanks for reporting!

@goalie7960
Copy link
Author

@gmarz Good to hear, any idea when this will be released via nuget?

@gmarz
Copy link
Contributor

gmarz commented Sep 8, 2014

@goalie7960, we are aiming for next week. In the mean time, you can grab our CI nuget package from myget: https://www.myget.org/gallery/elasticsearch-net

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