@@ -32,6 +32,7 @@ import (
32
32
"github.com/tigrisdata/tigris/schema"
33
33
"github.com/tigrisdata/tigris/server/config"
34
34
"github.com/tigrisdata/tigris/server/metadata"
35
+ "github.com/tigrisdata/tigris/server/request"
35
36
"github.com/tigrisdata/tigris/server/transaction"
36
37
"github.com/tigrisdata/tigris/store/kv"
37
38
"github.com/tigrisdata/tigris/store/search"
@@ -54,6 +55,10 @@ func NewSearchIndexer(searchStore search.Store, tenantMgr *metadata.TenantManage
54
55
}
55
56
56
57
func (i * SearchIndexer ) OnPostCommit (ctx context.Context , _ * metadata.Tenant , eventListener kv.EventListener ) error {
58
+ if request .DisableSearch (ctx ) {
59
+ return nil
60
+ }
61
+
57
62
for _ , event := range eventListener .GetEvents () {
58
63
var err error
59
64
@@ -77,11 +82,13 @@ func (i *SearchIndexer) OnPostCommit(ctx context.Context, _ *metadata.Tenant, ev
77
82
if searchIndex == nil {
78
83
return fmt .Errorf ("implicit search index not found" )
79
84
}
85
+
80
86
if event .Op == kv .DeleteEvent {
81
87
if err = i .searchStore .DeleteDocument (ctx , searchIndex .StoreIndexName (), searchKey ); err != nil {
82
88
if ! search .IsErrNotFound (err ) {
83
89
return err
84
90
}
91
+
85
92
return nil
86
93
}
87
94
} else {
@@ -101,13 +108,16 @@ func (i *SearchIndexer) OnPostCommit(ctx context.Context, _ *metadata.Tenant, ev
101
108
}
102
109
103
110
reader := bytes .NewReader (searchData )
111
+
104
112
var resp []search.IndexResp
113
+
105
114
if resp , err = i .searchStore .IndexDocuments (ctx , searchIndex .StoreIndexName (), reader , search.IndexDocumentsOptions {
106
115
Action : action ,
107
116
BatchSize : 1 ,
108
117
}); err != nil {
109
118
return err
110
119
}
120
+
111
121
if len (resp ) == 1 && ! resp [0 ].Success {
112
122
return search .NewSearchError (resp [0 ].Code , search .ErrCodeUnhandled , resp [0 ].Error )
113
123
}
0 commit comments