I need to pass complex query to Elasticsearch. In this query there will be a lot of range conditions mostly date range.
Example is below:
query = "module : ('mod45') AND code : ('667', '456') AND startTime:[2020-10-18T13:42:17 TO 2021-10-18T13:42:17] AND endTime:[2021-02-18T13:42:17 TO 2021-09-18T13:42:17]"
(
module,code,startTimeandendTimeit's a columns name)
And I have the following Elasticsearch function:
public async Task<IEnumerable<T>> GetQueryStringData<T>(string index, string query) where T : class
{
var client = GetClient();
var response = await client.SearchAsync<T>(s => s
.Index(index)
.Query(x => x.QueryString(a => a.Query(query))).Size(DefaultResultsSize));
return response?.Documents;
}
Is it possible to change this function that it could recieve a list of query conditions without "AND" connector?
Something like this:
var queryList = new List<string>();
queryList.Add("module : ('mod45')");
queryList.Add("code : ('667', '456')");
queryList.Add("startTime:[2020-10-18T13:42:17 TO 2021-10-18T13:42:17]");
queryList.Add("endTime:[2021-02-18T13:42:17 TO 2021-09-18T13:42:17]");
EDIT: Let's say I will have 100 queries like this, so lambda isn't works here