Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elasticsearch indexing not working and error message: node null not part of the cluster Cluster [elasticsearch], ignoring

I just downloaded the elastic search distribution and ran it.

curl 'localhost:9200'

{
   "status" : 200,
   "name" : "cbs",
   "cluster_name" : "elasticsearch",
   "version" : {
   "number" : "1.4.1",
   "build_hash" : "89d3241d670db65f994242c8e8383b169779e2d4",
   "build_timestamp" : "2014-11-26T15:49:29Z",
   "build_snapshot" : false,
   "lucene_version" : "4.10.2"
    },
  "tagline" : "You Know, for Search"
}

And I am trying to access it using spring-data. Added the following lines in application-context (as per spring data documentation) with xml namespace:

<elasticsearch:repositories base-package="com.cbs" />
<elasticsearch:transport-client id="client" cluster-nodes="127.0.0.1:9300" cluster-name="elasticsearch" />
<bean name="elasticsearchTemplate" class="org.springframework.data.elasticsearch.core.ElasticsearchTemplate">
    <constructor-arg name="client" ref="client" />
</bean>

Here is the entity and repository code:

@org.springframework.data.elasticsearch.annotations.Document(indexName = "product", type = "product", shards = 1, replicas = 0, indexStoreType = "memory", refreshInterval = "-1")
public class Product {
    @Id
    private String id;    
    private String name;
}


@Repository
public class ProductSearchDaoImpl implements IProductSearchDao {
@Autowired
private ElasticsearchOperations elasticsearchOperations;

@Override
public void index(Product product) {
    elasticsearchOperations.createIndex(Product.class);
    elasticsearchOperations.putMapping(Product.class);
    IndexQuery indexQuery = new IndexQueryBuilder().withId(product.getId()).withObject(product).build();
    elasticsearchOperations.index(indexQuery);
    elasticsearchOperations.refresh(Product.class, true);
}
}

Now when I run the test case to index the product, I am getting a consistent warning message (every 2 seconds or so) as

[Neuronne] node null not part of the cluster Cluster [elasticsearch], ignoring...
[Neuronne] node null not part of the cluster Cluster [elasticsearch], ignoring...

And the product is not getting indexed (even the index is not created)

curl 'localhost:9200/_cat/indices?v'
health status index    pri rep docs.count docs.deleted store.size pri.store.size 

Can anyone help me out with this?

like image 620
Sunny Agarwal Avatar asked Nov 27 '14 12:11

Sunny Agarwal


People also ask

How do I clean up storage space in Elasticsearch cluster?

Yes. You can go to the node where the indices reside and check the indices subdirectory of where your data resides and a df will show they are gone after deletion. Filesystem queue of I/O operations may delay the eventual removal, but you should see that the indices disappear almost instantly.

Why Elasticsearch cluster is red?

A cluster status that shows red status doesn't mean that your cluster is down. Rather, this status indicates that at least one primary shard and its replicas aren't allocated to a node. If your cluster status shows yellow status, then the primary shards for all indices are allocated to nodes in your cluster.


1 Answers

For those who met the same error and came here from search engines, make sure the TransportClient is using the same cluster name as the cluster itself.

  1. Verify cluster name.

Visit http://localhost:9200 to check the cluster name. The default name is elasticsearch. If you customised the cluster name using elasticsearch.yml file, make sure the config file is picked up.

  1. Set culster.name when creating TransportClient.

    Settings settings = ImmutableSettings.settingsBuilder()
            .put("cluster.name", clusterName)
            .put("client.transport.ignore_cluster_name", false)
            .put("node.client", true)
            .put("client.transport.sniff", true)
            .build();
    client = new TransportClient(settings).addTransportAddress(new  InetSocketTransportAddress(host, port)); 
    
  2. Ignore cluster name check

You can ignore the check of cluster name by setting client.transport.ignore_cluster_name to true.

  1. Debug if the error still exists

If the error still exists, launch your application in debug mode, and debug TransportClientNodesService.

like image 98
Alex Cheng Avatar answered Oct 27 '22 01:10

Alex Cheng