我在工作中经常使用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)