11'use strict' ;
22
33var watson = require ( 'watson-developer-cloud' ) ;
4- var fs = require ( 'fs' ) ;
54var async = require ( 'async' ) ;
6- var solr = require ( 'solr-client' ) ;
75
86var username = 'INSERT YOUR USERNAME FOR THE SERVICE HERE' ;
97var password = 'INSERT YOUR PASSWORD FOR THE SERVICE HERE' ;
@@ -30,10 +28,15 @@ var solrClient = search.createSolrClient({
3028async . series ( [
3129 function uploadConfig ( done ) {
3230 console . log ( 'Uploading Solr config ' + configName ) ;
33- search . uploadConfig ( { clusterId : clusterId , configName : configName , configZipPath : configZipPath } ,
34- function ( err , res ) {
35- printResponse ( err , 'Error uploading Solr config: ' , 'Uploaded Solr config ' + configName , done ) ;
36- } ) ;
31+ search . uploadConfig ( {
32+ clusterId : clusterId ,
33+ configName : configName ,
34+ configZipPath : configZipPath
35+ } ,
36+ function ( err ) {
37+ printResponse ( err , 'Error uploading Solr config: ' , 'Uploaded Solr config ' + configName , done ) ;
38+ } ) ;
39+
3740 } ,
3841
3942 function listConfigs ( done ) {
@@ -45,20 +48,29 @@ async.series([
4548
4649 function getConfig ( done ) {
4750 console . log ( 'Getting Solr config ' + configName ) ;
48- search . getConfig ( { clusterId : clusterId , configName : configName } , function ( err , res ) {
51+ search . getConfig ( {
52+ clusterId : clusterId ,
53+ configName : configName
54+ } , function ( err ) {
4955 if ( err ) {
5056 console . log ( 'Error getting config: ' + JSON . stringify ( err , null , 2 ) ) ;
5157 } else {
5258 // Save response to a local file here
5359 }
5460 done ( ) ;
5561 } ) ;
62+
5663 } ,
5764
5865 function createCollection ( done ) {
59- search . createCollection ( { clusterId : clusterId , collectionName : collectionName , configName : configName } , function ( err , res ) {
66+ search . createCollection ( {
67+ clusterId : clusterId ,
68+ collectionName : collectionName ,
69+ configName : configName
70+ } , function ( err , res ) {
6071 printResponse ( err , 'Error creating Solr collection: ' , res , done ) ;
6172 } ) ;
73+
6274 } ,
6375
6476 function listCollections ( done ) {
@@ -70,13 +82,13 @@ async.series([
7082 function indexAndCommit ( done ) {
7183 console . log ( 'Indexing a document...' ) ;
7284 var doc = { id : 1234 , title_t : 'Hello' , text : 'some text' } ;
73- solrClient . add ( doc , function ( err , addResponse ) {
85+ solrClient . add ( doc , function ( err ) {
7486 if ( err ) {
7587 console . log ( 'Error indexing document: ' + err ) ;
7688 done ( ) ;
7789 } else {
7890 console . log ( 'Indexed a document.' ) ;
79- solrClient . commit ( function ( err , commitResponse ) {
91+ solrClient . commit ( function ( err ) {
8092 if ( err ) {
8193 console . log ( 'Error committing change: ' + err ) ;
8294 } else {
@@ -88,7 +100,7 @@ async.series([
88100 } ) ;
89101 } ,
90102
91- function search ( done ) {
103+ function _search ( done ) {
92104 console . log ( 'Searching all documents.' ) ;
93105 var query = solrClient . createQuery ( ) ;
94106 query . q ( { '*' : '*' } ) ;
@@ -105,16 +117,24 @@ async.series([
105117
106118 function deleteCollection ( done ) {
107119 console . log ( 'Deleting Solr collection ' + collectionName ) ;
108- search . deleteCollection ( { clusterId : clusterId , collectionName : collectionName } , function ( err , res ) {
120+ search . deleteCollection ( {
121+ clusterId : clusterId ,
122+ collectionName : collectionName
123+ } , function ( err ) {
109124 printResponse ( err , 'Error deleting collection: ' , 'Deleted Solr collection ' + collectionName , done ) ;
110125 } ) ;
126+
111127 } ,
112128
113129 function deleteConfig ( done ) {
114130 console . log ( 'Deleting Solr config ' + configName ) ;
115- search . deleteConfig ( { clusterId : clusterId , configName : configName } , function ( err , res ) {
131+ search . deleteConfig ( {
132+ clusterId : clusterId ,
133+ configName : configName
134+ } , function ( err ) {
116135 printResponse ( err , 'Error deleting config: ' , 'Deleted Solr config ' + configName , done ) ;
117136 } ) ;
137+
118138 } ,
119139] ) ;
120140
0 commit comments