Rest style---ElasticSearch

Rest style

5.1 Introduction

RESTful is an architecture specification, constraints, and principles. An architecture that conforms to this specification is a RESTful architecture.

operating

method url address description
PUT localhost:9100/index name/type name/document id Create document (specify id)
POST localhost:9100/index name/type name Create document (random id)
POST localhost:9100/index name/document type/document id/_update Modify the document
DELETE localhost:9100/index name/document type/document id Delete document
GET localhost:9100/index name/document type/document id Query documents by document id
POST localhost:9100/index name/document type/_search Query all documents

5.2 Testing

  • 1. Create an indexPUT /索引名/类型名/id
  • The default is _doc

img

type of data

  1. Basic data type
  • String text, keyword
  • Data type long, integer, short, byte, double, float, half_float, scaled_float
  • Date
  • Boolean
  • Binary
  1. Develop data types

Create rules

PUT /test2
{
    
    
  "mappings": {
    
    
    
    "properties": {
    
    
      "name": {
    
    
        "type": "text"
      },
      "age": {
    
    
        "type": "long"
      },
      "birthday": {
    
    
        "type": "date"
      }
    }
  }  
}

Output:

{
    
    
  "acknowledged" : true,
  "shards_acknowledged" : true,
  "index" : "test2"
}

If you do not specify a specific type, es will configure the type by default

View index

GET test2

  • View es information

    get _cat/

modify

  1. 之前的办法:直接put
  2. 现在的办法:
 POST /test1/_doc/1/_update
  {
    
    
"doc": {
    
    
  "name": "庞世宗"
  }
  }

Delete index

DELETE test1

Guess you like

Origin blog.csdn.net/qq_45783660/article/details/112785027