C# 如何在elasticsearch中启用字段数据
我试图在elasticsearch中启用字段数据,但仍然得到相同的错误。 谁能告诉我我错过了什么 .NET代码C# 如何在elasticsearch中启用字段数据,c#,.net,
elasticsearch,C#,.net,
elasticsearch,我试图在elasticsearch中启用字段数据,但仍然得到相同的错误。 谁能告诉我我错过了什么 .NET代码 var resByApp = client.Search<ApiCall>(s => s.Aggregations(a => a .Filter("my_filter", f => f .Filter(fd => fd
var resByApp = client.Search<ApiCall>(s => s.Aggregations(a => a
.Filter("my_filter", f => f
.Filter(fd => fd
.DateRange(r => r
.GreaterThan(DateTime.UtcNow.ToBeginOfDay().AddDays(-DefaultDaysRange))
.Field(p => p.CreatedDate)
)
&&
fd.Term(t => t.ServiceId, serviceId)
)
.Aggregations(ag => ag
.Terms("app_agg", st => st
.Field(af => af.AppId))
)
)));
我的尝试:
Invalid NEST response built from a unsuccessful low level call on POST: /abc_apicalls/apicall/_search
# Audit trail of this API call:
- [1] BadResponse: Node: http://localhost:9200/ Took: 00:00:00.0459990
# ServerError: ServerError: 400Type: search_phase_execution_exception Reason: "all shards failed" CausedBy: "Type: illegal_argument_exception Reason: "Fielddata is disabled on text fields by default. Set fielddata=true on [appId] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory.""
# OriginalException: System.Net.WebException: The remote server returned an error: (400) Bad Request.
at System.Net.HttpWebRequest.GetResponse()
at Elasticsearch.Net.HttpConnection.Request[TReturn](RequestData requestData) in C:\Users\russc\source\git\elasticsearch-net-5.x\src\Elasticsearch.Net\Connection\HttpConnection.cs:line 164
# Request:
{"aggs":{"my_filter":{"filter":{"bool":{"must":[{"range":{"createdDate":{"gt":"2017-03-26T00:00:00"}}},{"term":{"serviceId":{"value":2}}}]}},"aggs":{"app_agg":{"terms":{"field":"appId"}}}}}}
# Response:
{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Fielddata is disabled on text fields by default. Set fielddata=true on [appId] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory."}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"abc_apicalls","node":"oYXnz0dhTZ6Bs5ZpspH1hg","reason":{"type":"illegal_argument_exception","reason":"Fielddata is disabled on text fields by default. Set fielddata=true on [appId] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory."}}],"caused_by":{"type":"illegal_argument_exception","reason":"Fielddata is disabled on text fields by default. Set fielddata=true on [appId] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory."}},"status":400}
PUT abc_apicalls/apicall/text
{
"properties": {
"appId": {
"type": "text",
"fielddata": true
}
}
}
这是GET abc\u apicall
{
"abc_apicalls": {
"aliases": {},
"mappings": {
"apicall": {
"properties": {
"appId": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"properties": {
"properties": {
"appId": {
"properties": {
"fielddata": {
"type": "boolean"
},
"type": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
},
...
}
}
参考资料:类型错误,这是启用字段数据的正确方法
PUT abc_apicalls/_mapping/apicall
{
"apicall": {
"properties": {
"appId": {
"type": "text",
"fielddata": true
}
}
}
}
类型错误,这是启用字段数据的正确方法
PUT abc_apicalls/_mapping/apicall
{
"apicall": {
"properties": {
"appId": {
"type": "text",
"fielddata": true
}
}
}
}
我正在使用Nest 5.4,并通过以下代码进行put映射:
_client.Map<AccountDoc>(m => m.Index("Your_Index_Name").Properties(p =>
p.Text(t => t.Name(n => n.Your_Field_Name).Fielddata(true))));
\u client.Map(m=>m.Index(“您的索引名”).Properties(p=>
p、 文本(t=>t.Name(n=>n.Your_Field_Name).Fielddata(true));
我使用Nest 5.4,并通过以下代码进行put映射:
_client.Map<AccountDoc>(m => m.Index("Your_Index_Name").Properties(p =>
p.Text(t => t.Name(n => n.Your_Field_Name).Fielddata(true))));
\u client.Map(m=>m.Index(“您的索引名”).Properties(p=>
p、 文本(t=>t.Name(n=>n.Your_Field_Name).Fielddata(true));
欢迎来到StackOverflow,感谢您的帮助。但是,您的答案可以通过使用标记格式和添加解释来改进。这里不太喜欢只使用代码的答案。有关这方面的详细信息,请参阅。我在最新版本的Nest中找不到.FieldData
!它被移到其他地方了吗?对我来说似乎没有什么区别,即使这样做了,我仍然会收到相同的错误…欢迎来到StackOverflow,谢谢你的帮助。但是,您的答案可以通过使用标记格式和添加解释来改进。这里不太喜欢只使用代码的答案。有关这方面的详细信息,请参阅。我在最新版本的Nest中找不到.FieldData
!它被移到别的地方了吗?对我来说似乎没有什么区别,即使这样做了,我还是会犯同样的错误。。。