如何删除具有特定属性的所有RavenDB文档
我需要以编程方式删除一堆文档。我可以在UI中使用javascript“补丁”功能来查找这些文档,并添加一个属性来标识它们,如下所示:如何删除具有特定属性的所有RavenDB文档,ravendb,Ravendb,我需要以编程方式删除一堆文档。我可以在UI中使用javascript“补丁”功能来查找这些文档,并添加一个属性来标识它们,如下所示: if (__document_id.indexOf("baddata") > 0) { this.'MakeThisGoAway' = true; } 但我找不到在“补丁”中删除文档的方法。(根据我的设想) 从Raven docs看来,正确的方法是通过curl执行删除请求,如下所述:使用如下请求: curl -X DELETE "http://loc
if (__document_id.indexOf("baddata") > 0) {
this.'MakeThisGoAway' = true;
}
但我找不到在“补丁”中删除文档的方法。(根据我的设想)
从Raven docs看来,正确的方法是通过curl执行删除请求,如下所述:使用如下请求:
curl -X DELETE "http://localhost:8080/databases/NorthWind/bulk_docs/Raven/DocumentsByEntityName?&query=Tag%3AShops&allowStale=false"
但唯一的例子是删除集合中的所有文档。看起来我应该能够包含一个类似“propertyname=MakeThisGoAway&value=true”的查询,但是我在文档中找不到任何关于具体工作方式的信息。我遗漏了什么吗?我发现了这一点,我遗漏了几个步骤,而且对lucene查询的语法也不清楚 如果它对任何人都有帮助,以下是我批量删除Ravendb文档所需的全部步骤:
// wrap with a conditional to only affect the data that meets your criteria
if (this.baddata == 1 || __document_id.indexOf("baddata") > 0) {
// remove Raven-Read-Only, or the delete will fail
this['@metadata']['Raven-Read-Only'] = false;
// add a flag field to identify the documents you will be deleting
this.MakeThisGoAway = true;
}
http://ravenserver:8080/databases/DbName/bulk_docs/This/Is/Your/Index?query="MakeThisGoAway:true"