title: How to use for loop to add new field into document index Lucene.
body: <p>what i am trying to do is to use a for loop to add data from mySQL DB into my index document. An if loop is to ensure that only columns with data are added into the index document else it skips to the next line. In total, there are 6 columns named tag1 to tag6 with a some blank columns. </p>
  
  <pre><code>for (int i = 1; i &lt; 6; i++) {   
              if (( result.getString("tag(i)")) != null) {
                                                  document.add(new Field("tag(i)", result.getString("tag(i)"),Field.Store.YES,
                                              Field.Index.NOT_ANALYZED));
          }
      }
  </code></pre>
  
  <p>However, there appears to be an error. Can anyone tell me what is wrong or any advice to make it work? Thanks</p>
  
  <p>Exception in thread "main" java.sql.SQLException: Column 'tag(i)' not found.</p>