Tag Archives: Getting started with Java

Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters:

Question content:

{
    "error": {
        "root_cause": [
            {
                "type": "mapper_parsing_exception",
                "reason": "Root mapping definition has unsupported parameters:  [article : {properties={id={index=not_analyzed, store=true, type=long}, title={analyzer=standard, index=analyzed, store=true, type=text}, content={analyzer=standard, index=analyzed, store=true, type=text}}}]"
            }
        ],
        "type": "mapper_parsing_exception",
        "reason": "Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters:  [article : {properties={id={index=not_analyzed, store=true, type=long}, title={analyzer=standard, index=analyzed, store=true, type=text}, content={analyzer=standard, index=analyzed, store=true, type=text}}}]",
        "caused_by": {
            "type": "mapper_parsing_exception",
            "reason": "Root mapping definition has unsupported parameters:  [article : {properties={id={index=not_analyzed, store=true, type=long}, title={analyzer=standard, index=analyzed, store=true, type=text}, content={analyzer=standard, index=analyzed, store=true, type=text}}}]"
        }
    },
    "status": 400
}

Wrong configuration

{
  "mappings": {
    "article": {
      "properties": {
        "id": {
          "type": "long",
          "store": true,
          "index":"not_analyzed"
        },
        "title": {
          "type": "text",
          "store": true,
          "index":"analyzed",
          "analyzer":"standard"
        },
        "content": {
          "type": "text",
          "store": true,
          "index":"analyzed",
          "analyzer":"standard"
        } 
      }
    } 
  }
}

Modify configuration

{
  "mappings": {
      "properties": {
        "id": {
          "type": "long",
          "store": true
        },
        "title": {
          "type": "text",
          "store": true,
          "analyzer":"standard"
        },
        "content": {
          "type": "text",
          "store": true,
          "analyzer":"standard"
        } 
      }
  }
}

Cause of problem: ES7 adjustment for configuration

Java foundation — printing Yang Hui triangle

problem: print out a 10-line yanghui triangle
point: two-dimensional array
idea: first analyze the law of yanghui triangle: 1. 2. Each line ends with a 1; 3. Starting from the third row, every non-first and last number is: yangHui[I][j]=yangHui[i-1][j-1]+yangHui[i-1][j]. The code is:

//        1.声明初始化二维数组
        int[][] yangHui = new int[10][];
//        2.给数组的元素赋值
        for (int i = 0; i < yangHui.length; i++) {
            yangHui[i] = new int[i+1];
//            2.1 给首末元素赋值
            yangHui[i][0] = 1;
            yangHui[i][i] = 1;
//            2.2 给每行的非首末元素赋值
            if (i>1){
                for (int j = 1; j <yangHui[i].length-1 ; j++) {
                    yangHui[i][j]=yangHui[i-1][j-1]+yangHui[i-1][j];
                }
            }
        }
        
//        3.遍历二维数组
        for (int i = 0; i < yangHui.length; i++) {
            for (int j = 0; j <yangHui[i].length ; j++) {
                System.out.print(yangHui[i][j]+"\t");
            }
            System.out.println();
        }

Output:

1 1 1 2 1 1 3 3 1

1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1
1 7 21 35 35 21 7 1
1 8 28 56 70 56 28日8 1
1 9 36 84 126 126 84 36 9 1