elasticsearch-net icon indicating copy to clipboard operation
elasticsearch-net copied to clipboard

[FEATURE] Support AutoMap to allow creation of mappings using type inference

Open lukapor opened this issue 3 years ago • 23 comments

My trying to rewrite my code with new elasticsearch client v8-beta.1.

I am using mapping attributes on index class and AutoMap function. I did not find this feature in new version.

I hope this will be possible.

Thank You in Advance.

lukapor avatar Jul 22 '22 20:07 lukapor

Hi, @lukapor. This is not in the current beta's, but we do plan to port the functionality before GA. It's always helpful to have examples of real usage that we can test against, so if you are able to share a code snippet of where you are using this, that would be great!

stevejgordon avatar Jul 25 '22 09:07 stevejgordon

Hi, I want to write a test but I saw that you allready have test for that.

7.17/tests/Tests/ClientConcepts/HighLevel/Mapping/AttributeMapping.doc.cs

lukapor avatar Aug 18 '22 13:08 lukapor

just to know...is it implemented now on 8.x version?

meriturva avatar Mar 14 '23 10:03 meriturva

@meriturva No, this didn't make the cut for the initial release. I don't have an ETA for us re-introducing it yet.

stevejgordon avatar Mar 14 '23 10:03 stevejgordon

@stevejgordon What would your advice be for my usecase: I want to use the inferred mapping for all properties of my type except for the one I want to set explicitly. I can't seem to find a way to do that through the .DefaultMappingFor method. Must I call .CreateIndexAsync and explicitly map out the whole object by hand?

Expanded usecase: I want to map all Guid properties to type keyword, but other than that keep the default mappings. Any advice for this is welcome, because I'm stuck on this for hours.

ErroneousFatality avatar Jul 15 '23 21:07 ErroneousFatality

I am also in need of mapping attributes in v8. My problem is in NEST v7, the densevector attribute is missing the index and similarity properties. It’s not clear to me how to me how to enable index=true and similarity=“dot_product” on new index mapping without those attribute properties. Assuming NEST v7 won’t be updated, please enable attribute mapping in v8 and include the index and similarity options for densevector.

mwrothbe-intc avatar Aug 07 '23 15:08 mwrothbe-intc

@mwrothbe-intc Manual mapping is already possible using the v8 client. This issue is only about the missing AutoMap functionality 🙂

For your case, something like this should work:

var mapResponse = client.Indices.PutMapping("index", x => x
    .Properties<Person>(p => p
        .DenseVector(x => x.Data, d => d
            .Index(true)
            .Similarity("dot_product"))));

flobernd avatar Aug 17 '23 10:08 flobernd

any idea when AutoMap will be added? still on v7, been waiting for this feature

huey2531 avatar Aug 17 '23 19:08 huey2531

hi, i agree also, the AutoMap Feature is near a "must have", if the index creation is fully OO driven, otherwise there is only a manual way with a static json mapping file usage, or write a own AutoMapper Function, But this seems not so trivial, if i take a look on the old AutoMapper code by the client 7.x. @stevejgordon what is your recommendation pls for a workaround about this missing AutoMap function?

sbodese avatar Aug 31 '23 11:08 sbodese

Steve is no longer maintaining the library (this is now my job). Until I reintroduce auto-mapping, your options are:

  • Use the v7 NEST client in compatibility mode just for index creation (it can be used side-by-side with the new v8 client)
  • Use manual mapping (like described in my previous comment)
  • Write your own auto-mapper implementation based on the NEST code

That being said, I'm fully aware this is one of the more frequently requested features, but I can't give you any definitive ETA.

flobernd avatar Aug 31 '23 12:08 flobernd

Hi @flobernd i got some APi issues with the index creation / mapping comparison by the nest 7.15.5 client, if i use the newer .map(...) api calls

https://github.com/elastic/elasticsearch-net/issues/7929

i have solved this issues with the older .mappings(... ) APi usage.

sbodese avatar Sep 13 '23 12:09 sbodese

I tried to use old NEST client to Automap, and it fails on enums.

DR9885 avatar Jan 09 '24 22:01 DR9885

Hi, @lukapor. This is not in the current beta's, but we do plan to port the functionality before GA. It's always helpful to have examples of real usage that we can test against, so if you are able to share a code snippet of where you are using this, that would be great!

So it's now 2024 and the NEST client is deprecated in nuget. Is there an ETA on this functionality? ... or should this issue have been closed as "won't do" and users need to switch to fluent mapping?

https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/release-notes-8.0.0.html#_attribute_mappings_2 mentions removal of attribute mappings and sounds like it won't come back, but https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/release-notes-8.0.0.html#_missing_features_2 OTOH mentions "AutoMap for field datatype inference" as being re-introduced. Can you elaborate on what to expect on an upcoming AutoMap functionality?

pschwarzpp avatar Apr 11 '24 06:04 pschwarzpp