我试图通过 Nest 5.5.0 设置“not_analyzed”索引类型,但我不知道该怎么做。
我的初始化:
var map = new CreateIndexDescriptor(INDEX_NAME)
.Mappings(ms => ms.Map<Project>(m => m.AutoMap()));
var connectionSettings = new ConnectionSettings().DefaultIndex(INDEX_NAME);
_client = new ElasticClient(connectionSettings);
_client.Index(map);
和项目类:
[ElasticsearchType(Name = "project")]
public class Project
{
public Guid Id { get; set; }
[Text(Analyzer = "not_analyzed")]
public string OwnerIdCode { get; set; }
}
在我通过 Postman 调用 index/_mapping REST 之后,这种 init 方式会创建某种奇怪的映射。有普通的“映射”JSON 部分,就在“createindexdescriptor”下方,数据几乎相同。
"examinations4": {
"mappings": {
"project": {
(...)
},
"createindexdescriptor": {
"properties": {
"mappings": {
"properties": {
"project": {
"properties": {
"properties": {
"properties": {
"id": {
"properties": {
"type": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
},
"ownerIdCode": {
"properties": {
"analyzer": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"type": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
(...)