使用ES时踩过的坑

报错信息

org.elasticsearch.ElasticsearchStatusException: Elasticsearch exception [type=invalid_index_name_exception, reason=Invalid index name [skuBulk], must be lowercase]
            bulkRequest.add(new IndexRequest("user")
                    .id(user.getId())
                    .source(JSON.toJSONString(user), XContentType.JSON)
            );

 

修改:创建索引的名必须是小写,尤其是

new IndexRequest("user")

 还不会报错,显示结果也是成功的,但是kibana里边就是没有数据

 

报错:java.net.ConnectException: Timeout connecting to [localhost/192.168.200.150:9200]

解决:在配置文件中添加:

# 设置连接ES超时时间
spring.elasticsearch.rest.connection-timeout=20s

 

注意问题:ES排序时不能用分词的字段作为排序的关键字

 

posted @ 2020-12-17 09:45  爱吃芒果的牛  阅读(837)  评论(0编辑  收藏  举报