code: static void createView(Map<String, MapReduce> views, String columnName, List<String> columns)
      {
          Iterator<String> iterator = columns.iterator();
  
          MapReduce mapr = new MapReduce();
          StringBuilder mapBuilder = new StringBuilder();
          StringBuilder ifBuilder = new StringBuilder("function(doc){if(");
          StringBuilder emitFunction = new StringBuilder("{emit(");
          if (columns != null && columns.size() > 1)
          {
              emitFunction.append("[");
          }
          while (iterator.hasNext())
          {
              String nextToken = iterator.next();
              ifBuilder.append("doc." + nextToken);
              ifBuilder.append(" && ");
              emitFunction.append("doc." + nextToken);
              emitFunction.append(",");
          }
          ifBuilder.delete(ifBuilder.toString().lastIndexOf(" && "), ifBuilder.toString().lastIndexOf(" && ") + 3);
          emitFunction.deleteCharAt(emitFunction.toString().lastIndexOf(","));
  
          ifBuilder.append(")");
          if (columns != null && columns.size() > 1)
          {
              emitFunction.append("]");
          }
          emitFunction.append(", doc)}}");
  
          mapBuilder.append(ifBuilder.toString()).append(emitFunction.toString());
  
          mapr.setMap(mapBuilder.toString());
          views.put(columnName, mapr);
      }
docs: Creates the view.
  
  @param views
  the views
  @param columnName
  the column name
  @param columns
  the columns