Es基本文法

6524 ワード

put/インデックス/タイプ
put   /  /  /1
{
json 
}
POST /  /  /1/_update
{
“doc”:{
  : //         
}
}

DELETE/インデックス
POST /_bulk  ---       
--       
{“create”:{“_index”:  ,“_type”:  ,“_id”:  }}
{json }
{“update”:{“index”:  ,“_type”:  ,“_id”:  }}
“doc”:{json }
{“delete”:{“index”:  ,“_type”:  ,“_id”:  }}
GET  /  /  /_search       

GET  /  /  /_search
{“query”:{“match_all”:{}}}
GET /  /  /1?_source=    
GET  /  /  /_search
{“query”:{
“match”:{json }
}
}

単一データcontentを変更するには、次の手順に従います.
PUT abc/article/1
{
  "content":"content"        #  
}
GET _analyze
{
  "analyzer": "whitespace",        #    
  "text": ["    huijia  ","        "]
}



#  
POST abc/article/_bulk
{
  "updata":{
    "_index":"abc",
    "_type":"article",
    "_id":"1",
    "doc":{
      "id":"2",
      "title":"biaot  2",
      "context":"context"
    }
  }
}

情報の追加:1
PUT _bulk
{"create":{"_index":"abc","_type":"article","_id":"1"}}         #        
{"id":"1","name":"sam","age":"18"}

2
PUT /abc/article/1
{"id": 1, "studentNo": "TH-CHEM-2016-C001", "name":"Jonh Smith", "major":"Chemistry", "gpa": 4.8,"yearOfBorn": 2000, "classOf": 2016,  "interest":"soccer, basketball, badminton, chess"}
GET  def/stu/_search
#      

複数のメッセージ文の追加
**#        **
POST _bulk
{"create":{"_index":"def","_type":"stu","_id":"2"}}         #           
{"id": 2, "studentNo": "TH-CHEM-2016-C001", "name":"Jonh Smith", "major":"Chemistry", "gpa": 4.8,"yearOfBorn": 2000, "classOf": 2016,  "interest":"soccer, basketball, badminton, chess"}
{"create":{"_index":"def","_type":"stu","_id":"3"}}
{"id": 3, "studentNo": "TH-PHY-2018-C001", "name": "Isaac Newton","major":"Physics", "gpa": 3.6, "yearOfBorn": 2001, "classOf": 2018,"interest": "novel, soccer, cooking"}
{"create":{"_index":"def","_type":"stu","_id":"4"}}
{"id": 4, "studentNo": "BU-POLI-2016-C001", "name": "John Kennedy","major":"Politics", "gpa": 4.2, "yearOfBorn": 2000, "classOf": 2016,"interest": "talking, dating, boxing, shooting, chess"}
{"create":{"_index":"def","_type":"stu","_id":"5"}}
{"id": 5, "studentNo": "BU-POLI-2015-C001", "name": "John Kerry","major":"Politics", "gpa": 4.1, "yearOfBorn": 1999, "classOf": 2015,"interest": "money, basketball"}
{"create":{"_index":"def","_type":"stu","_id":"6"}}
{"id": 6, "studentNo": "BU-ARTS-2016-C002", "name": "Da Vinci","major":"Arts", "gpa": 4.8, "yearOfBorn": 1995, "classOf":2016,"interest": "drawing, music, wine"}
PUT  demo.1234
{
  "settings": {
    "index":{
      "number_of_shards":3,       #number_of_replicas       ,        ,   0
      "number_of_replicas":2       #      ,   5,      3
    }
  }
}
DELETE demo.1234     #    
GET _analyze
{
  "analyzer": "standard",
  "text": ["Tom lives in Guangzhou,I live in Guangzhou too.","He once lived in Shanghai."]
}

classOf降順クエリー(desc)
GET def/stu/_search?sort=classOf:desc      

ページングクエリ

GET def/stu/_search?scroll=3m
{
  "query": {
    "match_all": {}
  }
  ,"size": 3        #    
  ,"from": 0        #  0  
}
GET _search/scroll
{
  "scroll_id":"DnF1ZXJ5VGhlbkZldGNoBQAAAAAAAABZFnpSdVVuQ0drVEstcENZcGtmYnNDMlEAAAAAAAAASRZxcUFOMWxxV1JrZTFtdGJBWXpzcExnAAAAAAAAAEsWWlZJbUFZZlRRWnVVQm5uVE5VMnFzZwAAAAAAAABYFnpSdVVuQ0drVEstcENZcGtmYnNDMlEAAAAAAAAAShZxcUFOMWxxV1JrZTFtdGJBWXpzcExn",
  "scroll":"3m"
}

氏名による照会
GET def/stu/_search
{
  "query": {
    "match": {
      "name":"Da Vinci"
    }
  }
}

すべてのクエリー
GET def/stu/_search
{
  "query": {
    "match_all": {}
  }
}

短文クエリ
GET def/stu/_search
{
  "query": {
    "match_phrase": {
      "interest": "music"
    }
  }
  }

ファジイクエリ
GET def/stu/_search
{
  "query": {
    "multi_match": {
      "query": "Da Vinci like music",
      "fields": ["name", "interest"]
    }
  }
}
GET  def/stu/_search
{"query": {
  "term": {
      "name": "da"
    
  }
}
}

範囲別クエリー
#        ,   gt  e     
GET def/stu/_search
{"query": {
  "range": {
    "gpa": {
      "gte": 4.1,
      "lte": 4.8
    }
  }
}
}

複数条件の問合せ
GET /def/stu/_search
{"query": {
  "bool": {
    "must": [
      {"match_phrase": {
        "name": "Da"
      }
        
      }
      , {"match": {
          "yearOfBorn": "1995"
        }}
      
    ]
    ,
    "must_not": [
      {"match": {
        "id": "5"
      }}
    ]
    ,
    "should": [
      {"match_phrase_prefix": {
        "interest": "music"
      }}
    ]
    ,"minimum_should_match": 1    #       should  1  
  }
}
}

補充待ち...