当我使用 NEST 和我的类型创建模式映射时,我从 ElasticSearch 收到以下异常。
public class MyClass{
{
.....
[ElasticProperty(Index = FieldIndexOption.NotAnalyzed, IncludeInAll = false,Type = FieldType.Boolean)]
public bool IsActive { get; set; }
}
private static void BuildSchema(ObjectMapping mapping)
{
var objItem = new MyClass();
var baseItemProps = objItem.GetType().GetProperties();
foreach (var baseProp in baseItemProps)
{
var basePropName = Convert.ToString(baseProp.Name);
var baseFieldType = Convert.ToString(baseProp.PropertyType);
mapping.Properties.Add(new KeyValuePair<PropertyNameMarker, IElasticType>(
new PropertyNameMarker { Name = basePropName },
new BooleanMapping { Index = (NonStringIndexOption)FieldIndexOption.NotAnalyzed}));
}
}
当我使用上述请求创建映射时,出现异常。Bool 字段未标记化。请帮我解决这个问题?