gpt4 book ai didi

elasticsearch - ElasticSearch跨多个索引C#查询

转载 作者:行者123 更新时间:2023-12-03 01:38:49 27 4
gpt4 key购买 nike

是否可以在一个搜索查询中跨多个索引进行查询?
我在C#中拥有的示例:

        ConnectionSettings connectionSettings = new ConnectionSettings(new Uri("http://localhost:9200/")); //local PC             
ElasticClient elasticClient = new ElasticClient(connectionSettings);

string index1 = "local-neal-test-other1-2018.04.06";
string index2 = "local-neal-test-other2-2018.04.06";

//Search query to retrieve info
var response = elasticClient.Search<Document2>(s => s
.Index(index1)
.Query (q=>q.
MatchAll()
)
.Sort(ss => ss
.Descending(p => p.CreatedDate))
);

例如,可以在上面放置index1和index2吗?

最佳答案

您可以明确地告诉ELK使用多个索引:

elasticClient.Search<Document2>(s=>s
.Index(new [] {"Index_A", "Index_B"})
...
)

关于elasticsearch - ElasticSearch跨多个索引C#查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49699699/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com