Reputation: 2785
I'm struggling to figure out how to include multiple indexes in a search using the Elastic low level client.
My understanding (right or wrong) is that I should be able to include multiple indexes by separation of commas, this doesn't work for me though. In the code example below, I find that the first index specified is still working and returning results, but the second one is ignored. Any ideas?
Appsettings.json file:
// System settings configured here for the WebApp. Applicable to all users.
"SystemSettings": {
// Sets the maximum number of distinct values returned by Elastic for a log property
"_distinctPropertyValuesLimit": 1000, // See LogPropertiesController.cs
// String for the list of Elastic Search indexes that are searched by default.
"indexesToSearch": "webapp-razor-*, systemconfig-api-*"
}
Query class:
_indexesToSearch = configuration.GetSection("SystemSettings").GetSection("indexesToSearch").Value;
var searchResponse = await _elasticLowLevelClient.SearchAsync<StringResponse>(_indexesToSearch, @"
{
""from"": """ + fromParameter + @""",
""size"": """ + rowsPerPage + @""",
""query"": {
""match"": {
""" + searchColumn + @""": {
""query"": """ + searchString + @"""
}
}
},
""sort"": [
{
""@timestamp"": {
""order"": ""desc""
}
}
]
}
");
Upvotes: 0
Views: 315
Reputation: 2785
Turns out that there must not be any spaces between the index names when multiple values are provided, see below:
Upvotes: 2