本文介绍了Elasticsearch索引无法正常工作并显示错误消息:节点null不在集群Cluster [elasticsearch]的一部分,忽略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚下载并运行了弹性搜索。

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"
}

我正在尝试使用spring-data访问它。
在带有XML名称空间的应用程序上下文中添加了以下几行(根据spring数据文档):

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);
}
}

现在,当我运行测试用例为产品建立索引时, ,我得到一个一致的警告消息(每2秒左右),例如

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 

有人可以帮我吗?

推荐答案

对于那些遇到相同的错误,并且来自搜索引擎,请确保 TransportClient 使用的群集名称与群集本身相同。

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. 验证集群名称。

访问检查群集名称。默认名称为 elasticsearch 。如果使用 elasticsearch.yml 文件自定义集群名称,请确保已拾取配置文件。

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. 在创建 TransportClient 时设置 culster.name

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)); 


  • 忽略群集名称检查

  • Ignore cluster name check

    通过将 client.transport.ignore_cluster_name 设置为 true 。

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


    1. 如果错误仍然存​​在,则进行调试

    如果错误仍然存​​在,请以调试模式启动应用程序,然后调试。

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

    这篇关于Elasticsearch索引无法正常工作并显示错误消息:节点null不在集群Cluster [elasticsearch]的一部分,忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

  • 09-27 02:47