Elasticsearch--入门(二)

Elasticsearch–入门(二)

1,发送requestq请求到Elasticsearch

1.1,Curl方式

curl -u elastic:<password> localhost:9200/

1.2,Kibana方式

Kibana page > Dev Tools > Console

  • 创建索引
PUT /my_goods_info
{
  "mappings": {
    "properties": {
      "goodsName": {
        "type": "keyword"
      },
      "sale_property": {
        "type": "keyword"
      },
      "required_matches": {
        "type": "long"
      }
    }
  }
}
PUT my-products
{
  "mappings": {
    "properties": {
      "brand": {
        "type": "keyword"
      },
      "pt": {
        "type": "date"
      },
      "name": {
        "type": "keyword"
      },
      "color": {
        "type": "keyword"
      },
      "price":{
        "type":"integer"
      }
    }
  }
}
  • 查询数据
GET /my_goods_info/_search
{
  "query": {
    "terms_set": {
      "sale_property": {
        "terms": [
          "white",
          "64"
        ],
        "minimum_should_match_field": "required_matches"
      }
    }
  }
}
  • 添加数据
PUT /my_goods_info/_doc/1?refresh
{
"name": "apple",
"sale_property": [ "white", "64","standard" ],
"required_matches": 2
}
  • 批量插入数据
PUT my-products/_bulk
{"index":{"_id":1}}
{"brand":"nike","pt":"2021-01-01","name":"product_01","color":"red","price":600}
{"index":{"_id":2}}
{"brand":"grke","pt":"2021-02-01","name":"product_02","color":"red","price":200}
{"index":{"_id":3}}
{"brand":"lining","pt":"2021-03-01","name":"product_03","color":"green","price":300}
{"index":{"_id":4}}
{"brand":"lining","pt":"2021-02-01","name":"product_04","color":"green","price":450}
{"index":{"_id":5}}
{"brand":"grke","pt":"2021-04-01","name":"product_05","color":"blue","price":180}
{"index":{"_id":6}}
{"brand":"grke","pt":"2021-02-01","name":"product_06","color":"yellow","price":165}
{"index":{"_id":7}}
{"brand":"grke","pt":"2021-02-01","name":"product_07","color":"yellow":"price":190}
{"index":{"_id":8}}
{"brand":"lining","pt":"2021-04-01","name":"product_08","color":"blue","price":500}
{"index":{"_id":9}}
{"brand":"nike","pt":"2021-01-01","name":"product_09","color":"blue","price":1000}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值