elasticsearch ElasticSearch跨多个索引C进行查询#
是否可以在一个搜索查询中跨多个索引进行查询? C#中的示例:
elasticsearch ElasticSearch跨多个索引C进行查询#,
elasticsearch,
elasticsearch,是否可以在一个搜索查询中跨多个索引进行查询? C#中的示例: ConnectionSettings ConnectionSettings=新连接设置(新Uri(“http://localhost:9200/")); //本地计算机 ElasticClient ElasticClient=新的ElasticClient(连接设置); string index1=“local-neal-test-other1-2018.04.06”; string index2=“local-neal-test-o
ConnectionSettings ConnectionSettings=新连接设置(新Uri(“http://localhost:9200/")); //本地计算机
ElasticClient ElasticClient=新的ElasticClient(连接设置);
string index1=“local-neal-test-other1-2018.04.06”;
string index2=“local-neal-test-other2-2018.04.06”;
//搜索查询以检索信息
var response=elasticClient.Search(s=>s
.索引(index1)
.Query(q=>q。
MatchAll()
)
.Sort(ss=>ss
.下降(p=>p.CreatedDate))
);
例如,我可以将index1和index2都放在上面吗 您可以明确告诉麋鹿使用多个索引:
elasticClient.Search(s=>s
.Index(新[]{“Index_A”,“Index_B”})
...
)
完美,但实际上是.Index而不是.Index。直到我测试后我才注意到。然后我尝试了。索引,得到了编译错误。不过有一个提示。现在,你能用任何面具吗?
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))
);