Elastic Search嵌套多重匹配查询
C# 代码写的查询Elastic Search,多值查询如何写?
实体类如下:
/// <summary>
/// 图像信息类
/// </summary>
public class CustomCTImageInfo
{
[Text(Name = "PRN")]
public string PRN { get; set; }
[Number(NumberType.Integer, Name = "ImageMode")]
public uint ImageMode { get; set; }
[Nested]
[PropertyName("Judges")]
public List<JudgeConclusion> Judges { get; set; }
[Nested]
[PropertyName("Checks")]
public List<CheckConclusion> Checks { get; set; }
[Nested]
[PropertyName("AiSusDatas")]
public List<AiSusData> AiSusDatas { get; set; }
}
public class AiSusData
{
[Date(Name = "RecvTime")]
public DateTime RecvTime { get; set; }
[Number(NumberType.Integer, Name = "TypeID")]
public int TypeID { get; set; }
[Text(Name = "TypeName")]
public string TypeName { get; set; }
[Number(NumberType.Integer, Name = "SubTypeID")]
public int SubTypeID { get; set; }
[Text(Name = "SubTypeName")]
public string SubTypeName { get; set; }
[Number(NumberType.Integer, Name = "Count")]
public int Count { get; set; }
[Number(NumberType.Integer, Name = "HandleType")]
public int HandleType { get; set; }
[Text(Name = "Description")]
public string Description { get; set; }
}
查询AiSusData 中的SubTypeID 在数组中(相当于SQL语句中的 IN)
var response = ESClient.Search<CustomCTImageInfo>(s => s.From((request.CurrentPage - 1)* request.PageSize).Size(request.PageSize)
.Sort(i => i.Descending(f => f.CreateTime))
.TrackTotalHits()
.Query(query: q => q.Bool(m => m.Must(
fs => fs.Bool(sh=>sh.Should(
f =>
{
return f.Nested(
l => l.Path(j => j.AiSusDatas).Query(p => p.Bool(k => k.Must(
h =>
{
if (string.IsNullOrEmpty(request.AISusDataId.ToString()) ||
request.AISusDataId.ToString().Equals("-1"))
{
return new QueryContainer();
}
** return h.Terms(o =>
o.Field(n => n.AiSusDatas.First().SubTypeID)
.Terms(AISusDataArray));__**
}
)))
);
}
))
最后的 AiSusDatas 筛选该如何写?