Repository: opensearch-project/opensearch-go
Pull request #175 (2022-10-24 23:18:54)

Bump github.com/stretchr/testify from 1.8.0 to 1.8.1
Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.8.0 to 1.8.1.
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/stretchr/testify/commit/b747d7c5f853d017ddbc5e623d026d7fc2770a58"><code>b747d7c</code></a> Bump github.com/stretchr/objx from 0.4.0 to 0.5.0 (<a href="https://github-redirect.dependabot.com/stretchr/testify/issues/1283">#1283</a>)</li>
<li>See full diff in <a href="https://github.com/stretchr/testify/compare/v1.8.0...v1.8.1">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/stretchr/testify&package-manager=go_modules&previous-version=1.8.0&new-version=1.8.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>

VachaShah: @dependabot recreate
dblock: @dependabot recreate
VachaShah: @dependabot recreate
VachaShah: @dependabot recreate

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5d0110e..1fa396c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
 ## [Unreleased]
 ### Added
 - Github workflow for changelog verification ([#172](https://github.com/opensearch-project/opensearch-go/pull/172))
+### Dependencies
+- Bumps `github.com/stretchr/testify` from 1.8.0 to 1.8.1
 
 ### Changed
 
@@ -12,6 +14,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
 ### Removed
 
 ### Fixed
+ - Renamed the sequence number struct tag to if_seq_no to fix optimistic concurrency control ([#166](https://github.com/opensearch-project/opensearch-go/pull/166))
 
 ### Security
 
diff --git a/USER_GUIDE.md b/USER_GUIDE.md
index 05a2106..727e0eb 100644
--- a/USER_GUIDE.md
+++ b/USER_GUIDE.md
@@ -46,12 +46,12 @@ func main() {
 
 	// Define index mapping.
 	mapping := strings.NewReader(`{
-     'settings': {
-       'index': {
-            'number_of_shards': 4
-            }
-          }
-     }`)
+	    "settings": {
+	        "index": {
+	            "number_of_shards": 4
+	        }
+	    }
+	}`)
 
 	// Create an index with non-default settings.
 	createIndex := opensearchapi.IndicesCreateRequest{
@@ -67,10 +67,10 @@ func main() {
 
 	// Add a document to the index.
 	document := strings.NewReader(`{
-        "title": "Moneyball",
-        "director": "Bennett Miller",
-        "year": "2011"
-    }`)
+	    "title": "Moneyball",
+	    "director": "Bennett Miller",
+	    "year": "2011"
+	}`)
 
 	docId := "1"
 	req := opensearchapi.IndexRequest{
@@ -87,14 +87,14 @@ func main() {
 
 	// Search for the document.
 	content := strings.NewReader(`{
-       "size": 5,
-       "query": {
-           "multi_match": {
-           "query": "miller",
-           "fields": ["title^2", "director"]
-           }
-      }
-    }`)
+	    "size": 5,
+	    "query": {
+	        "multi_match": {
+	            "query": "miller",
+	            "fields": ["title^2", "director"]
+	        }
+	    }
+	}`)
 
 	search := opensearchapi.SearchRequest{
 		Body: content,
diff --git a/go.mod b/go.mod
index 81c8c43..c14c3ae 100644
--- a/go.mod
+++ b/go.mod
@@ -6,5 +6,5 @@ require (
 	github.com/aws/aws-sdk-go v1.44.45
 	github.com/aws/aws-sdk-go-v2 v1.17.1
 	github.com/aws/aws-sdk-go-v2/config v1.17.10
-	github.com/stretchr/testify v1.8.0
+	github.com/stretchr/testify v1.8.1
 )
diff --git a/go.sum b/go.sum
index c13e26f..491d555 100644
--- a/go.sum
+++ b/go.sum
@@ -38,9 +38,11 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
 github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
+github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
 github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
-github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
 github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
+github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
+github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
 golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd h1:O7DYs+zxREGLKzKoMQrtrEacpb0ZVXA5rIwylE2Xchk=
 golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
 golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
diff --git a/opensearchutil/bulk_indexer.go b/opensearchutil/bulk_indexer.go
index 3f08cec..f56ceac 100644
--- a/opensearchutil/bulk_indexer.go
+++ b/opensearchutil/bulk_indexer.go
@@ -133,7 +133,7 @@ type bulkActionMetadata struct {
 	Routing             *string     `json:"routing,omitempty"`
 	Version             *int64      `json:"version,omitempty"`
 	VersionType         *string     `json:"version_type,omitempty"`
-	IfSeqNum            *int64      `json:"if_seq_num,omitempty"`
+	IfSeqNum            *int64      `json:"if_seq_no,omitempty"`
 	IfPrimaryTerm       *int64      `json:"if_primary_term,omitempty"`
 	WaitForActiveShards interface{} `json:"wait_for_active_shards,omitempty"`
 	Refresh             *string     `json:"refresh,omitempty"`


Test patch:
diff --git a/opensearchutil/bulk_indexer_internal_test.go b/opensearchutil/bulk_indexer_internal_test.go
index a5c909b..ff8539d 100644
--- a/opensearchutil/bulk_indexer_internal_test.go
+++ b/opensearchutil/bulk_indexer_internal_test.go
@@ -678,7 +678,18 @@ func TestBulkIndexer(t *testing.T) {
 				`{"index":{"_index":"test","_id":"42"}}` + "\n",
 			},
 			{
-				"with version and no document",
+				"with if_seq_no and if_primary_term",
+				args{BulkIndexerItem{
+					Action:        "index",
+					DocumentID:    "42",
+					Index:         "test",
+					IfSeqNum:      int64Pointer(5),
+					IfPrimaryTerm: int64Pointer(1),
+				}},
+				`{"index":{"_index":"test","_id":"42","if_seq_no":5,"if_primary_term":1}}` + "\n",
+			},
+			{
+				"with version and no document, if_seq_no, and if_primary_term",
 				args{BulkIndexerItem{
 					Action:  "index",
 					Index:   "test",