markdown [索引]操作文档,索引#elasticsearch

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown [索引]操作文档,索引#elasticsearch相关的知识,希望对你有一定的参考价值。


**Adding multiple documents into an `index` with an `id`**

``` json
POST /[index]/_bulk
{"index":{"_id":"[id1]"}}
{[json document]}
{"index":{"_id":"[id2]"}}
{[json document]}
``` 

**Update multiple documents into the `index` for `ids`**

``` json
PUT /[index]/_bulk
{"update":{"_id":"[id1]"}}
{"doc":{[json document]}}
{"update":{"_id":"[id2]"}}
{"doc":{[json document]}}
``` 

**Delete multiple documents in an index by `ids`**

``` json
PUT /[index]/_bulk
{"delete":{"_id":"[id1]"}}
{"delete":{"_id":"[id2]"}}

``` 

**Create an `index`**

``` json
PUT /[index]?pretty
``` 
**Delete an `index`**

``` json
DELETE /[index]
```

**Get all docuemnts in an `index`**

``` json
GET /[index]
``` 

**Get document by `id` in an `index`**

``` json
GET /[index]/[id]
``` 


**Addding a document into the `index` with `auto generated id`**

``` json
POST /[index]
{
 [json document]
}
```


**Adding a document into the `index` with an `id`**

``` json
POST /[index]/[id]
{
 [json document]
}

```
**Inserting or updating a document (upsert)**

``` json
POST /[index]/[id]/_update
{
    "script" : "ctx._source.price += 5",
    "upsert" : {
        "[filed]" : "[value]"
    }
}
```

**Updating a document with a script**

``` json
POST /[index]/[id]/_update
{
  "script": "ctx._source.price += 10"
}

```

**elete document in the `index` with an `id`**

``` json
DELETE /[index]/1
```


**Deleting documents by query which has `field` contains `text`**

``` json
POST /[index]/_delete_by_query
{
  "query": {
    "match": {
      "field": "text"
    }
  }
}

```




以上是关于markdown [索引]操作文档,索引#elasticsearch的主要内容,如果未能解决你的问题,请参考以下文章

Elasticsearch 索引库与文档操作

Elasticsearch 索引库与文档操作

探索Elasticsearch集群API

ES盲点记录

ES盲点记录

ES盲点记录