GET _search
{
"query": {
"match_all": {}
}
}
GET _analyze
{
"analyzer": "ik_smart"
, "text": "淘宝学员梁峰太棒峰峰梁梁,奥力给清明"
}
PUT /student
{
"mappings": {
"properties": {
"age":{
"type":"integer"
},
"weight":{
"type":"float"
},
"info":{
"type":"text",
"analyzer":"ik_smart"
},
"email":{
"type":"keyword",
"index":false
},
"score":{
"type":"float"
},
"name":{
"properties":{
"firstName":{
"type":"keyword"
},
"lastName":{
"type":"keyword"
}
}
}
}
}}
GET /student
PUT /student/_mapping
{
"properties":{
"isMarried":{
"type":"boolean"
}
}
}
DELETE /student
#新增
POST /student/_doc/1
{
"age":20,
"email":"2018691@qq.com",
"info":"java学员",
"name":{
"fistName":"云",
"lastName":"赵"
},
"score":[80.5,90],
"weight":50.5
}
#查询文档
GET /student/_doc/1
#修改全量方法一
PUT /student/_doc/1
{
"age":22,
"email":"2018691@qq.com",
"info":"UI学员",
"name":{
"fistName":"云",
"lastName":"赵"
},
"score":[80.5,90],
"weight":50.5
}
#修改增量方法2
POST /student/_update/1
{
"doc":{
"info":"java学员"
}
}
#删除文档
DELETE /student/_doc/1
GET /hotel
PUT /hotel
{
"mappings": {
"properties": {
"id":{
"type": "keyword"
},
"name":{
"type": "text",
"analyzer": "ik_max_word",
"copy_to": "all"
},
"address":{
"type": "keyword",
"index": false
},
"price":{
"type": "integer"
},
"score":{
"type":"integer"
},
"brand":{
"type": "keyword",
"copy_to": "all"
},
"city":{
"type":"keyword",
"copy_to": "all"
},
"starName":{
"type": "keyword"
},
"business":{
"type": "keyword"
},
"location":{
"type": "geo_point"
},
"pic":{
"type": "keyword",
"index": false
},
"all":{
"type": "text"
, "analyzer": "ik_max_word"
}
}
}
}
GET /hotel/_doc/1
#查询所有
GET /hotel/_search
{
"query":{
"match_all": {
}
}
}
#全文检索
#商城的输入框搜索和百度搜索框
#单字段查询
GET /hotel/_search
{
"query": {
"match": {
"brand": "希尔顿"
}
}
}
#多字段查询
GET /hotel/_search
{
"query": {
"multi_match": {
"query": "希尔顿",
"fields": ["brand","name"]
}
}
}
GET /hotel/_search
{
"query": {
"match": {
"all": "希尔顿"
}
}
}
#term查询
#词条精细匹配,一般搜索keyword类型,数值类型,布尔类型,日期类型字段
GET /hotel/_search
{
"query": {
"term": {
"city": {
"value": "太原"
}
}
}
}
#range查询,根据数值范围查询,可以是数值日期的范围
GET /hotel/_search
{
"query": {
"range": {
"price": {
"gte": 100,
"lte": 200
}
}
}
}
#地理坐标查询
#geo_bounding_box矩形范围查询
#附近查询
GET /hotel/_search
{
"query": {
"geo_distance":{
"distance":"500km",
"location":"32.32,24.9"
}
}
}
#复合查询
#算分函数查询fuction score
#布尔查询bool query
|