使用NEST 7.17.5库更新旧版本(NEST 1.4.3)的C#代码如下所示,双引号请不要用中文模式下的 public class SparePartEntity {…
- User
使用NEST 7.17.5库更新旧版本(NEST 1.4.3)的C#代码如下所示,双引号请不要用中文模式下的 public class SparePartEntity { private string _name;
public SparePartEntity() { RepkitEntities = new List(); GroupNames = new List(); AllGroupNames = new List(); Attributes = new List(); ImageNames = new List(); RepkitPartNames = new List(); AllAssemblyGroupNames = new List(); FollowUpIds = new List(); Synonyms = new List(); ElevatorManufacturerNames = new List(); ElevatorManufacturerNames = new List(); PartsManufacturerNames = new List(); ProductLineNames = new List(); ComponentTypeNames = new List(); AssemblyGroupNames = new List(); Downloads = new List(); AllAssemblyGroupNamesLocalized = new List(); AllGroupNamesLocalized = new List();
ProductLineIds = new List(); AssemblyGroupElevatorIds = new List(); AssemblyGroupEscalatorIds = new List(); ComponentTypeIds = new List(); PartsManufacturerIds = new List(); GroupIds = new List();
MainAttributeIds = new List(); SpecificAttributeIds = new List(); }
[ElasticProperty(Index = FieldIndexOption.NotAnalyzed)] public string Id { get; set; }
[ElasticProperty(Index = FieldIndexOption.Analyzed, AddSortField = true)] public string Name { get { return _name; } set { _name = value; NamePrefix = value != null ? value.ToLower() : null; } }
[ElasticProperty(Index = FieldIndexOption.NotAnalyzed)] public string NamePrefix { get; set; }
[ElasticProperty(Index = FieldIndexOption.NotAnalyzed)] public string SparePartId { get; set; }
[ElasticProperty(Index = FieldIndexOption.NotAnalyzed)] public string Kg { get; set; }
[ElasticProperty(Index = FieldIndexOption.NotAnalyzed)] public string OwnerKg { get; set; }
[ElasticProperty(Index = FieldIndexOption.NotAnalyzed)] public string Symbol { get; set; }
[ElasticProperty(Index = FieldIndexOption.NotAnalyzed, IncludeInAll = true)] public string Barcode { get; set; }
[ElasticProperty(Index = FieldIndexOption.NotAnalyzed)] public string LanguageKey { get; set; }
[ElasticProperty(Index = FieldIndexOption.Analyzed)] public string Description { get; set; }
public string Dimensions { get; set; }
[ElasticProperty(Index = FieldIndexOption.NotAnalyzed)] public double Length { get; set; }
[ElasticProperty(Index = FieldIndexOption.NotAnalyzed)] public double Width { get; set; }
[ElasticProperty(Index = FieldIndexOption.NotAnalyzed)] public double Height { get; set; }
[ElasticProperty(Index = FieldIndexOption.NotAnalyzed)] public string Weight { get; set; }
[ElasticProperty(Index = FieldIndexOption.NotAnalyzed)] public DateTime Timestamp { get; set; }
[ElasticProperty(Index = FieldIndexOption.NotAnalyzed)] public DateTime? MarkedDeletedTimestamp { get; set; }
[ElasticProperty(Index = FieldIndexOption.NotAnalyzed)] public DateTime CreateDate { get; set; }
- Assistant
- User
Fields = typeof(Barcode)报错
- Assistant
抱歉,我之前提供的代码中存在错误。对于
Fields = typeof(Barcode)这个选项,它不适用于NEST 7.x版本。在新版本中,如果你需要在同一个字段上应用多个不同的分析器,你可以使用MultiFields选项。以下是一个更正后的代码示例,修复了
[Text(Fields = typeof(Barcode))]的问题:csharppublic class SparePartEntity { // ... [Text(Analyzer = "standard")] public string Barcode { get; set; } // ... }在这个示例中,我将
[Text(Fields = typeof(Barcode))]更改为[Text(Analyzer = "standard")],以使用名为standard的标准分析器来分析Barcode属性。请注意,
[Text(Analyzer = "standard")]是一个示例,你可以根据实际需要选择适合的分析器。 - User
NumericResolution = NumericResolutionUnit.Ticks报错
- Assistant
抱歉,对于“NumericResolution = NumericResolutionUnit.Ticks”,请将其更改为“Index = true”。下面是更正后的代码示例:
csharppublic class SparePartEntity { // ... [Date(Index = true)] public DateTime? MarkedDeletedTimestamp { get; set; } // ... }在这个示例中,我将
[Date(NumericResolution = NumericResolutionUnit.Ticks)]更改为[Date(Index = true)],以将MarkedDeletedTimestamp属性标记为索引类型的日期字段。请记住,这个更正是基于我之前提供的示例代码。你可能还需要根据自己的需求对其他属性进行相应的更改
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.