目录
- 一、初始化文档数据
- 二、多关键字精确查询文档
- 2.1、概述
- 2.2、示例
一、初始化文档数据
-
在 Postman 中,向 ES 服务器发 POST 请求 :http://localhost:9200/user/_doc/1,请求体内容为:
{"name":"张三","age":22,"sex":"男" }
-
在 Postman 中,向 ES 服务器发 POST 请求 :http://localhost:9200/user/_doc/2,请求体内容为:
{"name":"张三1","age":22,"sex":"男" }
-
在 Postman 中,向 ES 服务器发 POST 请求 :http://localhost:9200/user/_doc/3,请求体内容为:
{"name":"李四","age":23,"sex":"女" }
-
在 Postman 中,向 ES 服务器发 POST 请求 :http://localhost:9200/user/_doc/4,请求体内容为:
{"name":"李四1","age":24,"sex":"女" }
二、多关键字精确查询文档
2.1、概述
- terms 查询和 term 查询一样,但它允许你指定多值进行匹配。
- 如果这个字段包含了指定值中的任何一个值,那么这个文档满足条件,类似于 mysql 的 in
2.2、示例
- 在 Postman 中,向 ES 服务器发 GET请求 :http://localhost:9200/user/_search,请求体内容为:
{"query": {"terms": {"age": ["20","22"]}} }
- 服务器响应结果