Struggling to remove files in Alfresco as Lucene search continues to display 1000 results, even after deleting nodes

Dealing with Alfresco Version 3.3 -

In my JavaScript program within the Alfresco Repository, I am attempting to delete all archived files similar to Windows' Recycle Bin. However, I have encountered an issue where the Lucene search only retrieves 1000 nodes at a time. To work around this limitation, I have tried deleting the initial results and running the search again in hopes of fetching more nodes up to the point of no search results. Despite waiting for Lucene to re-index after each deletion for as long as five minutes, the subsequent searches still return the same set of 1000 nodes, leading me to believe there might be some caching or transactional behavior at play.

Has anyone else faced this challenge? Is there a way to ensure that the search fetches fresh results on repeated executions within the same JavaScript process?

Below is a snippet demonstrating an attempt to delete 2000 nodes:

var query = 'ASPECT:"sys:archived"';
var results = search.luceneSearch('archive://SpacesStore/',query);
for(var i=0;i<results.length;i++){
    if(search.findNode(results[i].nodeRef)!=null){  
        results[i].remove();
    }
}
results = search.luceneSearch('archive://SpacesStore/',query);
for(var i=0;i<results.length;i++){
    if(search.findNode(results[i].nodeRef)!=null){  
        results[i].remove();
    }
}

Answer №1

When working in Javascript with Alfresco, you will encounter how transactions are handled. Your changes made within the Javascript execution will be grouped into a single transaction, and these changes will not be committed or update the index until the transaction exits.

If you want to batch cleanup of the archive, it is recommended to use Java for explicit transaction control. However, this process may become more complex if you are using SOLR due to its asynchronous indexation. Since you mentioned you are on version 3.4 and using lucene, this should not pose a problem as the API will hold off returning control until the index changes are committed.

For effective trashcan management, consider applying the sys:temporary aspect when performing deletes programmatically to bypass the trashcan step. Additionally, there is a Java-based AMP available that can handle trashcan cleanup in the background.

This solution should be suitable for your current setup.

Warm regards, Matthew

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Unexpected Disconnection of AJAX Response Moments Before Rebooting the Raspberry Pi

I currently have a LAMP server set up on my Raspberry Pi 4, where a web page is utilizing an AJAX call to trigger a php script that initiates a reboot of the pi. The php script echoes a JSON string response back to the web page indicating that it is prepar ...

Calculating interest rates in Javascript: A guide to determining values using two separate rates

I am currently working on an earnings calculator function EarningsCalculator.prototype.calculateEarning = function (interestRate, investmentAmount) { var earningHistory = {}; var currentInvestment = investmentAmount; for (var year = 1; year & ...

JavaScript: Invoking a function within another function via an HTML document

I have a unique scenario where I have one function inside another and I am looking to call the inner function from an HTML document. <head> <meta charset="utf-8"> <title></title> <link rel="stylesheet" href="style.css"> ...

Upgrade Angular from 12 to the latest version 13

I recently attempted to upgrade my Angular project from version 12 to 13 Following the recommendations provided in this link, which outlines the official Angular update process, I made sure to make all the necessary changes. List of dependencies for my p ...

Implement your own styling with i18next

There are two namespaces I am working with: The first namespace is global and contains business-related glossary terms The second namespace is specific to a certain page // Global Namespace { "amendment": "amendment" } // Page Name ...

Encountering a connection error when trying to access a Google spreadsheet within a Next.js application

I am currently exploring Next.js and attempting to utilize Google Sheets as a database for my project. Although my application is functioning correctly, there is still an error message displaying that says "not forgot to setup environment variable". I have ...

What is causing TypeScript to compile and remove local variables in my Angular base controller?

I am trying to develop a base controller in Typescript/Angular for accessing form data, but I'm encountering an issue where the form member seems to be getting removed during compilation and is not present in the generated JavaScript code. Could you ...

Start the setInterval function again after clearing it with the clearInterval button, but wait for

Currently, I am working on a content slider that automatically cycles through slides using the "next" function and setInterval. However, I want it to stop when the user clicks on the prev/next buttons by using clearInterval. Is there a way to resume setInt ...

Integrate the elements from the <template> section into the designated <slot> area

I am trying to retrieve template content, insert it into a custom element with shadow DOM, and style the span elements inside the template using the ::slotted selector. However, it seems like this functionality is not working as I expected. <!doctype h ...

Are there any disadvantages to an API endpoint not waiting for a promise to complete before returning?

Is it considered acceptable to invoke an async task within an express endpoint without awaiting it before returning to the caller if confirmation is not necessary? While this method may restrict error handling and retry options in case of async task failu ...

Having trouble with my jQuery autocomplete feature not functioning properly

I have implemented a jQuery autocomplete feature for a textbox on my website. The data is fetched from an ASMX webservice and I am monitoring the code using Firebug. Despite seeing the requests being sent and XML responses received, the autocomplete featur ...

The effects of external CSS are not being displayed or are being overridden

I am currently working on a webpage design that resembles the style of Microsoft's website. I came across a tutorial on W3 Schools for creating an image slideshow, which can be found here: https://www.w3schools.com/howto/howto_js_slideshow.asp. The ex ...

Delete the event handler if the original selector used to set up the handler is unknown

I need to remove an event handler from the element. The current handler is added by a third-party plugin, and I want to prevent its behavior. As far as I know, the functions off() and unbind() require the original selector to be used. The issue arises b ...

When echoing JSON data into a page used as a same-origin iframe, the outcome is not as anticipated

I am facing an issue with Javascript and PHP. Here is the setup I have: <html> <body> <iframe id="a" src="iframe.php" width="500" height="200"></iframe> </body> </html> Within ifr ...

Arranging an array according to the keys of the object

Here is a code structure with various participants: var person1 = { name : "", nickname : "", number "99999" } ; var person2 = { name : "bbb", nickname : "", } ; var person3 = { name : "", nickname : "aaa" } ; var person4 = ...

Embedding JavaScript directly into a Jade file(Note: This is

After spending about 3 hours trying to unravel the mystery, I'm still lost and unsure where to even begin looking for answers. We implemented a method that allows us to include JS files directly in a single Jade file, serving as a manifest for all ou ...

The HTML code is properly linked to the JavaScript file, but for some reason, it is still not

I'm facing an issue while trying to incorporate a js file into my html document. Even though I have linked the html file to the js file, it doesn't seem to be functioning properly. In the code snippet below, everything appears to be working fine ...

Exciting new slider spotlighting jQuery advancements

I'm currently facing an issue with my slider while using a newer version of jQuery. Some functions like rotate are deprecated, but the slider works well when the page is uploaded. My goal is to load images from the clicked tab on the right side. Howev ...

Encountering Next.JS Router Issue: Unable to Access Properties of Null (specifically 'useContext')

As a beginner in Next.js and React, I'm facing an issue with redirecting users from the "Projects" page to the Product Page Details. Here's the code snippet I am using: const openProjectDetails = () => { Router.push('/api/' + props ...

Create a modal dialog in CSS that dynamically adjusts its size without extending beyond the edges of the screen

I'm in the midst of developing a web application specifically for tablets. My goal is to display a modal dialog with a title bar and body that dynamically adjusts in height based on its content. If the content exceeds the viewport size, I want the dia ...