title: Searching on a variable-defined field with ElasticSearch
body: <p>Here is the relevant code:</p>
  
  <pre><code>var field = String(querystring.parse(postData).field).toLowerCase();
  var qryObj = {
  "fields" : view_options,
  "query":{
      "term" : { field : value} 
      }
  };
  </code></pre>
  
  <p>The variable 'field' will be a string, like "number", "date", etc.  What I want to do is search the index only in the field that is defined in the variable 'field'.  This code works if I hardcode the string, like this: </p>
  
  <pre><code>"term" : { "number" : value} 
  </code></pre>
  
  <p>So can someone shed some light on a way to only search a specific field using a predefined variable instead of a string?</p>