Search code examples
.netelasticsearchf#asp.net-core-2.0nest

IClrTypeMapping vs ClrTypeMappingDescriptor


I'm a new user of F#(.NETCore2.0/Ubuntu) and i'm trying to use it with Elasticsearch. In a quick Lab i'm trying to define an index for each type definition .

open System
open Nest

type Test = {
    Id: int
    FirstName: string
    FullName: string
} 

[<EntryPoint>]
let main argv =
    // Configuration
    let node = new Uri("http://127.0.0.1:9200")
    let settings = new ConnectionSettings(node)
    settings.DefaultIndex("index-default")
    settings.DefaultMappingFor<Test>(fun m-> m.IndexName("test-index")) |> ignore

    let testeDoc = {
        Id=1;
        FirstName="Lucas";
        FullName="Peixoto";
    }

But i keep getting the error:

This expression was expected to have type 'IClrTypeMapping<Test>' but 
here has type 'ClrTypeMappingDescriptor<Test>'  

Should I open many requests for each index? How can I return an IClrTypeMapping here?


Solution

  • Reposting as an answer:

    try adding this to the expression :> IClrTypeMapping<Test>. Interface types need to be cast explicitly.