Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

134
Visualizações
Bulk delete documents based on a pattern Marklogic/java script

I'm trying to bulk delete documents based on a pattern but, since the collection contains 500K plus documents, the forloop seem to get hung. Below is my code:

for (const uri of cts.uris("", null, cts.jsonPropertyValueQuery("source", "survey"))) {
  xdmp.documentDelete(uri);
}

Can somebody help me with a better way to delete documents in MarkLogic when there is large volume?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Attempting a "boil the ocean" type query to modify a really large set of documents in a single transaction is likely to run into limits, either in execution time, transaction size, expanded tree cache, etc.

It is best to break out the work into smaller units.

One easy way is to spawn the work into multiple transactions that get executed on the task server. You can do this rather easily in XQuery with xdmp:spawn-function() (unfortunately, the equivalent function is not available in SJS):

xquery version "1.0-ml";
for $URI in cts:uris("", (), cts:json-property-value-query("source", "survey"))
return xdmp:spawn-function(function(){ xdmp:document-delete($URI) })

You could modify the code above to delete subsets of URIs, instead of one at a time. However, those delete transactions should execute very quickly (and in parallel for as many threads as you have configured for the task server), so it may not be worth the hassle of more complicated code.

Another option is to use a batch tool, such as CoRB

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda