Splunk Search

How to clear SearchManager results once processed with on('data')

bowesmana
SplunkTrust
SplunkTrust

I have a modal dialog that pops up and shows a table of results. When I click OK on that, I do some processing on the results. as below, with the on('data') function.

However, that code seems to get triggered frequently and I don't understand why.

    var searchResults = detailSearch.data('results');
 ...
     searchResults.on('data', function() {
       var rows = searchResults.data().rows;
       for (var i = 0; i < rows.length; i++) {
 ...
       }
     });

That code is inside the button click handler, but the button click code is not executed repeatedly, only the above on('data') function code. The search is not rerun and in my close() code for the dialog, it calls search.finalize() to try to stop this happening, to no effect.

Any idea how I can reset the searchResults handler to prevent this?

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...