gpt4 book ai didi

.net - 使用Nest创建弹性索引

转载 作者:行者123 更新时间:2023-12-02 22:52:33 25 4
gpt4 key购买 nike

我在工作中(从Python)大量使用elasticsearch,但想将其应用到我在业余时间正在做的一个小型.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 docs所示。

我想念什么?

( flex 0.90.6)

最佳答案

我错过了处理此问题的属性属性...

<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

请注意带有一个Enum的 Index属性。感谢@geeky_sh提示我寻找正确的位置。

关于.net - 使用Nest创建弹性索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19825892/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com