ES基础语法之索引&基础查询
rror [02:12:23.167] [error][reporting] TimeoutError: waiting for target failed: timeout 30000ms exceeded
at Function.waitWithTimeout (/opt/es7/kibana-7.5.2-linux-x86_64/node_modules/puppeteer-core/lib/helper.js:215:26)
at Browser.waitForTarget (/opt/es7/kibana-7.5.2-linux-x86_64/node_modules/puppeteer-core/lib/Browser.js:214:27)
at Browser.<anonymous> (/opt/es7/kibana-7.5.2-linux-x86_64/node_modules/puppeteer-core/lib/helper.js:112:23)
at Launcher.launch (/opt/es7/kibana-7.5.2-linux-x86_64/node_modules/puppeteer-core/lib/Launcher.js:185:21)
at process._tickCallback (internal/process/next_tick.js:68:7)
启动kibana的时候会报错 虽然不影响 但是原因不知道!!
1. 创建一个索引 非结构化创建索引
PUT /test
{
"settings":{
"number_of_shards":1,
"number_of_replicas":1
}
}
分布式节点建设
更新其replicas状态,但是不能更新shards状态
PUT /test/_settings
{
"settings":{
"number_of_replicas":0
}
}
创建索引,指定id建立索引
PUT /employee/_doc/1
{
"name": "凯杰",
"age": 30
}
指定id全量修改索引
PUT /employee/_doc/1
{
"name": "凯dsfsf32杰",
"age"
}
假如_doc中有1 相当于替换
指定字段修改
POST /employee/_update/2
{
"doc":{
"name":"张桑367"
}
}
强制指定创建,若已存在,则失败
POST /employee/_create/11/
{
"name": "凯1213132杰",
"age": 30
}
// 删除某个文档
DELETE /employee/_doc/11
// 获取文档
GET /employee/_doc/11
// 查询全部文档 带分页会默认取前多少条记录
GET /employee/_search
// 使用结构化方式创建索引
PUT test
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 1
},
"mappings": {
"properties": {
"name":{"type": "text"},
"age":{"type": "integer"}
}
}
}
// 不带条件查询所有记录
GET /test/_search
{
"query": {
"match_all": {}
}
}
// 分页查询
GET /test/_search
{
"query": {
"match_all": {}
}
, "from": 0,
"size": 20
}
// 使用结构化方式创建索引
PUT test
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 1
},
"mappings": {
"properties": {
"name":{"type": "text"},
"age":{"type": "integer"}
}
}
}
// 分页查询
GET /test/_search
{
"query": {
"match_all": {}
}
, "from": 0,
"size": 20
}
// 带排序
GET /test/_search
{
"query": {
"match": {
"name": "兄"
}
},
"sort": [
{
"age": {
"order": "desc"
}
}
]
}
// 带filter
GET /test/_search
{
"query": {
"bool": {
"filter": {
"term": {
"name": "兄长她她她"
}
}
}
}
}
match 会进行analysize操作 会进行分词
term 不会进行分词
filter 表示score没有打分
GET /test/_search
{
"query": {
"bool": {
"filter": {
"match": {
"name": "兄长她她她"
}
}
}
}
}
// 带聚合
GET /test/_search
{
"query": {
"match": {
"name": "兄"
}
},
"sort": [
{
"age": {
"order": "desc"
}
}
],
"aggs": {
"group_by_age": {
"terms": {
"field": "age",
"size": 10
}
}
}
}