本文介绍了ElasticSearch和NEST:如何从索引中清除所有文档?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道如何,但如何清除索引中的所有文档?
I know how to delete an entire ElasticSearch index, but how do you purge all documents from an index?
我的动机:我想要一个清理索引的全部内容的ReIndex方法,以便我可以重新加载所有文件。
My Motivation: I'd like to have a "ReIndex" method that purges the entire contents of an index so that I can reload all documents.
ElasticSearch语法将是无效的。 NEST语法会更好一些。
ElasticSearch syntax would be helful. NEST syntax would be even better.
推荐答案
我在Nest中寻找类似的东西,我以为我会把语法放在这里寻找任何人:
I was looking for something similar in Nest and I thought I'd put the syntax here for anyone looking:
var node = new Uri("http://localhost:9200");
var settings = new ConnectionSettings(node);
var client = new ElasticClient(settings);
client.DeleteByQuery<ElasticsearchProject>(del => del
.Query(q => q.QueryString(qs=>qs.Query("*")))
);
这篇关于ElasticSearch和NEST:如何从索引中清除所有文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!