【问题标题】:Nest ElasticSearch cannot convert Lambda expressionNest ElasticSearch 无法转换 Lambda 表达式
【发布时间】:2018-07-09 22:32:48
【问题描述】:

以下 VB 代码旨在为嵌套弹性搜索添加别名索引,但最后一行收到错误 -

“lambda 表达式无法转换为 NEST.IAliasRequest,因为 Nest.IAliasRequest 不是委托类型”

    Dim client = ConnectToSearch()

    Dim Person = New Person With {.Id=  Id, .Description = Description, .Tags = Tags}

    client.Alias(Sub(a) a.Add(Function(add) add.Index("Person").Alias("Account1")))

【问题讨论】:

    标签: nest


    【解决方案1】:
    client.[Alias](Function(descriptor) descriptor.Add(Function(a) a.Index("Person").[Alias]("Account1")))
    

    更新

    也许这个可以帮助您使用过滤器创建别名。

    client.[Alias](Function([alias]) [alias].Add(Function(a) a.Index(indexName).[Alias]("alias").Filter(Of Person)(Function(f) f.Term("relationships.staffID", staffID))))
    

    希望这会有所帮助。

    【讨论】:

    • 我添加了一个过滤器,但现在收到此错误:Type parameter 'T' for 'Public Function Filter(Of T As Class)(filterSelector As System.Func(Of Nest.FilterDescriptor(Of T ), Nest.FilterContainer)) 因为 Nest.AliasAddDescriptor' 无法推断。代码现在是:client.[Alias](Function(descriptor) descriptor.Add(Function(a) a.Index(Index).[Alias](Index & " _" & AccountId).[Routing](AccountId)。 [Filter](Function(f) f.Term("relationships.staffID", staffID)))) 抱歉还没有掌握这个。你能看出我哪里出错了吗?
    • 谢谢,我想我现在更明白了。
    • 在 VB 中,使用对象初始化器语法可能会有更好的体验,例如 New AliasRequest With { .
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-31
    • 1970-01-01
    • 1970-01-01
    • 2023-01-07
    相关资源
    最近更新 更多