Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOCS] Upsert documentation clarification #120684

Merged
merged 2 commits into from
Jan 29, 2025
Merged

Conversation

thekofimensah
Copy link
Contributor

  • Added explanation to explain what an upsert is

  • Used a more simple example as to prevent confusion with a more dense example. Also added the explanation of what behavior we can expect

Copy link
Contributor

Documentation preview:

@elasticsearchmachine elasticsearchmachine added v9.0.0 external-contributor Pull request authored by a developer outside the Elasticsearch team needs:triage Requires assignment of a team area label labels Jan 22, 2025
@gbanasiak gbanasiak added the >docs General docs changes label Jan 23, 2025
@elasticsearchmachine elasticsearchmachine added Team:Docs Meta label for docs team and removed needs:triage Requires assignment of a team area label labels Jan 23, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-docs (Team:Docs)

@lcawl
Copy link
Contributor

lcawl commented Jan 24, 2025

Hi! These API docs will be removed imminently so it's fine to backport this PR if it's only intended for V8 but for V9+ I've copied your suggested changes to elastic/elasticsearch-specification#3591

That's where we'll be generating docs like https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-update from going forward.

NOTE: I didn't update the /test/... since it worked as-is when I did a quick test. If you have any other clarifications you want to add to that PR or want more information about the new process, I'm happy to provide more info!

Copy link
Contributor

@leemthompo leemthompo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of clarifying introduction.

But I think the flow of examples could be improved, from simplest to most complex. The base case would be to have the same value for update and upsert, so I think that should be the first example.

Something like this in terms of flow:

1. The simplest approach uses doc_as_upsert:

POST /test/_update/1
{
  "doc": {
    "price": 100
  },
  "doc_as_upsert": true
}

2. If you need different behavior for new documents, specify an upsert value:

POST /test/_update/1
{
  "doc": {
    "price": 100
  },
  "upsert": {
    "price": 100,
    "created_at": "2024-01-24"
  }
}

3. For complex update logic, use scripted_upsert...

docs/reference/docs/update.asciidoc Outdated Show resolved Hide resolved
@georgewallace georgewallace self-assigned this Jan 24, 2025
@georgewallace georgewallace added auto-backport Automatically create backport pull requests when merged v8.18.0 v8.17.2 labels Jan 24, 2025
@georgewallace
Copy link
Contributor

@leemthompo are you good if we don't update the order of the examples in this version and tackle it in a future PR?

@leemthompo leemthompo merged commit 63a890e into elastic:main Jan 29, 2025
7 checks passed
@elasticsearchmachine
Copy link
Collaborator

💚 Backport successful

Status Branch Result
8.x
8.17

georgewallace pushed a commit to georgewallace/elasticsearch that referenced this pull request Jan 29, 2025
elasticsearchmachine pushed a commit that referenced this pull request Jan 29, 2025
elasticsearchmachine pushed a commit that referenced this pull request Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Automatically create backport pull requests when merged >docs General docs changes external-contributor Pull request authored by a developer outside the Elasticsearch team Team:Docs Meta label for docs team v8.17.2 v8.18.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants