title: How to connect to ES cluster locally made using Spring Data Elasticsearch?
body: <p>I just started to learn <code>Elasticsearch</code> and <code>Spring Data Elasticsearch</code> with a demo project and I was able to get up and running.</p>
  
  <p>Installed <code>Elasticsearch</code> on Mac using <code>brew install elasticsearch</code> and started it using <code>brew service start elasticsearch</code>.</p>
  
  <p>For the project,</p>
  
  <pre><code>@Configuration
  @EnableElasticsearchRepositories(basePackages = "com.shubham.entities")
  @ComponentScan(basePackages = "com.shubham")
  public class DataConfig {
  
  private static Logger logger = LoggerFactory.getLogger(DataConfig.class);
  
  @Value("${elasticsearch.home}")
  private String elasticsearchHome;
  
  @Bean
  public NodeBuilder nodeBuilder() {
      return new NodeBuilder();
  }
  
  @Bean
  public ElasticsearchOperations elasticsearchTemplate() {
      try {
          final File tmpDir = File.createTempFile("elasticsearch_data", Long.toString(System.nanoTime()));
          final Settings.Builder elasticsearchSettings =
                  Settings.settingsBuilder().put("http.enabled", "true")
                          .put("index.number_of_shards", "1")
                          .put("path.data", new File(tmpDir, "data").getAbsolutePath()) // 2
                          .put("path.logs", new File(tmpDir, "logs").getAbsolutePath()) // 2
                          .put("path.work", new File(tmpDir, "work").getAbsolutePath());
  
          return new ElasticsearchTemplate(nodeBuilder()
                  .local(true)
                  .settings(elasticsearchSettings.build())
                  .node()
                  .client());
  
          // @formatter:on
      } catch (final IOException ioex) {
          logger.error("Cannot create temp dir", ioex);
          throw new RuntimeException();
      }
  }
  }
  </code></pre>
  
  <p><code>elasticsearchHome</code> in above config file is actually empty, I wonder why is this still working. In <code>application.properties</code> file,</p>
  
  <pre><code>spring.data.elasticsearch.cluster-name=shubham_lookup_cs_default
  spring.data.elasticsearch.repositories.enabled=true
  </code></pre>
  
  <p>I am able to perform CRUD and other DB operations through Spring Data JPA and tested it as well, works good.</p>
  
  <p>My question is, how can I query it through command line?</p>
  
  <p>When I use <code>curl 'http://localhost:9200/?pretty'</code>, I get back:</p>
  
  <pre><code>{
    "name" : "4IVQcts",
    "cluster_name" : "elasticsearch_shubham",
    "cluster_uuid" : "WxCAzE51TfS7P4eFYJpvCA",
    "version" : {
      "number" : "5.3.0",
      "build_hash" : "3adb13b",
      "build_date" : "2017-03-23T03:31:50.652Z",
      "build_snapshot" : false,
      "lucene_version" : "6.4.1"
    },
    "tagline" : "You Know, for Search"
  }
  </code></pre>
  
  <p>Clearly, not the expected one as <code>cluster_name</code> is <code>elasticsearch_shubham</code> which is default I guess.</p>
  
  <p>What I am thinking is that I am missing something very basic here. 2 different clusters exist on my machine now.</p>
  
  <p>For more info about how I know that <code>elasticsearch</code> project is working, I made some entities and persisted them, queried using Controllers, working.</p>
  
  <p>So, I have the following questions:</p>
  
  <ol>
  <li>How do I connect through the cluster made by <code>Spring Data Elasticsearch</code> through command line, using CURL?</li>
  <li>Is there any User Interface through which I can see all data in <code>elasticsearch</code>, maybe using <code>Kibana</code>?</li>
  <li>Is <code>Spring Data Elasticsearch</code> actually using the default cluster, instead of the cluster name I mentioned in <code>application.properties</code> file?</li>
  </ol>