sách gpt4 ai đã đi

c# - 题-ElasticSearch-Nest v7.x “Ignore = true”在字段上不起作用

In lại 作者:行者123 更新时间:2023-12-02 23:13:12 32 4
mua khóa gpt4 Nike

我正在尝试对POCO类中的某些字段进行索引,并将某些属性装饰为“忽略= true”,并且这些字段不应被索引,而应该被存储。我希望这些字段出现在搜索结果中,但不应作为索引。

我正在尝试对应索引的几个字段进行映射,并忽略所有其他具有“Ignore = true”作为Nest Library提供的装饰器的字段。

这是POCO类的示例。

[PropertyName("doi")]
public string Doi { get; set; }

[PropertyName("displayName")]
public string DisplayName { get; set; }

[PropertyName("itemType")]
public string ItemType { get; set; }

[PropertyName("fileReference")]
public string FileReference { get; set; }

[PropertyName("textFirstPage", Ignore = true)]
public string TextFirstPage { get; set; }

[PropertyName("textLastPage", Ignore = true)]
public string TextLastPage { get; set; }

[PropertyName("citationTitle", Ignore = true)]
public string CitationTitle { get; set; }

[PropertyName("translatedPublicationTitle", Ignore = true)]
public string TranslatedPublicationTitle { get; set; }

[PropertyName("alternatePublicationTitle", Ignore = true)]
public string AlternatePublicationTitle { get; set; }

[PropertyName("publicationSubTitle", Ignore = true)]
public string PublicationSubTitle { get; set; }

但是,当我尝试查看索引的映射时,POCO类中已提到的所有字段都会出现在“映射”中。
{
"cweeindex" : {
"mapping": {
"properties" : {
"doi": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"displayName": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"fileReference": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"itemType": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"citationTitle": {
"type": "boolean"
},
"publicationSubTitle": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"textFirstPage": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"textLastPage": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"translatedPublicationSubTitle": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"translatedPublicationTitle": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
}
}
}
}

更新!
映射的Nest代码如下
var createIndexResponse = _connectionToEs.EsClient().Indices.Create("cweeindex", c => c
.Map(m => m.AutoMap())
);

拜托,让我我在做什么错!提前致谢。

1 Câu trả lời

这看起来像是从6.x到7.x的序列化所带来的回归。我已经打开an issueđể giải quyết.

现在,您可以使用Nest.IgnoreAttribute。例如

[PropertyName("doi")]
public string Doi { get; set; }

[PropertyName("displayName")]
public string DisplayName { get; set; }

[PropertyName("itemType")]
public string ItemType { get; set; }

[PropertyName("fileReference")]
public string FileReference { get; set; }

[Ignore]
public string TextFirstPage { get; set; }

[Ignore]
public string TextLastPage { get; set; }

[Ignore]
public string CitationTitle { get; set; }

[Ignore]
public string TranslatedPublicationTitle { get; set; }

[Ignore]
public string AlternatePublicationTitle { get; set; }

[Ignore]
public string PublicationSubTitle { get; set; }

关于c# - 题-ElasticSearch-Nest v7.x “Ignore = true”在字段上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58157898/

32 4 0
Bài viết được đề xuất: Mercurial Changegroup Hook 因分支而异
Bài viết được đề xuất: javascript - 当我只选择一个节目时如何阻止其他节目条目工作
Bài viết được đề xuất: bluetooth - 蓝牙 MIDI
Bài viết được đề xuất: javascript - 在离线(无网络)模式下显示 SVG
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com