title: ElasticSearch TypeError: Request path contains unescaped characters
body: <p>I am writing server code that listens for search requests on the firebase database and return the search result.  This is the code that indexes the data from Firebase Database to Elastic Search.  Is this the correct way to index data?</p>
  
  <pre><code>var firebase = require('firebase');
  var ElasticClient = require('elasticsearchclient');
  
  // listen for changes to Firebase data
  var client = new ElasticClient({host:'localhost',port:9200});
  
  firebase.initializeApp({
      serviceAccount: {
          ...
      },
  
      databaseURL: "https://searchserver.firebaseio.com/"
  })
  
  var db = firebase.database();
  var ref = db.ref("realtime");
  
  ref.on('child_added', upsert);
  ref.on('child_changed', upsert);
  ref.on('child_removed', remove);
  
  function upsert(snap) {
      client.index({
          index: 'firebase',
          type: 'users',
          id: snap.key,
          body: snap.val()
      }, function (err, response) {
          if (err) {
              console.log("error indexing " + error)
          }
      });
  }
  
  function remove(snap) {
      client.delete({
          index: 'firebase',
          type: 'users',
          id: snap.key
      }, function (error, response) {
          if (error) {
              console.log("Error deleting user : " + error);
          }
      });
  }
  </code></pre>
  
  <p>This is the error message.</p>
  
  <pre><code>TypeError: Request path contains unescaped characters.
  at new ClientRequest (_http_client.js:50:11)
  at Object.exports.request (http.js:31:10)
  at ElasticSearchCall.exec (C:\Users\jojo\Documents\readouts-search\readouts-server\node_modules\elasticsearchclient\lib\elasticsearchclient\calls\elasticSearchCall.js:45:26)
  at ElasticSearchClient.createCall (C:\Users\jojo\Documents\readouts-search\readouts-server\node_modules\elasticsearchclient\lib\elasticsearchclient\elasticSearchClient.js:28:14)
  at ElasticSearchClient.index (C:\Users\jojo\Documents\readouts-search\readouts-server\node_modules\elasticsearchclient\lib\elasticsearchclient\calls\core.js:37:17)
  at upsert (C:\Users\jojo\Documents\readouts-search\readouts-server\readouts-server.js:28:12)
  at C:\Users\jojo\Documents\readouts-search\readouts-server\node_modules\firebase\database-node.js:146:375
  at Qb (C:\Users\jojo\Documents\readouts-search\readouts-server\node_modules\firebase\database-node.js:43:165)
  at nc (C:\Users\jojo\Documents\readouts-search\readouts-server\node_modules\firebase\database-node.js:31:216)
  at oc (C:\Users\jojo\Documents\readouts-search\readouts-server\node_modules\firebase\database-node.js:30:701)
  </code></pre>
  
  <p>Value of snap.val()</p>
  
  <pre><code>{ '5Nyu7Px7vNYGizJqlyGHhAfnvwu2':
  { allOwnerVideos: 'none',
   allRatedVideos: 'none',
   email: 'iron@man.com',
   favorite_category:
    { fifth: 'Business',
      first: 'Sports',
      fourth: 'Biography',
      second: 'Sci-Fi',
      seventh: 'Action and Adventure',
      sixth: 'Art',
      third: 'Satire' },
   name: 'iron',
   personalmessage: 'man',
   profileimage: 'https://firebasestorage.googleapis.com/v0/b/readoutsa75e0.appspot.com/o/ProfilePictures%2F_5Nyu7Px7vNYGizJqlyGHhAfnvwu2.jpg?alt=media&amp;token=743dbd6a-985c-4481-9d63-4ed30e8703a9' },
   '6bt3EqdWyfQ3ksEdy9BTyYvQK4F3'
  </code></pre>