1

我在工作中经常使用elasticsearch(来自Python),但想将它整合到我在业余时间正在做的一个小.Net项目中。快速浏览 NuGet 将我带到Nest

我将我的“模型”定义如下......

<ElasticType(Name:="Document")>
Public Class Document
    Property UserId As Long
    <ElasticProperty(IndexAnalyzer:="not_analyzed")>
    Property Something As String
    Property EmailAddress As String
End Class

然后尝试像这样创建和索引...

Dim Ret = ES.CreateIndex(IndexName,
               Function(x) x.AddMapping(Of Document)(
                   Function(m) m.MapFromAttributes))
If Not Ret.OK Then
    With Ret.ConnectionStatus.Error
        Throw New Exception(String.Format("Failed to create index ({0}): {1}", .HttpStatusCode, .ExceptionMessage))
    End With
End If

我得到Failed to create index (BadRequest): MapperParsingException[mapping [Document]]; nested: MapperParsingException[Analyzer [not_analyzed] not found for field [something]];

我都试过了

<ElasticProperty(Analyzer:="not_analyzed")>

<ElasticProperty(IndexAnalyzer:="not_analyzed")>

我试图让它构建的是json相当于

"something" : {"type" : "string", "index" : "not_analyzed"}

es 文档中所示。

我错过了什么?

(弹性 0.90.6)

4

1 回答 1

3

我错过了一个属性属性来处理这个......

<ElasticType(Name:="Document")>
Public Class Document
    Property UserId As Long
    <ElasticProperty(Index:=FieldIndexOption.not_analyzed)>
    Property Something As String
    Property EmailAddress As String
End Class

请注意Index采用枚举的属性。感谢@geeky_sh 提示我找对地方。

于 2013-11-07T13:22:56.267 回答