<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Get reults from SearchManager  / SplunkJS in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Get-reults-from-SearchManager-SplunkJS/m-p/114840#M6572</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;iam trying to start a search with Javascript and the SearchManager inside my own js-libary on a Dashboard . My Dashboard-header is binding: splunk.js, myownlibary.js and myOwncss.css. After reading some documentations and some help from here i found out how to call a search with the correct framework, objects and methods. &lt;/P&gt;

&lt;P&gt;Iam also using the plugin "DB Connect", with that plugin you can &lt;BR /&gt;
query directly to the database like: "| dbquery myDB \"(SQL STATEMENT)\""&lt;/P&gt;

&lt;P&gt;Now ive got a db-query which works and iam trying to fire it with javascript-code which is also firing when my MutationObserver react by defined events.&lt;/P&gt;

&lt;P&gt;So my actual code now is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; var searchIncrementer = "1";
 require(["splunkjs/ready!"], function(mvc) {
    var deps = [
        "splunkjs/ready!",
        "splunkjs/mvc/searchmanager",
    ];
    require(deps, function(mvc) {

        var SearchManager = require("splunkjs/mvc/searchmanager");
        new SearchManager({
            id: "mvasearch" + searchIncrementer,
            earliest_time: "-24h@h",
            latest_time: "now",
            search: "| dbquery PrixB limit=1000 \"select * from bild b join shopposition s on                    b.bildnummer=s.bildnummer\n join shoppositionartikelgruppe spag on s.datensatznummer=spag.shopposinummer\n join artikelnummer artnr on artnr.artikelgruppennummer=spag.artikelgruppennummer\n where artnr.artikelnummer='" + mvaArticleNumber + "'\"",
   });

   var mvaDataObj = splunkjs.mvc.Components.getInstance("mvasearch" + searchIncrementer);

    mvaDataObj.on('search:progress', function(properties) {
        console.log("IN PROGRESS:", properties)
    });

    mvaDataObj.on('search:done', function(properties) {
        console.log("DONE:", properties)
    });

    mvaDataObj.on('search:failed', function(properties) {
        console.log("FAIL:", properties)
    });  

var myResults = mvaDataObj.data("preview", { count: 25, offset: 10 });
myResults.on("data", function() {
        // The full data object
        console.log(myResults.data());

        // Indicates whether the results model has data
        console.log("Has data? ", myResults.hasData());

        // The results rows
        console.log("Data (rows): ", myResults.data().rows);

     // The Backbone collection
        console.log("Backbone collection: ", myResults.collection());
});
    var tmpIncrementer = parseInt(searchIncrementer);
    tmpIncrementer++;
    searchIncrementer = String(tmpIncrementer);

   }); // require
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Its mostly from the examples....&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;console.log() / IN PROGRESS, DONE&lt;/STRONG&gt; &lt;/P&gt;

&lt;P&gt;Tells me that there is no error, &lt;CODE&gt;resultCount: 4&lt;/CODE&gt; and some links like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;results: "/servicesNS/-/-/search/jobs/user__user__app__mvasearch229_1389779059.39108/results"

search.log: "/servicesNS/-/-/search/jobs/user__user__app__mvasearch229_1389779059.39108/search.log"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;console.log("Has data? ", myResults.hasData());&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Is &lt;CODE&gt;false&lt;/CODE&gt; but why? Also the result from both logs are empty.&lt;/P&gt;

&lt;P&gt;I dont get it because the resultCount is 4 so he founds something?&lt;BR /&gt;
But why are the results empty? Is there a function like "getResultsFromSearch(row, fields)" which you can use by Splunk SDK (Javascript) on jobs?&lt;/P&gt;

&lt;P&gt;Thanks..&lt;/P&gt;</description>
    <pubDate>Wed, 15 Jan 2014 10:10:47 GMT</pubDate>
    <dc:creator>gaRe</dc:creator>
    <dc:date>2014-01-15T10:10:47Z</dc:date>
    <item>
      <title>Get reults from SearchManager  / SplunkJS</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Get-reults-from-SearchManager-SplunkJS/m-p/114840#M6572</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;iam trying to start a search with Javascript and the SearchManager inside my own js-libary on a Dashboard . My Dashboard-header is binding: splunk.js, myownlibary.js and myOwncss.css. After reading some documentations and some help from here i found out how to call a search with the correct framework, objects and methods. &lt;/P&gt;

&lt;P&gt;Iam also using the plugin "DB Connect", with that plugin you can &lt;BR /&gt;
query directly to the database like: "| dbquery myDB \"(SQL STATEMENT)\""&lt;/P&gt;

&lt;P&gt;Now ive got a db-query which works and iam trying to fire it with javascript-code which is also firing when my MutationObserver react by defined events.&lt;/P&gt;

&lt;P&gt;So my actual code now is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; var searchIncrementer = "1";
 require(["splunkjs/ready!"], function(mvc) {
    var deps = [
        "splunkjs/ready!",
        "splunkjs/mvc/searchmanager",
    ];
    require(deps, function(mvc) {

        var SearchManager = require("splunkjs/mvc/searchmanager");
        new SearchManager({
            id: "mvasearch" + searchIncrementer,
            earliest_time: "-24h@h",
            latest_time: "now",
            search: "| dbquery PrixB limit=1000 \"select * from bild b join shopposition s on                    b.bildnummer=s.bildnummer\n join shoppositionartikelgruppe spag on s.datensatznummer=spag.shopposinummer\n join artikelnummer artnr on artnr.artikelgruppennummer=spag.artikelgruppennummer\n where artnr.artikelnummer='" + mvaArticleNumber + "'\"",
   });

   var mvaDataObj = splunkjs.mvc.Components.getInstance("mvasearch" + searchIncrementer);

    mvaDataObj.on('search:progress', function(properties) {
        console.log("IN PROGRESS:", properties)
    });

    mvaDataObj.on('search:done', function(properties) {
        console.log("DONE:", properties)
    });

    mvaDataObj.on('search:failed', function(properties) {
        console.log("FAIL:", properties)
    });  

var myResults = mvaDataObj.data("preview", { count: 25, offset: 10 });
myResults.on("data", function() {
        // The full data object
        console.log(myResults.data());

        // Indicates whether the results model has data
        console.log("Has data? ", myResults.hasData());

        // The results rows
        console.log("Data (rows): ", myResults.data().rows);

     // The Backbone collection
        console.log("Backbone collection: ", myResults.collection());
});
    var tmpIncrementer = parseInt(searchIncrementer);
    tmpIncrementer++;
    searchIncrementer = String(tmpIncrementer);

   }); // require
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Its mostly from the examples....&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;console.log() / IN PROGRESS, DONE&lt;/STRONG&gt; &lt;/P&gt;

&lt;P&gt;Tells me that there is no error, &lt;CODE&gt;resultCount: 4&lt;/CODE&gt; and some links like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;results: "/servicesNS/-/-/search/jobs/user__user__app__mvasearch229_1389779059.39108/results"

search.log: "/servicesNS/-/-/search/jobs/user__user__app__mvasearch229_1389779059.39108/search.log"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;console.log("Has data? ", myResults.hasData());&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Is &lt;CODE&gt;false&lt;/CODE&gt; but why? Also the result from both logs are empty.&lt;/P&gt;

&lt;P&gt;I dont get it because the resultCount is 4 so he founds something?&lt;BR /&gt;
But why are the results empty? Is there a function like "getResultsFromSearch(row, fields)" which you can use by Splunk SDK (Javascript) on jobs?&lt;/P&gt;

&lt;P&gt;Thanks..&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jan 2014 10:10:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Get-reults-from-SearchManager-SplunkJS/m-p/114840#M6572</guid>
      <dc:creator>gaRe</dc:creator>
      <dc:date>2014-01-15T10:10:47Z</dc:date>
    </item>
    <item>
      <title>Re: Get reults from SearchManager  / SplunkJS</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Get-reults-from-SearchManager-SplunkJS/m-p/114841#M6573</link>
      <description>&lt;P&gt;Where are the examples you were referencing to get to this point?&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2014 20:47:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Get-reults-from-SearchManager-SplunkJS/m-p/114841#M6573</guid>
      <dc:creator>grossb</dc:creator>
      <dc:date>2014-01-17T20:47:34Z</dc:date>
    </item>
    <item>
      <title>Re: Get reults from SearchManager  / SplunkJS</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Get-reults-from-SearchManager-SplunkJS/m-p/114842#M6574</link>
      <description>&lt;P&gt;So in your original call, you have this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;var myResults = mvaDataObj.data("preview", { count: 25, offset: 10 });
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And then you say you get four results. Is there a reason you're using "offset=10", which would mean that you won't see any results from 0-10? In this case, if you only have 4 results, you won't see them.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2014 00:51:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Get-reults-from-SearchManager-SplunkJS/m-p/114842#M6574</guid>
      <dc:creator>ineeman</dc:creator>
      <dc:date>2014-01-21T00:51:22Z</dc:date>
    </item>
    <item>
      <title>Re: Get reults from SearchManager  / SplunkJS</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Get-reults-from-SearchManager-SplunkJS/m-p/114843#M6575</link>
      <description>&lt;P&gt;You should try to use&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;var myResults = mvaDataObj.data("results") ;
myResults.on("data", function() {
                    console.log("Has data? ", myResults.hasData());
                    console.log("Type: ", myChoice);
                    console.log("Data (rows): ", myResults.data().rows);
                    console.log("Backbone collection: (rows) ", myResults.collection().raw.rows);
                });
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;instead of&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;var myResults = mvaDataObj.data("preview", { count: 25, offset: 10 });
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me know if it works!&lt;/P&gt;</description>
      <pubDate>Fri, 24 Apr 2015 10:29:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Get-reults-from-SearchManager-SplunkJS/m-p/114843#M6575</guid>
      <dc:creator>cafissimo</dc:creator>
      <dc:date>2015-04-24T10:29:58Z</dc:date>
    </item>
  </channel>
</rss>

