关于java:ES

66次阅读

共计 1557 个字符,预计需要花费 4 分钟才能阅读完成。

示例:

{
    "code":"test",
    "value":{
        "title":"Invest Money",
        "body":"Please start investing money as soon...",
        "tags":[
            "money",
            "invest"
        ],
        "published_on":"1635096096659",
        "friend":{
            "name":"zhangsan",
            "age":14,
            "pets":[
                {
                    "name":"dog",
                    "age":10
                }
            ]
        },
        "comments":[
            {
                "name":"William",
                "age":34,
                "rating":8,
                "comment":"Nice article..",
                "commented_on":"1635096096659"
            },
            {
                "name":"John",
                "age":38,
                "rating":9,
                "comment":"I started investing after reading this.",
                "commented_on":"1635096096659"
            },
            {
                "name":"Smith",
                "age":33,
                "rating":7,
                "comment":"Very good post",
                "commented_on":"1635096096659"
            }
        ]
    }
}

映射:

PUT test
{
    "mappings":{
        "doc":{
            "properties":{
                "title":{"type":"text"},
                "body":{"type":"text"},
                "tags":{"type":"text"},
                "published_on":{
                    "type":"date",
                    "format":"yyyy-MM-dd HH:mm:ss || yyyy-MM-dd || yyyy/MM/dd HH:mm:ss|| yyyy/MM/dd ||epoch_millis"
                },
                "friend":{
                    "type":"nested",
                    "properties":{
                        "name":{"type":"text"},
                        "age":{"type":"long"},
                        "pets":{
                            "type":"nested",
                            "properties":{
                                "name":{"type":"text"},
                                "age":{"type":"long"}
                            }
                        }
                    }
                },
                "comments":{
                    "type":"nested",
                    "properties":{
                        "name":{"type":"text"},
                        "age":{"type":"long"},
                        "rating":{"type":"long"},
                        "comment":{"type":"text"},
                        "commented_on":{
                            "type":"date",
                            "format":"yyyy-MM-dd HH:mm:ss || yyyy-MM-dd || yyyy/MM/dd HH:mm:ss|| yyyy/MM/dd ||epoch_millis"
                        }
                    }
                },
                "creatorId":{"type":"text"},
                "creatorName":{"type":"text"},
                "createTime":{
                    "type":"date",
                    "format":"yyyy-MM-dd HH:mm:ss || yyyy-MM-dd || yyyy/MM/dd HH:mm:ss|| yyyy/MM/dd ||epoch_millis"
                },
                "modifierId":{"type":"text"},
                "modifierName":{"type":"text"},
                "modifyTime":{
                    "type":"date",
                    "format":"yyyy-MM-dd HH:mm:ss || yyyy-MM-dd || yyyy/MM/dd HH:mm:ss|| yyyy/MM/dd ||epoch_millis"
                }
            }
        }
    }
}

正文完
 0