DSL搜索(五)

本文详细介绍了DSL搜索中的过滤器,包括gt、lt、gte、lte的使用,以及post_filter与query的区别。接着讨论了排序功能,如倒序、正序、组合排序,并强调了对text字段排序的注意事项。最后讲解了高亮highlight的实现,展示了如何自定义高亮标签。
摘要由CSDN通过智能技术生成

1. 过滤器 post_filter

1.1 gt:大于 、lt:小于

返回60<money<1000的数据:

{
	"took": 2,
	"timed_out": false,
	"_shards": {
		"total": 3,
		"successful": 3,
		"skipped": 0,
		"failed": 0
	},
	"hits": {
		"total": {
			"value": 4,
			"relation": "eq"
		},
		"max_score": 7.372511,
		"hits": [
			{
				"_index": "shop",
				"_type": "_doc",
				"_id": "1001",
				"_score": 7.372511,
				"_source": {
					"id": 1001,
					"age": 18,
					"username": "imoocAmazing",
					"nickname": "慕课网",
					"money": 88.8,
					"desc": "我在慕课网学习java和前端, 学习到了很多知识",
					"sex": 0,
					"birthday": "1922-12-24",
					"face": "https://www.imooc.com/static/img/index/logo.png"
				}
			},
			{
				"_index": "shop",
				"_type": "_doc",
				"_id": "1003",
				"_score": 6.846202,
				"_source": {
					"id": 1003,
					"age": 20,
					"username": "bigFace",
					"nickname": "飞翔的巨鹰",
					"money": 66.8,
					"desc": "慕课网团队和导游坐飞机去海外旅游,去了新马泰和欧洲",
					"sex": 1,
					"birthday": "1996-01-14",
					"face": "https://www.imooc.com/static/img/index/logo.png"
				}
			},
			{
				"_index": "shop",
				"_type": "_doc",
				"_id": "1005",
				"_score": 1.6699551,
				"_source": {
					"id": 1005,
					"age": 25,
					"username": "gotoplay",
					"nickname": "ps游戏机",
					"money": 155.8,
					"desc": "今天生日,女友送了我一台play station游戏机,非常好玩,非常不错",
					"sex": 1,
					"birthday": "1989-03-14",
					"face": "https://www.imooc.com/static/img/index/logo.png"
				}
			},
			{
				"_index": "shop",
				"_type": "_doc",
				"_id": "1006",
				"_score": 0.88025683,
				"_source": {
					"id": 1006,
					"age": 19,
					"username": "missimooc",
					"nickname": "我叫小慕",
					"money": 156.8,
					"desc": "我叫凌云慕,今年20岁,是一名律师,我在奇䯲星球做演讲",
					"sex": 1,
					"birthday": "1993-04-14",
					"face": "https://www.imooc.com/static/img/index/logo.png"
				}
			}
		]
	}
}

1.2 gte:大于等于 、lte:小于等于

返回66.8<=money<=155.8的数据:

{
	"took": 2,
	"timed_out": false,
	"_shards": {
		"total": 3,
		"successful": 3,
		"skipped": 0,
		"failed": 0
	},
	"hits": {
		"total": {
			"value": 3,
			"relation": "eq"
		},
		"max_score": 7.372511,
		"hits": [
			{
				"_index": "shop",
				"_type": "_doc",
				"_id": "1001",
				"_score": 7.372511,
				"_source": {
					"id": 1001,
					"age": 18,
					"username": "imoocAmazing",
					"nickname": "慕课网",
					"money": 88.8,
					"desc": "我在慕课网学习java和前端, 学习到了很多知识",
					"sex": 0,
					"birthday": "1922-12-24",
					"face": "https://www.imooc.com/static/img/index/logo.png"
				}
			},
			{
				"_index": "shop",
				"_type": "_doc",
				"_id": "1003",
				"_score": 6.846202,
				"_sou
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

@所谓伊人

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值