elasticsearch使用教程

完整教程:https://www.cnblogs.com/Neeo/category/1442079.html
GET /waiter/_doc/_search
{
	"query":{
		"match":{
			"name":"zhengjie"
		}
	},
	"from":1,
	"size":2,
	"sort":{
		"age":{
			"order":"desc"
		}
	}
}



//注意点:should 是个数组
GET /waiter/_doc/_search
{
	"query":{
		"bool":{
			"should":[{
				"match":{
					"name":"zhengjie"
				}
			},
			{
				"match":{
					"age":34
				}
			}
		]
		}
	}
}

//加了filter
{
	"query":{
		"bool":{
			"should":[{
				"match":{
					"name":"zhengjie"
				}
			},
			{
				"match":{
					"age":33
				}
			}
		]
		,
		"filter":{
			"range":{
					"age":{
						"gte":33
					}
				}
			}
		}
	}
}

//加高亮
{
	"query":{
		"bool":{
			"should":[{
				"match":{
					"name":"zhengjie"
				}
			},
			{
				"match":{
					"age":33
				}
			}
		]
		,
		"filter":{
			"range":{
					"age":{
						"gte":33
					}
				}
			}
		}
	},
	"highlight":{
		"fields":{
			"name":{}
		}
	}
}


// _source
{
	"query":{
		"bool":{
			"should":[{
				"match":{
					"name":"zhengjie"
				}
			},
			{
				"match":{
					"age":33
				}
			}
		]
		}
	},
	"_source":["name","age"]
}

//聚合
{
	"query":{
		"bool":{
			"should":[{
				"match":{
					"name":"zhengjie"
				}
			},
			{
				"match":{
					"age":33
				}
			}
		]
		}
	},
	"aggs":{
		"my_sum":{
			"sum":{
				"field":"age"
			}
		}
	}
}
{
	"query":{
		"bool":{
			"should":[
				{
					"match":{
						"content":"乡村爱情"
					}
				},
				{
					"match":{
						"author":"张老三"
					}	
				}
			],
			"filter":{
				"range":{
					"name":{
						"gte":23
					}	
				}
			}
		}
	},
	"from":0,
	"size":10,

	"sort":{
		"price":{
			"order":"desc"
		}
	},
	"_source":["name","publish"],
	"highlight":{
		"fields":{
			"name":{}
		}
	},
	"aggs":{
		"my_sum":{
			"sum":{
				"field":"price"
			}
		}
	}
	
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值