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

Correcting the response format for ingest simulate #3640

Merged
merged 5 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 46 additions & 1 deletion output/openapi/elasticsearch-openapi.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

158 changes: 156 additions & 2 deletions output/schema/schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion output/typescript/types.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 49 additions & 1 deletion specification/simulate/ingest/SimulateIngestResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,56 @@
* under the License.
*/

import { SimulateDocumentResult } from '@ingest/_types/Simulation'
import { AdditionalProperties } from '@spec_utils/behaviors'
import { Dictionary } from '@spec_utils/Dictionary'
import { Stringified } from '@spec_utils/Stringified'
import { UserDefinedValue } from '@spec_utils/UserDefinedValue'
import { Id, IndexName, VersionNumber } from '@_types/common'
import { ErrorCause } from '@_types/Errors'

export class Response {
body: { docs: SimulateDocumentResult[] }
}

export class SimulateDocumentResult {
Copy link
Contributor

Choose a reason for hiding this comment

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

we try to avoid duplicate names since it can break certain clients, could we rename this to something else? like SimulateIngestDocumentResult

doc?: DocumentSimulation
/**
* Any error resulting from simulatng ingest on this doc. This can be an error generated by
* executing a processor, or a mapping validation error when simulating indexing the resulting
* doc.
*/
error?: ErrorCause
}

/**
* The results of ingest simulation on a single document. The _source of the document contains
* the results after running all pipelines listed in executed_pipelines on the document. The
* list of executed pipelines is derived from the pipelines that would be executed if this
* document had been ingested into _index.
*
* @behavior_meta AdditionalProperties fieldname=metadata description="Additional metadata"
*/
export class DocumentSimulation
Copy link
Contributor

Choose a reason for hiding this comment

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

same here, coule be IngestDocumentSimulation?

implements AdditionalProperties<string, string>
{
/**
* Identifier for the document.
*/
_id: Id
/**
* Name of the index that the document would be indexed into if this were not a simulation.
*/
_index: IndexName
/**
* JSON body for the document.
*/
_source: Dictionary<string, UserDefinedValue>
/**
*
*/
_version?: Stringified<VersionNumber>
Copy link
Contributor

Choose a reason for hiding this comment

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

is _version actually nullable? checking the server code it seems like it's always added.

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right -- I had just copy/pasted without looking.

Copy link
Member Author

Choose a reason for hiding this comment

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

I also realized that error was in the wrong place (it should be within the doc), and ignored_fields was missing altogether.

/**
* A list of the names of the pipelines executed on this document.
*/
executed_pipelines: Array<string>
}