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

Add config PopulateFailedDocsSource to bulk indexer #236

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

carsonip
Copy link
Member

Add config PopulateFailedDocsSource to bulk indexer to opt-in to getting back the source document that caused a failure. Should be used for testing and debugging only.

// in BulkIndexerResponseStat.FailedDocs is populated with the source of the item,
// which includes the action line and the document line.
// For testing and debugging only. Use with caution.
PopulateFailedDocsSource bool
Copy link
Member Author

Choose a reason for hiding this comment

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

[to reviewer] any suggestions for a better name? is PopulateFailedDocsBody clearer?

Copy link
Member Author

Choose a reason for hiding this comment

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

Source might sound too much like _source, which is only the document content while in reality we return both action line and document line.

Copy link
Member

Choose a reason for hiding this comment

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

I initially assumed it was _source from the PR title, so I think it does sound a bit too much like that. Maybe PopulateFailedDocsInput?

@carsonip carsonip requested a review from lahsivjar February 17, 2025 11:38
Copy link
Member

@axw axw left a comment

Choose a reason for hiding this comment

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

LGTM, just a few minor things

Comment on lines +98 to +99
// For testing and debugging only. Use with caution as it may expose sensitive data.
// Any clients should relay this warning to users.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// For testing and debugging only. Use with caution as it may expose sensitive data.
// Any clients should relay this warning to users.
//
// WARNING: this is provided for testing and debugging only.
// Use with caution as it may expose sensitive data; any clients
// of go-docappender enabling this should relay this warning to
// their users. Setting this will also add memory overhead.

Couple of suggestions:

  • make the warning a bit more prominent
  • mention that this will also impact memory usage (further discouraging use, and avoiding surprises)

// in BulkIndexerResponseStat.FailedDocs is populated with the source of the item,
// which includes the action line and the document line.
// For testing and debugging only. Use with caution.
PopulateFailedDocsSource bool
Copy link
Member

Choose a reason for hiding this comment

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

I initially assumed it was _source from the PR title, so I think it does sound a bit too much like that. Maybe PopulateFailedDocsInput?

@@ -132,6 +139,8 @@ type BulkIndexerResponseItem struct {
Type string `json:"type"`
Reason string `json:"reason"`
} `json:"error,omitempty"`

Source string `json:"source"`
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Source string `json:"source"`
Source string `json:"-"`

This doesn't come back from Elasticsearch, let's make that clear with json:"-"

@@ -295,3 +297,77 @@ func TestItemRequireDataStream(t *testing.T) {
require.NoError(t, err)
require.Equal(t, int64(2), stat.Indexed)
}

func TestPopulateFailedItemSource(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

Should we add a negative check, or is that covered elsewhere? i.e. check that Source is not populated unless we set the new config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe-to-test Automated label for running bench-diff on forked PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants