Hey,
I have to create dynamic query to be more precise, create multiple filters, here's my code :
Filter dynamic creation :
var filters = new List<Func<QueryContainerDescriptor<Source>, QueryContainer>>();
for (int i = 0; i < nbPoint; i++)
{
filters.Add(
mu => mu.GeoBoundingBox(ge => ge
.Field(f => f.End)
.BoundingBox(latLeftTab[i], lonLeftTab[i], latRightTab[i], lonRightTab[i])
) && mu
.GeoBoundingBox(ge => ge
.Field(f => f.Start)
.BoundingBox(latLeftTab[i], lonLeftTab[i], latRightTab[i], lonRightTab[i])
) || mu
.GeoBoundingBox(ge => ge
.Field(f => f.End)
.BoundingBox(latLeftTab2[i], lonLeftTab2[i], latRightTab2[i], lonRightTab2[i])
) && mu
.GeoBoundingBox(ge => ge
.Field(f => f.Start)
.BoundingBox(latLeftTab2[i], lonLeftTab2[i], latRightTab2[i], lonRightTab2[i])
)
);
}
My request :
var searchResponse = client.LowLevel.Search<StringResponse>("jam", "jam", PostData.Serializable(new SearchDescriptor<Source>()
.From(0)
.Size(size)
.Query(q => q
.Bool(b => b
.Must(fi => fi
.DateRange(r => r
.Field(f => f.Timestamp)
.GreaterThanOrEquals(limitDate)
.LessThan(DateTime.Now)
), mi => mi
)
.Filter(filters)
)
)
));
qJson = searchResponse.Body;
Only the last filter in my loop is taken