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 processor target_field trait #2026

Merged
merged 2 commits into from
Nov 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Updated `php-cs-fixer` to `3.3.2` [#2022](https://github.com/ruflin/Elastica/pull/2022)
* Updated `composer-normalize` to `2.15.0` [#2021](https://github.com/ruflin/Elastica/pull/2021)
* Extracted setting gap policy to `\Elastica\Aggregation\Traits\GapPolicyTrait` and introduced `\Elastica\Aggregation\GapPolicyInterface` with constants for options [#2023](https://github.com/ruflin/Elastica/pull/2023)
* Extracted setting `target_field` to `Elastica\Processor\Traits\TargetFieldTrait` [#2026](https://github.com/ruflin/Elastica/pull/2026)
### Deprecated
* Deprecated `Elastica\Query\Common` class, use `Elastica\Query\MatchQuery` instead [#2013](https://github.com/ruflin/Elastica/pull/2013)
* Deprecated `Elastica\QueryBuilder\DSL\Query::common_terms()`, use `match()` instead [#2013](https://github.com/ruflin/Elastica/pull/2013)
Expand Down
11 changes: 1 addition & 10 deletions src/Processor/AttachmentProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
class AttachmentProcessor extends AbstractProcessor
{
use Traits\IgnoreMissingTrait;
use Traits\TargetFieldTrait;

public const DEFAULT_TARGET_FIELD_VALUE = 'attachment';
public const DEFAULT_INDEXED_CHARS_VALUE = 100000;
Expand All @@ -32,16 +33,6 @@ public function setField(string $field): self
return $this->setParam('field', $field);
}

/**
* Set target_field. Default attachment.
*
* @return $this
*/
public function setTargetField(string $targetField): self
{
return $this->setParam('target_field', $targetField);
}

/**
* Set indexed_chars. Default 100000.
*
Expand Down
11 changes: 1 addition & 10 deletions src/Processor/BytesProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class BytesProcessor extends AbstractProcessor
{
use Traits\IgnoreFailureTrait;
use Traits\IgnoreMissingTrait;
use Traits\TargetFieldTrait;

public function __construct(string $field)
{
Expand All @@ -24,14 +25,4 @@ public function setField(string $field): self
{
return $this->setParam('field', $field);
}

/**
* Set target_field.
*
* @return $this
*/
public function setTargetField(string $targetField): self
{
return $this->setParam('target_field', $targetField);
}
}
11 changes: 1 addition & 10 deletions src/Processor/ConvertProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class ConvertProcessor extends AbstractProcessor
{
use Traits\IgnoreFailureTrait;
use Traits\IgnoreMissingTrait;
use Traits\TargetFieldTrait;

public const DEFAULT_TARGET_FIELD_VALUE = 'field';
public const DEFAULT_IGNORE_MISSING_VALUE = false;
Expand Down Expand Up @@ -42,14 +43,4 @@ public function setType(string $type): self
{
return $this->setParam('type', $type);
}

/**
* Set target_field. Default value field.
*
* @return $this
*/
public function setTargetField(string $targetField): self
{
return $this->setParam('target_field', $targetField);
}
}
11 changes: 1 addition & 10 deletions src/Processor/DateProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
class DateProcessor extends AbstractProcessor
{
use Traits\IgnoreFailureTrait;
use Traits\TargetFieldTrait;

public const DEFAULT_TARGET_FIELD_VALUE = '@timestamp';
public const DEFAULT_TIMEZONE_VALUE = 'UTC';
Expand Down Expand Up @@ -43,16 +44,6 @@ public function setFormats(array $formats): self
return $this->setParam('formats', $formats);
}

/**
* Set target_field. Default value @timestamp.
*
* @return $this
*/
public function setTargetField(string $targetField): self
{
return $this->setParam('target_field', $targetField);
}

/**
* Set the timezone use when parsing the date. Default UTC.
*
Expand Down
11 changes: 1 addition & 10 deletions src/Processor/JsonProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
class JsonProcessor extends AbstractProcessor
{
use Traits\IgnoreFailureTrait;
use Traits\TargetFieldTrait;

public const DEFAULT_TARGET_FIELD_VALUE = 'field';
public const DEFAULT_ADD_TO_ROOT_VALUE = false;
Expand All @@ -31,16 +32,6 @@ public function setField(string $field): self
return $this->setParam('field', $field);
}

/**
* Set target_field. Default field.
*
* @return $this
*/
public function setTargetField(string $targetField): self
{
return $this->setParam('target_field', $targetField);
}

/**
* Set add_to_root. Default value false.
*
Expand Down
11 changes: 1 addition & 10 deletions src/Processor/KvProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class KvProcessor extends AbstractProcessor
{
use Traits\IgnoreFailureTrait;
use Traits\IgnoreMissingTrait;
use Traits\TargetFieldTrait;

public const DEFAULT_TARGET_FIELD_VALUE = null;
public const DEFAULT_IGNORE_MISSING_VALUE = false;
Expand Down Expand Up @@ -54,16 +55,6 @@ public function setValueSplit(string $valueSplit): self
return $this->setParam('value_split', $valueSplit);
}

/**
* Set target_field. Default value null.
*
* @return $this
*/
public function setTargetField(string $targetField): self
{
return $this->setParam('target_field', $targetField);
}

/**
* Set include_keys.
*
Expand Down
11 changes: 1 addition & 10 deletions src/Processor/RenameProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class RenameProcessor extends AbstractProcessor
{
use Traits\IgnoreFailureTrait;
use Traits\IgnoreMissingTrait;
use Traits\TargetFieldTrait;

public const DEFAULT_IGNORE_MISSING_VALUE = false;

Expand All @@ -31,14 +32,4 @@ public function setField(string $field): self
{
return $this->setParam('field', $field);
}

/**
* Set target_field.
*
* @return $this
*/
public function setTargetField(string $targetField): self
{
return $this->setParam('target_field', $targetField);
}
}
14 changes: 14 additions & 0 deletions src/Processor/Traits/TargetFieldTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Elastica\Processor\Traits;

trait TargetFieldTrait
{
/**
* @return $this
*/
public function setTargetField(string $targetField): self
{
return $this->setParam('target_field', $targetField);
}
}