elasticsearch *** 作

elasticsearch *** 作,第1张

elasticsearch *** 作
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":"[email protected]",
  "info":"java学员",
  "name":{
    "fistName":"云",
    "lastName":"赵"
  },
  "score":[80.5,90],
  "weight":50.5
}
#查询文档
GET /student/_doc/1


#修改全量方法一
PUT /student/_doc/1
{
  "age":22,
  "email":"[email protected]",
  "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

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5681891.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存