Hello,
i am in caught a situation where i need to apply a match query based on a condition.
my code is as below:
var searchResponse = await client.SearchAsync<StringResponse>("custom-index", @"
{
""from"": " + entity.Offset + @",
""size"": " + entity.Count + @",
""query"": {
""bool"":{
""must"":[{
""match"": { ""fields.category"": """ + entity.Category + @""" }
}]
}
}
}");
i need to add match condition only when "entity.Category" is not null or empty.
how can i achieve this ?
Thanks