在net core中 NEST查询类型为List 且为空的数据
可以使用以下代码来查询类型为List且为空的数据:
var searchResponse = client.Search<YourDocument>(s => s
.Query(q => q
.Bool(b => b
.Must(m => m
.MatchAll()
)
.Filter(f => f
.Nested(n => n
.Path(p => p.YourListField)
.Query(qq => qq
.Bool(bb => bb
.Must(must => must
.Match(m => m
.Field(f => f.YourListField)
.Query("")
)
)
)
)
)
)
)
)
);
其中,YourDocument代表你的文档类型,YourListField代表你的包含List类型的字段名。在查询中,我们使用了Nested查询来查询Nested类型的字段,然后在Nested查询中使用了Bool查询来组合Match查询和Must查询,以查询List字段为空的文档。注意,我们在Match查询中将查询字符串设为空字符串,以查询空的List字段
原文地址: https://www.cveoy.top/t/topic/ciib 著作权归作者所有。请勿转载和采集!