Elasticsearch 按属性搜索,发现它不为 null。我这样做了.Query(s => s.Bool(b => b.Must(m => m.Exists(e => e.Field(f => f.fields.EventId.Id))))),但答案中没有文档。elastic本身就有这样的文档:"fields": { "address": "https://0.0.0.0:81", "EventId": { "Id": 14,"Name": "ListeningOnAddress"},. 这是来自应用程序的 Logger 日志。用于映射本身的类是通过 Visual Studio 2022 中的特殊插入创建的。
public class _Source
{
[Date(Format = DateFormat.strict_date_hour_minute_second, Name = "@timestamp")]
public DateTime Timestamp { get; set; }
public string level { get; set; }
public string messageTemplate { get; set; }
public string message { get; set; }
public Fields fields { get; set; }
}
public class Fields
{
public string status { get; set; }
public string chargePoint { get; set; }
public Eventid EventId { get; set; }
public string SourceContext { get; set; }
public string ActionId { get; set; }
public string ActionName { get; set; }
public string RequestId { get; set; }
public string RequestPath { get; set; }
public string ConnectionId { get; set; }
public string MachineName { get; set; }
public object UserId { get; set; }
public string RemoteIpAddress { get; set; }
public string Environment { get; set; }
}
public class Eventid
{
public int Id { get; set; }
}
一切原来都是映射的,如果不可能序列化成c#对象,那么就没有搜索。需要添加的属性
和
链接到文档