elasticsearch - 弹性低级客户端 - 如何在搜索查询中包含多个索引
问题描述
我正在努力弄清楚如何使用 Elastic 低级客户端在搜索中包含多个索引。
我的理解(对或错)是我应该能够通过逗号分隔来包含多个索引,但这对我不起作用。在下面的代码示例中,我发现指定的第一个索引仍在工作并返回结果,但第二个被忽略了。有任何想法吗?
Appsettings.json 文件:
// 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-*"
}
查询类:
_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""
}
}
]
}
");
解决方案
推荐阅读
- c# - 远程服务器返回错误:(401) Unauthorized doing multiple rally API calls
- javascript - 带有 ts-loader 的输出文件名不重命名声明文件
- gradle - 在 groovy 中安全取消引用项目属性
- google-cloud-platform - 使入口/服务在 GKE 上公开 DNS 可解析
- javascript - Vue.js - 在组件属性中使用实例全局属性作为默认值
- c# - 当父进程关闭时,使用 WaitForExit() 杀死子进程
- python - 我无法正确绘制边界框
- java - 尝试批处理 SQL 存储过程调用:“@p0”附近的语法不正确
- xamarin - 如何在同一行插入多个项目
- android - 支持每个片段中的操作栏标题和图标