ES入门(一)

//put localhost:9200/people


{
  "settings": {
    "number_of_shards": 3,
    "number_of_replicas": 1
  },
  "mappings": {
    "man": {
      "properties": {
        "name": {
          "type": "text"
        },
        "country": {
          "type": "keyword"
        },
        "age": {
          "type": "integer"
        },
        "date": {
          "type": "date",
          "format": "yyyy-MM-dd HH:mm:ss || yyyy-MM-dd || epoch_millis"
        }
      }
    },
    "woman": {
    }
  }
}
//新增 put localhost:9200/people/man/1


{
  "name": "瓦力",
  "country": "China",
  "age": 30,
  "date": "1987-03-07"
}
//新增 post localhost:9200/people/man/


{
  "name": "瓦力",
  "country": "China",
  "age": 30,
  "date": "1987-03-07"
}


//修改 post localhost:9200/people/man/1/_update


{
  "doc": {
    "name": "66n"
  }
}


// POST 127.0.0.1: 9200/people/man/1/_update

{
  "script": {
    "lang": "painless",
    //es内置的语言
    "inline": "ctx._source.age = params.age"
    //es单前的文档
    "params": {
      "age": 100
    }
  }
}
//remove delete 127.0.0.1: 9200/people


//查询 GET localhost:9200/people/man/1 POST 127.0.0.1: 9200/people/_search
{
  "query": {
    "match_all": {
    }
  }
  POST
  127.0.0.1: 9200/people/_search
{
  "query": {
    "match": {
      "title": "es"
    }
  }


  "sort": [
    {
      "title": {
        "order": "desc"
      }
    }
  ]
}
// POST 127.0.0: 9200/people/_search


{
  "aggs"
  :{
  "group_by_word_count": {
    "terms": {
      "field": "word_count"
    }
  },
  "group_by_publish_date": {
    "terms": {
      "field": "publish_date"
    }
  }
}
}
发布了55 篇原创文章 · 获赞 11 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/AAA17864308253/article/details/79620682