examples/node/helloworld/search_oneshot.js
function(results, done) {
                // Find the index of the fields we want
                var rawIndex = results.fields.indexOf("_raw");
                var sourcetypeIndex = results.fields.indexOf("sourcetype");
                var userIndex = results.fields.indexOf("user");
                
                // Print out each result and the key-value pairs we want
                console.log("Results: ");
                for(var i = 0; i < results.rows.length; i++) {
                    console.log("  Result " + i + ": ");
                    console.log("    sourcetype: " + results.rows[i][sourcetypeIndex]);
                    console.log("    user: " + results.rows[i][userIndex]);
                    console.log("    _raw: " + results.rows[i][rawIndex]);
                }
                
                done();
            }
function(results, done) {
                // Find the index of the fields we want
                var rawIndex = results.fields.indexOf("_raw");
                var sourcetypeIndex = results.fields.indexOf("sourcetype");
                var userIndex = results.fields.indexOf("user");
                
                // Print out each result and the key-value pairs we want
                console.log("Results: ");
                for(var i = 0; i < results.rows.length; i++) {
                    console.log("  Result " + i + ": ");
                    console.log("    sourcetype: " + results.rows[i][sourcetypeIndex]);
                    console.log("    user: " + results.rows[i][userIndex]);
                    console.log("    _raw: " + results.rows[i][rawIndex]);
                }
                
                done();
            }
function ( results , done ) { // Find the index of the fields we want var rawIndex = results . fields . indexOf ( "_raw" ) ; var sourcetypeIndex = results . fields . indexOf ( "sourcetype" ) ; var userIndex = results . fields . indexOf ( "user" ) ; // Print out each result and the key-value pairs we want console . log ( "Results: " ) ; for ( var i = 0 ; i < results . rows . length ; i ++ ) { console . log ( "  Result " + i + ": " ) ; console . log ( "    sourcetype: " + results . rows [ i ] [ sourcetypeIndex ] ) ; console . log ( "    user: " + results . rows [ i ] [ userIndex ] ) ; console . log ( "    _raw: " + results . rows [ i ] [ rawIndex ] ) ; } done ( ) ; }
The job is done, and the results are returned inline
The job is done and the results are returned inline