-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Inheritance from abstract type not working #1682
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
Comments
You need to either specify Hope this helps!
I'm not sure I quite follow? Mind explaining what you meant with that statement ? 😄 |
Hah, I didn't realize this but it makes total sense. FWIW docs on how to do inheritance would probably avoid this for someone else. I kind of made this up as I went from various comments you've made on here and StackOverflow. I was under the impression that if you have a parent-child relationship and the parent type has mappings set up, the child will inherit those mappings. Does that not work for fluent mappings? |
I'm actually doing a Search/Scroll operation and the Scroll has no ability to specify types or a |
Types should inherit mappings when you call MapFromAttributes() and call https://nest.azurewebsites.net/nest/search/basics.html has some docs on the covariance albeit very terse 😄 The |
The following is the mapping logic called on a
CommonForActivity:
|
This is expected behaviour, it would be hard for us to stitch two mappings together I think, abstracting too shared methods is the way to go. Open to suggestions though! |
👍 Nah that's fine, just wanted to verify. I agree stitching would be strange, it just wasn't clear from the docs. The scroll thing is unfortunately a major blocker for me. If you don't have time to fix this ASAP, can you point me in the right direction so I can fix and pull request? |
This is now also implemented in 2.0 |
I've got an abstract base class of type
Activity
and subtypes of a variety of types, includingSearched
.For mappings, I fluent-mapped
Activity
but was forced when fluent-mappingSearched
to remap everything mapped onActivity
.On the storage side, I do for example
client.Index<Activity>(instanceOfSearched, x => x.Index("Activities").Type(typeof(Searched)))
.When I search, using
client.Search<Activity>(x => x.Indices("Activity").AllTypes().MatchAll())
, I getJsonSerializationException
s based around an inability to instantiateActivity
because it is abstract. It doesn't seem to notice that the stored type is actually aSearched
.The text was updated successfully, but these errors were encountered: