public LinkedList<IndexCluster> getClusters(String query) {
    LinkedList<IndexCluster> clusterList = new LinkedList<IndexCluster>();
    
    try {
      // URL obj = new URL(solrURL + "/collection1/dismax?q=" + query
      // + "&wt=xml&rows=100");
      String queryEnc = URLEncoder.encode(query, "UTF-8");
      URI uri = new URI("http", null, "localhost", 8983,
          "/solr/collection1" + request_handler, "q=" + queryEnc
              + "&wt=xml&" + "rows=" + CLUSTER_ROWS, null);
      HttpURLConnection con = (HttpURLConnection) (uri.toURL())
          .openConnection();
      con.setRequestMethod("GET");

      // Parse the XML given as result
      DocumentBuilderFactory dbFactory = DocumentBuilderFactory
          .newInstance();
      DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
      Document doc = dBuilder.parse(con.getInputStream());
      doc.getDocumentElement().normalize();
      Node response = doc.getElementsByTagName("response").item(0);
      NodeList children = response.getChildNodes();

      Node clusters = children.item(3);// "clusters" node
      NodeList clusterNodes = clusters.getChildNodes();// all its elements

      for (int i = 0; i < clusterNodes.getLength(); i++) {
        NodeList info = clusterNodes.item(i).getChildNodes(); // All the
                                    // cluster's
                                    // info
        Node labels = info.item(0);
        if (labels.getTextContent().equals("Other Topics")) {
          break;
        }
        NodeList docs = info.item(2).getChildNodes();
        IndexCluster cl = new IndexCluster();
        cl.label = labels.getTextContent();
        for (int j = 0; j < docs.getLength(); j++) {
          cl.solrID.add(docs.item(j).getChildNodes().item(0)
              .getTextContent());
        }
        clusterList.add(cl);
      }
      con.getInputStream().close();
    } catch (Exception e) {

      System.err
          .println("Could not cluster. Error in getClusters(query) in Index:");
      System.err.println(e.getMessage());
    }
    return clusterList;
  }