我是 F#(.NETCore2.0/Ubuntu) 的新用户,我正在尝试将它与 Elasticsearch 一起使用。在一个快速实验室中,我试图为每个类型定义定义一个索引。
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";
}
但我不断收到错误:
This expression was expected to have type 'IClrTypeMapping<Test>' but
here has type 'ClrTypeMappingDescriptor<Test>'
我应该为每个索引打开许多请求吗?如何在这里返回 IClrTypeMapping?
最佳答案
转发作为答案:
尝试将其添加到表达式 :> IClrTypeMapping<Test>
.接口(interface)类型需要显式转换。
关于.net - IClrTypeMapping 与 ClrTypeMappingDescriptor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52911052/