Springboot整合es7.12.1自动创建mapping

springboot 整合 es 需要添加 mapping 文件:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
{
  "properties": {
    "id": {
      "type": "keyword"
    },
    "tableId": {
      "type": "keyword"
    },
    "layerId": {
      "type": "keyword"
    },
    "name": {
      "type": "text",
      "analyzer": "ik_max_word",
      "fields": {
        "keyword": {
          "type": "keyword"
        },
        "pinyin": {
          "type": "text",
          "analyzer": "pinyin"
        },
        "suggest": {
          "type": "completion",
          "analyzer": "ik_max_word"
        },
        "suggest_pinyin": {
          "type": "completion",
          "analyzer": "pinyin"
        }
      }
    },
    "longitude": {
      "type": "double"
    },
    "latitude": {
      "type": "double"
    },
    "attribute": {
      "type": "keyword"
    },
    "dataType": {
      "type": "keyword"
    },
    "dataTypeDesc": {
      "type": "keyword"
    }
  }
}

image-20220802100102475

整合的版本为 7.12.1。

引入的方式为:@Mapping(mappingPath = “/mapping/es/remote_statistics.json”)

image-20220802100143392

遇到的坑:

报错:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
{
  "error": {
    "root_cause": [
      {
        "type": "mapper_parsing_exception",
        "reason": "Root mapping definition has unsupported parameters:  [book : {properties={price={type=double}, name={type=keyword}, id={type=integer}, detail={type=text}}}]"
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters:  [book : {properties={price={type=double}, name={type=keyword}, id={type=integer}, detail={type=text}}}]",
    "caused_by": {
      "type": "mapper_parsing_exception",
      "reason": "Root mapping definition has unsupported parameters:  [book : {properties={price={type=double}, name={type=keyword}, id={type=integer}, detail={type=text}}}]"
    }
  },
  "status": 400
}

因为 json 中包含 mapping,去掉接口。

Licensed under CC BY-NC-SA 4.0
最后更新于 Jan 06, 2025 05:52 UTC
comments powered by Disqus
Built with Hugo
主题 StackJimmy 设计
Caret Up