mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-07 13:46:38 +02:00
Add an option to set the op_type for the ElasticsearchHandler (#1766)
Co-authored-by: Identei <>
This commit is contained in:
@@ -85,6 +85,7 @@ class ElasticsearchHandler extends AbstractProcessingHandler
|
||||
'index' => 'monolog', // Elastic index name
|
||||
'type' => '_doc', // Elastic document type
|
||||
'ignore_error' => false, // Suppress Elasticsearch exceptions
|
||||
'op_type' => 'index', // Elastic op_type (index or create) (https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html#docs-index-api-op_type)
|
||||
],
|
||||
$options
|
||||
);
|
||||
@@ -162,7 +163,7 @@ class ElasticsearchHandler extends AbstractProcessingHandler
|
||||
|
||||
foreach ($records as $record) {
|
||||
$params['body'][] = [
|
||||
'index' => $this->needsType ? [
|
||||
$this->options['op_type'] => $this->needsType ? [
|
||||
'_index' => $record['_index'],
|
||||
'_type' => $record['_type'],
|
||||
] : [
|
||||
|
@@ -33,6 +33,7 @@ class ElasticsearchHandlerTest extends TestCase
|
||||
protected array $options = [
|
||||
'index' => 'my_index',
|
||||
'type' => 'doc_type',
|
||||
'op_type' => 'index',
|
||||
];
|
||||
|
||||
public function setUp(): void
|
||||
@@ -93,6 +94,7 @@ class ElasticsearchHandlerTest extends TestCase
|
||||
'index' => $this->options['index'],
|
||||
'type' => $this->options['type'],
|
||||
'ignore_error' => false,
|
||||
'op_type' => $this->options['op_type'],
|
||||
];
|
||||
|
||||
if ($this->client instanceof Client8 || $this->client::VERSION[0] === '7') {
|
||||
|
Reference in New Issue
Block a user