Skip to content

Nested类型查询

iamazy edited this page Aug 5, 2019 · 2 revisions

1. elasticsql理论上支持无限嵌套nested查询(虽然不推荐太大的嵌套层数)

语法:

[nestedPath,expression]

比如mapping为

"mappings": {
    "apple": {
        "properties": {
	    "productName": {
		"type": "string",
		"index": "not_analyzed"
	     },
	    "buyers": {
		"type": "nested",
		"properties": {
		    "buyerName": {
			"type": "string",
			"index": "not_analyzed"
		    },
		     "productPrice": {
			"type": "double"
		     },
                     "family":{
                        "type":"nested",
                        "properties":{
                            "son":{
                                "type":"keyword"
                            }
                        }
                    }
		}
	    }
        }
    }
}

nested的sql示例

select * from apple where [buyers,buyers.buyerName='小明' and [buyers.family,buyers.family.son='小小明']];
Clone this wiki locally