当前位置:   article > 正文

Elasticsearch 6 创建索引报错 invalid_index_name_exception Invalid index name [testDemo], must be lowercase_elasticsearch exception [type=invalid_index_name_e

elasticsearch exception [type=invalid_index_name_exception, reason=invalid i

Elasticsearch 6 创建索引报错:

Invalid index name [testDemo], must be lowercase

原因:Elasticsearch 6 默认索引类型是_doc,如果想改变则要指定索引类型

示例:

  1. PUT testDemo
  2. {
  3. "mappings": {
  4. "properties": {
  5. "name": {
  6. "type": "text"
  7. },
  8. "location": {
  9. "type": "geo_point"
  10. }
  11. }
  12. }
  13. }

返回:

  1. {
  2. "error": {
  3. "root_cause": [
  4. {
  5. "type": "invalid_index_name_exception",
  6. "reason": "Invalid index name [testDemo], must be lowercase",
  7. "index_uuid": "_na_",
  8. "index": "testDemo"
  9. }
  10. ],
  11. "type": "invalid_index_name_exception",
  12. "reason": "Invalid index name [testDemo], must be lowercase",
  13. "index_uuid": "_na_",
  14. "index": "testDemo"
  15. },
  16. "status": 400
  17. }

指定索引类型:

  1. PUT testDemo
  2. {
  3. "mappings": {
  4. "product": {
  5. "properties": {
  6. "name": {
  7. "type": "text"
  8. },
  9. "location": {
  10. "type": "geo_point"
  11. }
  12. }
  13. }
  14. }
  15. }

结果:

  1. {
  2. "acknowledged" : true,
  3. "shards_acknowledged" : true,
  4. "index" : "testDemo"
  5. }

product为指定索引类型

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/325632
推荐阅读
相关标签
  

闽ICP备14008679号