本篇文章为你整理了Use a data stream()的详细内容,包含有 Use a data stream,希望能帮助你了解 Use a data stream。
IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
Add documents to a data streamedit
To add an individual document, use the index API.
Ingest pipelines are supported.
POST /my-data-stream/_doc/
"@timestamp": "2020-12-07T11:06:07.000Z",
"user": {
"id": "8a4f500d"
"message": "Login successful"
}
You cannot add new documents to a data stream using the index API s PUT
/ target /_doc/ _id request format. To specify a document ID, use the PUT
/ target /_create/ _id format instead. Only an
op_type of create is supported.
To add multiple documents with a single request, use the bulk API.
Only create actions are supported.
PUT /my-data-stream/_bulk?refresh
{"create":{ }}
{ "@timestamp": "2020-12-08T11:04:05.000Z", "user": { "id": "vlb44hny" }, "message": "Login attempt failed" }
{"create":{ }}
{ "@timestamp": "2020-12-08T11:06:07.000Z", "user": { "id": "8a4f500d" }, "message": "Login successful" }
{"create":{ }}
{ "@timestamp": "2020-12-09T11:07:08.000Z", "user": { "id": "l7gk7f82" }, "message": "Logout successful" }
To re-open all closed backing indices for a data stream, submit an open index
API request to the stream:
POST /my-data-stream/_open/
Reindex with a data streamedit
Use the reindex API to copy documents from an
existing index, index alias, or data stream to a data stream. Because data streams are
append-only, a reindex into a data stream must use
an op_type of create. A reindex cannot update existing documents in a data
stream.
POST /_reindex
"source": {
"index": "archive"
"dest": {
"index": "my-data-stream",
"op_type": "create"
}
Update documents in a data stream by queryedit
Use the update by query API to update documents in a
data stream that match a provided query:
POST /my-data-stream/_update_by_query
"query": {
"match": {
"user.id": "l7gk7f82"
"script": {
"source": "ctx._source.user.id = params.new_id",
"params": {
"new_id": "XgdX0NoX"
}
Delete documents in a data stream by queryedit
Use the delete by query API to delete documents in a
data stream that match a provided query:
POST /my-data-stream/_delete_by_query
"query": {
"match": {
"user.id": "vlb44hny"
}
Update or delete documents in a backing indexedit
If needed, you can update or delete documents in a data stream by sending
requests to the backing index containing the document. You ll need:
To get this information, use a search request:
GET /my-data-stream/_search
"seq_no_primary_term": true,
"query": {
"match": {
"user.id": "yWIumJd7"
}
"_id": "bfspvnIBr7VVZlfp2lqX",
"_seq_no": 0,
"_primary_term": 1,
"_score": 0.2876821,
"_source": {
"@timestamp": "2020-12-07T11:06:07.000Z",
"user": {
"id": "yWIumJd7"
"message": "Login successful"
}
To update the document, use an index API request with valid
if_seq_no and if_primary_term arguments:
PUT /.ds-my-data-stream-000003/_doc/bfspvnIBr7VVZlfp2lqX?if_seq_no=0 if_primary_term=1
"@timestamp": "2020-12-07T11:06:07.000Z",
"user": {
"id": "8a4f500d"
"message": "Login successful"
}
To delete the document, use the delete API:
DELETE /.ds-my-data-stream-000003/_doc/bfspvnIBr7VVZlfp2lqX
To delete or update multiple documents with a single request, use the
bulk APIs delete, index, and update actions. For index
actions, include valid if_seq_no andif_primary_term arguments.
PUT /_bulk?refresh
{ "index": { "_index": ".ds-my-data-stream-000003", "_id": "bfspvnIBr7VVZlfp2lqX", "if_seq_no": 0, "if_primary_term": 1 } }
{ "@timestamp": "2020-12-07T11:06:07.000Z", "user": { "id": "8a4f500d" }, "message": "Login successful" }
以上就是Use a data stream()的详细内容,想要了解更多 Use a data stream的内容,请持续关注盛行IT软件开发工作室。
郑重声明:本文由网友发布,不代表盛行IT的观点,版权归原作者所有,仅为传播更多信息之目的,如有侵权请联系,我们将第一时间修改或删除,多谢。