-
Notifications
You must be signed in to change notification settings - Fork 737
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
Improvements on the Reindex API #1752
Changes from 4 commits
d05888a
e4d7c5c
06ffaa7
fb3e933
aa5d5f5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,12 +23,18 @@ class Reindex extends Param | |
public const REMOTE = 'remote'; | ||
public const SLICE = 'slice'; | ||
public const REFRESH = 'refresh'; | ||
public const REFRESH_TRUE = 'true'; | ||
public const REFRESH_FALSE = 'false'; | ||
public const REFRESH_WAIT_FOR = 'wait_for'; | ||
public const WAIT_FOR_COMPLETION = 'wait_for_completion'; | ||
public const WAIT_FOR_COMPLETION_FALSE = 'false'; | ||
public const WAIT_FOR_ACTIVE_SHARDS = 'wait_for_active_shards'; | ||
public const TIMEOUT = 'timeout'; | ||
public const SCROLL = 'scroll'; | ||
public const REQUESTS_PER_SECOND = 'requests_per_second'; | ||
public const PIPELINE = 'pipeline'; | ||
public const SLICES = 'slices'; | ||
public const SLICES_AUTO = 'auto'; | ||
|
||
/** | ||
* @var Index | ||
|
@@ -96,6 +102,12 @@ protected function _getDestPartBody(Index $index, array $params): array | |
'index' => $index->getName(), | ||
], $this->_resolveDestOptions($params)); | ||
|
||
// Resolves the pipeline name | ||
$pipeline = $destBody[self::PIPELINE] ?? null; | ||
if ($pipeline instanceof Pipeline) { | ||
$destBody[self::PIPELINE] = $pipeline->getId(); | ||
} | ||
|
||
return $destBody; | ||
} | ||
|
||
|
@@ -115,6 +127,7 @@ private function _resolveDestOptions(array $params): array | |
return \array_intersect_key($params, [ | ||
self::VERSION_TYPE => null, | ||
self::OPERATION_TYPE => null, | ||
self::PIPELINE => null, | ||
]); | ||
} | ||
|
||
|
@@ -184,6 +197,26 @@ public function setScript(Script $script) | |
$this->setParam(self::SCRIPT, $script); | ||
} | ||
|
||
public function setQuery(AbstractQuery $query): void | ||
{ | ||
$this->setParam(self::QUERY, $query); | ||
} | ||
|
||
public function setPipeline(Pipeline $pipeline): void | ||
{ | ||
$this->setParam(self::PIPELINE, $pipeline); | ||
} | ||
|
||
/** | ||
* @param bool|string $value | ||
*/ | ||
public function setRefresh($value): void | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we force the value type to be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The valid values are: We could also create some class constants for them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like your solution, it would be cleaner IMHO and would allow us to validate the parameter... or should it be something for the lower-level client library? 🤔 @ruflin , what do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In general I like the idea of validation at the same time it can put a burden on "us". Class constant would definitively be helpful but i would not validate that only these are used. If a new param is introduced in ES, we need to add it to support it which I don't think it optimal. Happy to also only have the most common / used ones as constants (or none to get started). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I quite agree with the "burden", I just wanted to have a more strict typing here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added some constants via fb3e933 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for the new fixes, what about only allowing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see #1758 |
||
{ | ||
\is_bool($value) && $value = $value ? self::REFRESH_TRUE : self::REFRESH_FALSE; | ||
|
||
$this->setParam(self::REFRESH, $value); | ||
} | ||
|
||
public function getTaskId() | ||
{ | ||
$taskId = null; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Could you add the links to the PR's? I'm just realising we miss it in some entries below too :-(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done aa5d5f5 :-)