first commit
This commit is contained in:
commit
ba848e218d
1001 changed files with 152333 additions and 0 deletions
62
ELK/es学习记录03-数据简单写入搜索.md
Normal file
62
ELK/es学习记录03-数据简单写入搜索.md
Normal file
|
@ -0,0 +1,62 @@
|
|||
#### 写入数据:
|
||||
举例说明,在索引名称未item中添加一个类型名称为es,编号为3的数据
|
||||
```
|
||||
curl -XPUT 127.0.0.1:9200/item/es/3?pretty -H 'content-Type:application/json' -d '{"name": "bi", "age": 21}'
|
||||
```
|
||||
或
|
||||
```
|
||||
curl -XPOST 127.0.0.1:9200/item/es/3?pretty -H 'content-Type:application/json' -d '{"name": "bi", "age": 21}'
|
||||
```
|
||||
结果如下
|
||||
```
|
||||
{
|
||||
"_index" : "item", ## 索引
|
||||
"_type" : "es", ## 类型名称
|
||||
"_id" : "3", ## 编号
|
||||
"_version" : 1, ## 对该数据的第几次操作
|
||||
"result" : "created", ## 因为之前没有,即创建
|
||||
"_shards" : {
|
||||
"total" : 2, ## 分片数
|
||||
"successful" : 1, ## 分片成功次数
|
||||
"failed" : 0 ## 分片失败数
|
||||
},
|
||||
"_seq_no" : 4, ## 序列编号
|
||||
"_primary_term" : 1 ##
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### get数据
|
||||
```
|
||||
curl -XGET 127.0.0.1:9200/item/es/3?pretty
|
||||
```
|
||||
结果为
|
||||
```
|
||||
{
|
||||
"_index" : "item",
|
||||
"_type" : "es",
|
||||
"_id" : "3",
|
||||
"_version" : 1,
|
||||
"_seq_no" : 4,
|
||||
"_primary_term" : 1,
|
||||
"found" : true,
|
||||
"_source" : {
|
||||
"name" : "bi",
|
||||
"age" : 21
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 搜索数据
|
||||
```
|
||||
curl -XGET 127.0.0.1:9200/item/es/_search?pretty
|
||||
```
|
||||
返回的结果方在hints数组中,默认展示匹配到的前10条数据
|
||||
|
||||
### 精确搜索
|
||||
```
|
||||
curl -XGET 127.0.0.1:9200/item/es/_search?q=name:wang?pretty
|
||||
```
|
||||
```
|
||||
curl -XGET 127.0.0.1:9200/item/es/_search?q=name:bi
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue