File tree Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Expand file tree Collapse file tree 3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -174,4 +174,9 @@ final public function indexingLock(): Lock
174
174
{
175
175
return Cache::lock (__CLASS__ .$ this ->getName ());
176
176
}
177
+
178
+ public function ingoreIndexingErrors (): bool
179
+ {
180
+ return false ;
181
+ }
177
182
}
Original file line number Diff line number Diff line change @@ -145,4 +145,12 @@ public function getModelInstance(Document $document): Model;
145
145
public function getDocumentInstance (Model |ElasticsearchableInterface $ model ): ?Document ;
146
146
147
147
public function indexingLock (): Lock ;
148
+
149
+ /**
150
+ * Should errors during indexing be ignored?
151
+ * Recommendation: set getBatchSize() to 1 if this is enabled.
152
+ *
153
+ * @return bool
154
+ */
155
+ public function ingoreIndexingErrors (): bool ;
148
156
}
Original file line number Diff line number Diff line change 13
13
use Illuminate \Queue \SerializesModels ;
14
14
use Limenet \LaravelElasticaBridge \Index \IndexInterface ;
15
15
use Limenet \LaravelElasticaBridge \Model \ElasticsearchableInterface ;
16
+ use Throwable ;
16
17
17
18
class PopulateBatchIndex implements ShouldQueue
18
19
{
@@ -53,6 +54,12 @@ public function handle(): void
53
54
return ;
54
55
}
55
56
56
- $ this ->index ->addDocuments ($ esDocuments );
57
+ try {
58
+ $ this ->index ->addDocuments ($ esDocuments );
59
+ } catch (Throwable $ th ) {
60
+ if (! $ this ->indexConfig ->ingoreIndexingErrors ()) {
61
+ throw $ th ;
62
+ }
63
+ }
57
64
}
58
65
}
You can’t perform that action at this time.
0 commit comments